|
1 | | -# angular-github-api-factory |
2 | | -AngularJS Factory for GitHub v3 JSON REST API requests |
| 1 | +**angular-github-api-factory** is an angularjs module with a github api factory. |
| 2 | + |
| 3 | +Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank)) |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +1. Install via [bower](http://bower.io/) : |
| 8 | + 1. `bower install --save angular-github-api-factory` |
| 9 | +2. Add `jtt_github` to your application's module dependencies. |
| 10 | +3. Include dependencies in your HTML. |
| 11 | + 1. When using bower: |
| 12 | + |
| 13 | + ```html |
| 14 | + <script src="bower_components/angular/angular.js"></script> |
| 15 | + <script src="bower_components/angular-github-api-factory/src/angular-github-api-factory.js"></script> |
| 16 | + ``` |
| 17 | + |
| 18 | +4. Use the factory `githubFactory`. |
| 19 | + |
| 20 | + |
| 21 | +### factory methods |
| 22 | + |
| 23 | +#### getUser |
| 24 | +```js |
| 25 | +githubFactory.getUser({ |
| 26 | + user:"<USERNAME_NAME>", |
| 27 | + access_token:"<ACCESS_TOKEN>" |
| 28 | +}).success(function(_data){ |
| 29 | + //on success |
| 30 | +}).error(function (_data) { |
| 31 | + //on error |
| 32 | +}); |
| 33 | +``` |
| 34 | + |
| 35 | +#### getRepo |
| 36 | +```js |
| 37 | +githubFactory.getRepoByUserAndName({ |
| 38 | + user:"<USER_NAME>", |
| 39 | + repo:"<REPO_NAME>", |
| 40 | + access_token:"<ACCESS_TOKEN>" |
| 41 | +}).success(function(_data){ |
| 42 | + //on success |
| 43 | +}).error(function (_data) { |
| 44 | + //on error |
| 45 | +}); |
| 46 | +``` |
| 47 | + |
| 48 | +#### getRepos |
| 49 | +```js |
| 50 | +// https://developer.github.com/v3/search/#search-repositories |
| 51 | +githubFactory.getReposByName({ |
| 52 | + q:"<SEARCH_STRING>", |
| 53 | + sort:"<SORT_STRING>", // (optional) 'stars', 'forks', or 'updated' |
| 54 | + order:"<SORT_ORDER>", // (optional) 'desc', 'asc' |
| 55 | + per_page:"<ITEMS_PER_PAGE>", // (optional) default: 20 |
| 56 | + access_token:"<ACCESS_TOKEN>" |
| 57 | +}).success(function(_data){ |
| 58 | + //on success |
| 59 | +}).error(function (_data) { |
| 60 | + //on error |
| 61 | +}); |
| 62 | +``` |
| 63 | + |
| 64 | +```js |
| 65 | +githubFactory.getReposByUser({ |
| 66 | + user:"<USER_NAME>", |
| 67 | + q:"<SEARCH_STRING>", // (optional) |
| 68 | + sort:"<SORT_STRING>", // (optional) 'stars', 'forks', or 'updated' |
| 69 | + order:"<SORT_ORDER>", // (optional) 'desc', 'asc' |
| 70 | + per_page:"<ITEMS_PER_PAGE>", // (optional) default: 20 |
| 71 | + access_token:"<ACCESS_TOKEN>" |
| 72 | +}).success(function(_data){ |
| 73 | + //on success |
| 74 | +}).error(function (_data) { |
| 75 | + //on error |
| 76 | +}); |
| 77 | +``` |
| 78 | + |
| 79 | +#### getEvents |
| 80 | +```js |
| 81 | +githubFactory.getEventsFromRepoByUserAndName({ |
| 82 | + user:"<USER_NAME>", |
| 83 | + repo:"<REPO_NAME>", |
| 84 | + q:"<SEARCH_STRING>", // (optional) |
| 85 | + sort:"<SORT_STRING>", // (optional) |
| 86 | + order:"<SORT_ORDER>", // (optional) 'desc', 'asc' |
| 87 | + per_page:"<ITEMS_PER_PAGE>", // (optional) default: 20 |
| 88 | + access_token:"<ACCESS_TOKEN>" |
| 89 | +}).success(function(_data){ |
| 90 | + //on success |
| 91 | +}).error(function (_data) { |
| 92 | + //on error |
| 93 | +}); |
| 94 | +``` |
| 95 | + |
| 96 | +```js |
| 97 | +githubFactory.getEventsByUser({ |
| 98 | + user:"<USER_NAME>", |
| 99 | + q:"<SEARCH_STRING>", // (optional) |
| 100 | + sort:"<SORT_STRING>", // (optional) |
| 101 | + order:"<SORT_ORDER>", // (optional) 'desc', 'asc' |
| 102 | + per_page:"<ITEMS_PER_PAGE>", // (optional) default: 20 |
| 103 | + access_token:"<ACCESS_TOKEN>" |
| 104 | +}).success(function(_data){ |
| 105 | + //on success |
| 106 | +}).error(function (_data) { |
| 107 | + //on error |
| 108 | +}); |
| 109 | +``` |
| 110 | + |
| 111 | + |
| 112 | +## Github JSON API |
| 113 | + |
| 114 | +* docs: https://developer.github.com/v3/ |
| 115 | +* api playground: https://apigee.com/console/github |
| 116 | + |
| 117 | + |
| 118 | +## License |
| 119 | + |
| 120 | +MIT |
0 commit comments