lingfennan-github_api 0.18.2

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.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.md +741 -0
  4. data/lib/github_api.rb +93 -0
  5. data/lib/github_api/api.rb +398 -0
  6. data/lib/github_api/api/actions.rb +60 -0
  7. data/lib/github_api/api/arguments.rb +253 -0
  8. data/lib/github_api/api/config.rb +105 -0
  9. data/lib/github_api/api/config/property.rb +30 -0
  10. data/lib/github_api/api/config/property_set.rb +120 -0
  11. data/lib/github_api/api/factory.rb +33 -0
  12. data/lib/github_api/authorization.rb +75 -0
  13. data/lib/github_api/client.rb +77 -0
  14. data/lib/github_api/client/activity.rb +31 -0
  15. data/lib/github_api/client/activity/events.rb +233 -0
  16. data/lib/github_api/client/activity/feeds.rb +50 -0
  17. data/lib/github_api/client/activity/notifications.rb +181 -0
  18. data/lib/github_api/client/activity/starring.rb +130 -0
  19. data/lib/github_api/client/activity/watching.rb +176 -0
  20. data/lib/github_api/client/authorizations.rb +142 -0
  21. data/lib/github_api/client/authorizations/app.rb +98 -0
  22. data/lib/github_api/client/emojis.rb +19 -0
  23. data/lib/github_api/client/gists.rb +289 -0
  24. data/lib/github_api/client/gists/comments.rb +100 -0
  25. data/lib/github_api/client/git_data.rb +31 -0
  26. data/lib/github_api/client/git_data/blobs.rb +51 -0
  27. data/lib/github_api/client/git_data/commits.rb +101 -0
  28. data/lib/github_api/client/git_data/references.rb +150 -0
  29. data/lib/github_api/client/git_data/tags.rb +95 -0
  30. data/lib/github_api/client/git_data/trees.rb +113 -0
  31. data/lib/github_api/client/gitignore.rb +57 -0
  32. data/lib/github_api/client/issues.rb +248 -0
  33. data/lib/github_api/client/issues/assignees.rb +77 -0
  34. data/lib/github_api/client/issues/comments.rb +146 -0
  35. data/lib/github_api/client/issues/events.rb +50 -0
  36. data/lib/github_api/client/issues/labels.rb +189 -0
  37. data/lib/github_api/client/issues/milestones.rb +146 -0
  38. data/lib/github_api/client/markdown.rb +62 -0
  39. data/lib/github_api/client/meta.rb +19 -0
  40. data/lib/github_api/client/orgs.rb +127 -0
  41. data/lib/github_api/client/orgs/hooks.rb +182 -0
  42. data/lib/github_api/client/orgs/members.rb +142 -0
  43. data/lib/github_api/client/orgs/memberships.rb +131 -0
  44. data/lib/github_api/client/orgs/projects.rb +57 -0
  45. data/lib/github_api/client/orgs/teams.rb +407 -0
  46. data/lib/github_api/client/projects.rb +83 -0
  47. data/lib/github_api/client/projects/cards.rb +158 -0
  48. data/lib/github_api/client/projects/columns.rb +146 -0
  49. data/lib/github_api/client/pull_requests.rb +195 -0
  50. data/lib/github_api/client/pull_requests/comments.rb +140 -0
  51. data/lib/github_api/client/pull_requests/reviews.rb +158 -0
  52. data/lib/github_api/client/repos.rb +468 -0
  53. data/lib/github_api/client/repos/branches.rb +48 -0
  54. data/lib/github_api/client/repos/branches/protections.rb +75 -0
  55. data/lib/github_api/client/repos/collaborators.rb +84 -0
  56. data/lib/github_api/client/repos/comments.rb +125 -0
  57. data/lib/github_api/client/repos/commits.rb +80 -0
  58. data/lib/github_api/client/repos/contents.rb +246 -0
  59. data/lib/github_api/client/repos/deployments.rb +138 -0
  60. data/lib/github_api/client/repos/downloads.rb +62 -0
  61. data/lib/github_api/client/repos/forks.rb +48 -0
  62. data/lib/github_api/client/repos/hooks.rb +214 -0
  63. data/lib/github_api/client/repos/keys.rb +104 -0
  64. data/lib/github_api/client/repos/merging.rb +47 -0
  65. data/lib/github_api/client/repos/pages.rb +48 -0
  66. data/lib/github_api/client/repos/projects.rb +62 -0
  67. data/lib/github_api/client/repos/pub_sub_hubbub.rb +133 -0
  68. data/lib/github_api/client/repos/releases.rb +189 -0
  69. data/lib/github_api/client/repos/releases/assets.rb +136 -0
  70. data/lib/github_api/client/repos/releases/tags.rb +24 -0
  71. data/lib/github_api/client/repos/statistics.rb +89 -0
  72. data/lib/github_api/client/repos/statuses.rb +91 -0
  73. data/lib/github_api/client/say.rb +25 -0
  74. data/lib/github_api/client/scopes.rb +46 -0
  75. data/lib/github_api/client/search.rb +133 -0
  76. data/lib/github_api/client/search/legacy.rb +111 -0
  77. data/lib/github_api/client/users.rb +117 -0
  78. data/lib/github_api/client/users/emails.rb +65 -0
  79. data/lib/github_api/client/users/followers.rb +115 -0
  80. data/lib/github_api/client/users/keys.rb +104 -0
  81. data/lib/github_api/configuration.rb +70 -0
  82. data/lib/github_api/connection.rb +82 -0
  83. data/lib/github_api/constants.rb +61 -0
  84. data/lib/github_api/core_ext/array.rb +25 -0
  85. data/lib/github_api/core_ext/hash.rb +91 -0
  86. data/lib/github_api/core_ext/ordered_hash.rb +107 -0
  87. data/lib/github_api/deprecation.rb +39 -0
  88. data/lib/github_api/error.rb +32 -0
  89. data/lib/github_api/error/client_error.rb +89 -0
  90. data/lib/github_api/error/service_error.rb +223 -0
  91. data/lib/github_api/ext/faraday.rb +38 -0
  92. data/lib/github_api/mash.rb +7 -0
  93. data/lib/github_api/middleware.rb +37 -0
  94. data/lib/github_api/mime_type.rb +33 -0
  95. data/lib/github_api/normalizer.rb +23 -0
  96. data/lib/github_api/null_encoder.rb +25 -0
  97. data/lib/github_api/page_iterator.rb +138 -0
  98. data/lib/github_api/page_links.rb +63 -0
  99. data/lib/github_api/paged_request.rb +42 -0
  100. data/lib/github_api/pagination.rb +115 -0
  101. data/lib/github_api/parameter_filter.rb +35 -0
  102. data/lib/github_api/params_hash.rb +115 -0
  103. data/lib/github_api/rate_limit.rb +25 -0
  104. data/lib/github_api/request.rb +85 -0
  105. data/lib/github_api/request/basic_auth.rb +36 -0
  106. data/lib/github_api/request/jsonize.rb +54 -0
  107. data/lib/github_api/request/oauth2.rb +44 -0
  108. data/lib/github_api/request/verbs.rb +63 -0
  109. data/lib/github_api/response.rb +48 -0
  110. data/lib/github_api/response/atom_parser.rb +22 -0
  111. data/lib/github_api/response/follow_redirects.rb +140 -0
  112. data/lib/github_api/response/header.rb +87 -0
  113. data/lib/github_api/response/jsonize.rb +28 -0
  114. data/lib/github_api/response/mashify.rb +24 -0
  115. data/lib/github_api/response/raise_error.rb +22 -0
  116. data/lib/github_api/response/xmlize.rb +27 -0
  117. data/lib/github_api/response_wrapper.rb +161 -0
  118. data/lib/github_api/ssl_certs/cacerts.pem +2183 -0
  119. data/lib/github_api/utils/url.rb +63 -0
  120. data/lib/github_api/validations.rb +22 -0
  121. data/lib/github_api/validations/format.rb +26 -0
  122. data/lib/github_api/validations/presence.rb +32 -0
  123. data/lib/github_api/validations/required.rb +21 -0
  124. data/lib/github_api/validations/token.rb +41 -0
  125. data/lib/github_api/version.rb +5 -0
  126. metadata +338 -0
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ class Client::Activity::Feeds < API
7
+ # List all the feeds available to the authenticated user.
8
+ #
9
+ # @see https://developer.github.com/v3/activity/feeds/#list-feeds
10
+ #
11
+ # @example
12
+ # github = Github.new
13
+ # github.activity.feeds.list
14
+ #
15
+ # @api public
16
+ def list(*args)
17
+ arguments(args)
18
+
19
+ response = get_request("/feeds", arguments.params)
20
+ return response unless block_given?
21
+ response.each { |el| yield el }
22
+ end
23
+ alias_method :all, :list
24
+
25
+ # Get all the items for a named timeline
26
+ #
27
+ # @see https://developer.github.com/v3/activity/feeds/#list-feeds
28
+ #
29
+ # @example
30
+ # github = Github.new
31
+ # github.activity.feeds.get "timeline"
32
+ #
33
+ # @param [String] name
34
+ # the name of the timeline resource
35
+ #
36
+ # @api public
37
+ def get(*args)
38
+ arguments(args, required: [:name])
39
+
40
+ name = arguments.name
41
+ response = list.body._links[name]
42
+ if response
43
+ params = arguments.params
44
+ params['accept'] = response.type
45
+ get_request(response.href, params)
46
+ end
47
+ end
48
+ alias_method :find, :get
49
+ end
50
+ end # Github
@@ -0,0 +1,181 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ class Client::Activity::Notifications < API
7
+ # List your notifications
8
+ #
9
+ # List all notifications for the current user, grouped by repository.
10
+ #
11
+ # @see https://developer.github.com/v3/activity/notifications/#list-your-notifications
12
+ #
13
+ # @param [Hash] params
14
+ # @option params [Boolean] :all
15
+ # If true, show notifications marked as read.
16
+ # Default: false
17
+ # @option params [Boolean] :participating
18
+ # If true, only shows notifications in which the user
19
+ # is directly participating or mentioned. Default: false
20
+ # @option params [String] :since
21
+ # Filters out any notifications updated before the given time.
22
+ # This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
23
+ # Default: Time.now
24
+ #
25
+ # @example
26
+ # github = Github.new oauth_token: 'token'
27
+ # github.activity.notifications.list
28
+ #
29
+ # List your notifications in a repository
30
+ #
31
+ # @see https://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository
32
+ #
33
+ # @example
34
+ # github = Github.new
35
+ # github.activity.notifications.list user: 'user-name', repo: 'repo-name'
36
+ #
37
+ # @api public
38
+ def list(*args)
39
+ arguments(args)
40
+ params = arguments.params
41
+
42
+ response = if ( (user_name = params.delete('user')) &&
43
+ (repo_name = params.delete('repo')) )
44
+ get_request("/repos/#{user_name}/#{repo_name}/notifications", params)
45
+ else
46
+ get_request('/notifications', params)
47
+ end
48
+ return response unless block_given?
49
+ response.each { |el| yield el }
50
+ end
51
+ alias_method :all, :list
52
+
53
+ # View a single thread
54
+ #
55
+ # @see https://developer.github.com/v3/activity/notifications/#view-a-single-thread
56
+ #
57
+ # @example
58
+ # github = Github.new oauth_token: 'token'
59
+ # github.activity.notifications.get 'thread_id'
60
+ # github.activity.notifications.get 'thread_id' { |thread| ... }
61
+ #
62
+ # @api public
63
+ def get(*args)
64
+ arguments(args, required: [:thread_id])
65
+
66
+ response = get_request("/notifications/threads/#{arguments.thread_id}", arguments.params)
67
+ return response unless block_given?
68
+ response.each { |el| yield el }
69
+ end
70
+ alias_method :find, :get
71
+
72
+ # Mark as read
73
+ #
74
+ # Marking a notification as “read” removes it from the default view on GitHub.com.
75
+ #
76
+ # @see https://developer.github.com/v3/activity/notifications/#mark-as-read
77
+ #
78
+ # @param [Hash] params
79
+ # @option params [String] :last_read_at
80
+ # Describes the last point that notifications were checked.
81
+ # Anything updated since this time will not be updated.
82
+ # This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
83
+ # Default: Time.now
84
+ #
85
+ # @example
86
+ # github = Github.new oauth_token: 'token'
87
+ # github.activity.notifications.mark
88
+ #
89
+ # Mark notifications as read in a repository
90
+ #
91
+ # @see https://developer.github.com/v3/activity/notifications/#mark-notifications-as-read-in-a-repository
92
+ #
93
+ # @example
94
+ # github.activity.notifications.mark user: 'user-name', repo: 'repo-name'
95
+ #
96
+ # Mark a thread as read
97
+ #
98
+ # @see https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read
99
+ #
100
+ # @example
101
+ # github.activity.notifications.mark id: 'thread-id'
102
+ #
103
+ # @api public
104
+ def mark(*args)
105
+ arguments(args)
106
+ params = arguments.params
107
+
108
+ if ( (user_name = params.delete('user')) &&
109
+ (repo_name = params.delete('repo')) )
110
+
111
+ put_request("/repos/#{user_name}/#{repo_name}/notifications", params)
112
+ elsif (thread_id = params.delete("id"))
113
+ patch_request("/notifications/threads/#{thread_id}", params)
114
+ else
115
+ put_request('/notifications', params)
116
+ end
117
+ end
118
+
119
+ # Check to see if the current user is subscribed to a thread.
120
+ #
121
+ # @see https://developer.github.com/v3/activity/notifications/#get-a-thread-subscription
122
+ #
123
+ # @example
124
+ # github = Github.new oauth_token: 'token'
125
+ # github.activity.notifications.subscribed? 'thread-id'
126
+ #
127
+ # @example
128
+ # github.activity.notifications.subscribed? id: 'thread-id'
129
+ #
130
+ # @api public
131
+ def subscribed?(*args)
132
+ arguments(args, required: [:thread_id])
133
+
134
+ get_request("/notifications/threads/#{arguments.thread_id}/subscription", arguments.params)
135
+ end
136
+
137
+ # Create a thread subscription
138
+ #
139
+ # This lets you subscribe to a thread, or ignore it. Subscribing to a thread
140
+ # is unnecessary if the user is already subscribed to the repository. Ignoring
141
+ # a thread will mute all future notifications (until you comment or get
142
+ # @mentioned).
143
+ #
144
+ # @see https://developer.github.com/v3/activity/notifications/#set-a-thread-subscription
145
+ #
146
+ # @param [Hash] params
147
+ # @option params [Boolean] :subscribed
148
+ # Determines if notifications should be received from this thread
149
+ # @option params [Boolean] :ignored
150
+ # Determines if all notifications should be blocked from this thread
151
+ #
152
+ # @example
153
+ # github = Github.new oauth_token: 'token'
154
+ # github.activity.notifications.create 'thread-id',
155
+ # subscribed: true
156
+ # ignored: false
157
+ #
158
+ # @api public
159
+ def create(*args)
160
+ arguments(args, required: [:thread_id])
161
+
162
+ put_request("/notifications/threads/#{arguments.thread_id}/subscription", arguments.params)
163
+ end
164
+
165
+ # Delete a thread subscription
166
+ #
167
+ # @see https://developer.github.com/v3/activity/notifications/#delete-a-thread-subscription
168
+ #
169
+ # @example
170
+ # github = Github.new oauth_token: 'token'
171
+ # github.activity.notifications.delete 'thread_id'
172
+ #
173
+ # @api public
174
+ def delete(*args)
175
+ arguments(args, required: [:thread_id])
176
+
177
+ delete_request("/notifications/threads/#{arguments.thread_id}/subscription", arguments.params)
178
+ end
179
+ alias_method :remove, :delete
180
+ end # Client::Activity::Notifications
181
+ end # Github
@@ -0,0 +1,130 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ # Repository Starring is a feature that lets users bookmark repositories.
7
+ # Stars are shown next to repositories to show an approximate level of interest.
8
+ # Stars have no effect on notifications or the activity feed.
9
+ class Client::Activity::Starring < API
10
+ # List stargazers
11
+ #
12
+ # @see https://developer.github.com/v3/activity/starring/#list-stargazers
13
+ #
14
+ # @example
15
+ # github = Github.new
16
+ # github.activity.starring.list user: 'user-name', repo: 'repo-name'
17
+ # github.activity.starring.list user: 'user-name', repo: 'repo-name' { |star| ... }
18
+ #
19
+ # @api public
20
+ def list(*args)
21
+ arguments(args, required: [:user, :repo])
22
+
23
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/stargazers", arguments.params)
24
+ return response unless block_given?
25
+ response.each { |el| yield el }
26
+ end
27
+ alias_method :all, :list
28
+
29
+ # List repos being starred by a user
30
+ #
31
+ # @see https://developer.github.com/v3/activity/starring/#list-repositories-being-starred
32
+ #
33
+ # @param [Hash] params
34
+ # @option params [String] :sort
35
+ # One of created (when the repository was starred) or
36
+ # updated (when it was last pushed to).
37
+ # Default: created
38
+ # @option params [String] :direction
39
+ # One of asc (ascending) or desc (descending).
40
+ # Default: desc
41
+ #
42
+ # @example
43
+ # github = Github.new
44
+ # github.activity.starring.starred user: 'user-name'
45
+ #
46
+ # List repos being starred by the authenticated user
47
+ #
48
+ # @example
49
+ # github = Github.new oauth_token: '...'
50
+ # github.activity.starring.starred
51
+ #
52
+ # @api public
53
+ def starred(*args)
54
+ arguments(args)
55
+ params = arguments.params
56
+
57
+ response = if (user_name = params.delete('user'))
58
+ get_request("/users/#{user_name}/starred", params)
59
+ else
60
+ get_request('/user/starred', params)
61
+ end
62
+ return response unless block_given?
63
+ response.each { |el| yield el }
64
+ end
65
+
66
+ # Check if you are starring a repository
67
+ #
68
+ # @see https://developer.github.com/v3/activity/starring/#check-if-you-are-starring-a-repository
69
+ #
70
+ # @example
71
+ # github = Github.new
72
+ # github.activity.starring.starring? 'user-name', 'repo-name'
73
+ #
74
+ # @example
75
+ # github.activity.starring.starring? user: 'user-name', repo: 'repo-name'
76
+ #
77
+ # @return [Boolean]
78
+ # Returns true if this repo is starred by you, false otherwise.
79
+ #
80
+ # @api public
81
+ def starring?(*args)
82
+ arguments(args, required: [:user, :repo])
83
+
84
+ get_request("/user/starred/#{arguments.user}/#{arguments.repo}", arguments.params)
85
+ true
86
+ rescue Github::Error::NotFound
87
+ false
88
+ end
89
+
90
+ # Star a repository
91
+ #
92
+ # You need to be authenticated to star a repository
93
+ #
94
+ # @see https://developer.github.com/v3/activity/starring/#star-a-repository
95
+ #
96
+ # @example
97
+ # github = Github.new
98
+ # github.activity.starring.star 'user-name', 'repo-name'
99
+ #
100
+ # @example
101
+ # github.activity.starring.star user: 'user-name', repo: 'repo-name'
102
+ #
103
+ # @api public
104
+ def star(*args)
105
+ arguments(args, required: [:user, :repo])
106
+
107
+ put_request("/user/starred/#{arguments.user}/#{arguments.repo}", arguments.params)
108
+ end
109
+
110
+ # Unstar a repository
111
+ #
112
+ # You need to be authenticated to unstar a repository.
113
+ #
114
+ # @see https://developer.github.com/v3/activity/starring/#unstar-a-repository
115
+ #
116
+ # @example
117
+ # github = Github.new
118
+ # github.activity.starring.unstar 'user-name', 'repo-name'
119
+ #
120
+ # @example
121
+ # github.activit.starring.unstar user: 'user-name', repo: 'repo-name'
122
+ #
123
+ # @api public
124
+ def unstar(*args)
125
+ arguments(args, required: [:user, :repo])
126
+
127
+ delete_request("/user/starred/#{arguments.user}/#{arguments.repo}", arguments.params)
128
+ end
129
+ end # Client::Activity::Starring
130
+ end # Github
@@ -0,0 +1,176 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ # Watching a Repository registers the user to receive notificactions on new
7
+ # discussions, as well as events in the user's activity feed.
8
+ class Client::Activity::Watching < API
9
+ # List repository watchers
10
+ #
11
+ # @see https://developer.github.com/v3/activity/watching/#list-watchers
12
+ #
13
+ # @example
14
+ # github = Github.new
15
+ # github.activity.watching.list user: 'user-name', repo: 'repo-name'
16
+ # github.activity.watching.list user: 'user-naem', repo: 'repo-name' { |watcher| ... }
17
+ #
18
+ # @api public
19
+ def list(*args)
20
+ arguments(args, required: [:user, :repo])
21
+
22
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/subscribers", arguments.params)
23
+ return response unless block_given?
24
+ response.each { |el| yield el }
25
+ end
26
+ alias_method :all, :list
27
+
28
+ # List repos being watched by a user
29
+ #
30
+ # @see https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
31
+ #
32
+ # @example
33
+ # github = Github.new
34
+ # github.activity.watching.watched user: 'user-name'
35
+ #
36
+ # List repos being watched by the authenticated user
37
+ #
38
+ # @example
39
+ # github = Github.new oauth_token: '...'
40
+ # github.activity.watching.watched
41
+ #
42
+ # @api public
43
+ def watched(*args)
44
+ arguments(args)
45
+ params = arguments.params
46
+
47
+ response = if (user_name = params.delete('user'))
48
+ get_request("/users/#{user_name}/subscriptions", params)
49
+ else
50
+ get_request('/user/subscriptions', params)
51
+ end
52
+ return response unless block_given?
53
+ response.each { |el| yield el }
54
+ end
55
+
56
+ # Check if you are subscribed to a repository
57
+ #
58
+ # @see https://developer.github.com/v3/activity/watching/#get-a-repository-subscription
59
+ #
60
+ # @example
61
+ # github = Github.new
62
+ # github.activity.watching.subscribed? 'user-name', 'repo-name'
63
+ #
64
+ # @example
65
+ # github.activity.watching.subscribed? user: 'user-name', repo: 'repo-name'
66
+ #
67
+ # @api public
68
+ def subscribed?(*args)
69
+ arguments(args, required: [:user, :repo])
70
+
71
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/subscription", arguments.params)
72
+ true
73
+ rescue Github::Error::NotFound
74
+ false
75
+ end
76
+
77
+ # Create subscription to a repository
78
+ #
79
+ # @see https://developer.github.com/v3/activity/watching/#set-a-repository-subscription
80
+ #
81
+ # @param [Hash] params
82
+ # @option params [Boolean] :subscribed
83
+ # Determines if notifications should be received from this repository.
84
+ # @option params [Boolean] :ignored
85
+ # Determines if all notifications should be blocked from this repository.
86
+ #
87
+ # @example
88
+ # github = Github.new
89
+ # github.activity.watching.create 'user-name', 'repo-name'
90
+ #
91
+ # @example
92
+ # github.activity.watching.create user: 'user-name', repo: 'repo-name'
93
+ #
94
+ # @api public
95
+ def create(*args)
96
+ arguments(args, required: [:user, :repo])
97
+
98
+ put_request("/repos/#{arguments.user}/#{arguments.repo}/subscription", arguments.params)
99
+ end
100
+ alias_method :subscribe, :create
101
+
102
+ # Delete a repository subscription
103
+ #
104
+ # @see https://developer.github.com/v3/activity/watching/#delete-a-repository-subscription
105
+ #
106
+ # @example
107
+ # github = Github.new oauth_token: '...'
108
+ # github.activity.watching.delete 'user-name', 'repo-name'
109
+ #
110
+ # @example
111
+ # github.activity.watching.delete user: 'user-name', repo: 'repo-name'
112
+ #
113
+ # @api public
114
+ def delete(*args)
115
+ arguments(args, required: [:user, :repo])
116
+
117
+ delete_request("/repos/#{arguments.user}/#{arguments.repo}/subscription", arguments.params)
118
+ end
119
+ alias_method :unsubscribe, :delete
120
+
121
+ # Check if you are watching a repository
122
+ #
123
+ # @see https://developer.github.com/v3/activity/watching/#check-if-you-are-watching-a-repository-legacy
124
+ #
125
+ # @example
126
+ # github = Github.new
127
+ # github.activity.watching.watching? 'user-name', 'repo-name'
128
+ #
129
+ # @return [Boolean]
130
+ # Returns true if this repo is watched by you, false otherwise.
131
+ #
132
+ # @api public
133
+ def watching?(*args)
134
+ arguments(args, required: [:user, :repo])
135
+
136
+ get_request("/user/subscriptions/#{arguments.user}/#{arguments.repo}", arguments.params)
137
+ true
138
+ rescue Github::Error::NotFound
139
+ false
140
+ end
141
+
142
+ # Watch a repository
143
+ #
144
+ # You need to be authenticated to watch a repository
145
+ #
146
+ # @see https://developer.github.com/v3/activity/watching/#watch-a-repository-legacy
147
+ #
148
+ # @example
149
+ # github = Github.new
150
+ # github.activity.watching.watch 'user-name', 'repo-name'
151
+ #
152
+ # @api public
153
+ def watch(*args)
154
+ arguments(args, required: [:user, :repo])
155
+
156
+ put_request("/user/subscriptions/#{arguments.user}/#{arguments.repo}", arguments.params)
157
+ end
158
+
159
+ # Stop watching a repository
160
+ #
161
+ # You need to be authenticated to stop watching a repository.
162
+ #
163
+ # @see https://developer.github.com/v3/activity/watching/#stop-watching-a-repository-legacy
164
+ #
165
+ # @example
166
+ # github = Github.new
167
+ # github.activity.watching.unwatch 'user-name', 'repo-name'
168
+ #
169
+ # @api public
170
+ def unwatch(*args)
171
+ arguments(args, required: [:user, :repo])
172
+
173
+ delete_request("/user/subscriptions/#{arguments.user}/#{arguments.repo}", arguments.params)
174
+ end
175
+ end # Activity::Watching
176
+ end # Github