UNPKG

ares-ide

Version:

A browser-based code editor and UI designer for Enyo 2 projects

53 lines (52 loc) 14.3 kB
{ "name": "phonegap-build-api", "description": "REST Client for the PhoneGap Build API", "version": "0.3.3", "homepage": "http://github.com/phonegap/phonegap-build-api-js", "repository": { "type": "git", "url": "git://github.com/phonegap/phonegap-build-api-js.git" }, "keywords": [ "phonegap", "phonegap build" ], "preferGlobal": false, "main": "./lib/client.js", "scripts": { "test": "jasmine-node --color --verbose spec" }, "engines": { "node": ">=0.8.0" }, "dependencies": { "request": "2.11.x" }, "devDependencies": { "jasmine-node": "1.1.x" }, "optionalDependencies": {}, "contributors": [ { "name": "Michael Brooks", "email": "michael@michaelbrooks.ca", "url": "http://michaelbrooks.ca/" }, { "name": "Fil Maj", "email": "maj.fil@gmail.com", "url": "http://filmaj.ca" } ], "readme": "# phonegap-build-api-js [![Build Status][travis-ci-img]][travis-ci-url]\n\n> Node.js REST Client for the PhoneGap Build API\n\n## Overview\n\nThis library simplfies authentication and requests to the\n[PhoneGap Build REST API][build-api-docs] for node.js clients.\n\nIn many ways, this library is little more than a convenience wrapper\nfor [mikeal's][github-mikeal] [request][github-request] library. You can expect\nthat all of [request's][github-request] functionality to be available to the\n`API` object returned by `client.auth();`.\n\nIf something is inaccurate or missing, please send a pull request!\n\n## Usage\n\n### Authenticate with Username and Password\n\n var client = require('phonegap-build-api');\n\n client.auth({ username: 'zelda', password: 'tr1f0rce' }, function(e, api) {\n // time to make requests\n });\n\n### Authenticate with Token\n\n var client = require('phonegap-build-api');\n\n client.auth({ token: 'abc123' }, function(e, api) {\n // time to make requests\n });\n\n### GET https://build.phonegap.com/api/v1/me\n\n api.get('/me', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### GET https://build.phonegap.com/api/v1/apps\n\n api.get('/apps', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### GET https://build.phonegap.com/api/v1/apps/:id\n\n api.get('/apps/199692', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### GET https://build.phonegap.com/api/v1/apps/:id/icon\n\n api.get('/apps/199692/icon').pipe(fs.createWriteStream('icon.png'));\n\n### GET https://build.phonegap.com/api/v1/apps/:id/:platform\n\n api.get('/apps/199692/android').pipe(fs.createWriteStream('app.apk'));\n\n### GET https://build.phonegap.com/api/v1/keys\n\n api.get('/keys', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### GET https://build.phonegap.com/api/v1/keys/:platform\n\n api.get('/keys/ios', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### GET https://build.phonegap.com/api/v1/keys/:platform/:id\n\n api.get('/keys/ios/917', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### POST https://build.phonegap.com/api/v1/apps\n\n var options = {\n form: {\n data: {\n title: 'My App',\n create_method: 'file'\n },\n file: '/path/to/app.zip'\n }\n };\n\n api.post('/apps', options, function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### PUT https://build.phonegap.com/api/v1/apps/:id\n\n var options = {\n form: {\n data: {\n debug: false\n },\n file: '/path/to/app.zip'\n }\n };\n\n api.put('/apps/197196', options, function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### POST https://build.phonegap.com/api/v1/apps/:id/icon\n\n var options = {\n form: {\n icon: 'my-icon.png'\n }\n };\n\n api.post('/apps/232741/icon', options, function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### POST https://build.phonegap.com/api/v1/apps/:id/build\n\nBuild all platforms:\n\n api.post('/apps/232741/build', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n \nBuild specific platforms:\n\n var options = {\n form: {\n data: {\n platforms: [ 'android', 'blackberry', 'ios', 'winphone', 'webos' ]\n }\n }\n };\n\n api.post('/apps/232741/build', options, function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### POST https://build.phonegap.com/api/v1/apps/:id/build/:platform\n\n api.post('/apps/232741/build/android', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### POST https://build.phonegap.com/api/v1/apps/:id/collaborators\n\n var options = {\n form: {\n data: {\n email: 'michael@michaelbrooks.ca',\n role: 'dev'\n }\n }\n };\n\n api.post('/apps/232741/collaborators', options, function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### PUT https://build.phonegap.com/api/v1/apps/:id/collaborators/:id\n\n var options = {\n form: {\n data: {\n role: 'tester'\n }\n }\n };\n\n api.put('/apps/232741/collaborators/263955', options, function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### POST https://build.phonegap.com/api/v1/keys/:platform\n\n var options = {\n form: {\n data: {\n title: 'My BlackBerry Signing Key',\n password: 'my-password'\n },\n db: '/path/to/sigtool.db',\n csk: '/path/to/sigtool.csk'\n }\n };\n\n api.post('/keys/blackberry', options, function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### PUT https://build.phonegap.com/api/v1/keys/:platform/:id\n\n var options = {\n form: {\n data: {\n password: 'my-updated-password'\n }\n }\n };\n\n api.put('/keys/blackberry/1505', options, function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### DELETE https://build.phonegap.com/api/v1/apps/:id\n\n api.del('/apps/14450', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### DELETE https://build.phonegap.com/api/v1/apps/:id/collaborators/:id\n\n api.del('/apps/232741/collaborators/263955', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### DELETE https://build.phonegap.com/api/v1/keys/:platform/:id\n\n api.del('/keys/ios/2729', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n## API\n\n### client.auth(options, callback)\n\nPhoneGap Build Authentication.\n\nAuthentications with PhoneGap Build and returns an instance of `API`.\nThe authentication credentials can be a username and password or user-token.\n\n#### Options:\n\n - `options` `{Object}` is the authentication settings.\n - `options.username` `{String}` is the phonegap build username.\n - `options.password` `{String}` is the phonegap build password.\n - `options.token` `{String}` can be used instead of username and password.\n - [`options.proxy`] `{String}` specifies an optional proxy server. e.g. 'http://myproxy.com:8181'.\n - `callback` `{Function}` is trigger after the authentication.\n - `e` `{Error}` is null unless there is an error.\n - `api` `{Object}` is the `API` instance to interact with phonegap build.\n\n#### Example:\n\n var client = require('phonegap-build-api');\n\n client.auth({ username: 'zelda', password: 'tr1force' }, function(e, api) {\n if (e) {\n console.log('error:', e);\n return;\n }\n\n // make some api requests\n });\n\n### api(path, [options], [callback])\n\nAPI Request.\n\nCreate a RESTful request to the PhoneGap Build API. The `api` function is a\nwrapper to [request][github-request]'s interface.\n\nThe `path` parameter is a relative path to a PhoneGap Build API response.\nFor example, to the resource `https://build.phonegap.com/api/v1/me` is specified\nas the path `/me`.\n\nThe `options` parameter maps directly to [request][github-request]'s options.\n\nThe default request method is `GET`. You can specify a specific but you can be changed\nin the `options` parameters (e.g. `{ method: 'POST' }`).\n\nTo send form data, you can use the `options.form` parameter. The key `data` is\nassumed to be JSON and all other keys are assumed to be file paths.\n\n#### Options:\n\n - `path` `{String}` is a relative resource path (e.g. `\"/apps\"`).\n - `[options]` `{Object}` is a request options object.\n - `[callback]` `{Function}` is trigger after the request\n - `e` `{Error}` is null unless there is an error\n - `data` `{Object}` is the JSON response.\n\n#### Example: GET Request\n\n api('/me', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n#### Example: POST Request\n\n var options = {\n form: {\n data: {\n title: 'My App',\n create_method: 'file'\n },\n file: '/path/to/app.zip'\n },\n method: 'POST'\n };\n\n api('/apps', options, function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### api.get(path, [options], [callback])\n\nGET API Request.\n\nA convenience function for `api(path, [options], [callback])`, where `options`\nuses `{ method: 'GET' }`.\n\n#### Options:\n\n - `path` `{String}` is a relative resource path (e.g. `\"/apps\"`).\n - `[options]` `{Object}` is a request options object.\n - `[callback]` `{Function}` is trigger after the request\n - `e` `{Error}` is null unless there is an error\n - `data` `{Object}` is the JSON response.\n\n#### Example:\n\n api.get('/me', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### api.post(path, [options], [callback])\n\nPOST API Request.\n\nA convenience function for `api(path, [options], [callback])`, where `options`\nuses `{ method: 'POST' }`.\n\n#### Options:\n\n - `path` `{String}` is a relative resource path (e.g. `\"/apps\"`).\n - `[options]` `{Object}` is a request options object.\n - `[callback]` `{Function}` is trigger after the request\n - `e` `{Error}` is null unless there is an error\n - `data` `{Object}` is the JSON response.\n\n#### Example:\n\n var options = {\n form: {\n data: {\n title: 'My App',\n create_method: 'file'\n },\n file: '/path/to/app.zip'\n }\n };\n\n api.post('/apps', options, function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### api.put(path, [options], [callback])\n\nPUT API Request.\n\nA convenience function for `api(path, [options], [callback])`, where `options`\nuses `{ method: 'PUT' }`.\n\n#### Options:\n\n - `path` `{String}` is a relative resource path (e.g. `\"/apps\"`).\n - `[options]` `{Object}` is a request options object.\n - `[callback]` `{Function}` is trigger after the request\n - `e` `{Error}` is null unless there is an error\n - `data` `{Object}` is the JSON response.\n\n#### Example:\n\n var options = {\n form: {\n data: {\n debug: false\n },\n file: '/path/to/app.zip'\n }\n };\n\n api.put('/apps/197196', options, function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### api.del(path, [options], [callback])\n\nDELETE API Request.\n\nA convenience function for `api(path, [options], [callback])`, where `options`\nuses `{ method: 'DELETE' }`.\n\n#### Options:\n\n - `path` `{String}` is a relative resource path (e.g. `\"/apps\"`).\n - `[options]` `{Object}` is a request options object.\n - `[callback]` `{Function}` is trigger after the request\n - `e` `{Error}` is null unless there is an error\n - `data` `{Object}` is the JSON response.\n\n#### Example:\n\n api.del('/apps/14450', function(e, data) {\n console.log('error:', e);\n console.log('data:', data);\n });\n\n### api.defaults(options)\n\nThis maps directly to [request][github-request]'s `default` method.\n\n> This method returns a wrapper around the normal request API that defaults to whatever options you pass in to it.\n\n## Alternative Libraries\n\n### Java\n\n- [pgbuild-api][pgbuild-api] by [Hardeep Shoker][github-hardeep]\n\n### Node.js\n\n- [phonegapbuildapi][github-phonegapbuildapi] by [germallon][github-germallon]\n\n[travis-ci-img]: https://travis-ci.org/phonegap/phonegap-build-api-js.png?branch=master\n[travis-ci-url]: https://travis-ci.org/phonegap/phonegap-build-api-js\n[build-api-docs]: https://build.phonegap.com/docs/api\n[github-mikeal]: https://github.com/mikeal\n[github-request]: https://github.com/mikeal/request\n[pgbuild-api]: https://github.com/hardeep/pgbuild-api\n[github-hardeep]: https://github.com/hardeep\n[github-phonegapbuildapi]: https://github.com/germallon/phonegapbuildapi\n[github-germallon]: https://github.com/germallon\n\n", "readmeFilename": "README.md", "bugs": { "url": "https://github.com/phonegap/phonegap-build-api-js/issues" }, "_id": "phonegap-build-api@0.3.3", "dist": { "shasum": "68c393d5d1ae3addc4152bb3a6dd9e6b389f96e4" }, "_from": "phonegap-build-api@0.3.3", "_resolved": "https://registry.npmjs.org/phonegap-build-api/-/phonegap-build-api-0.3.3.tgz" }