{"action":"created","issue":{"url":"https://api.github.com/repos/scottgonzalez/node-browserstack/issues/36","labels_url":"https://api.github.com/repos/scottgonzalez/node-browserstack/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/scottgonzalez/node-browserstack/issues/36/comments","events_url":"https://api.github.com/repos/scottgonzalez/node-browserstack/issues/36/events","html_url":"https://github.com/scottgonzalez/node-browserstack/pull/36","id":126617608,"number":36,"title":"Support for Automate REST API","user":{"login":"kartsims","id":4136975,"avatar_url":"https://avatars.githubusercontent.com/u/4136975?v=3","gravatar_id":"","url":"https://api.github.com/users/kartsims","html_url":"https://github.com/kartsims","followers_url":"https://api.github.com/users/kartsims/followers","following_url":"https://api.github.com/users/kartsims/following{/other_user}","gists_url":"https://api.github.com/users/kartsims/gists{/gist_id}","starred_url":"https://api.github.com/users/kartsims/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kartsims/subscriptions","organizations_url":"https://api.github.com/users/kartsims/orgs","repos_url":"https://api.github.com/users/kartsims/repos","events_url":"https://api.github.com/users/kartsims/events{/privacy}","received_events_url":"https://api.github.com/users/kartsims/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2016-01-14T09:51:30Z","updated_at":"2016-01-25T14:38:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scottgonzalez/node-browserstack/pulls/36","html_url":"https://github.com/scottgonzalez/node-browserstack/pull/36","diff_url":"https://github.com/scottgonzalez/node-browserstack/pull/36.diff","patch_url":"https://github.com/scottgonzalez/node-browserstack/pull/36.patch"},"body":"Here is the PR related to issue #35 to support Automate REST API.\r\n\r\n### Linting\r\n\r\nI added the `.jscsrc` file to the repo as it may help anyone willing to contribute. It worked fine for me after a bit of IDE configuration so I guess this will prevent any more code style issues.\r\n\r\n### Automate Support\r\n\r\nThe support for Automate REST API was done in the same fashion as Screenshots. We should not have much issues with that.\r\n\r\n### API objects format\r\n\r\nThere is something slightly odd with the API results. For instance, if you use the `getProjects` method to fetch information about a specific project, it returns this object structure :\r\n\r\n```javascript\r\n[ { automation_project: \r\n     { id: 0000,\r\n       created_at: '2015-12-03T12:37:35Z',\r\n       name: 'xxxx',\r\n       user_id: 0000,\r\n       updated_at: '2015-12-09T14:16:44Z',\r\n       group_id: 000 } } ]\r\n\r\n\r\n```\r\n\r\nEven worse, when fetching for a project using `getProject`, you would get :\r\n\r\n```javascript\r\n{ project: \r\n   { updated_at: '2016-01-06T17:29:43Z',\r\n     group_id: 0000,\r\n     builds: [ { automation_build: \r\n       { hashed_id: 'xxxx',\r\n         updated_at: '2015-12-09T16:26:32Z',\r\n         delta: false,\r\n         group_id: 0000,\r\n         status: 'done',\r\n         id: 0000,\r\n         name: 'Wed  09 Dec 2015 16:25:17 GMT',\r\n         duration: 69,\r\n         tags: null,\r\n         created_at: '2015-12-09T16:25:23Z',\r\n         user_id: 0000,\r\n         automation_project_id: 0000 } },\r\n         ...\r\n        ],\r\n     id: 0000,\r\n     name: 'xxxxx',\r\n     created_at: '2015-12-09T16:25:23Z',\r\n     user_id: null } }\r\n```\r\n\r\nThis obviously makes it complicated for anyone to access data in a clean way. I am in touch with BrowserStack support and waiting for input on whether this is made to be changed (this along with some other small stuff on the same API).\r\n\r\nIn order to make this NPM module's API easier to use, I added a function to clean the data out of these unnecessary levels of hierarchy. I let you have a look into it in `lib/automate.js`.\r\n\r\nPlease look into this function's implementation I would be happy to hear your feedback and suggestions.\r\n\r\nFYI this is the result of the two previous API calls after cleaning the data :\r\n\r\n```javascript\r\n[ { id: 0000,\r\n    name: 'xxxx',\r\n    group_id: 0000,\r\n    created_at: '2015-12-03T12:37:35Z',\r\n    updated_at: '2015-12-09T14:16:44Z',\r\n    user_id: 0000 } ]\r\n```\r\n\r\n```javascript\r\n{ created_at: '2015-12-09T16:25:23Z',\r\n  group_id: 0000,\r\n  builds: \r\n   [ { created_at: '2015-12-09T16:25:23Z',\r\n       group_id: 0000,\r\n       hashed_id: 'xxxx',\r\n       id: 0000,\r\n       name: 'Wed  09 Dec 2015 16:25:17 GMT',\r\n       user_id: 0000,\r\n       automation_project_id: 0000,\r\n       status: 'done',\r\n       tags: null,\r\n       delta: false,\r\n       updated_at: '2015-12-09T16:26:32Z',\r\n       duration: 69 }\r\n       ...\r\n      ],\r\n  id: 0000,\r\n  name: 'xxxx',\r\n  user_id: null,\r\n  updated_at: '2016-01-06T17:29:43Z' }\r\n```\r\n\r\n### Documentation\r\n\r\n... is in progress, I thought we would like to settle the point about objects manipulation first."},"comment":{"url":"https://api.github.com/repos/scottgonzalez/node-browserstack/issues/comments/174525575","html_url":"https://github.com/scottgonzalez/node-browserstack/pull/36#issuecomment-174525575","issue_url":"https://api.github.com/repos/scottgonzalez/node-browserstack/issues/36","id":174525575,"user":{"login":"scottgonzalez","id":141167,"avatar_url":"https://avatars.githubusercontent.com/u/141167?v=3","gravatar_id":"","url":"https://api.github.com/users/scottgonzalez","html_url":"https://github.com/scottgonzalez","followers_url":"https://api.github.com/users/scottgonzalez/followers","following_url":"https://api.github.com/users/scottgonzalez/following{/other_user}","gists_url":"https://api.github.com/users/scottgonzalez/gists{/gist_id}","starred_url":"https://api.github.com/users/scottgonzalez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottgonzalez/subscriptions","organizations_url":"https://api.github.com/users/scottgonzalez/orgs","repos_url":"https://api.github.com/users/scottgonzalez/repos","events_url":"https://api.github.com/users/scottgonzalez/events{/privacy}","received_events_url":"https://api.github.com/users/scottgonzalez/received_events","type":"User","site_admin":false},"created_at":"2016-01-25T14:38:30Z","updated_at":"2016-01-25T14:38:30Z","body":"I just sent you a PR with some cleanup. I did notice that the API doesn't handle errors properly. When I make a request to get a project with an id that doesn't exist, I get back a response of `{ status: 404, message: 'Not Found' }` but the actual HTTP status code is 200. We either need to get BrowserStack to return the proper status code or we need to detect this in the `request()` method.\r\n\r\n@nakula @rahulnwn Can we get this fixed in the API?"}}