github_api2 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +770 -0
- data/LICENSE.txt +20 -0
- data/README.md +741 -0
- data/lib/github_api2/api/actions.rb +60 -0
- data/lib/github_api2/api/arguments.rb +253 -0
- data/lib/github_api2/api/config/property.rb +30 -0
- data/lib/github_api2/api/config/property_set.rb +120 -0
- data/lib/github_api2/api/config.rb +105 -0
- data/lib/github_api2/api/factory.rb +33 -0
- data/lib/github_api2/api.rb +398 -0
- data/lib/github_api2/authorization.rb +75 -0
- data/lib/github_api2/client/activity/events.rb +233 -0
- data/lib/github_api2/client/activity/feeds.rb +50 -0
- data/lib/github_api2/client/activity/notifications.rb +181 -0
- data/lib/github_api2/client/activity/starring.rb +130 -0
- data/lib/github_api2/client/activity/watching.rb +176 -0
- data/lib/github_api2/client/activity.rb +31 -0
- data/lib/github_api2/client/authorizations/app.rb +98 -0
- data/lib/github_api2/client/authorizations.rb +142 -0
- data/lib/github_api2/client/emojis.rb +19 -0
- data/lib/github_api2/client/gists/comments.rb +100 -0
- data/lib/github_api2/client/gists.rb +289 -0
- data/lib/github_api2/client/git_data/blobs.rb +51 -0
- data/lib/github_api2/client/git_data/commits.rb +101 -0
- data/lib/github_api2/client/git_data/references.rb +150 -0
- data/lib/github_api2/client/git_data/tags.rb +95 -0
- data/lib/github_api2/client/git_data/trees.rb +113 -0
- data/lib/github_api2/client/git_data.rb +31 -0
- data/lib/github_api2/client/gitignore.rb +57 -0
- data/lib/github_api2/client/issues/assignees.rb +77 -0
- data/lib/github_api2/client/issues/comments.rb +146 -0
- data/lib/github_api2/client/issues/events.rb +50 -0
- data/lib/github_api2/client/issues/labels.rb +189 -0
- data/lib/github_api2/client/issues/milestones.rb +146 -0
- data/lib/github_api2/client/issues.rb +248 -0
- data/lib/github_api2/client/markdown.rb +62 -0
- data/lib/github_api2/client/meta.rb +19 -0
- data/lib/github_api2/client/orgs/hooks.rb +182 -0
- data/lib/github_api2/client/orgs/members.rb +142 -0
- data/lib/github_api2/client/orgs/memberships.rb +131 -0
- data/lib/github_api2/client/orgs/projects.rb +57 -0
- data/lib/github_api2/client/orgs/teams.rb +407 -0
- data/lib/github_api2/client/orgs.rb +127 -0
- data/lib/github_api2/client/projects/cards.rb +158 -0
- data/lib/github_api2/client/projects/columns.rb +146 -0
- data/lib/github_api2/client/projects.rb +83 -0
- data/lib/github_api2/client/pull_requests/comments.rb +140 -0
- data/lib/github_api2/client/pull_requests/reviews.rb +158 -0
- data/lib/github_api2/client/pull_requests.rb +195 -0
- data/lib/github_api2/client/repos/branches/protections.rb +75 -0
- data/lib/github_api2/client/repos/branches.rb +48 -0
- data/lib/github_api2/client/repos/collaborators.rb +84 -0
- data/lib/github_api2/client/repos/comments.rb +125 -0
- data/lib/github_api2/client/repos/commits.rb +80 -0
- data/lib/github_api2/client/repos/contents.rb +263 -0
- data/lib/github_api2/client/repos/deployments.rb +138 -0
- data/lib/github_api2/client/repos/downloads.rb +62 -0
- data/lib/github_api2/client/repos/forks.rb +50 -0
- data/lib/github_api2/client/repos/hooks.rb +214 -0
- data/lib/github_api2/client/repos/invitations.rb +41 -0
- data/lib/github_api2/client/repos/keys.rb +104 -0
- data/lib/github_api2/client/repos/merging.rb +47 -0
- data/lib/github_api2/client/repos/pages.rb +48 -0
- data/lib/github_api2/client/repos/projects.rb +62 -0
- data/lib/github_api2/client/repos/pub_sub_hubbub.rb +133 -0
- data/lib/github_api2/client/repos/releases/assets.rb +136 -0
- data/lib/github_api2/client/repos/releases/tags.rb +24 -0
- data/lib/github_api2/client/repos/releases.rb +189 -0
- data/lib/github_api2/client/repos/statistics.rb +89 -0
- data/lib/github_api2/client/repos/statuses.rb +91 -0
- data/lib/github_api2/client/repos.rb +473 -0
- data/lib/github_api2/client/say.rb +25 -0
- data/lib/github_api2/client/scopes.rb +46 -0
- data/lib/github_api2/client/search/legacy.rb +111 -0
- data/lib/github_api2/client/search.rb +133 -0
- data/lib/github_api2/client/users/emails.rb +65 -0
- data/lib/github_api2/client/users/followers.rb +115 -0
- data/lib/github_api2/client/users/keys.rb +104 -0
- data/lib/github_api2/client/users.rb +117 -0
- data/lib/github_api2/client.rb +77 -0
- data/lib/github_api2/configuration.rb +70 -0
- data/lib/github_api2/connection.rb +82 -0
- data/lib/github_api2/constants.rb +61 -0
- data/lib/github_api2/core_ext/array.rb +25 -0
- data/lib/github_api2/core_ext/hash.rb +91 -0
- data/lib/github_api2/deprecation.rb +39 -0
- data/lib/github_api2/error/client_error.rb +89 -0
- data/lib/github_api2/error/service_error.rb +223 -0
- data/lib/github_api2/error.rb +32 -0
- data/lib/github_api2/ext/faraday.rb +40 -0
- data/lib/github_api2/mash.rb +7 -0
- data/lib/github_api2/middleware.rb +37 -0
- data/lib/github_api2/mime_type.rb +33 -0
- data/lib/github_api2/normalizer.rb +23 -0
- data/lib/github_api2/null_encoder.rb +25 -0
- data/lib/github_api2/page_iterator.rb +138 -0
- data/lib/github_api2/page_links.rb +63 -0
- data/lib/github_api2/paged_request.rb +42 -0
- data/lib/github_api2/pagination.rb +115 -0
- data/lib/github_api2/parameter_filter.rb +35 -0
- data/lib/github_api2/params_hash.rb +115 -0
- data/lib/github_api2/rate_limit.rb +25 -0
- data/lib/github_api2/request/basic_auth.rb +36 -0
- data/lib/github_api2/request/jsonize.rb +54 -0
- data/lib/github_api2/request/oauth2.rb +45 -0
- data/lib/github_api2/request/verbs.rb +63 -0
- data/lib/github_api2/request.rb +84 -0
- data/lib/github_api2/response/atom_parser.rb +22 -0
- data/lib/github_api2/response/follow_redirects.rb +140 -0
- data/lib/github_api2/response/header.rb +87 -0
- data/lib/github_api2/response/jsonize.rb +28 -0
- data/lib/github_api2/response/mashify.rb +24 -0
- data/lib/github_api2/response/raise_error.rb +22 -0
- data/lib/github_api2/response/xmlize.rb +28 -0
- data/lib/github_api2/response.rb +48 -0
- data/lib/github_api2/response_wrapper.rb +161 -0
- data/lib/github_api2/ssl_certs/cacerts.pem +2183 -0
- data/lib/github_api2/utils/url.rb +63 -0
- data/lib/github_api2/validations/format.rb +26 -0
- data/lib/github_api2/validations/presence.rb +32 -0
- data/lib/github_api2/validations/required.rb +21 -0
- data/lib/github_api2/validations/token.rb +41 -0
- data/lib/github_api2/validations.rb +22 -0
- data/lib/github_api2/version.rb +5 -0
- data/lib/github_api2.rb +92 -0
- metadata +363 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../api'
|
|
4
|
+
require_relative '../utils/url'
|
|
5
|
+
|
|
6
|
+
module Github
|
|
7
|
+
# The Search API is optimized to help you find the specific item
|
|
8
|
+
# you're looking for (e.g., a specific user, a specific file
|
|
9
|
+
# in a repository, etc.).
|
|
10
|
+
class Client::Search < API
|
|
11
|
+
include Github::Utils::Url
|
|
12
|
+
|
|
13
|
+
require_all 'github_api2/client/search', 'legacy'
|
|
14
|
+
|
|
15
|
+
# Access to Search::Legacy API
|
|
16
|
+
namespace :legacy
|
|
17
|
+
|
|
18
|
+
# Search issues
|
|
19
|
+
#
|
|
20
|
+
# Find issues by state and keyword.
|
|
21
|
+
# (This method returns up to 100 results per page.)
|
|
22
|
+
#
|
|
23
|
+
# @param [Hash] params
|
|
24
|
+
# @option params [String] :q
|
|
25
|
+
# The search terms. This can be any combination of the supported
|
|
26
|
+
# issue search parameters.
|
|
27
|
+
# @option params [String] :sort
|
|
28
|
+
# Optional sort field. One of comments, created, or updated.
|
|
29
|
+
# If not provided, results are sorted by best match.
|
|
30
|
+
# @option params [String] :order
|
|
31
|
+
# The sort order if sort parameter is provided.
|
|
32
|
+
# One of asc or desc. Default: desc
|
|
33
|
+
#
|
|
34
|
+
# @example
|
|
35
|
+
# github = Github.new
|
|
36
|
+
# github.search.issues 'query'
|
|
37
|
+
#
|
|
38
|
+
# @example
|
|
39
|
+
# github.search.issues q: 'query'
|
|
40
|
+
#
|
|
41
|
+
# @api public
|
|
42
|
+
def issues(*args)
|
|
43
|
+
params = arguments(args, required: [:q]).params
|
|
44
|
+
params['q'] ||= arguments.q
|
|
45
|
+
|
|
46
|
+
get_request('/search/issues' , params)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Search repositories
|
|
50
|
+
#
|
|
51
|
+
# Find repositories via various criteria.
|
|
52
|
+
# (This method returns up to 100 results per page.)
|
|
53
|
+
#
|
|
54
|
+
# @param [Hash] params
|
|
55
|
+
# @option params [String] :q
|
|
56
|
+
# The search keywords, as well as any qualifiers.
|
|
57
|
+
# @option params [String] :sort
|
|
58
|
+
# The sort field. One of stars, forks, or updated.
|
|
59
|
+
# Default: results are sorted by best match.
|
|
60
|
+
# @option params [String] :order
|
|
61
|
+
# The sort order if sort parameter is provided.
|
|
62
|
+
# One of asc or desc. Default: desc
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# github = Github.new
|
|
66
|
+
# github.search.repos 'query'
|
|
67
|
+
#
|
|
68
|
+
# @example
|
|
69
|
+
# github.search.repos q: 'query'
|
|
70
|
+
#
|
|
71
|
+
# @api public
|
|
72
|
+
def repos(*args)
|
|
73
|
+
params = arguments(args, required: [:q]).params
|
|
74
|
+
params['q'] ||= arguments.q
|
|
75
|
+
|
|
76
|
+
get_request('/search/repositories', arguments.params)
|
|
77
|
+
end
|
|
78
|
+
alias :repositories :repos
|
|
79
|
+
|
|
80
|
+
# Search users
|
|
81
|
+
#
|
|
82
|
+
# Find users by keyword.
|
|
83
|
+
#
|
|
84
|
+
# @param [Hash] params
|
|
85
|
+
# @option params [String] :q
|
|
86
|
+
# The search terms. This can be any combination of the supported
|
|
87
|
+
# issue search parameters.
|
|
88
|
+
# @option params [String] :sort
|
|
89
|
+
# Optional sort field. One of comments, created, or updated.
|
|
90
|
+
# If not provided, results are sorted by best match.
|
|
91
|
+
# @option params [String] :order
|
|
92
|
+
# The sort order if sort parameter is provided.
|
|
93
|
+
# One of asc or desc. Default: desc
|
|
94
|
+
#
|
|
95
|
+
# @example
|
|
96
|
+
# github = Github.new
|
|
97
|
+
# github.search.users q: 'wycats'
|
|
98
|
+
#
|
|
99
|
+
# @api public
|
|
100
|
+
def users(*args)
|
|
101
|
+
params = arguments(args, required: [:q]).params
|
|
102
|
+
params['q'] ||= arguments.q
|
|
103
|
+
|
|
104
|
+
get_request('/search/users', arguments.params)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Find file contents via various criteria.
|
|
108
|
+
# (This method returns up to 100 results per page.)
|
|
109
|
+
#
|
|
110
|
+
# @param [Hash] params
|
|
111
|
+
# @option params [String] :q
|
|
112
|
+
# The search terms. This can be any combination of the supported
|
|
113
|
+
# issue search parameters.
|
|
114
|
+
# @option params [String] :sort
|
|
115
|
+
# Optional sort field. One of comments, created, or updated.
|
|
116
|
+
# If not provided, results are sorted by best match.
|
|
117
|
+
# @option params [String] :order
|
|
118
|
+
# The sort order if sort parameter is provided.
|
|
119
|
+
# One of asc or desc. Default: desc
|
|
120
|
+
#
|
|
121
|
+
# @example
|
|
122
|
+
# github = Github.new
|
|
123
|
+
# github.search.code q: 'wycats'
|
|
124
|
+
#
|
|
125
|
+
# @api public
|
|
126
|
+
def code(*args)
|
|
127
|
+
params = arguments(args, required: [:q]).params
|
|
128
|
+
params['q'] ||= arguments.q
|
|
129
|
+
|
|
130
|
+
get_request('/search/code', params)
|
|
131
|
+
end
|
|
132
|
+
end # Search
|
|
133
|
+
end # Github
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'cgi'
|
|
4
|
+
|
|
5
|
+
require_relative '../../api'
|
|
6
|
+
|
|
7
|
+
module Github
|
|
8
|
+
class Client::Users::Emails < API
|
|
9
|
+
|
|
10
|
+
# List email addresses for the authenticated user
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
# github = Github.new oauth_token: '...'
|
|
14
|
+
# github.users.emails.list
|
|
15
|
+
# github.users.emails.list { |email| ... }
|
|
16
|
+
#
|
|
17
|
+
# @return [Hash]
|
|
18
|
+
#
|
|
19
|
+
# @api public
|
|
20
|
+
def list(*args)
|
|
21
|
+
arguments(args)
|
|
22
|
+
response = get_request("/user/emails", arguments.params)
|
|
23
|
+
return response unless block_given?
|
|
24
|
+
response.each { |el| yield el }
|
|
25
|
+
end
|
|
26
|
+
alias :all :list
|
|
27
|
+
|
|
28
|
+
# Add email address(es) for the authenticated user
|
|
29
|
+
#
|
|
30
|
+
# @param [Array[String]] emails
|
|
31
|
+
# You can include a single email address or an array of addresses
|
|
32
|
+
#
|
|
33
|
+
# @example
|
|
34
|
+
# github = Github.new oauth_token: '...'
|
|
35
|
+
# github.users.emails.add "octocat@github.com", "support@github.com"
|
|
36
|
+
#
|
|
37
|
+
# @api public
|
|
38
|
+
def add(*args)
|
|
39
|
+
arguments(args)
|
|
40
|
+
params = arguments.params
|
|
41
|
+
params['data'] = arguments.remaining unless arguments.remaining.empty?
|
|
42
|
+
|
|
43
|
+
post_request("/user/emails", params)
|
|
44
|
+
end
|
|
45
|
+
alias :<< :add
|
|
46
|
+
|
|
47
|
+
# Delete email address(es) for the authenticated user
|
|
48
|
+
#
|
|
49
|
+
# @param [Array[String]] emails
|
|
50
|
+
# You can include a single email address or an array of addresses
|
|
51
|
+
#
|
|
52
|
+
# @example
|
|
53
|
+
# github = Github.new oauth_token: '...'
|
|
54
|
+
# github.users.emails.delete "octocat@github.com", "support@github.com"
|
|
55
|
+
#
|
|
56
|
+
# @api public
|
|
57
|
+
def delete(*args)
|
|
58
|
+
arguments(args)
|
|
59
|
+
params = arguments.params
|
|
60
|
+
params['data'] = arguments.remaining unless arguments.remaining.empty?
|
|
61
|
+
|
|
62
|
+
delete_request("/user/emails", params)
|
|
63
|
+
end
|
|
64
|
+
end # Users::Emails
|
|
65
|
+
end # Github
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Users::Followers < API
|
|
7
|
+
|
|
8
|
+
# List a user's followers
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# github = Github.new
|
|
12
|
+
# github.users.followers.list 'user-name'
|
|
13
|
+
# github.users.followers.list 'user-name' { |user| ... }
|
|
14
|
+
#
|
|
15
|
+
# List the authenticated user's followers
|
|
16
|
+
#
|
|
17
|
+
# @example
|
|
18
|
+
# github = Github.new oauth_token: '...'
|
|
19
|
+
# github.users.followers
|
|
20
|
+
# github.users.followers { |user| ... }
|
|
21
|
+
#
|
|
22
|
+
# @api public
|
|
23
|
+
def list(*args)
|
|
24
|
+
params = arguments(args).params
|
|
25
|
+
|
|
26
|
+
response = if user_name = arguments.remaining.first
|
|
27
|
+
get_request("/users/#{user_name}/followers", params)
|
|
28
|
+
else
|
|
29
|
+
get_request("/user/followers", params)
|
|
30
|
+
end
|
|
31
|
+
return response unless block_given?
|
|
32
|
+
response.each { |el| yield el }
|
|
33
|
+
end
|
|
34
|
+
alias :all :list
|
|
35
|
+
|
|
36
|
+
# List who a user is following
|
|
37
|
+
#
|
|
38
|
+
# @example
|
|
39
|
+
# github = Github.new
|
|
40
|
+
# github.users.followers.following 'user-name'
|
|
41
|
+
# github.users.followers.following 'user-name' { |user| ... }
|
|
42
|
+
#
|
|
43
|
+
# List who the authenicated user is following
|
|
44
|
+
#
|
|
45
|
+
# @example
|
|
46
|
+
# github = Github.new oauth_token: '...'
|
|
47
|
+
# github.users.followers.following
|
|
48
|
+
#
|
|
49
|
+
# @api public
|
|
50
|
+
def following(*args)
|
|
51
|
+
params = arguments(args).params
|
|
52
|
+
|
|
53
|
+
response = if user_name = arguments.remaining.first
|
|
54
|
+
get_request("/users/#{user_name}/following", params)
|
|
55
|
+
else
|
|
56
|
+
get_request("/user/following", params)
|
|
57
|
+
end
|
|
58
|
+
return response unless block_given?
|
|
59
|
+
response.each { |el| yield el }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Check if you are following a user
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# github = Github.new oauth_token: '...'
|
|
66
|
+
# github.users.followers.following? 'user-name'
|
|
67
|
+
# github.users.followers.following? username: 'user-name'
|
|
68
|
+
#
|
|
69
|
+
# Check if one user follows another
|
|
70
|
+
#
|
|
71
|
+
# @example
|
|
72
|
+
# github = Github.new oauth_token: '...'
|
|
73
|
+
# github.users.followers.following? username: 'user-name',
|
|
74
|
+
# target_user: 'target-user-name'
|
|
75
|
+
#
|
|
76
|
+
# @api public
|
|
77
|
+
def following?(*args)
|
|
78
|
+
arguments(args, required: [:username])
|
|
79
|
+
params = arguments.params
|
|
80
|
+
if target_user = params.delete('target_user')
|
|
81
|
+
get_request("/users/#{arguments.username}/following/#{target_user}", params)
|
|
82
|
+
else
|
|
83
|
+
get_request("/user/following/#{arguments.username}", params)
|
|
84
|
+
end
|
|
85
|
+
true
|
|
86
|
+
rescue Github::Error::NotFound
|
|
87
|
+
false
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Follow a user
|
|
91
|
+
#
|
|
92
|
+
# @example
|
|
93
|
+
# github = Github.new oauth_token: '...'
|
|
94
|
+
# github.users.followers.follow 'user-name'
|
|
95
|
+
# github.users.followers.follow username: 'user-name'
|
|
96
|
+
#
|
|
97
|
+
# @api public
|
|
98
|
+
def follow(*args)
|
|
99
|
+
arguments(args, required: [:username])
|
|
100
|
+
put_request("/user/following/#{arguments.username}", arguments.params)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Unfollow a user
|
|
104
|
+
#
|
|
105
|
+
# @example
|
|
106
|
+
# github = Github.new oauth_token: '...'
|
|
107
|
+
# github.users.followers.unfollow 'user-name'
|
|
108
|
+
# github.users.followers.unfollow username: 'user-name'
|
|
109
|
+
#
|
|
110
|
+
def unfollow(*args)
|
|
111
|
+
arguments(args, required: [:username])
|
|
112
|
+
delete_request("/user/following/#{arguments.username}", arguments.params)
|
|
113
|
+
end
|
|
114
|
+
end # Users::Followers
|
|
115
|
+
end # Github
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Users::Keys < API
|
|
7
|
+
|
|
8
|
+
VALID_KEY_PARAM_NAMES = %w[ title key ].freeze
|
|
9
|
+
|
|
10
|
+
# List public keys for the authenticated user
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
# github = Github.new oauth_token: '...'
|
|
14
|
+
# github.users.keys.list
|
|
15
|
+
# github.users.keys.list { |key| ... }
|
|
16
|
+
#
|
|
17
|
+
# List public keys for the specified user
|
|
18
|
+
#
|
|
19
|
+
# @example
|
|
20
|
+
# github.users.keys.list user: 'user-name'
|
|
21
|
+
# github.users.keys.list user: 'user-name' { |key| ... }
|
|
22
|
+
#
|
|
23
|
+
# @return [Hash]
|
|
24
|
+
#
|
|
25
|
+
# @api public
|
|
26
|
+
def list(*args)
|
|
27
|
+
params = arguments(args).params
|
|
28
|
+
response = if (user = params.delete('user'))
|
|
29
|
+
get_request("/users/#{user}/keys", params)
|
|
30
|
+
else
|
|
31
|
+
get_request("/user/keys", params)
|
|
32
|
+
end
|
|
33
|
+
return response unless block_given?
|
|
34
|
+
response.each { |el| yield el }
|
|
35
|
+
end
|
|
36
|
+
alias :all :list
|
|
37
|
+
|
|
38
|
+
# Get a single pulic key for the authenticated user
|
|
39
|
+
#
|
|
40
|
+
# @example
|
|
41
|
+
# github = Github.new oauth_token: '...'
|
|
42
|
+
# github.users.keys.get 'key-id'
|
|
43
|
+
#
|
|
44
|
+
# @api public
|
|
45
|
+
def get(*args)
|
|
46
|
+
arguments(args, required: [:id])
|
|
47
|
+
get_request("/user/keys/#{arguments.id}", arguments.params)
|
|
48
|
+
end
|
|
49
|
+
alias :find :get
|
|
50
|
+
|
|
51
|
+
# Create a public key for the authenticated user
|
|
52
|
+
#
|
|
53
|
+
# @param [Hash] params
|
|
54
|
+
# @option [String] :title
|
|
55
|
+
# Required string
|
|
56
|
+
# @option [String] :key
|
|
57
|
+
# Required string. sha key
|
|
58
|
+
#
|
|
59
|
+
# @example
|
|
60
|
+
# github = Github.new oauth_token: '...'
|
|
61
|
+
# github.users.keys.create "title": "octocat@octomac", "key": "ssh-rsa AAA..."
|
|
62
|
+
#
|
|
63
|
+
# @api public
|
|
64
|
+
def create(*args)
|
|
65
|
+
arguments(args) do
|
|
66
|
+
permit VALID_KEY_PARAM_NAMES
|
|
67
|
+
end
|
|
68
|
+
post_request("/user/keys", arguments.params)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Update a public key for the authenticated user
|
|
72
|
+
#
|
|
73
|
+
# @param [Hash] params
|
|
74
|
+
# @option [String] :title
|
|
75
|
+
# Required string
|
|
76
|
+
# @option [String] :key
|
|
77
|
+
# Required string. sha key
|
|
78
|
+
#
|
|
79
|
+
# @example
|
|
80
|
+
# github = Github.new oauth_token: '...'
|
|
81
|
+
# github.users.keys.update 'key-id', "title": "octocat@octomac",
|
|
82
|
+
# "key": "ssh-rsa AAA..."
|
|
83
|
+
#
|
|
84
|
+
# @api public
|
|
85
|
+
def update(*args)
|
|
86
|
+
arguments(args, required: [:id]) do
|
|
87
|
+
permit VALID_KEY_PARAM_NAMES
|
|
88
|
+
end
|
|
89
|
+
patch_request("/user/keys/#{arguments.id}", arguments.params)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Delete a public key for the authenticated user
|
|
93
|
+
#
|
|
94
|
+
# @example
|
|
95
|
+
# github = Github.new oauth_token: '...'
|
|
96
|
+
# github.users.keys.delete 'key-id'
|
|
97
|
+
#
|
|
98
|
+
# @api public
|
|
99
|
+
def delete(*args)
|
|
100
|
+
arguments(args, required: [:id])
|
|
101
|
+
delete_request("/user/keys/#{arguments.id}", arguments.params)
|
|
102
|
+
end
|
|
103
|
+
end # Users::Keys
|
|
104
|
+
end # Github
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Users < API
|
|
7
|
+
# Load all the modules after initializing Repos to avoid superclass mismatch
|
|
8
|
+
require_all 'github_api2/client/users',
|
|
9
|
+
'emails',
|
|
10
|
+
'followers',
|
|
11
|
+
'keys'
|
|
12
|
+
|
|
13
|
+
VALID_USER_PARAMS_NAMES = %w[
|
|
14
|
+
name
|
|
15
|
+
email
|
|
16
|
+
blog
|
|
17
|
+
company
|
|
18
|
+
location
|
|
19
|
+
hireable
|
|
20
|
+
bio
|
|
21
|
+
].freeze
|
|
22
|
+
|
|
23
|
+
# Access to Users::Emails API
|
|
24
|
+
namespace :emails
|
|
25
|
+
|
|
26
|
+
# Access to Users::Followers API
|
|
27
|
+
namespace :followers
|
|
28
|
+
|
|
29
|
+
# Access to Users::Keys API
|
|
30
|
+
namespace :keys
|
|
31
|
+
|
|
32
|
+
# List all users.
|
|
33
|
+
#
|
|
34
|
+
# This provides a dump of every user, in the order that they signed up
|
|
35
|
+
# for GitHub.
|
|
36
|
+
#
|
|
37
|
+
# @param [Hash] params
|
|
38
|
+
# @option [Integer] :since
|
|
39
|
+
# The integer ID of the last User that you’ve seen.
|
|
40
|
+
#
|
|
41
|
+
# @example
|
|
42
|
+
# users = Github::Users.new
|
|
43
|
+
# users.list
|
|
44
|
+
#
|
|
45
|
+
# @api public
|
|
46
|
+
def list(*args)
|
|
47
|
+
arguments(args)
|
|
48
|
+
|
|
49
|
+
response = get_request("/users", arguments.params)
|
|
50
|
+
return response unless block_given?
|
|
51
|
+
response.each { |el| yield el }
|
|
52
|
+
end
|
|
53
|
+
alias :all :list
|
|
54
|
+
|
|
55
|
+
# Get a single unauthenticated user
|
|
56
|
+
#
|
|
57
|
+
# @example
|
|
58
|
+
# github = Github.new
|
|
59
|
+
# github.users.get user: 'user-name'
|
|
60
|
+
#
|
|
61
|
+
# Get the authenticated user
|
|
62
|
+
#
|
|
63
|
+
# @example
|
|
64
|
+
# github = Github.new oauth_token: '...'
|
|
65
|
+
# github.users.get
|
|
66
|
+
#
|
|
67
|
+
# @api public
|
|
68
|
+
def get(*args)
|
|
69
|
+
params = arguments(args).params
|
|
70
|
+
|
|
71
|
+
if user_name = params.delete('user')
|
|
72
|
+
get_request("/users/#{user_name}", params)
|
|
73
|
+
else
|
|
74
|
+
get_request("/user", params)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
alias :find :get
|
|
78
|
+
|
|
79
|
+
# Update the authenticated user
|
|
80
|
+
#
|
|
81
|
+
# @param [Hash] params
|
|
82
|
+
# @option params [String] :name
|
|
83
|
+
# Optional string
|
|
84
|
+
# @option params [String] :email
|
|
85
|
+
# Optional string - publically visible email address
|
|
86
|
+
# @option params [String] :blog
|
|
87
|
+
# Optional string
|
|
88
|
+
# @option params [String] :company
|
|
89
|
+
# Optional string
|
|
90
|
+
# @option params [String] :location
|
|
91
|
+
# Optional string
|
|
92
|
+
# @option params [String] :hireable
|
|
93
|
+
# Optional boolean
|
|
94
|
+
# @option params [String] :bio
|
|
95
|
+
# Optional string
|
|
96
|
+
#
|
|
97
|
+
# @example
|
|
98
|
+
# github = Github.new oauth_token: '..'
|
|
99
|
+
# github.users.update
|
|
100
|
+
# name: "monalisa octocat",
|
|
101
|
+
# email: "octocat@github.com",
|
|
102
|
+
# blog: "https://github.com/blog",
|
|
103
|
+
# company: "GitHub",
|
|
104
|
+
# location: "San Francisco",
|
|
105
|
+
# hireable: true,
|
|
106
|
+
# bio: "There once..."
|
|
107
|
+
#
|
|
108
|
+
# @api public
|
|
109
|
+
def update(*args)
|
|
110
|
+
arguments(args) do
|
|
111
|
+
permit VALID_USER_PARAMS_NAMES
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
patch_request("/user", arguments.params)
|
|
115
|
+
end
|
|
116
|
+
end # Users
|
|
117
|
+
end # Github
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative 'api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client < API
|
|
7
|
+
require_all 'github_api2/client',
|
|
8
|
+
'activity',
|
|
9
|
+
'authorizations',
|
|
10
|
+
'emojis',
|
|
11
|
+
'gists',
|
|
12
|
+
'gitignore',
|
|
13
|
+
'git_data',
|
|
14
|
+
'issues',
|
|
15
|
+
'markdown',
|
|
16
|
+
'meta',
|
|
17
|
+
'orgs',
|
|
18
|
+
'projects',
|
|
19
|
+
'pull_requests',
|
|
20
|
+
'repos',
|
|
21
|
+
'say',
|
|
22
|
+
'scopes',
|
|
23
|
+
'search',
|
|
24
|
+
'users'
|
|
25
|
+
|
|
26
|
+
# Serving up the 'social' in Social Coding, the Activity APIs
|
|
27
|
+
# provide access to notifications, subscriptions, and timelines.
|
|
28
|
+
namespace :activity
|
|
29
|
+
|
|
30
|
+
namespace :emojis
|
|
31
|
+
|
|
32
|
+
namespace :gists
|
|
33
|
+
|
|
34
|
+
namespace :gitignore
|
|
35
|
+
alias :git_ignore :gitignore
|
|
36
|
+
|
|
37
|
+
# The Git Database API gives you access to read and write raw Git objects
|
|
38
|
+
# to your Git database on GitHub and to list and update your references
|
|
39
|
+
# (branch heads and tags).
|
|
40
|
+
namespace :git_data
|
|
41
|
+
alias :git :git_data
|
|
42
|
+
|
|
43
|
+
namespace :issues
|
|
44
|
+
|
|
45
|
+
namespace :markdown
|
|
46
|
+
|
|
47
|
+
namespace :meta
|
|
48
|
+
|
|
49
|
+
# An API for users to manage their own tokens. You can only access your own
|
|
50
|
+
# tokens, and only through Basic Authentication.
|
|
51
|
+
namespace :authorizations
|
|
52
|
+
alias :oauth :authorizations
|
|
53
|
+
alias :auth :authorizations
|
|
54
|
+
|
|
55
|
+
namespace :orgs
|
|
56
|
+
alias :organizations :orgs
|
|
57
|
+
|
|
58
|
+
namespace :projects
|
|
59
|
+
|
|
60
|
+
namespace :pull_requests
|
|
61
|
+
alias :pulls :pull_requests
|
|
62
|
+
|
|
63
|
+
namespace :repos
|
|
64
|
+
alias :repositories :repos
|
|
65
|
+
|
|
66
|
+
namespace :say
|
|
67
|
+
alias :octocat :say
|
|
68
|
+
|
|
69
|
+
namespace :scopes
|
|
70
|
+
|
|
71
|
+
namespace :search
|
|
72
|
+
|
|
73
|
+
# Many of the resources on the users API provide a shortcut for getting
|
|
74
|
+
# information about the currently authenticated user.
|
|
75
|
+
namespace :users
|
|
76
|
+
end # Client
|
|
77
|
+
end # Github
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative 'api/config'
|
|
4
|
+
require_relative 'version'
|
|
5
|
+
|
|
6
|
+
module Github
|
|
7
|
+
# Stores the configuration
|
|
8
|
+
class Configuration < API::Config
|
|
9
|
+
|
|
10
|
+
# Other adapters are :typhoeus, :patron, :em_synchrony, :excon, :test
|
|
11
|
+
property :adapter, default: :net_http
|
|
12
|
+
|
|
13
|
+
# By default, don't traverse the page links
|
|
14
|
+
property :auto_pagination, default: false
|
|
15
|
+
|
|
16
|
+
property :follow_redirects, default: true
|
|
17
|
+
|
|
18
|
+
# Basic authentication
|
|
19
|
+
property :basic_auth
|
|
20
|
+
|
|
21
|
+
# By default, don't set an application key
|
|
22
|
+
property :client_id
|
|
23
|
+
|
|
24
|
+
# By default, don't set an application secret
|
|
25
|
+
property :client_secret
|
|
26
|
+
|
|
27
|
+
# By default, don't set a user oauth access token
|
|
28
|
+
property :oauth_token
|
|
29
|
+
|
|
30
|
+
# The api endpoint used to connect to GitHub if none is set
|
|
31
|
+
property :endpoint, default: 'https://api.github.com'.freeze
|
|
32
|
+
|
|
33
|
+
# The web endpoint used to connect to GitHub if none is set
|
|
34
|
+
property :site, default: 'https://github.com'.freeze
|
|
35
|
+
|
|
36
|
+
# The web endpoint used to upload release assets to GitHub if none is set
|
|
37
|
+
property :upload_endpoint, default: 'https://uploads.github.com'.freeze
|
|
38
|
+
|
|
39
|
+
# The default SSL configuration
|
|
40
|
+
property :ssl, default: {
|
|
41
|
+
:ca_file => File.expand_path('../ssl_certs/cacerts.pem', __FILE__)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# By default the Accept header will make a request for JSON
|
|
45
|
+
property :mime_type
|
|
46
|
+
|
|
47
|
+
# The value sent in the http header for 'User-Agent' if none is set
|
|
48
|
+
property :user_agent, default: "Github API Ruby Gem #{Github::VERSION}".freeze
|
|
49
|
+
|
|
50
|
+
# By default uses the Faraday connection options if none is set
|
|
51
|
+
property :connection_options, default: {}
|
|
52
|
+
|
|
53
|
+
# Global repository name
|
|
54
|
+
property :repo
|
|
55
|
+
|
|
56
|
+
property :user
|
|
57
|
+
|
|
58
|
+
property :org
|
|
59
|
+
|
|
60
|
+
property :login
|
|
61
|
+
|
|
62
|
+
property :password
|
|
63
|
+
|
|
64
|
+
# By default display 30 resources
|
|
65
|
+
property :per_page, default: 30
|
|
66
|
+
|
|
67
|
+
# Add Faraday::RackBuilder to overwrite middleware
|
|
68
|
+
property :stack
|
|
69
|
+
end # Configuration
|
|
70
|
+
end # Github
|