octokit 4.6.2 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +14 -13
- data/LICENSE.md +1 -1
- data/README.md +218 -109
- data/Rakefile +5 -3
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +2 -2
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_secrets.rb +57 -0
- data/lib/octokit/client/actions_workflow_jobs.rb +61 -0
- data/lib/octokit/client/actions_workflow_runs.rb +121 -0
- data/lib/octokit/client/actions_workflows.rb +66 -0
- data/lib/octokit/client/apps.rb +222 -0
- data/lib/octokit/client/authorizations.rb +30 -89
- data/lib/octokit/client/checks.rb +200 -0
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +20 -0
- data/lib/octokit/client/commits.rb +31 -34
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +25 -20
- data/lib/octokit/client/deployments.rb +25 -5
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +7 -6
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +10 -10
- data/lib/octokit/client/issues.rb +60 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +4 -7
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +56 -0
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +5 -5
- data/lib/octokit/client/notifications.rb +6 -10
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +181 -61
- data/lib/octokit/client/pages.rb +5 -7
- data/lib/octokit/client/projects.rb +49 -69
- data/lib/octokit/client/pub_sub_hubbub.rb +16 -16
- data/lib/octokit/client/pull_requests.rb +47 -46
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +6 -11
- data/lib/octokit/client/refs.rb +33 -18
- data/lib/octokit/client/releases.rb +14 -13
- data/lib/octokit/client/repositories.rb +194 -53
- data/lib/octokit/client/repository_invitations.rb +4 -11
- data/lib/octokit/client/reviews.rb +227 -0
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +45 -17
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +8 -13
- data/lib/octokit/client/stats.rb +12 -9
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/traffic.rb +6 -11
- data/lib/octokit/client/users.rb +106 -25
- data/lib/octokit/client.rb +60 -15
- data/lib/octokit/configurable.rb +42 -30
- data/lib/octokit/connection.rb +34 -20
- data/lib/octokit/default.rb +61 -34
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
- data/lib/octokit/enterprise_admin_client/license.rb +4 -5
- data/lib/octokit/enterprise_admin_client/orgs.rb +5 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +17 -16
- data/lib/octokit/enterprise_admin_client.rb +9 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +33 -33
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +106 -25
- data/lib/octokit/gist.rb +3 -4
- data/lib/octokit/middleware/follow_redirects.rb +17 -13
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +6 -6
- data/lib/octokit/repo_arguments.rb +2 -3
- data/lib/octokit/repository.rb +27 -25
- data/lib/octokit/response/base_middleware.rb +10 -0
- data/lib/octokit/response/feed_parser.rb +5 -9
- data/lib/octokit/response/raise_error.rb +4 -6
- data/lib/octokit/user.rb +4 -2
- data/lib/octokit/version.rb +5 -3
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +15 -8
- data/octokit.gemspec +13 -10
- metadata +52 -21
- data/lib/octokit/preview.rb +0 -35
@@ -1,13 +1,13 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'erb'
|
2
4
|
|
3
5
|
module Octokit
|
4
6
|
class Client
|
5
|
-
|
6
7
|
# Methods for the Issue Labels API
|
7
8
|
#
|
8
9
|
# @see https://developer.github.com/v3/issues/labels/
|
9
10
|
module Labels
|
10
|
-
|
11
11
|
# List available labels for a repository
|
12
12
|
#
|
13
13
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -26,9 +26,9 @@ module Octokit
|
|
26
26
|
# @return [Sawyer::Resource] A single label from the repository
|
27
27
|
# @see https://developer.github.com/v3/issues/labels/#get-a-single-label
|
28
28
|
# @example Get the "V3 Addition" label from octokit/octokit.rb
|
29
|
-
# Octokit.
|
29
|
+
# Octokit.label("octokit/octokit.rb", "V3 Addition")
|
30
30
|
def label(repo, name, options = {})
|
31
|
-
get "#{Repository.path repo}/labels/#{name}", options
|
31
|
+
get "#{Repository.path repo}/labels/#{ERB::Util.url_encode(name)}", options
|
32
32
|
end
|
33
33
|
|
34
34
|
# Add a label to a repository
|
@@ -40,8 +40,8 @@ module Octokit
|
|
40
40
|
# @see https://developer.github.com/v3/issues/labels/#create-a-label
|
41
41
|
# @example Add a new label "Version 1.0" with color "#cccccc"
|
42
42
|
# Octokit.add_label("octokit/octokit.rb", "Version 1.0", "cccccc")
|
43
|
-
def add_label(repo, label, color=
|
44
|
-
post "#{Repository.path repo}/labels", options.merge({:
|
43
|
+
def add_label(repo, label, color = 'ffffff', options = {})
|
44
|
+
post "#{Repository.path repo}/labels", options.merge({ name: label, color: color })
|
45
45
|
end
|
46
46
|
|
47
47
|
# Update a label
|
@@ -56,7 +56,7 @@ module Octokit
|
|
56
56
|
# @example Update the label "Version 1.0" with new color "#cceeaa"
|
57
57
|
# Octokit.update_label("octokit/octokit.rb", "Version 1.0", {:color => "cceeaa"})
|
58
58
|
def update_label(repo, label, options = {})
|
59
|
-
patch "#{Repository.path repo}/labels/#{label}", options
|
59
|
+
patch "#{Repository.path repo}/labels/#{ERB::Util.url_encode(label)}", options
|
60
60
|
end
|
61
61
|
|
62
62
|
# Delete a label from a repository.
|
@@ -70,7 +70,7 @@ module Octokit
|
|
70
70
|
# @example Delete the label "Version 1.0" from the repository.
|
71
71
|
# Octokit.delete_label!("octokit/octokit.rb", "Version 1.0")
|
72
72
|
def delete_label!(repo, label, options = {})
|
73
|
-
boolean_from_response :delete, "#{Repository.path repo}/labels/#{label}", options
|
73
|
+
boolean_from_response :delete, "#{Repository.path repo}/labels/#{ERB::Util.url_encode(label)}", options
|
74
74
|
end
|
75
75
|
|
76
76
|
# Remove a label from an Issue
|
@@ -78,14 +78,14 @@ module Octokit
|
|
78
78
|
# This removes the label from the Issue
|
79
79
|
#
|
80
80
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
81
|
-
# @param number [
|
81
|
+
# @param number [Integer] Number ID of the issue
|
82
82
|
# @param label [String] String name of the label
|
83
83
|
# @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
|
84
84
|
# @see https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue
|
85
85
|
# @example Remove the label "Version 1.0" from the repository.
|
86
86
|
# Octokit.remove_label("octokit/octokit.rb", 23, "Version 1.0")
|
87
87
|
def remove_label(repo, number, label, options = {})
|
88
|
-
delete "#{Repository.path repo}/issues/#{number}/labels/#{label}", options
|
88
|
+
delete "#{Repository.path repo}/issues/#{number}/labels/#{ERB::Util.url_encode(label)}", options
|
89
89
|
end
|
90
90
|
|
91
91
|
# Remove all label from an Issue
|
@@ -93,7 +93,7 @@ module Octokit
|
|
93
93
|
# This removes the label from the Issue
|
94
94
|
#
|
95
95
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
96
|
-
# @param number [
|
96
|
+
# @param number [Integer] Number ID of the issue
|
97
97
|
# @return [Boolean] Success of operation
|
98
98
|
# @see https://developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue
|
99
99
|
# @example Remove all labels from Issue #23
|
@@ -105,7 +105,7 @@ module Octokit
|
|
105
105
|
# List labels for a given issue
|
106
106
|
#
|
107
107
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
108
|
-
# @param number [
|
108
|
+
# @param number [Integer] Number ID of the issue
|
109
109
|
# @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
|
110
110
|
# @see https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue
|
111
111
|
# @example List labels for octokit/octokit.rb, issue # 1
|
@@ -117,7 +117,7 @@ module Octokit
|
|
117
117
|
# Add label(s) to an Issue
|
118
118
|
#
|
119
119
|
# @param repo [Integer, String, Repository, Hash] A Github repository
|
120
|
-
# @param number [
|
120
|
+
# @param number [Integer] Number ID of the issue
|
121
121
|
# @param labels [Array] An array of labels to apply to this Issue
|
122
122
|
# @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
|
123
123
|
# @see https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue
|
@@ -130,20 +130,20 @@ module Octokit
|
|
130
130
|
# Replace all labels on an Issue
|
131
131
|
#
|
132
132
|
# @param repo [Integer, String, Repository, Hash] A Github repository
|
133
|
-
# @param number [
|
133
|
+
# @param number [Integer] Number ID of the issue
|
134
134
|
# @param labels [Array] An array of labels to use as replacement
|
135
135
|
# @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
|
136
136
|
# @see https://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue
|
137
137
|
# @example Replace labels for octokit/octokit.rb Issue #10
|
138
138
|
# Octokit.replace_all_labels("octokit/octokit.rb", 10, ['V3 Transition', 'Improvement'])
|
139
|
-
def replace_all_labels(repo, number, labels,
|
139
|
+
def replace_all_labels(repo, number, labels, _options = {})
|
140
140
|
put "#{Repository.path repo}/issues/#{number}/labels", labels
|
141
141
|
end
|
142
142
|
|
143
143
|
# Get labels for every issue in a milestone
|
144
144
|
#
|
145
145
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
146
|
-
# @param number [
|
146
|
+
# @param number [Integer] Number ID of the milestone
|
147
147
|
# @return [Array<Sawyer::Resource>] A list of the labels across the milestone
|
148
148
|
# @see http://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone
|
149
149
|
# @example List all labels for milestone #2 on octokit/octokit.rb
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Legacy Search API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/search/
|
7
8
|
module LegacySearch
|
8
|
-
|
9
9
|
# Legacy repository search
|
10
10
|
#
|
11
11
|
# @see https://developer.github.com/v3/search/#search-repositories
|
@@ -23,7 +23,7 @@ module Octokit
|
|
23
23
|
# @return [Array<Sawyer::Resource>] A list of issues matching the search term and state
|
24
24
|
# @example Search for 'test' in the open issues for sferik/rails_admin
|
25
25
|
# Octokit.search_issues("sferik/rails_admin", 'test', 'open')
|
26
|
-
def legacy_search_issues(repo, search_term, state='open', options = {})
|
26
|
+
def legacy_search_issues(repo, search_term, state = 'open', options = {})
|
27
27
|
get("legacy/issues/search/#{Repository.new(repo)}/#{state}/#{search_term}", options)['issues']
|
28
28
|
end
|
29
29
|
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for licenses API
|
5
6
|
#
|
6
7
|
module Licenses
|
7
|
-
|
8
8
|
# List all licenses
|
9
9
|
#
|
10
10
|
# @see https://developer.github.com/v3/licenses/#list-all-licenses
|
@@ -12,8 +12,7 @@ module Octokit
|
|
12
12
|
# @example
|
13
13
|
# Octokit.licenses
|
14
14
|
def licenses(options = {})
|
15
|
-
|
16
|
-
paginate "licenses", options
|
15
|
+
paginate 'licenses', options
|
17
16
|
end
|
18
17
|
|
19
18
|
# List an individual license
|
@@ -24,7 +23,6 @@ module Octokit
|
|
24
23
|
# @example
|
25
24
|
# Octokit.license 'mit'
|
26
25
|
def license(license_name, options = {})
|
27
|
-
options = ensure_api_media_type(:licenses, options)
|
28
26
|
get "licenses/#{license_name}", options
|
29
27
|
end
|
30
28
|
|
@@ -35,9 +33,8 @@ module Octokit
|
|
35
33
|
# @option options [String] :ref name of the Commit/Branch/Tag. Defaults to 'master'.
|
36
34
|
# @return [Sawyer::Resource] The detail of the license file
|
37
35
|
# @example
|
38
|
-
# Octokit.
|
36
|
+
# Octokit.repository_license_contents 'benbalter/licensee'
|
39
37
|
def repository_license_contents(repo, options = {})
|
40
|
-
options = ensure_api_media_type(:licenses, options)
|
41
38
|
get "#{Repository.path repo}/license", options
|
42
39
|
end
|
43
40
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Markdown API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/markdown/
|
7
8
|
module Markdown
|
8
|
-
|
9
9
|
# Render an arbitrary Markdown document
|
10
10
|
#
|
11
11
|
# @param text [String] Markdown source
|
@@ -20,7 +20,7 @@ module Octokit
|
|
20
20
|
options[:repo] = Repository.new(options[:repo]) if options[:repo]
|
21
21
|
options[:accept] = 'application/vnd.github.raw'
|
22
22
|
|
23
|
-
post
|
23
|
+
post 'markdown', options
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Marketplace Listing API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/apps/marketplace/
|
8
|
+
module Marketplace
|
9
|
+
# List all plans for an app's marketplace listing
|
10
|
+
#
|
11
|
+
# @param options [Hash] A customizable set of options
|
12
|
+
#
|
13
|
+
# @see https://developer.github.com/v3/apps/marketplace/#list-all-plans-for-your-marketplace-listing
|
14
|
+
#
|
15
|
+
# @return [Array<Sawyer::Resource>] A list of plans
|
16
|
+
def list_plans(options = {})
|
17
|
+
paginate '/marketplace_listing/plans', options
|
18
|
+
end
|
19
|
+
|
20
|
+
# List all GitHub accounts on a specific plan
|
21
|
+
#
|
22
|
+
# @param plan_id [Integer] The id of the GitHub plan
|
23
|
+
# @param options [Hash] A customizable set of options
|
24
|
+
#
|
25
|
+
# @see https://developer.github.com/v3/apps/marketplace/#list-all-github-accounts-user-or-organization-on-a-specific-plan
|
26
|
+
#
|
27
|
+
# @return [Array<Sawyer::Resource>] A list of accounts
|
28
|
+
def list_accounts_for_plan(plan_id, options = {})
|
29
|
+
paginate "/marketplace_listing/plans/#{plan_id}/accounts", options
|
30
|
+
end
|
31
|
+
|
32
|
+
# Get the plan associated with a given GitHub account
|
33
|
+
#
|
34
|
+
# @param account_id [Integer] The id of the GitHub account
|
35
|
+
# @param options [Hash] A customizable set of options
|
36
|
+
#
|
37
|
+
# @see https://developer.github.com/v3/apps/marketplace/#check-if-a-github-account-is-associated-with-any-marketplace-listing
|
38
|
+
#
|
39
|
+
# @return <Sawyer::Resource> Account with plan details, or nil
|
40
|
+
def plan_for_account(account_id, options = {})
|
41
|
+
get "/marketplace_listing/accounts/#{account_id}", options
|
42
|
+
end
|
43
|
+
|
44
|
+
# Get user's Marketplace purchases
|
45
|
+
#
|
46
|
+
# @param options [Hash] A customizable set of options
|
47
|
+
#
|
48
|
+
# @see https://developer.github.com/v3/apps/marketplace/#get-a-users-marketplace-purchases
|
49
|
+
#
|
50
|
+
# @return [Array<Sawyer::Resource>] A list of Marketplace purchases
|
51
|
+
def marketplace_purchases(options = {})
|
52
|
+
get '/user/marketplace_purchases', options
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/octokit/client/meta.rb
CHANGED
@@ -1,21 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Meta API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/meta/
|
7
8
|
module Meta
|
8
|
-
|
9
9
|
# Get meta information about GitHub.com, the service.
|
10
10
|
# @see https://developer.github.com/v3/meta/#meta
|
11
11
|
# @return [Sawyer::Resource] Hash with meta information.
|
12
12
|
# @example Get GitHub meta information
|
13
13
|
# @client.github_meta
|
14
14
|
def meta(options = {})
|
15
|
-
get
|
15
|
+
get 'meta', options
|
16
16
|
end
|
17
|
-
alias
|
18
|
-
|
17
|
+
alias github_meta meta
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Issues Milestones API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/issues/milestones/
|
7
8
|
module Milestones
|
8
|
-
|
9
9
|
# List milestones for a repository
|
10
10
|
#
|
11
11
|
# @param repository [Integer, String, Repository, Hash] A GitHub repository
|
@@ -21,7 +21,7 @@ module Octokit
|
|
21
21
|
def list_milestones(repository, options = {})
|
22
22
|
paginate "#{Repository.path repository}/milestones", options
|
23
23
|
end
|
24
|
-
alias
|
24
|
+
alias milestones list_milestones
|
25
25
|
|
26
26
|
# Get a single milestone for a repository
|
27
27
|
#
|
@@ -49,7 +49,7 @@ module Octokit
|
|
49
49
|
# @example Create a milestone for a repository
|
50
50
|
# Octokit.create_milestone("octokit/octokit.rb", "0.7.0", {:description => 'Add support for v3 of Github API'})
|
51
51
|
def create_milestone(repository, title, options = {})
|
52
|
-
post "#{Repository.path repository}/milestones", options.merge({:title
|
52
|
+
post "#{Repository.path repository}/milestones", options.merge({ title: title })
|
53
53
|
end
|
54
54
|
|
55
55
|
# Update a milestone for a repository
|
@@ -68,7 +68,7 @@ module Octokit
|
|
68
68
|
def update_milestone(repository, number, options = {})
|
69
69
|
patch "#{Repository.path repository}/milestones/#{number}", options
|
70
70
|
end
|
71
|
-
alias
|
71
|
+
alias edit_milestone update_milestone
|
72
72
|
|
73
73
|
# Delete a single milestone for a repository
|
74
74
|
#
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Notifications API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/activity/notifications/
|
7
8
|
module Notifications
|
8
|
-
|
9
9
|
# List your notifications
|
10
10
|
#
|
11
11
|
# @param options [Hash] Optional parameters
|
@@ -24,7 +24,7 @@ module Octokit
|
|
24
24
|
# @example Get all notifications since a certain time.
|
25
25
|
# @client.notifications({all: true, since: '2012-10-09T23:39:01Z'})
|
26
26
|
def notifications(options = {})
|
27
|
-
paginate
|
27
|
+
paginate 'notifications', options
|
28
28
|
end
|
29
29
|
|
30
30
|
# List your notifications in a repository
|
@@ -48,7 +48,7 @@ module Octokit
|
|
48
48
|
def repository_notifications(repo, options = {})
|
49
49
|
paginate "#{Repository.path repo}/notifications", options
|
50
50
|
end
|
51
|
-
alias
|
51
|
+
alias repo_notifications repository_notifications
|
52
52
|
|
53
53
|
# Mark notifications as read
|
54
54
|
#
|
@@ -66,7 +66,7 @@ module Octokit
|
|
66
66
|
# @example
|
67
67
|
# @client.mark_notifications_as_read
|
68
68
|
def mark_notifications_as_read(options = {})
|
69
|
-
request :put,
|
69
|
+
request :put, 'notifications', options
|
70
70
|
|
71
71
|
last_response.status == 205
|
72
72
|
end
|
@@ -91,7 +91,7 @@ module Octokit
|
|
91
91
|
|
92
92
|
last_response.status == 205
|
93
93
|
end
|
94
|
-
alias
|
94
|
+
alias mark_repo_notifications_as_read mark_repository_notifications_as_read
|
95
95
|
|
96
96
|
# List notifications for a specific thread
|
97
97
|
#
|
@@ -108,10 +108,6 @@ module Octokit
|
|
108
108
|
# Mark thread as read
|
109
109
|
#
|
110
110
|
# @param thread_id [Integer] Id of the thread to update.
|
111
|
-
# @param options [Hash] Optional parameters.
|
112
|
-
# @option options [Boolean] :unread Changes the unread status of the
|
113
|
-
# threads.
|
114
|
-
# @option options [Boolean] :read Inverse of 'unread'.
|
115
111
|
# @return [Boolean] True if updated, false otherwise.
|
116
112
|
# @see https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read
|
117
113
|
# @example
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the OauthApplications API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/apps/oauth_applications
|
8
|
+
module OauthApplications
|
9
|
+
# Check if a token is valid.
|
10
|
+
#
|
11
|
+
# Applications can check if a token is valid without rate limits.
|
12
|
+
#
|
13
|
+
# @param access_token [String] 40 character GitHub OAuth access token
|
14
|
+
#
|
15
|
+
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
16
|
+
# @see https://developer.github.com/v3/apps/oauth_applications/#check-a-token
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
20
|
+
# client.check_token('deadbeef1234567890deadbeef987654321')
|
21
|
+
def check_token(access_token, options = {})
|
22
|
+
options[:access_token] = access_token
|
23
|
+
|
24
|
+
key = options.delete(:client_id) || client_id
|
25
|
+
secret = options.delete(:client_secret) || client_secret
|
26
|
+
|
27
|
+
as_app(key, secret) do |app_client|
|
28
|
+
app_client.post "applications/#{client_id}/token", options
|
29
|
+
end
|
30
|
+
end
|
31
|
+
alias check_application_authorization check_token
|
32
|
+
|
33
|
+
# Reset a token
|
34
|
+
#
|
35
|
+
# Applications can reset a token without requiring a user to re-authorize.
|
36
|
+
#
|
37
|
+
# @param access_token [String] 40 character GitHub OAuth access token
|
38
|
+
#
|
39
|
+
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
40
|
+
# @see https://developer.github.com/v3/apps/oauth_applications/#reset-a-token
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
44
|
+
# client.reset_token('deadbeef1234567890deadbeef987654321')
|
45
|
+
def reset_token(access_token, options = {})
|
46
|
+
options[:access_token] = access_token
|
47
|
+
|
48
|
+
key = options.delete(:client_id) || client_id
|
49
|
+
secret = options.delete(:client_secret) || client_secret
|
50
|
+
|
51
|
+
as_app(key, secret) do |app_client|
|
52
|
+
app_client.patch "applications/#{client_id}/token", options
|
53
|
+
end
|
54
|
+
end
|
55
|
+
alias reset_application_authorization reset_token
|
56
|
+
|
57
|
+
# Delete an app token
|
58
|
+
#
|
59
|
+
# Applications can revoke (delete) a token
|
60
|
+
#
|
61
|
+
# @param access_token [String] 40 character GitHub OAuth access token
|
62
|
+
#
|
63
|
+
# @return [Boolean] Result
|
64
|
+
# @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
|
65
|
+
#
|
66
|
+
# @example
|
67
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
68
|
+
# client.delete_token('deadbeef1234567890deadbeef987654321')
|
69
|
+
def delete_app_token(access_token, options = {})
|
70
|
+
options[:access_token] = access_token
|
71
|
+
|
72
|
+
key = options.delete(:client_id) || client_id
|
73
|
+
secret = options.delete(:client_secret) || client_secret
|
74
|
+
|
75
|
+
begin
|
76
|
+
as_app(key, secret) do |app_client|
|
77
|
+
app_client.delete "applications/#{client_id}/token", options
|
78
|
+
app_client.last_response.status == 204
|
79
|
+
end
|
80
|
+
rescue Octokit::NotFound
|
81
|
+
false
|
82
|
+
end
|
83
|
+
end
|
84
|
+
alias delete_application_authorization delete_app_token
|
85
|
+
alias revoke_application_authorization delete_app_token
|
86
|
+
|
87
|
+
# Delete an app authorization
|
88
|
+
#
|
89
|
+
# OAuth application owners can revoke a grant for their OAuth application and a specific user.
|
90
|
+
#
|
91
|
+
# @param access_token [String] 40 character GitHub OAuth access token
|
92
|
+
#
|
93
|
+
# @return [Boolean] Result
|
94
|
+
# @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
98
|
+
# client.delete_app_authorization('deadbeef1234567890deadbeef987654321')
|
99
|
+
def delete_app_authorization(access_token, options = {})
|
100
|
+
options[:access_token] = access_token
|
101
|
+
|
102
|
+
key = options.delete(:client_id) || client_id
|
103
|
+
secret = options.delete(:client_secret) || client_secret
|
104
|
+
|
105
|
+
begin
|
106
|
+
as_app(key, secret) do |app_client|
|
107
|
+
app_client.delete "applications/#{client_id}/grant", options
|
108
|
+
app_client.last_response.status == 204
|
109
|
+
end
|
110
|
+
rescue Octokit::NotFound
|
111
|
+
false
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Git Data API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/git/
|
7
8
|
module Objects
|
8
|
-
|
9
9
|
# Get a single tree, fetching information about its root-level objects
|
10
10
|
#
|
11
11
|
# Pass <tt>:recursive => true</tt> in <tt>options</tt> to fetch information about all of the tree's objects, including those in subdirectories.
|
@@ -38,7 +38,7 @@ module Octokit
|
|
38
38
|
# tree.sha # => "cd8274d15fa3ae2ab983129fb037999f264ba9a7"
|
39
39
|
# tree.tree.first.path # => "file.rb"
|
40
40
|
def create_tree(repo, tree, options = {})
|
41
|
-
parameters = { :
|
41
|
+
parameters = { tree: tree }
|
42
42
|
post "#{Repository.path repo}/git/trees", options.merge(parameters)
|
43
43
|
end
|
44
44
|
|
@@ -74,10 +74,10 @@ module Octokit
|
|
74
74
|
# @example Create a blob containing <tt>foo bar baz</tt>, encoded using base64
|
75
75
|
# require "base64"
|
76
76
|
# Octokit.create_blob("octocat/Hello-World", Base64.encode64("foo bar baz"), "base64")
|
77
|
-
def create_blob(repo, content, encoding=
|
77
|
+
def create_blob(repo, content, encoding = 'utf-8', options = {})
|
78
78
|
parameters = {
|
79
|
-
:
|
80
|
-
:
|
79
|
+
content: content,
|
80
|
+
encoding: encoding
|
81
81
|
}
|
82
82
|
blob = post "#{Repository.path repo}/git/blobs", options.merge(parameters)
|
83
83
|
|
@@ -124,14 +124,14 @@ module Octokit
|
|
124
124
|
# )
|
125
125
|
def create_tag(repo, tag, message, object_sha, type, tagger_name, tagger_email, tagger_date, options = {})
|
126
126
|
options.merge!(
|
127
|
-
:
|
128
|
-
:
|
129
|
-
:
|
130
|
-
:
|
131
|
-
:
|
132
|
-
:
|
133
|
-
:
|
134
|
-
:
|
127
|
+
tag: tag,
|
128
|
+
message: message,
|
129
|
+
object: object_sha,
|
130
|
+
type: type,
|
131
|
+
tagger: {
|
132
|
+
name: tagger_name,
|
133
|
+
email: tagger_email,
|
134
|
+
date: tagger_date
|
135
135
|
}
|
136
136
|
)
|
137
137
|
post "#{Repository.path repo}/git/tags", options
|