-
Notifications
You must be signed in to change notification settings - Fork 0
/
github.js
75 lines (57 loc) · 2.16 KB
/
github.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
(function(){
var github = function($http){
var getUser = function(username){
//Return the success promise with data proccessed... so I won't need to deal with reponse
//just the data I care about - return promise(return data);
return $http.get("https://api.github.com/users/" + username)
.then(function(response){
return response.data;
});
};
var getRepos = function(user){
//Return the success promise with data proccessed... so I won't need to deal with reponse
//just the data I care about - return promise(return data);
return $http.get(user.repos_url)
.then(function(response){
return response.data;
});
};
var getRepoDetails = function(username, reponame){
var repo = null;
var repoUrl = "https://api.github.com/repos/" + username
+ "/" + reponame;
return $http.get(repoUrl)
.then(function(response){
repo = response.data;
return $http.get(repoUrl + "/contributors");
})
.then(function(response){
repo.contributors = response.data;
return repo;
});
};
// var getIssuesCount = function(username, reponame){
// return $http.get("https://api.github.com/repos/" + username
// + "/" + reponame + "/issues")
// .then(function(response){
// return response.data;
// });
// };
// var getContributors = function(username, reponame){
// return $http.get("https://api.github.com/repos/" + username
// + "/" + reponame + "/contributors")
// .then(function(response){
// return response.data;
// });
// };
return{
getUser : getUser,
getRepos: getRepos,
getRepoDetails: getRepoDetails
// getIssuesCount: getIssuesCount,
// getContributors: getContributors
};
};
var module = angular.module("apiApp");
module.factory('github', github);
}());