{"action":"created","comment":{"url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/comments/131681740","pull_request_review_id":54633622,"id":131681740,"diff_hunk":"@@ -0,0 +1,157 @@\n+import { Headers, RequestAPI, get, post } from \"request\";\n+import { deleteRequest, getFile, getRequest, postRequest } from \"./Service\";\n+\n+interface DeployError {\n+    errorMessage: string;\n+    errorCode: string;\n+}\n+\n+export interface Build {\n+    PackageId: string;\n+}\n+\n+export interface Package {\n+    PackageId: string;\n+    Name: string;\n+    Description: string;\n+    Version: string;\n+    Creator: string;\n+    CreationDate: number;\n+    Status: \"Succeeded\" | \"Queued\" | \"Building\" | \"Uploading\" | \"Failed\";\n+    Size: number;\n+}\n+\n+/**\n+ * The Build API allows you to manage deployment packages and create new deployment packages using our build server. You will need the information from the Teamserver API as input for these API calls.\n+ * Based on https://docs.mendix.com/apidocs-mxsdk/apidocs/build-api\n+ */\n+export class BuildService {\n+    private headers: Headers;\n+    private baseUrl = \"https://deploy.mendix.com/api/1\";\n+\n+    constructor(private user: string, private key: string) {\n+        // todo  strip last of base url.\n+        this.headers = {\n+            \"Mendix-Username\": user,\n+            \"Mendix-ApiKey\": key,\n+            \"ContentType\": \"application/json\"\n+        };\n+    }\n+\n+    setBaseUrl(url: string) {\n+        this.baseUrl = url;\n+    }\n+\n+    /**\n+     * Start the process to build a deployment package, based on the team server project of a specific app that the authenticated user has access to as a regular user. This package can be found if you click Details on an app in the Nodes screen in the Mendix Platform. For a Sandbox, this will also trigger a deployment of the new package.\n+     * @param appId Subdomain name of an app.\n+     * @param branchName Name of the branch. This is ‘trunk’ for the main line or a specific branch name.\n+     * @param revision Number of the revision to build a package from.\n+     * @param version Package version. This will also be the name of the tag on the project team server.\n+     */\n+    startBuild(appId: string, branchName: string, revision: string, version: string): Promise<Build> {\n+        const currentDate = new Date();\n+        const timeStamp = currentDate.getFullYear() + \"-\"\n+                        + (currentDate.getMonth() + 1) + \"-\"\n+                        + currentDate.getDate() + \" \"\n+                        + currentDate.getHours() + \":\"\n+                        + currentDate.getMinutes() + \":\"\n+                        + currentDate.getSeconds();\n+        return postRequest<Build>({\n+            url: `${this.baseUrl}/apps/${appId}/packages/`,\n+            headers: this.headers,\n+            body: JSON.stringify({\n+                Branch: branchName,\n+                Revision: revision,\n+                Version: version,\n+                Description: `CI Build ${timeStamp}`\n+            })\n+        });\n+    }\n+\n+    /**\n+     * Wait for building process to finish\n+     * @param appId Subdomain name of an app.\n+     * @param packageId Unique identification of the package that build\n+     * @param timeOutSeconds maximum waiting time for build to complete.\n+     */\n+    waitForBuild(appId: string, packageId: string, timeOutSeconds: number): Promise<Package> {\n+        return new Promise<Package>((resolve, reject) => {\n+            const date = Date.now();\n+            const checkStatus = () => {\n+                const duration = (Date.now() - date) / 1000;\n+\n+                if (duration > timeOutSeconds) {\n+                    reject(`Build timed out after ${timeOutSeconds}`);\n+                    return;","path":"src/services/BuildService.ts","position":86,"original_position":86,"commit_id":"85683d3a9fc0ab007a808194ecc162012997a8dd","original_commit_id":"750cc64e0f1fa2925abdc9752e6a7f616ac3004d","user":{"login":"edwinmp","id":5672438,"avatar_url":"https://avatars2.githubusercontent.com/u/5672438?v=4","gravatar_id":"","url":"https://api.github.com/users/edwinmp","html_url":"https://github.com/edwinmp","followers_url":"https://api.github.com/users/edwinmp/followers","following_url":"https://api.github.com/users/edwinmp/following{/other_user}","gists_url":"https://api.github.com/users/edwinmp/gists{/gist_id}","starred_url":"https://api.github.com/users/edwinmp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edwinmp/subscriptions","organizations_url":"https://api.github.com/users/edwinmp/orgs","repos_url":"https://api.github.com/users/edwinmp/repos","events_url":"https://api.github.com/users/edwinmp/events{/privacy}","received_events_url":"https://api.github.com/users/edwinmp/received_events","type":"User","site_admin":false},"body":"Blank line before","created_at":"2017-08-07T15:16:28Z","updated_at":"2017-08-07T15:25:02Z","html_url":"https://github.com/FlockOfBirds/mendix-widget-build-script/pull/1#discussion_r131681740","pull_request_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/comments/131681740"},"html":{"href":"https://github.com/FlockOfBirds/mendix-widget-build-script/pull/1#discussion_r131681740"},"pull_request":{"href":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/1","id":134381385,"html_url":"https://github.com/FlockOfBirds/mendix-widget-build-script/pull/1","diff_url":"https://github.com/FlockOfBirds/mendix-widget-build-script/pull/1.diff","patch_url":"https://github.com/FlockOfBirds/mendix-widget-build-script/pull/1.patch","issue_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/issues/1","number":1,"state":"open","locked":false,"title":"Review PR","user":{"login":"Andries-Smit","id":6724749,"avatar_url":"https://avatars0.githubusercontent.com/u/6724749?v=4","gravatar_id":"","url":"https://api.github.com/users/Andries-Smit","html_url":"https://github.com/Andries-Smit","followers_url":"https://api.github.com/users/Andries-Smit/followers","following_url":"https://api.github.com/users/Andries-Smit/following{/other_user}","gists_url":"https://api.github.com/users/Andries-Smit/gists{/gist_id}","starred_url":"https://api.github.com/users/Andries-Smit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andries-Smit/subscriptions","organizations_url":"https://api.github.com/users/Andries-Smit/orgs","repos_url":"https://api.github.com/users/Andries-Smit/repos","events_url":"https://api.github.com/users/Andries-Smit/events{/privacy}","received_events_url":"https://api.github.com/users/Andries-Smit/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-08-07T07:59:15Z","updated_at":"2017-08-07T15:25:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"968f70a6ba8d76a3cb43dad6cfbb78f29e9b4142","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/1/commits","review_comments_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/1/comments","review_comment_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/issues/1/comments","statuses_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/statuses/85683d3a9fc0ab007a808194ecc162012997a8dd","head":{"label":"FlockOfBirds:master","ref":"master","sha":"85683d3a9fc0ab007a808194ecc162012997a8dd","user":{"login":"FlockOfBirds","id":22542218,"avatar_url":"https://avatars2.githubusercontent.com/u/22542218?v=4","gravatar_id":"","url":"https://api.github.com/users/FlockOfBirds","html_url":"https://github.com/FlockOfBirds","followers_url":"https://api.github.com/users/FlockOfBirds/followers","following_url":"https://api.github.com/users/FlockOfBirds/following{/other_user}","gists_url":"https://api.github.com/users/FlockOfBirds/gists{/gist_id}","starred_url":"https://api.github.com/users/FlockOfBirds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FlockOfBirds/subscriptions","organizations_url":"https://api.github.com/users/FlockOfBirds/orgs","repos_url":"https://api.github.com/users/FlockOfBirds/repos","events_url":"https://api.github.com/users/FlockOfBirds/events{/privacy}","received_events_url":"https://api.github.com/users/FlockOfBirds/received_events","type":"Organization","site_admin":false},"repo":{"id":98660212,"name":"mendix-widget-build-script","full_name":"FlockOfBirds/mendix-widget-build-script","owner":{"login":"FlockOfBirds","id":22542218,"avatar_url":"https://avatars2.githubusercontent.com/u/22542218?v=4","gravatar_id":"","url":"https://api.github.com/users/FlockOfBirds","html_url":"https://github.com/FlockOfBirds","followers_url":"https://api.github.com/users/FlockOfBirds/followers","following_url":"https://api.github.com/users/FlockOfBirds/following{/other_user}","gists_url":"https://api.github.com/users/FlockOfBirds/gists{/gist_id}","starred_url":"https://api.github.com/users/FlockOfBirds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FlockOfBirds/subscriptions","organizations_url":"https://api.github.com/users/FlockOfBirds/orgs","repos_url":"https://api.github.com/users/FlockOfBirds/repos","events_url":"https://api.github.com/users/FlockOfBirds/events{/privacy}","received_events_url":"https://api.github.com/users/FlockOfBirds/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FlockOfBirds/mendix-widget-build-script","description":"CI Build scripts for Mendix widgets","fork":false,"url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script","forks_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/forks","keys_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/teams","hooks_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/hooks","issue_events_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/issues/events{/number}","events_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/events","assignees_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/assignees{/user}","branches_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/branches{/branch}","tags_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/tags","blobs_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/git/refs{/sha}","trees_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/statuses/{sha}","languages_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/languages","stargazers_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/stargazers","contributors_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/contributors","subscribers_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/subscribers","subscription_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/subscription","commits_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/commits{/sha}","git_commits_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/git/commits{/sha}","comments_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/comments{/number}","issue_comment_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/issues/comments{/number}","contents_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/contents/{+path}","compare_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/merges","archive_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/downloads","issues_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/issues{/number}","pulls_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls{/number}","milestones_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/milestones{/number}","notifications_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/labels{/name}","releases_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/releases{/id}","deployments_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/deployments","created_at":"2017-07-28T14:58:31Z","updated_at":"2017-07-28T15:02:32Z","pushed_at":"2017-08-07T14:22:11Z","git_url":"git://github.com/FlockOfBirds/mendix-widget-build-script.git","ssh_url":"git@github.com:FlockOfBirds/mendix-widget-build-script.git","clone_url":"https://github.com/FlockOfBirds/mendix-widget-build-script.git","svn_url":"https://github.com/FlockOfBirds/mendix-widget-build-script","homepage":null,"size":193,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"FlockOfBirds:review","ref":"review","sha":"db6eccc072d10572d389b08b7905c6805c74e7c8","user":{"login":"FlockOfBirds","id":22542218,"avatar_url":"https://avatars2.githubusercontent.com/u/22542218?v=4","gravatar_id":"","url":"https://api.github.com/users/FlockOfBirds","html_url":"https://github.com/FlockOfBirds","followers_url":"https://api.github.com/users/FlockOfBirds/followers","following_url":"https://api.github.com/users/FlockOfBirds/following{/other_user}","gists_url":"https://api.github.com/users/FlockOfBirds/gists{/gist_id}","starred_url":"https://api.github.com/users/FlockOfBirds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FlockOfBirds/subscriptions","organizations_url":"https://api.github.com/users/FlockOfBirds/orgs","repos_url":"https://api.github.com/users/FlockOfBirds/repos","events_url":"https://api.github.com/users/FlockOfBirds/events{/privacy}","received_events_url":"https://api.github.com/users/FlockOfBirds/received_events","type":"Organization","site_admin":false},"repo":{"id":98660212,"name":"mendix-widget-build-script","full_name":"FlockOfBirds/mendix-widget-build-script","owner":{"login":"FlockOfBirds","id":22542218,"avatar_url":"https://avatars2.githubusercontent.com/u/22542218?v=4","gravatar_id":"","url":"https://api.github.com/users/FlockOfBirds","html_url":"https://github.com/FlockOfBirds","followers_url":"https://api.github.com/users/FlockOfBirds/followers","following_url":"https://api.github.com/users/FlockOfBirds/following{/other_user}","gists_url":"https://api.github.com/users/FlockOfBirds/gists{/gist_id}","starred_url":"https://api.github.com/users/FlockOfBirds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FlockOfBirds/subscriptions","organizations_url":"https://api.github.com/users/FlockOfBirds/orgs","repos_url":"https://api.github.com/users/FlockOfBirds/repos","events_url":"https://api.github.com/users/FlockOfBirds/events{/privacy}","received_events_url":"https://api.github.com/users/FlockOfBirds/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FlockOfBirds/mendix-widget-build-script","description":"CI Build scripts for Mendix widgets","fork":false,"url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script","forks_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/forks","keys_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/teams","hooks_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/hooks","issue_events_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/issues/events{/number}","events_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/events","assignees_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/assignees{/user}","branches_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/branches{/branch}","tags_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/tags","blobs_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/git/refs{/sha}","trees_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/statuses/{sha}","languages_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/languages","stargazers_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/stargazers","contributors_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/contributors","subscribers_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/subscribers","subscription_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/subscription","commits_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/commits{/sha}","git_commits_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/git/commits{/sha}","comments_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/comments{/number}","issue_comment_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/issues/comments{/number}","contents_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/contents/{+path}","compare_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/merges","archive_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/downloads","issues_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/issues{/number}","pulls_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls{/number}","milestones_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/milestones{/number}","notifications_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/labels{/name}","releases_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/releases{/id}","deployments_url":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/deployments","created_at":"2017-07-28T14:58:31Z","updated_at":"2017-07-28T15:02:32Z","pushed_at":"2017-08-07T14:22:11Z","git_url":"git://github.com/FlockOfBirds/mendix-widget-build-script.git","ssh_url":"git@github.com:FlockOfBirds/mendix-widget-build-script.git","clone_url":"https://github.com/FlockOfBirds/mendix-widget-build-script.git","svn_url":"https://github.com/FlockOfBirds/mendix-widget-build-script","homepage":null,"size":193,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/1"},"html":{"href":"https://github.com/FlockOfBirds/mendix-widget-build-script/pull/1"},"issue":{"href":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/issues/1"},"comments":{"href":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/FlockOfBirds/mendix-widget-build-script/statuses/85683d3a9fc0ab007a808194ecc162012997a8dd"}}}}
{"actor":{"display_login":"edwinmp"}}