trav3 0.2.0 → 0.2.1

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.
data/.travis.yml CHANGED
@@ -14,7 +14,9 @@ before_script:
14
14
  - chmod +x ./cc-test-reporter
15
15
  - ./cc-test-reporter before-build
16
16
 
17
- script: bundle exec rake
17
+ script:
18
+ - bundle exec rake
19
+ - bundle exec rubocop
18
20
 
19
21
  after_script:
20
22
  - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile CHANGED
@@ -1,14 +1,15 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in trav3.gemspec
6
6
  gemspec
7
7
 
8
8
  group :test do
9
- gem 'simplecov', require: false, group: :test
9
+ gem 'byebug'
10
10
  gem 'codeclimate-test-reporter', '~> 1.0.0'
11
- gem 'webmock', '~> 3.5'
11
+ gem 'rubocop', require: false
12
+ gem 'simplecov', require: false
12
13
  gem 'vcr', '~> 4.0'
13
- gem 'byebug'
14
+ gem 'webmock', '~> 3.5'
14
15
  end
data/README.md CHANGED
@@ -2,14 +2,14 @@
2
2
  [![Build Status](https://travis-ci.org/danielpclark/trav3.svg?branch=master)](https://travis-ci.org/danielpclark/trav3)
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/1ed07a4baea3832b6207/maintainability)](https://codeclimate.com/github/danielpclark/trav3/maintainability)
4
4
  [![Test Coverage](https://api.codeclimate.com/v1/badges/1ed07a4baea3832b6207/test_coverage)](https://codeclimate.com/github/danielpclark/trav3/test_coverage)
5
- [![Red The Docs](https://img.shields.io/badge/Read-the%20docs-blue.svg)](http://www.rubydoc.info/github/danielpclark/trav3/master/Trav3/Travis)
5
+ [![Red The Docs](https://img.shields.io/badge/Read-the%20docs-blue.svg)](https://www.rubydoc.info/github/danielpclark/trav3/0af161/Trav3/Travis)
6
6
  [![SayThanks.io](https://img.shields.io/badge/SayThanks.io-%E2%98%BC-1EAEDB.svg)](https://saythanks.io/to/danielpclark)
7
7
 
8
8
  # Trav3
9
9
 
10
10
  A simple abstraction layer for Travis CI API v3. The results from queries return either `Success`
11
11
  or `RequestError` which both repsond with Hash like query methods for the JSON data or the Net::HTTP
12
- resonse object methods. Documentation from the API has been added to this package. Please [check it out](http://www.rubydoc.info/github/danielpclark/trav3/master/Trav3/Travis).
12
+ resonse object methods.
13
13
 
14
14
 
15
15
  ## Installation
data/Rakefile CHANGED
@@ -1,10 +1,7 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
 
3
- begin
4
- require 'rspec/core/rake_task'
3
+ require 'rspec/core/rake_task'
5
4
 
6
- RSpec::Core::RakeTask.new(:spec)
5
+ RSpec::Core::RakeTask.new(:spec)
7
6
 
8
- task :default => :spec
9
- rescue LoadError # no rspec available
10
- end
7
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "trav3"
3
+ require 'bundler/setup'
4
+ require 'trav3'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "trav3"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
data/lib/trav3.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'trav3/version'
3
4
  require 'trav3/pagination'
4
5
  require 'trav3/options'
@@ -9,7 +10,7 @@ require 'trav3/get'
9
10
 
10
11
  # Trav3 project namespace
11
12
  module Trav3
12
- API_ROOT = 'https://api.travis-ci.org'
13
+ API_ROOT = 'https://api.travis-ci.org'.freeze
13
14
 
14
15
  # An abstraction for the Travis CI v3 API
15
16
  #
@@ -20,6 +21,7 @@ module Trav3
20
21
  # @return [Options] Request options object
21
22
  # @!attribute [r] headers
22
23
  # @return [Headers] Request headers object
24
+ # rubocop:disable Metrics/ClassLength
23
25
  class Travis
24
26
  API_ENDPOINT = API_ROOT
25
27
  attr_reader :api_endpoint
@@ -31,29 +33,27 @@ module Trav3
31
33
  # conform to valid repository identifier format
32
34
  # @return [Travis]
33
35
  def initialize(repo)
34
- raise InvalidRepository unless repo.is_a?(String) and
35
- Regexp.new(/(^\d+$)|(^\w+(?:\/|%2F){1}\w+$)/) === repo
36
+ raise InvalidRepository unless repo_slug_or_id? repo
36
37
 
37
38
  @api_endpoint = API_ENDPOINT
38
- @repo = repo.gsub(/\//, '%2F')
39
- defaults(limit: 25)
40
- h('Content-Type': 'application/json')
41
- h('Accept': 'application/json')
42
- h('Travis-API-Version': 3)
39
+ @repo = sanitize_repo_name repo
40
+
41
+ initial_defaults
43
42
  end
44
43
 
45
44
  # @overload api_endpoint=(endpoint)
46
45
  # Set as the API endpoint
47
46
  # @param endpoint [String] name for value to set
48
47
  # @return [self]
49
- def api_endpoint= endpoint
50
- if /^https:\/\/api\.travis-ci\.(?:org|com)$/ === endpoint
51
- @api_endpoint = endpoint
52
- else
53
- raise InvalidAPIEndpoint
54
- end
48
+ # rubocop:disable Lint/Void
49
+ def api_endpoint=(endpoint)
50
+ raise InvalidAPIEndpoint unless /^https:\/\/api\.travis-ci\.(?:org|com)$/.match? endpoint
51
+
52
+ @api_endpoint = endpoint
53
+
55
54
  self
56
55
  end
56
+ # rubocop:enable Lint/Void
57
57
 
58
58
  # @overload defaults(key: value, ...)
59
59
  # Set as many options as you'd like for collections queried via an API request
@@ -66,9 +66,9 @@ module Trav3
66
66
  end
67
67
 
68
68
  # Set as many headers as you'd like for API requests
69
- #
69
+ #
70
70
  # h("Authorization": "token xxxxxxxxxxxxxxxxxxxxxx")
71
- #
71
+ #
72
72
  # @overload h(key: value, ...)
73
73
  # @param key [Symbol, String] name for value to set
74
74
  # @param value [Symbol, String, Integer] value for key
@@ -78,396 +78,234 @@ module Trav3
78
78
  self
79
79
  end
80
80
 
81
- # This will be either a user or organization.
82
- #
81
+ # The branch of a GitHub repository. Useful for obtaining information about the last build on a given branch.
82
+ #
83
+ # **If querying using the repository slug, it must be formatted using {http://www.w3schools.com/tags/ref_urlencode.asp standard URL encoding}, including any special characters.**
84
+ #
83
85
  # ## Attributes
84
86
  #
85
87
  # **Minimal Representation**
86
88
  #
87
89
  # Included when the resource is returned as part of another resource.
88
- #
89
- # Name Type Description
90
- # id Integer Value uniquely identifying the owner.
91
- # login String User or organization login set on GitHub.
90
+ #
91
+ # Name Type Description
92
+ # name String Name of the git branch.
92
93
  #
93
94
  # **Standard Representation**
94
95
  #
95
- # Included when the resource is the main response of a request, or is eager loaded.
96
- #
97
- # Name Type Description
98
- # id Integer Value uniquely identifying the owner.
99
- # login String User or organization login set on GitHub.
100
- # name String User or organization name set on GitHub.
101
- # github_id Integer User or organization id set on GitHub.
102
- # avatar_url String Link to user or organization avatar (image) set on GitHub.
96
+ # Included when the resource is the main response of a request, or is {https://developer.travis-ci.com/eager-loading eager loaded}.
97
+ #
98
+ # Name Type Description
99
+ # name String Name of the git branch.
100
+ # repository Repository GitHub user or organization the branch belongs to.
101
+ # default_branch Boolean Whether or not this is the resposiotry's default branch.
102
+ # exists_on_github Boolean Whether or not the branch still exists on GitHub.
103
+ # last_build Build Last build on the branch.
103
104
  #
104
105
  # **Additional Attributes**
105
- #
106
- # Name Type Description
107
- # repositories [Repository] Repositories belonging to this account.
106
+ #
107
+ # Name Type Description
108
+ # recent_builds [Build] Last 10 builds on the branch (when `include=branch.recent_builds` is used).
108
109
  #
109
110
  # ## Actions
110
111
  #
111
112
  # **Find**
112
113
  #
113
- # This returns an individual owner. It is possible to use the GitHub login or github_id in the request.
114
- #
115
- # GET <code>/owner/{owner.login}</code>
116
- #
117
- # Template Variable Type Description
118
- # owner.login String User or organization login set on GitHub.
114
+ # This will return information about an individual branch. The request can include either the repository id or slug.
119
115
  #
120
- # Query Parameter Type Description
121
- # include [String] List of attributes to eager load.
116
+ # GET <code>/repo/{repository.id}/branch/{branch.name}</code>
122
117
  #
123
- # Example: GET /owner/danielpclark
124
- #
125
- # GET <code>/owner/{user.login}</code>
126
- #
127
- # Template Variable Type Description
128
- # user.login String Login set on Github.
129
- #
130
- # Query Parameter Type Description
131
- # include [String] List of attributes to eager load.
132
- #
133
- # Example: GET /owner/danielpclark
134
- #
135
- # GET <code>/owner/{organization.login}</code>
136
- #
137
- # Template Variable Type Description
138
- # organization.login String Login set on GitHub.
139
- #
140
- # Query Parameter Type Description
141
- # include [String] List of attributes to eager load.
142
- #
143
- # Example: GET /owner/travis-ci
144
- #
145
- # GET <code>/owner/github_id/{owner.github_id}</code>
146
- #
147
- # Template Variable Type Description
148
- # owner.github_id Integer User or organization id set on GitHub.
149
- #
150
- # Query Parameter Type Description
151
- # include [String] List of attributes to eager load.
152
- #
153
- # Example: GET /owner/github_id/639823
118
+ # Template Variable Type Description
119
+ # repository.id Integer Value uniquely identifying the repository.
120
+ # branch.name String Name of the git branch.
121
+ # Query Parameter Type Description
122
+ # include [String] List of attributes to eager load.
154
123
  #
155
- # @param owner [String] username or github ID
124
+ # Example:GET /repo/891/branch/master
125
+ #
126
+ # GET <code>/repo/{repository.slug}/branch/{branch.name}</code>
127
+ #
128
+ # Template Variable Type Description
129
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
130
+ # branch.name String Name of the git branch.
131
+ # Query Parameter Type Description
132
+ # include [String] List of attributes to eager load.
133
+ #
134
+ # Example:GET /repo/rails%2Frails/branch/master
135
+ #
136
+ # @param id [String] the branch name for the current repository
156
137
  # @return [Success, RequestError]
157
- def owner(owner = username)
158
- if /^\d+$/ === "#{owner}"
159
- get("#{self[]}/owner/github_id/#{owner}")
160
- else
161
- get("#{self[]}/owner/#{owner}")
162
- end
138
+ def branch(name)
139
+ get("#{with_repo}/branch/#{name}#{opts}")
163
140
  end
164
141
 
165
- # A list of repositories for the current user.
166
- #
167
- # ## Attributes
168
- #
169
- # Name Type Description
170
- # repositories [Repository] List of repositories.
171
- #
142
+ # A list of branches.
143
+ #
144
+ # **If querying using the repository slug, it must be formatted using {http://www.w3schools.com/tags/ref_urlencode.asp standard URL encoding}, including any special characters.**
145
+ #
146
+ # ##Attributes
147
+ #
148
+ # Name Type Description
149
+ # branches [Branch] List of branches.
150
+ #
172
151
  # **Collection Items**
173
152
  #
174
- # Each entry in the repositories array has the following attributes:
175
- #
176
- # Name Type Description
177
- # id Integer Value uniquely identifying the repository.
178
- # name String The repository's name on GitHub.
179
- # slug String Same as {repository.owner.name}/{repository.name}.
180
- # description String The repository's description from GitHub.
181
- # github_language String The main programming language used according to GitHub.
182
- # active Boolean Whether or not this repository is currently enabled on Travis CI.
183
- # private Boolean Whether or not this repository is private.
184
- # owner Owner GitHub user or organization the repository belongs to.
185
- # default_branch Branch The default branch on GitHub.
186
- # starred Boolean Whether or not this repository is starred.
187
- # current_build Build The most recently started build (this excludes builds that have been created but have not yet started).
188
- # last_started_build Build Alias for current_build.
189
- #
153
+ # Each entry in the **branches** array has the following attributes:
154
+ #
155
+ # Name Type Description
156
+ # name String Name of the git branch.
157
+ # repository Repository GitHub user or organization the branch belongs to.
158
+ # default_branch Boolean Whether or not this is the resposiotry's default branch.
159
+ # exists_on_github Boolean Whether or not the branch still exists on GitHub.
160
+ # last_build Build Last build on the branch.
161
+ # recent_builds [Build] Last 10 builds on the branch (when `include=branch.recent_builds` is used).
162
+ #
190
163
  # ## Actions
191
164
  #
192
- # **For Owner**
165
+ # **Find**
193
166
  #
194
- # This returns a list of repositories an owner has access to.
195
- #
196
- # GET <code>/owner/{owner.login}/repos</code>
197
- #
198
- # Template Variable Type Description
199
- # owner.login String User or organization login set on GitHub.
200
- #
201
- # Query Parameter Type Description
202
- # active [Boolean] Alias for repository.active.
203
- # include [String] List of attributes to eager load.
204
- # limit Integer How many repositories to include in the response. Used for pagination.
205
- # offset Integer How many repositories to skip before the first entry in the response. Used for pagination.
206
- # private [Boolean] Alias for repository.private.
207
- # repository.active [Boolean] Filters repositories by whether or not this repository is currently enabled on Travis CI.
208
- # repository.private [Boolean] Filters repositories by whether or not this repository is private.
209
- # repository.starred [Boolean] Filters repositories by whether or not this repository is starred.
210
- # sort_by [String] Attributes to sort repositories by. Used for pagination.
211
- # starred [Boolean] Alias for repository.starred.
212
- #
213
- # Example: GET /owner/danielpclark/repos?limit=5&sort_by=active,name
214
- #
215
- # **Sortable by:** id, github_id, owner_name, name, active, default_branch.last_build, append :desc to any attribute to reverse order.
216
- #
217
- # GET <code>/owner/{user.login}/repos</code>
218
- #
219
- # Template Variable Type Description
220
- # user.login String Login set on Github.
167
+ # This will return a list of branches a repository has on GitHub.
221
168
  #
222
- # Query Parameter Type Description
223
- # active [Boolean] Alias for repository.active.
224
- # include [String] List of attributes to eager load.
225
- # limit Integer How many repositories to include in the response. Used for pagination.
226
- # offset Integer How many repositories to skip before the first entry in the response. Used for pagination.
227
- # private [Boolean] Alias for repository.private.
228
- # repository.active [Boolean] Filters repositories by whether or not this repository is currently enabled on Travis CI.
229
- # repository.private [Boolean] Filters repositories by whether or not this repository is private.
230
- # repository.starred [Boolean] Filters repositories by whether or not this repository is starred.
231
- # sort_by [String] Attributes to sort repositories by. Used for pagination.
232
- # starred [Boolean] Alias for repository.starred.
233
- #
234
- # Example: GET /owner/danielpclark/repos?limit=5&sort_by=active,name
235
- #
236
- # **Sortable by:** id, github_id, owner_name, name, active, default_branch.last_build, append :desc to any attribute to reverse order.
237
- #
238
- # GET <code>/owner/{organization.login}/repos</code>
239
- #
240
- # Template Variable Type Description
241
- # organization.login String Login set on GitHub.
169
+ # GET <code>/repo/{repository.id}/branches</code>
242
170
  #
243
- # Query Parameter Type Description
244
- # active [Boolean] Alias for repository.active.
245
- # include [String] List of attributes to eager load.
246
- # limit Integer How many repositories to include in the response. Used for pagination.
247
- # offset Integer How many repositories to skip before the first entry in the response. Used for pagination.
248
- # private [Boolean] Alias for repository.private.
249
- # repository.active [Boolean] Filters repositories by whether or not this repository is currently enabled on Travis CI.
250
- # repository.private [Boolean] Filters repositories by whether or not this repository is private.
251
- # repository.starred [Boolean] Filters repositories by whether or not this repository is starred.
252
- # sort_by [String] Attributes to sort repositories by. Used for pagination.
253
- # starred [Boolean] Alias for repository.starred.
254
- #
255
- # Example: GET /owner/travis-ci/repos?limit=5&sort_by=active,name
256
- #
257
- # **Sortable by:** id, github_id, owner_name, name, active, default_branch.last_build, append :desc to any attribute to reverse order.
258
- #
259
- # GET <code>/owner/github_id/{owner.github_id}/repos</code>
260
- #
261
171
  # Template Variable Type Description
262
- # owner.github_id Integer User or organization id set on GitHub.
172
+ # repository.id Integer Value uniquely identifying the repository.
173
+ # Query Parameter Type Description
174
+ # branch.exists_on_github [Boolean] Filters branches by whether or not the branch still exists on GitHub.
175
+ # exists_on_github [Boolean] Alias for branch.exists_on_github.
176
+ # include [String] List of attributes to eager load.
177
+ # limit Integer How many branches to include in the response. Used for pagination.
178
+ # offset Integer How many branches to skip before the first entry in the response. Used for pagination.
179
+ # sort_by [String] Attributes to sort branches by. Used for pagination.
263
180
  #
264
- # Query Parameter Type Description
265
- # active [Boolean] Alias for repository.active.
266
- # include [String] List of attributes to eager load.
267
- # limit Integer How many repositories to include in the response. Used for pagination.
268
- # offset Integer How many repositories to skip before the first entry in the response. Used for pagination.
269
- # private [Boolean] Alias for repository.private.
270
- # repository.active [Boolean] Filters repositories by whether or not this repository is currently enabled on Travis CI.
271
- # repository.private [Boolean] Filters repositories by whether or not this repository is private.
272
- # repository.starred [Boolean] Filters repositories by whether or not this repository is starred.
273
- # sort_by [String] Attributes to sort repositories by. Used for pagination.
274
- # starred [Boolean] Alias for repository.starred.
275
- #
276
- # Example: GET /owner/github_id/639823/repos?limit=5&sort_by=active,name
277
- #
278
- # **Sortable by:** id, github_id, owner_name, name, active, default_branch.last_build, append :desc to any attribute to reverse order.
279
- #
280
- # **For Current User**<br />
281
- # This returns a list of repositories the current user has access to.
282
- #
283
- # GET <code>/repos</code>
284
- #
285
- # Query Parameter Type Description
286
- # active [Boolean] Alias for repository.active.
287
- # include [String] List of attributes to eager load.
288
- # limit Integer How many repositories to include in the response. Used for pagination.
289
- # offset Integer How many repositories to skip before the first entry in the response. Used for pagination.
290
- # private [Boolean] Alias for repository.private.
291
- # repository.active [Boolean] Filters repositories by whether or not this repository is currently enabled on Travis CI.
292
- # repository.private [Boolean] Filters repositories by whether or not this repository is private.
293
- # repository.starred [Boolean] Filters repositories by whether or not this repository is starred.
294
- # sort_by [String] Attributes to sort repositories by. Used for pagination.
295
- # starred [Boolean] Alias for repository.starred.
181
+ # Example:GET /repo/891/branches?limit=5&exists_on_github=true
296
182
  #
297
- # Example: GET /repos?limit=5&sort_by=active,name
298
- #
299
- # **Sortable by:** id, github_id, owner_name, name, active, default_branch.last_build, append :desc to any attribute to reverse order.
183
+ # **Sortable by:** <code>name</code>, <code>last_build</code>, <code>exists_on_github</code>, <code>default_branch</code>, append <code>:desc</code> to any attribute to reverse order.
184
+ # The default value is <code>default_branch</code>,<code>exists_on_github</code>,<code>last_build:desc</code>.
185
+ #
186
+ # GET <code>/repo/{repository.slug}/branches</code>
187
+ #
188
+ # Template Variable Type Description
189
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
190
+ # Query Parameter Type Description
191
+ # branch.exists_on_github [Boolean] Filters branches by whether or not the branch still exists on GitHub.
192
+ # exists_on_github [Boolean] Alias for branch.exists_on_github.
193
+ # include [String] List of attributes to eager load.
194
+ # limit Integer How many branches to include in the response. Used for pagination.
195
+ # offset Integer How many branches to skip before the first entry in the response. Used for pagination.
196
+ # sort_by [String] Attributes to sort branches by. Used for pagination.
197
+ #
198
+ # Example:GET /repo/rails%2Frails/branches?limit=5&exists_on_github=true
199
+ #
200
+ # **Sortable by:** <code>name</code>, <code>last_build</code>, <code>exists_on_github</code>, <code>default_branch</code>, append <code>:desc</code> to any attribute to reverse order.
201
+ # The default value is <code>default_branch</code>,<code>exists_on_github</code>,<code>last_build:desc</code>.
300
202
  #
301
- # @param owner [String] username or github ID
302
203
  # @return [Success, RequestError]
303
- def repositories(owner = username)
304
- if /^\d+$/ === "#{owner}"
305
- get("#{self[]}/owner/github_id/#{owner}/repos#{opts}")
306
- else
307
- get("#{self[]}/owner/#{owner}/repos#{opts}")
308
- end
204
+ def branches
205
+ get("#{with_repo}/branches#{opts}")
309
206
  end
310
207
 
311
- # An individual repository.
312
- #
208
+ # An individual build.
209
+ #
313
210
  # ## Attributes
314
211
  #
315
212
  # **Minimal Representation**
316
213
  #
317
214
  # Included when the resource is returned as part of another resource.
318
- #
319
- # Name Type Description
320
- # id Integer Value uniquely identifying the repository.
321
- # name String The repository's name on GitHub.
322
- # slug String Same as {repository.owner.name}/{repository.name}.
323
- #
215
+ #
216
+ # Name Type Description
217
+ # id Integer Value uniquely identifying the build.
218
+ # number String Incremental number for a repository's builds.
219
+ # state String Current state of the build.
220
+ # duration Integer Wall clock time in seconds.
221
+ # event_type String Event that triggered the build.
222
+ # previous_state String State of the previous build (useful to see if state changed).
223
+ # pull_request_title String Title of the build's pull request.
224
+ # pull_request_number Integer Number of the build's pull request.
225
+ # started_at String When the build started.
226
+ # finished_at String When the build finished.
227
+ #
324
228
  # **Standard Representation**
325
229
  #
326
230
  # Included when the resource is the main response of a request, or is eager loaded.
327
- #
328
- # Name Type Description
329
- # id Integer Value uniquely identifying the repository.
330
- # name String The repository's name on GitHub.
331
- # slug String Same as {repository.owner.name}/{repository.name}.
332
- # description String The repository's description from GitHub.
333
- # github_language String The main programming language used according to GitHub.
334
- # active Boolean Whether or not this repository is currently enabled on Travis CI.
335
- # private Boolean Whether or not this repository is private.
336
- # owner Owner GitHub user or organization the repository belongs to.
337
- # default_branch Branch The default branch on GitHub.
338
- # starred Boolean Whether or not this repository is starred.
339
- #
231
+ #
232
+ # Name Type Description
233
+ # id Integer Value uniquely identifying the build.
234
+ # number String Incremental number for a repository's builds.
235
+ # state String Current state of the build.
236
+ # duration Integer Wall clock time in seconds.
237
+ # event_type String Event that triggered the build.
238
+ # previous_state String State of the previous build (useful to see if state changed).
239
+ # pull_request_title String Title of the build's pull request.
240
+ # pull_request_number Integer Number of the build's pull request.
241
+ # started_at String When the build started.
242
+ # finished_at String When the build finished.
243
+ # repository Repository GitHub user or organization the build belongs to.
244
+ # branch Branch The branch the build is associated with.
245
+ # tag Unknown The build's tag.
246
+ # commit Commit The commit the build is associated with.
247
+ # jobs Jobs List of jobs that are part of the build's matrix.
248
+ # stages [Stage] The stages of a build.
249
+ # created_by Owner The User or Organization that created the build.
250
+ # updated_at Unknown The build's updated_at.
251
+ #
340
252
  # ## Actions
341
253
  #
342
254
  # **Find**
343
255
  #
344
- # This returns an individual repository.
345
- #
346
- # GET <code>/repo/{repository.id}</code>
347
- #
256
+ # This returns a single build.
257
+ #
258
+ # GET <code>/build/{build.id}</code>
259
+ #
348
260
  # Template Variable Type Description
349
- # repository.id Integer Value uniquely identifying the repository.
350
- #
351
- # Query Parameter Type Description
352
- # include [String] List of attributes to eager load.
353
- #
354
- # Example: GET /repo/891
355
- #
356
- # GET <code>/repo/{repository.slug}</code>
357
- #
358
- # Template Variable Type Description
359
- # repository.slug String Same as {repository.owner.name}/{repository.name}.
360
- #
261
+ # build.id Integer Value uniquely identifying the build.
262
+ #
361
263
  # Query Parameter Type Description
362
264
  # include [String] List of attributes to eager load.
363
- #
364
- # Example: GET /repo/rails%2Frails
365
- #
366
- # **Activate**
367
265
  #
368
- # This will activate a repository, allowing its tests to be run on Travis CI.
369
- #
370
- # POST <code>/repo/{repository.id}/activate</code>
371
- #
372
- # Template Variable Type Description
373
- # repository.id Integer Value uniquely identifying the repository.
374
- #
375
- # Example: POST /repo/891/activate
376
- #
377
- # POST <code>/repo/{repository.slug}/activate</code>
378
- #
379
- # Template Variable Type Description
380
- # repository.slug String Same as {repository.owner.name}/{repository.name}.
381
- #
382
- # Example: POST /repo/rails%2Frails/activate
383
- #
384
- # **Deactivate**
385
- #
386
- # This will deactivate a repository, preventing any tests from running on Travis CI.
387
- #
388
- # POST <code>/repo/{repository.id}/deactivate</code>
389
- #
390
- # Template Variable Type Description
391
- # repository.id Integer Value uniquely identifying the repository.
392
- #
393
- # Example: POST /repo/891/deactivate
394
- #
395
- # POST <code>/repo/{repository.slug}/deactivate</code>
396
- #
397
- # Template Variable Type Description
398
- # repository.slug String Same as {repository.owner.name}/{repository.name}.
399
- #
400
- # Example: POST /repo/rails%2Frails/deactivate
401
- #
402
- # **Star**
266
+ # Example: GET /build/86601346
267
+ #
268
+ # **Cancel**
269
+ #
270
+ # This cancels a currently running build. It will set the build and associated jobs to "state": "canceled".
271
+ #
272
+ # POST <code>/build/{build.id}/cancel</code>
403
273
  #
404
- # This will star a repository based on the currently logged in user.
405
- #
406
- # POST <code>/repo/{repository.id}/star</code>
407
- #
408
274
  # Template Variable Type Description
409
- # repository.id Integer Value uniquely identifying the repository.
410
- #
411
- # Example: POST /repo/891/star
412
- #
413
- # POST <code>/repo/{repository.slug}/star</code>
414
- #
415
- # Template Variable Type Description
416
- # repository.slug String Same as {repository.owner.name}/{repository.name}.
417
- #
418
- # Example: POST /repo/rails%2Frails/star
419
- #
420
- # **Unstar**
275
+ # build.id Integer Value uniquely identifying the build.
276
+ #
277
+ # Example: POST /build/86601346/cancel
278
+ #
279
+ # **Restart**
280
+ #
281
+ # This restarts a build that has completed or been canceled.
282
+ #
283
+ # POST <code>/build/{build.id}/restart</code>
421
284
  #
422
- # This will unstar a repository based on the currently logged in user.
423
- #
424
- # POST <code>/repo/{repository.id}/unstar</code>
425
- #
426
285
  # Template Variable Type Description
427
- # repository.id Integer Value uniquely identifying the repository.
428
- #
429
- # Example: POST /repo/891/unstar
430
- #
431
- # POST <code>/repo/{repository.slug}/unstar</code>
432
- #
433
- # Template Variable Type Description
434
- # repository.slug String Same as {repository.owner.name}/{repository.name}.
435
- #
436
- # Example: POST /repo/rails%2Frails/unstar
437
- #
286
+ # build.id Integer Value uniquely identifying the build.
287
+ #
288
+ # Example: POST /build/86601346/restart
289
+ #
438
290
  # @note POST requests require an authorization token set in the headers. See: {h}
439
291
  #
440
- # @param repo [String] github_username/repository_name
441
- # @param action [String, Symbol] Optional argument for star/unstar/activate/deactivate
442
- # @raise [InvalidRepository] if given input does not
443
- # conform to valid repository identifier format
292
+ # @param id [String, Integer] the build id number
444
293
  # @return [Success, RequestError]
445
- def repository(repo = repository_name, action = nil)
446
- raise InvalidRepository unless repo.is_a?(String) and
447
- Regexp.new(/(^\d+$)|(^\w+(?:\/|%2F){1}\w+$)/) === repo
448
-
449
- repo = repo.gsub(/\//, '%2F')
450
-
451
- action = '' if !%w(star unstar activate deavtivate).include? "#{action}"
452
-
453
- if action.empty?
454
- get("#{self[]}/repo/#{repo}")
455
- else
456
- post("#{self[]}/repo/#{repo}/#{action}")
457
- end
294
+ def build(id)
295
+ get("#{without_repo}/build/#{id}")
458
296
  end
459
297
 
460
298
  # A list of builds.
461
- #
299
+ #
462
300
  # ## Attributes
463
- #
301
+ #
464
302
  # Name Type Description
465
303
  # builds [Build] List of builds.
466
- #
304
+ #
467
305
  # **Collection Items**
468
306
  #
469
307
  # Each entry in the builds array has the following attributes:
470
- #
308
+ #
471
309
  # Name Type Description
472
310
  # id Integer Value uniquely identifying the build.
473
311
  # number String Incremental number for a repository's builds.
@@ -488,15 +326,15 @@ module Trav3
488
326
  # created_by Owner The User or Organization that created the build.
489
327
  # updated_at Unknown The build's updated_at.
490
328
  # request Unknown The build's request.
491
- #
329
+ #
492
330
  # ## Actions
493
331
  #
494
332
  # **For Current User**
495
333
  #
496
334
  # This returns a list of builds for the current user. The result is paginated.
497
- #
335
+ #
498
336
  # GET <code>/builds</code>
499
- #
337
+ #
500
338
  # Query Parameter Type Description
501
339
  # include [String] List of attributes to eager load.
502
340
  # limit Integer How many builds to include in the response. Used for pagination.
@@ -505,17 +343,17 @@ module Trav3
505
343
  # offset Integer How many builds to skip before the first entry in the response. Used for pagination.
506
344
  # sort_by [String] Attributes to sort builds by. Used for pagination.
507
345
  # sort_by [String] Attributes to sort builds by. Used for pagination.
508
- #
346
+ #
509
347
  # Example: GET /builds?limit=5
510
- #
511
- # **Sortable by:** id, started_at, finished_at, append :desc to any attribute to reverse order.
512
- #
348
+ #
349
+ # **Sortable by:** <code>id</code>, <code>started_at</code>, <code>finished_at</code>, append <code>:desc</code> to any attribute to reverse order.
350
+ #
513
351
  # **Find**
514
352
  #
515
353
  # This returns a list of builds for an individual repository. It is possible to use the repository id or slug in the request. The result is paginated. Each request will return 25 results.
516
- #
354
+ #
517
355
  # GET <code>/repo/{repository.id}/builds</code>
518
- #
356
+ #
519
357
  # Template Variable Type Description
520
358
  # repository.id Integer Value uniquely identifying the repository.
521
359
  #
@@ -535,11 +373,11 @@ module Trav3
535
373
  # state [String] Alias for build.state.
536
374
  #
537
375
  # Example: GET /repo/891/builds?limit=5
538
- #
539
- # **Sortable by:** id, started_at, finished_at, append :desc to any attribute to reverse order.
540
- #
376
+ #
377
+ # **Sortable by:** <code>id</code>, <code>started_at</code>, <code>finished_at</code>, append <code>:desc</code> to any attribute to reverse order.
378
+ #
541
379
  # GET <code>/repo/{repository.slug}/builds</code>
542
- #
380
+ #
543
381
  # Template Variable Type Description
544
382
  # repository.slug String Same as {repository.owner.name}/{repository.name}.
545
383
  #
@@ -559,115 +397,25 @@ module Trav3
559
397
  # state [String] Alias for build.state.
560
398
  #
561
399
  # Example: GET /repo/rails%2Frails/builds?limit=5
562
- #
563
- # **Sortable by:** id, started_at, finished_at, append :desc to any attribute to reverse order.
564
- #
565
- # @return [Success, RequestError]
566
- def builds
567
- get("#{self[true]}/builds#{opts}")
568
- end
569
-
570
- # An individual build.
571
- #
572
- # ## Attributes
573
- #
574
- # **Minimal Representation**
575
- #
576
- # Included when the resource is returned as part of another resource.
577
- #
578
- # Name Type Description
579
- # id Integer Value uniquely identifying the build.
580
- # number String Incremental number for a repository's builds.
581
- # state String Current state of the build.
582
- # duration Integer Wall clock time in seconds.
583
- # event_type String Event that triggered the build.
584
- # previous_state String State of the previous build (useful to see if state changed).
585
- # pull_request_title String Title of the build's pull request.
586
- # pull_request_number Integer Number of the build's pull request.
587
- # started_at String When the build started.
588
- # finished_at String When the build finished.
589
- #
590
- # **Standard Representation**
591
- #
592
- # Included when the resource is the main response of a request, or is eager loaded.
593
- #
594
- # Name Type Description
595
- # id Integer Value uniquely identifying the build.
596
- # number String Incremental number for a repository's builds.
597
- # state String Current state of the build.
598
- # duration Integer Wall clock time in seconds.
599
- # event_type String Event that triggered the build.
600
- # previous_state String State of the previous build (useful to see if state changed).
601
- # pull_request_title String Title of the build's pull request.
602
- # pull_request_number Integer Number of the build's pull request.
603
- # started_at String When the build started.
604
- # finished_at String When the build finished.
605
- # repository Repository GitHub user or organization the build belongs to.
606
- # branch Branch The branch the build is associated with.
607
- # tag Unknown The build's tag.
608
- # commit Commit The commit the build is associated with.
609
- # jobs Jobs List of jobs that are part of the build's matrix.
610
- # stages [Stage] The stages of a build.
611
- # created_by Owner The User or Organization that created the build.
612
- # updated_at Unknown The build's updated_at.
613
- #
614
- # ## Actions
615
- #
616
- # **Find**
617
- #
618
- # This returns a single build.
619
- #
620
- # GET <code>/build/{build.id}</code>
621
- #
622
- # Template Variable Type Description
623
- # build.id Integer Value uniquely identifying the build.
624
- #
625
- # Query Parameter Type Description
626
- # include [String] List of attributes to eager load.
627
- #
628
- # Example: GET /build/86601346
629
- #
630
- # **Cancel**
631
400
  #
632
- # This cancels a currently running build. It will set the build and associated jobs to "state": "canceled".
633
- #
634
- # POST <code>/build/{build.id}/cancel</code>
635
- #
636
- # Template Variable Type Description
637
- # build.id Integer Value uniquely identifying the build.
638
- #
639
- # Example: POST /build/86601346/cancel
640
- #
641
- # **Restart**
642
- #
643
- # This restarts a build that has completed or been canceled.
644
- #
645
- # POST <code>/build/{build.id}/restart</code>
646
- #
647
- # Template Variable Type Description
648
- # build.id Integer Value uniquely identifying the build.
649
- #
650
- # Example: POST /build/86601346/restart
651
- #
652
- # @note POST requests require an authorization token set in the headers. See: {h}
401
+ # **Sortable by:** <code>id</code>, <code>started_at</code>, <code>finished_at</code>, append <code>:desc</code> to any attribute to reverse order.
653
402
  #
654
- # @param id [String, Integer] the build id number
655
403
  # @return [Success, RequestError]
656
- def build(id)
657
- get("#{self[]}/build/#{id}")
404
+ def builds
405
+ get("#{with_repo}/builds#{opts}")
658
406
  end
659
407
 
660
408
  # A list of jobs.
661
- #
409
+ #
662
410
  # ## Attributes
663
- #
411
+ #
664
412
  # Name Type Description
665
413
  # jobs [Job] List of jobs.
666
- #
414
+ #
667
415
  # **Collection Items**
668
416
  #
669
417
  # Each entry in the jobs array has the following attributes:
670
- #
418
+ #
671
419
  # Name Type Description
672
420
  # id Integer Value uniquely identifying the job.
673
421
  # allow_failure Unknown The job's allow_failure.
@@ -684,29 +432,29 @@ module Trav3
684
432
  # created_at String When the job was created.
685
433
  # updated_at String When the job was updated.
686
434
  # config Object The job's config.
687
- #
435
+ #
688
436
  # ## Actions
689
437
  #
690
438
  # **Find**
691
439
  #
692
440
  # This returns a list of jobs belonging to an individual build.
693
- #
441
+ #
694
442
  # GET <code>/build/{build.id}/jobs</code>
695
- #
443
+ #
696
444
  # Template Variable Type Description
697
445
  # build.id Integer Value uniquely identifying the build.
698
446
  #
699
447
  # Query Parameter Type Description
700
448
  # include [String] List of attributes to eager load.
701
- #
449
+ #
702
450
  # Example: GET /build/86601346/jobs
703
- #
451
+ #
704
452
  # **For Current User**
705
453
  #
706
454
  # This returns a list of jobs a current user has access to.
707
- #
455
+ #
708
456
  # GET <code>/jobs</code>
709
- #
457
+ #
710
458
  # Query Parameter Type Description
711
459
  # active Unknown Alias for job.active.
712
460
  # created_by Unknown Alias for job.created_by.
@@ -718,33 +466,33 @@ module Trav3
718
466
  # offset Integer How many jobs to skip before the first entry in the response. Used for pagination.
719
467
  # sort_by [String] Attributes to sort jobs by. Used for pagination.
720
468
  # state [String] Alias for job.state.
721
- #
469
+ #
722
470
  # Example: GET /jobs?limit=5
723
- #
724
- # **Sortable by:** id, append :desc to any attribute to reverse order.
471
+ #
472
+ # **Sortable by:** <code>id</code>, append <code>:desc</code> to any attribute to reverse order.
725
473
  # The default value is id:desc.
726
474
  #
727
475
  # @param id [String, Integer] the build id number
728
476
  # @return [Success, RequestError]
729
477
  def build_jobs(id)
730
- get("#{self[]}/build/#{id}/jobs")
478
+ get("#{without_repo}/build/#{id}/jobs")
731
479
  end
732
480
 
733
481
  # An individual job.
734
- #
482
+ #
735
483
  # ## Attributes
736
484
  #
737
485
  # **Minimal Representation**
738
486
  #
739
487
  # Included when the resource is returned as part of another resource.
740
- #
488
+ #
741
489
  # Name Type Description
742
490
  # id Integer Value uniquely identifying the job.
743
- #
491
+ #
744
492
  # **Standard Representation**
745
493
  #
746
494
  # Included when the resource is the main response of a request, or is eager loaded.
747
- #
495
+ #
748
496
  # Name Type Description
749
497
  # id Integer Value uniquely identifying the job.
750
498
  # allow_failure Unknown The job's allow_failure.
@@ -760,56 +508,56 @@ module Trav3
760
508
  # stage [Stage] The stages of a job.
761
509
  # created_at String When the job was created.
762
510
  # updated_at String When the job was updated.
763
- #
511
+ #
764
512
  # ## Actions
765
513
  #
766
514
  # **Find**
767
515
  #
768
516
  # This returns a single job.
769
- #
517
+ #
770
518
  # GET <code>/job/{job.id}</code>
771
- #
519
+ #
772
520
  # Template Variable Type Description
773
521
  # job.id Integer Value uniquely identifying the job.
774
- #
522
+ #
775
523
  # Query Parameter Type Description
776
524
  # include [String] List of attributes to eager load.
777
- #
525
+ #
778
526
  # Example: GET /job/86601347
779
- #
527
+ #
780
528
  # **Cancel**
781
529
  #
782
530
  # This cancels a currently running job.
783
- #
531
+ #
784
532
  # POST <code>/job/{job.id}/cancel</code>
785
- #
533
+ #
786
534
  # Template Variable Type Description
787
535
  # job.id Integer Value uniquely identifying the job.
788
- #
536
+ #
789
537
  # Example: POST /job/86601347/cancel
790
- #
538
+ #
791
539
  # **Restart**
792
540
  #
793
541
  # This restarts a job that has completed or been canceled.
794
- #
542
+ #
795
543
  # POST <code>/job/{job.id}/restart</code>
796
- #
544
+ #
797
545
  # Template Variable Type Description
798
546
  # job.id Integer Value uniquely identifying the job.
799
- #
547
+ #
800
548
  # Example: POST /job/86601347/restart
801
- #
549
+ #
802
550
  # **Debug**
803
551
  #
804
552
  # This restarts a job in debug mode, enabling the logged-in user to ssh into the build VM. Please note this feature is only available on the travis-ci.com domain, and those repositories on the travis-ci.org domain for which the debug feature is enabled. See this document for more details.
805
- #
553
+ #
806
554
  # POST <code>/job/{job.id}/debug</code>
807
- #
555
+ #
808
556
  # Template Variable Type Description
809
557
  # job.id Integer Value uniquely identifying the job.
810
- #
558
+ #
811
559
  # Example: POST /job/86601347/debug
812
- #
560
+ #
813
561
  # @note POST requests require an authorization token set in the headers. See: {h}
814
562
  #
815
563
  # @param id [String, Integer] the job id number
@@ -818,53 +566,82 @@ module Trav3
818
566
  def job(id, option = nil)
819
567
  case option
820
568
  when :cancel
821
- post("#{self[]}/job/#{id}/cancel")
569
+ post("#{without_repo}/job/#{id}/cancel")
822
570
  when :restart
823
- post("#{self[]}/job/#{id}/restart")
571
+ post("#{without_repo}/job/#{id}/restart")
824
572
  when :debug
825
- post("#{self[]}/job/#{id}/debug")
573
+ post("#{without_repo}/job/#{id}/debug")
826
574
  else
827
- get("#{self[]}/job/#{id}")
575
+ get("#{without_repo}/job/#{id}")
828
576
  end
829
577
  end
830
578
 
579
+ # This validates the `.travis.yml` file and returns any warnings.
580
+ #
581
+ # The request body can contain the content of the .travis.yml file directly as a string, eg "foo: bar".
582
+ #
583
+ # ## Attributes
584
+ #
585
+ # Name Type Description
586
+ # warnings Array An array of hashes with keys and warnings.
587
+ #
588
+ # ## Actions
589
+ #
590
+ # **Lint**
591
+ #
592
+ # POST <code>/lint</code>
593
+ #
594
+ # Example:POST /lint
595
+ #
596
+ # @param yaml_content [String] the contents for the file `.travis.yml`
597
+ # @return [Success, RequestError]
598
+ def lint(yaml_content)
599
+ raise TypeError, "String expected, #{yaml_content.class} given" unless \
600
+ yaml_content.is_a? String
601
+
602
+ ct = headers.remove(:'Content-Type')
603
+ result = post("#{without_repo}/lint", body: yaml_content)
604
+ h('Content-Type': ct) if ct
605
+ result
606
+ end
607
+
831
608
  # An individual log.
832
- #
609
+ #
833
610
  # ## Attributes
834
611
  #
835
612
  # **Minimal Representation**
836
613
  #
837
614
  # Included when the resource is returned as part of another resource.
838
- #
615
+ #
839
616
  # Name Type Description
840
617
  # id Unknown The log's id.
841
- #
618
+ #
842
619
  # **Standard Representation**
843
620
  #
844
621
  # Included when the resource is the main response of a request, or is eager loaded.
845
- #
622
+ #
846
623
  # Name Type Description
847
624
  # id Unknown The log's id.
848
625
  # content Unknown The log's content.
849
626
  # log_parts Unknown The log's log_parts.
850
- #
627
+ #
851
628
  # ## Actions
852
629
  #
853
630
  # **Find**
854
631
  #
855
632
  # This returns a single log.
856
- #
633
+ #
857
634
  # It's possible to specify the accept format of the request as text/plain if required. This will return the content of the log as a single blob of text.
858
- #
635
+ #
859
636
  # curl -H "Travis-API-Version: 3" \
860
637
  # -H "Accept: text/plain" \
861
638
  # -H "Authorization: token xxxxxxxxxxxx" \
862
639
  # https://api.travis-ci.org/job/{job.id}/log
863
- #
640
+ #
864
641
  # The default response type is application/json, and will include additional meta data such as @type, @representation etc. (see [https://developer.travis-ci.org/format](https://developer.travis-ci.org/format)).
865
- #
642
+ #
866
643
  # GET <code>/job/{job.id}/log</code>
867
- #
644
+ #
868
645
  # Template Variable Type Description
869
646
  # job.id Integer Value uniquely identifying the job.
870
647
  #
@@ -873,34 +650,34 @@ module Trav3
873
650
  # log.token Unknown Documentation missing.
874
651
  #
875
652
  # Example: GET /job/86601347/log
876
- #
653
+ #
877
654
  # GET <code>/job/{job.id}/log.txt</code>
878
- #
655
+ #
879
656
  # Template Variable Type Description
880
657
  # job.id Integer Value uniquely identifying the job.
881
- #
658
+ #
882
659
  # Query Parameter Type Description
883
660
  # include [String] List of attributes to eager load.
884
661
  # log.token Unknown Documentation missing.
885
- #
886
- # Example:GET/job/86601347/log.txt
887
- #
662
+ #
663
+ # Example:GET /job/86601347/log.txt
664
+ #
888
665
  # **Delete**
889
666
  #
890
667
  # This removes the contents of a log. It gets replace with the message: Log removed by XXX at 2017-02-13 16:00:00 UTC.
891
- #
668
+ #
892
669
  # curl -X DELETE \
893
670
  # -H "Travis-API-Version: 3" \
894
671
  # -H "Authorization: token xxxxxxxxxxxx" \
895
672
  # https://api.travis-ci.org/job/{job.id}/log
896
673
  #
897
674
  # DELETE <code>/job/{job.id}/log</code>
898
- #
675
+ #
899
676
  # Template Variable Type Description
900
677
  # job.id Integer Value uniquely identifying the job.
901
- #
678
+ #
902
679
  # Example: DELETE /job/86601347/log
903
- #
680
+ #
904
681
  # @note DELETE is unimplemented
905
682
  #
906
683
  # @param id [String, Integer] the job id number
@@ -909,37 +686,626 @@ module Trav3
909
686
  def log(id, option = nil)
910
687
  case option
911
688
  when :text
912
- get("#{self[]}/job/#{id}/log.txt", true)
689
+ get("#{without_repo}/job/#{id}/log.txt", true)
913
690
  when :delete
914
691
  raise Unimplemented
915
692
  else
916
- get("#{self[]}/job/#{id}/log")
693
+ get("#{without_repo}/job/#{id}/log")
917
694
  end
918
695
  end
919
696
 
920
- private # @private
921
- def [](repository = false)
922
- [api_endpoint()].tap {|a| a.push("repo/#{@repo}") if repository }.join('/')
923
- end
697
+ # An individual organization.
698
+ #
699
+ # ## Attributes
700
+ #
701
+ # **Minimal Representation**
702
+ #
703
+ # Included when the resource is returned as part of another resource.
704
+ #
705
+ # Name Type Description
706
+ # id Integer Value uniquely identifying the organization.
707
+ # login String Login set on GitHub.
708
+ #
709
+ # **Standard Representation**
710
+ #
711
+ # Included when the resource is the main response of a request, or is {https://developer.travis-ci.com/eager-loading eager loaded}.
712
+ #
713
+ # Name Type Description
714
+ # id Integer Value uniquely identifying the organization.
715
+ # login String Login set on GitHub.
716
+ # name String Name set on GitHub.
717
+ # github_id Integer Id set on GitHub.
718
+ # avatar_url String Avatar_url set on GitHub.
719
+ # education Boolean Whether or not the organization has an education account.
720
+ # allow_migration Unknown The organization's allow_migration.
721
+ #
722
+ # **Additional Attributes**
723
+ #
724
+ # Name Type Description
725
+ # repositories [Repository] Repositories belonging to this organization.
726
+ # installation Installation Installation belonging to the organization.
727
+ #
728
+ # ## Actions
729
+ #
730
+ # **Find**
731
+ #
732
+ # This returns an individual organization.
733
+ #
734
+ # GET <code>/org/{organization.id}</code>
735
+ #
736
+ # Template Variable Type Description
737
+ # organization.id Integer Value uniquely identifying the organization.
738
+ # Query Parameter Type Description
739
+ # include [String] List of attributes to eager load.
740
+ #
741
+ # Example:GET /org/87
742
+ #
743
+ # @param org_id [String, Integer] the organization id
744
+ # @raise [TypeError] if given organization id is not a number
745
+ # @return [Success, RequestError]
746
+ def organization(org_id)
747
+ raise TypeError, 'Integer expected for organization id' unless /^\d+$/.match? org_id.to_s
924
748
 
925
- def repository_name
926
- @repo
749
+ get("#{without_repo}/org/#{org_id}")
927
750
  end
928
751
 
929
- def opts
930
- @options
931
- end
752
+ # A list of organizations for the current user.
753
+ #
754
+ # ## Attributes
755
+ #
756
+ # Name Type Description
757
+ # organizations [Organization] List of organizations.
758
+ #
759
+ # **Collection Items**
760
+ #
761
+ # Each entry in the **organizations** array has the following attributes:
762
+ #
763
+ # Name Type Description
764
+ # id Integer Value uniquely identifying the organization.
765
+ # login String Login set on GitHub.
766
+ # name String Name set on GitHub.
767
+ # github_id Integer Id set on GitHub.
768
+ # avatar_url String Avatar_url set on GitHub.
769
+ # education Boolean Whether or not the organization has an education account.
770
+ # allow_migration Unknown The organization's allow_migration.
771
+ # repositories [Repository] Repositories belonging to this organization.
772
+ # installation Installation Installation belonging to the organization.
773
+ #
774
+ # ## Actions
775
+ #
776
+ # **For Current User**
777
+ #
778
+ # This returns a list of organizations the current user is a member of.
779
+ #
780
+ # GET <code>/orgs</code>
781
+ #
782
+ # Query Parameter Type Description
783
+ # include [String] List of attributes to eager load.
784
+ # limit Integer How many organizations to include in the response. Used for pagination.
785
+ # offset Integer How many organizations to skip before the first entry in the response. Used for pagination.
786
+ # organization.role Unknown Documentation missing.
787
+ # role Unknown Alias for organization.role.
788
+ # sort_by [String] Attributes to sort organizations by. Used for pagination.
789
+ #
790
+ # Example:GET /orgs?limit=5
791
+ #
792
+ # **Sortable by:** <code>id</code>, <code>login</code>, <code>name</code>, <code>github_id</code>, append <code>:desc</code> to any attribute to reverse order.
793
+ #
794
+ # @return [Success, RequestError]
795
+ def organizations
796
+ get("#{without_repo}/orgs")
797
+ end
798
+
799
+ # This will be either a user or organization.
800
+ #
801
+ # ## Attributes
802
+ #
803
+ # **Minimal Representation**
804
+ #
805
+ # Included when the resource is returned as part of another resource.
806
+ #
807
+ # Name Type Description
808
+ # id Integer Value uniquely identifying the owner.
809
+ # login String User or organization login set on GitHub.
810
+ #
811
+ # **Standard Representation**
812
+ #
813
+ # Included when the resource is the main response of a request, or is eager loaded.
814
+ #
815
+ # Name Type Description
816
+ # id Integer Value uniquely identifying the owner.
817
+ # login String User or organization login set on GitHub.
818
+ # name String User or organization name set on GitHub.
819
+ # github_id Integer User or organization id set on GitHub.
820
+ # avatar_url String Link to user or organization avatar (image) set on GitHub.
821
+ #
822
+ # **Additional Attributes**
823
+ #
824
+ # Name Type Description
825
+ # repositories [Repository] Repositories belonging to this account.
826
+ #
827
+ # ## Actions
828
+ #
829
+ # **Find**
830
+ #
831
+ # This returns an individual owner. It is possible to use the GitHub login or github_id in the request.
832
+ #
833
+ # GET <code>/owner/{owner.login}</code>
834
+ #
835
+ # Template Variable Type Description
836
+ # owner.login String User or organization login set on GitHub.
837
+ #
838
+ # Query Parameter Type Description
839
+ # include [String] List of attributes to eager load.
840
+ #
841
+ # Example: GET /owner/danielpclark
842
+ #
843
+ # GET <code>/owner/{user.login}</code>
844
+ #
845
+ # Template Variable Type Description
846
+ # user.login String Login set on Github.
847
+ #
848
+ # Query Parameter Type Description
849
+ # include [String] List of attributes to eager load.
850
+ #
851
+ # Example: GET /owner/danielpclark
852
+ #
853
+ # GET <code>/owner/{organization.login}</code>
854
+ #
855
+ # Template Variable Type Description
856
+ # organization.login String Login set on GitHub.
857
+ #
858
+ # Query Parameter Type Description
859
+ # include [String] List of attributes to eager load.
860
+ #
861
+ # Example: GET /owner/travis-ci
862
+ #
863
+ # GET <code>/owner/github_id/{owner.github_id}</code>
864
+ #
865
+ # Template Variable Type Description
866
+ # owner.github_id Integer User or organization id set on GitHub.
867
+ #
868
+ # Query Parameter Type Description
869
+ # include [String] List of attributes to eager load.
870
+ #
871
+ # Example: GET /owner/github_id/639823
872
+ #
873
+ # @param owner [String] username or github ID
874
+ # @return [Success, RequestError]
875
+ def owner(owner = username)
876
+ if /^\d+$/.match? owner.to_s
877
+ get("#{without_repo}/owner/github_id/#{owner}")
878
+ else
879
+ get("#{without_repo}/owner/#{owner}")
880
+ end
881
+ end
882
+
883
+ # A list of repositories for the current user.
884
+ #
885
+ # ## Attributes
886
+ #
887
+ # Name Type Description
888
+ # repositories [Repository] List of repositories.
889
+ #
890
+ # **Collection Items**
891
+ #
892
+ # Each entry in the repositories array has the following attributes:
893
+ #
894
+ # Name Type Description
895
+ # id Integer Value uniquely identifying the repository.
896
+ # name String The repository's name on GitHub.
897
+ # slug String Same as {repository.owner.name}/{repository.name}.
898
+ # description String The repository's description from GitHub.
899
+ # github_language String The main programming language used according to GitHub.
900
+ # active Boolean Whether or not this repository is currently enabled on Travis CI.
901
+ # private Boolean Whether or not this repository is private.
902
+ # owner Owner GitHub user or organization the repository belongs to.
903
+ # default_branch Branch The default branch on GitHub.
904
+ # starred Boolean Whether or not this repository is starred.
905
+ # current_build Build The most recently started build (this excludes builds that have been created but have not yet started).
906
+ # last_started_build Build Alias for current_build.
907
+ #
908
+ # ## Actions
909
+ #
910
+ # **For Owner**
911
+ #
912
+ # This returns a list of repositories an owner has access to.
913
+ #
914
+ # GET <code>/owner/{owner.login}/repos</code>
915
+ #
916
+ # Template Variable Type Description
917
+ # owner.login String User or organization login set on GitHub.
918
+ #
919
+ # Query Parameter Type Description
920
+ # active [Boolean] Alias for repository.active.
921
+ # include [String] List of attributes to eager load.
922
+ # limit Integer How many repositories to include in the response. Used for pagination.
923
+ # offset Integer How many repositories to skip before the first entry in the response. Used for pagination.
924
+ # private [Boolean] Alias for repository.private.
925
+ # repository.active [Boolean] Filters repositories by whether or not this repository is currently enabled on Travis CI.
926
+ # repository.private [Boolean] Filters repositories by whether or not this repository is private.
927
+ # repository.starred [Boolean] Filters repositories by whether or not this repository is starred.
928
+ # sort_by [String] Attributes to sort repositories by. Used for pagination.
929
+ # starred [Boolean] Alias for repository.starred.
930
+ #
931
+ # Example: GET /owner/danielpclark/repos?limit=5&sort_by=active,name
932
+ #
933
+ # **Sortable by:** <code>id</code>, <code>github_id</code>, <code>owner_name</code>, <code>name</code>, <code>active</code>, <code>default_branch.last_build</code>, append <code>:desc</code> to any attribute to reverse order.
934
+ #
935
+ # GET <code>/owner/{user.login}/repos</code>
936
+ #
937
+ # Template Variable Type Description
938
+ # user.login String Login set on Github.
939
+ #
940
+ # Query Parameter Type Description
941
+ # active [Boolean] Alias for repository.active.
942
+ # include [String] List of attributes to eager load.
943
+ # limit Integer How many repositories to include in the response. Used for pagination.
944
+ # offset Integer How many repositories to skip before the first entry in the response. Used for pagination.
945
+ # private [Boolean] Alias for repository.private.
946
+ # repository.active [Boolean] Filters repositories by whether or not this repository is currently enabled on Travis CI.
947
+ # repository.private [Boolean] Filters repositories by whether or not this repository is private.
948
+ # repository.starred [Boolean] Filters repositories by whether or not this repository is starred.
949
+ # sort_by [String] Attributes to sort repositories by. Used for pagination.
950
+ # starred [Boolean] Alias for repository.starred.
951
+ #
952
+ # Example: GET /owner/danielpclark/repos?limit=5&sort_by=active,name
953
+ #
954
+ # **Sortable by:** <code>id</code>, <code>github_id</code>, <code>owner_name</code>, <code>name</code>, <code>active</code>, <code>default_branch.last_build</code>, append <code>:desc</code> to any attribute to reverse order.
955
+ #
956
+ # GET <code>/owner/{organization.login}/repos</code>
957
+ #
958
+ # Template Variable Type Description
959
+ # organization.login String Login set on GitHub.
960
+ #
961
+ # Query Parameter Type Description
962
+ # active [Boolean] Alias for repository.active.
963
+ # include [String] List of attributes to eager load.
964
+ # limit Integer How many repositories to include in the response. Used for pagination.
965
+ # offset Integer How many repositories to skip before the first entry in the response. Used for pagination.
966
+ # private [Boolean] Alias for repository.private.
967
+ # repository.active [Boolean] Filters repositories by whether or not this repository is currently enabled on Travis CI.
968
+ # repository.private [Boolean] Filters repositories by whether or not this repository is private.
969
+ # repository.starred [Boolean] Filters repositories by whether or not this repository is starred.
970
+ # sort_by [String] Attributes to sort repositories by. Used for pagination.
971
+ # starred [Boolean] Alias for repository.starred.
972
+ #
973
+ # Example: GET /owner/travis-ci/repos?limit=5&sort_by=active,name
974
+ #
975
+ # **Sortable by:** <code>id</code>, <code>github_id</code>, <code>owner_name</code>, <code>name</code>, <code>active</code>, <code>default_branch.last_build</code>, append <code>:desc</code> to any attribute to reverse order.
976
+ #
977
+ # GET <code>/owner/github_id/{owner.github_id}/repos</code>
978
+ #
979
+ # Template Variable Type Description
980
+ # owner.github_id Integer User or organization id set on GitHub.
981
+ #
982
+ # Query Parameter Type Description
983
+ # active [Boolean] Alias for repository.active.
984
+ # include [String] List of attributes to eager load.
985
+ # limit Integer How many repositories to include in the response. Used for pagination.
986
+ # offset Integer How many repositories to skip before the first entry in the response. Used for pagination.
987
+ # private [Boolean] Alias for repository.private.
988
+ # repository.active [Boolean] Filters repositories by whether or not this repository is currently enabled on Travis CI.
989
+ # repository.private [Boolean] Filters repositories by whether or not this repository is private.
990
+ # repository.starred [Boolean] Filters repositories by whether or not this repository is starred.
991
+ # sort_by [String] Attributes to sort repositories by. Used for pagination.
992
+ # starred [Boolean] Alias for repository.starred.
993
+ #
994
+ # Example: GET /owner/github_id/639823/repos?limit=5&sort_by=active,name
995
+ #
996
+ # **Sortable by:** <code>id</code>, <code>github_id</code>, <code>owner_name</code>, <code>name</code>, <code>active</code>, <code>default_branch.last_build</code>, append <code>:desc</code> to any attribute to reverse order.
997
+ #
998
+ # **For Current User**<br />
999
+ # This returns a list of repositories the current user has access to.
1000
+ #
1001
+ # GET <code>/repos</code>
1002
+ #
1003
+ # Query Parameter Type Description
1004
+ # active [Boolean] Alias for repository.active.
1005
+ # include [String] List of attributes to eager load.
1006
+ # limit Integer How many repositories to include in the response. Used for pagination.
1007
+ # offset Integer How many repositories to skip before the first entry in the response. Used for pagination.
1008
+ # private [Boolean] Alias for repository.private.
1009
+ # repository.active [Boolean] Filters repositories by whether or not this repository is currently enabled on Travis CI.
1010
+ # repository.private [Boolean] Filters repositories by whether or not this repository is private.
1011
+ # repository.starred [Boolean] Filters repositories by whether or not this repository is starred.
1012
+ # sort_by [String] Attributes to sort repositories by. Used for pagination.
1013
+ # starred [Boolean] Alias for repository.starred.
1014
+ #
1015
+ # Example: GET /repos?limit=5&sort_by=active,name
1016
+ #
1017
+ # **Sortable by:** <code>id</code>, <code>github_id</code>, <code>owner_name</code>, <code>name</code>, <code>active</code>, <code>default_branch.last_build</code>, append <code>:desc</code> to any attribute to reverse order.
1018
+ #
1019
+ # @param owner [String] username or github ID
1020
+ # @return [Success, RequestError]
1021
+ def repositories(owner = username)
1022
+ if /^\d+$/.match? owner.to_s
1023
+ get("#{without_repo}/owner/github_id/#{owner}/repos#{opts}")
1024
+ else
1025
+ get("#{without_repo}/owner/#{owner}/repos#{opts}")
1026
+ end
1027
+ end
932
1028
 
933
- def get(x, raw_reply = false)
934
- Trav3::GET.(self, x, raw_reply)
1029
+ # An individual repository.
1030
+ #
1031
+ # ## Attributes
1032
+ #
1033
+ # **Minimal Representation**
1034
+ #
1035
+ # Included when the resource is returned as part of another resource.
1036
+ #
1037
+ # Name Type Description
1038
+ # id Integer Value uniquely identifying the repository.
1039
+ # name String The repository's name on GitHub.
1040
+ # slug String Same as {repository.owner.name}/{repository.name}.
1041
+ #
1042
+ # **Standard Representation**
1043
+ #
1044
+ # Included when the resource is the main response of a request, or is eager loaded.
1045
+ #
1046
+ # Name Type Description
1047
+ # id Integer Value uniquely identifying the repository.
1048
+ # name String The repository's name on GitHub.
1049
+ # slug String Same as {repository.owner.name}/{repository.name}.
1050
+ # description String The repository's description from GitHub.
1051
+ # github_language String The main programming language used according to GitHub.
1052
+ # active Boolean Whether or not this repository is currently enabled on Travis CI.
1053
+ # private Boolean Whether or not this repository is private.
1054
+ # owner Owner GitHub user or organization the repository belongs to.
1055
+ # default_branch Branch The default branch on GitHub.
1056
+ # starred Boolean Whether or not this repository is starred.
1057
+ #
1058
+ # ## Actions
1059
+ #
1060
+ # **Find**
1061
+ #
1062
+ # This returns an individual repository.
1063
+ #
1064
+ # GET <code>/repo/{repository.id}</code>
1065
+ #
1066
+ # Template Variable Type Description
1067
+ # repository.id Integer Value uniquely identifying the repository.
1068
+ #
1069
+ # Query Parameter Type Description
1070
+ # include [String] List of attributes to eager load.
1071
+ #
1072
+ # Example: GET /repo/891
1073
+ #
1074
+ # GET <code>/repo/{repository.slug}</code>
1075
+ #
1076
+ # Template Variable Type Description
1077
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
1078
+ #
1079
+ # Query Parameter Type Description
1080
+ # include [String] List of attributes to eager load.
1081
+ #
1082
+ # Example: GET /repo/rails%2Frails
1083
+ #
1084
+ # **Activate**
1085
+ #
1086
+ # This will activate a repository, allowing its tests to be run on Travis CI.
1087
+ #
1088
+ # POST <code>/repo/{repository.id}/activate</code>
1089
+ #
1090
+ # Template Variable Type Description
1091
+ # repository.id Integer Value uniquely identifying the repository.
1092
+ #
1093
+ # Example: POST /repo/891/activate
1094
+ #
1095
+ # POST <code>/repo/{repository.slug}/activate</code>
1096
+ #
1097
+ # Template Variable Type Description
1098
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
1099
+ #
1100
+ # Example: POST /repo/rails%2Frails/activate
1101
+ #
1102
+ # **Deactivate**
1103
+ #
1104
+ # This will deactivate a repository, preventing any tests from running on Travis CI.
1105
+ #
1106
+ # POST <code>/repo/{repository.id}/deactivate</code>
1107
+ #
1108
+ # Template Variable Type Description
1109
+ # repository.id Integer Value uniquely identifying the repository.
1110
+ #
1111
+ # Example: POST /repo/891/deactivate
1112
+ #
1113
+ # POST <code>/repo/{repository.slug}/deactivate</code>
1114
+ #
1115
+ # Template Variable Type Description
1116
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
1117
+ #
1118
+ # Example: POST /repo/rails%2Frails/deactivate
1119
+ #
1120
+ # **Star**
1121
+ #
1122
+ # This will star a repository based on the currently logged in user.
1123
+ #
1124
+ # POST <code>/repo/{repository.id}/star</code>
1125
+ #
1126
+ # Template Variable Type Description
1127
+ # repository.id Integer Value uniquely identifying the repository.
1128
+ #
1129
+ # Example: POST /repo/891/star
1130
+ #
1131
+ # POST <code>/repo/{repository.slug}/star</code>
1132
+ #
1133
+ # Template Variable Type Description
1134
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
1135
+ #
1136
+ # Example: POST /repo/rails%2Frails/star
1137
+ #
1138
+ # **Unstar**
1139
+ #
1140
+ # This will unstar a repository based on the currently logged in user.
1141
+ #
1142
+ # POST <code>/repo/{repository.id}/unstar</code>
1143
+ #
1144
+ # Template Variable Type Description
1145
+ # repository.id Integer Value uniquely identifying the repository.
1146
+ #
1147
+ # Example: POST /repo/891/unstar
1148
+ #
1149
+ # POST <code>/repo/{repository.slug}/unstar</code>
1150
+ #
1151
+ # Template Variable Type Description
1152
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
1153
+ #
1154
+ # Example: POST /repo/rails%2Frails/unstar
1155
+ #
1156
+ # @note POST requests require an authorization token set in the headers. See: {h}
1157
+ #
1158
+ # @param repo [String] github_username/repository_name
1159
+ # @param action [String, Symbol] Optional argument for star/unstar/activate/deactivate
1160
+ # @raise [InvalidRepository] if given input does not
1161
+ # conform to valid repository identifier format
1162
+ # @return [Success, RequestError]
1163
+ def repository(repo = repository_name, action = nil)
1164
+ raise InvalidRepository unless repo_slug_or_id? repo
1165
+
1166
+ repo = sanitize_repo_name repo
1167
+ action = '' unless %w[star unstar activate deavtivate].include? action.to_s
1168
+
1169
+ if action.empty?
1170
+ get("#{without_repo}/repo/#{repo}")
1171
+ else
1172
+ post("#{without_repo}/repo/#{repo}/#{action}")
1173
+ end
935
1174
  end
936
1175
 
937
- def post(x, fields = {})
938
- Trav3::POST.(self, x, fields)
1176
+ # An individual user.
1177
+ #
1178
+ # ## Attributes
1179
+ #
1180
+ # **Minimal Representation**
1181
+ #
1182
+ # Included when the resource is returned as part of another resource.
1183
+ #
1184
+ # Name Type Description
1185
+ # id Integer Value uniquely identifying the user.
1186
+ # login String Login set on Github.
1187
+ #
1188
+ # **Standard Representation**
1189
+ #
1190
+ # Included when the resource is the main response of a request, or is {https://developer.travis-ci.com/eager-loading eager loaded}.
1191
+ #
1192
+ # Name Type Description
1193
+ # id Integer Value uniquely identifying the user.
1194
+ # login String Login set on Github.
1195
+ # name String Name set on GitHub.
1196
+ # github_id Integer Id set on GitHub.
1197
+ # avatar_url String Avatar URL set on GitHub.
1198
+ # education Boolean Whether or not the user has an education account.
1199
+ # allow_migration Unknown The user's allow_migration.
1200
+ # is_syncing Boolean Whether or not the user is currently being synced with Github.
1201
+ # synced_at String The last time the user was synced with GitHub.
1202
+ #
1203
+ # **Additional Attributes**
1204
+ #
1205
+ # Name Type Description
1206
+ # repositories [Repository] Repositories belonging to this user.
1207
+ # installation Installation Installation belonging to the user.
1208
+ # emails Unknown The user's emails.
1209
+ #
1210
+ # ## Actions
1211
+ #
1212
+ # **Find**
1213
+ #
1214
+ # This will return information about an individual user.
1215
+ #
1216
+ # GET <code>/user/{user.id}</code>
1217
+ #
1218
+ # Template Variable Type Description
1219
+ # user.id Integer Value uniquely identifying the user.
1220
+ # Query Parameter Type Description
1221
+ # include [String] List of attributes to eager load.
1222
+ #
1223
+ # Example:GET /user/119240
1224
+ #
1225
+ # **Sync**
1226
+ #
1227
+ # This triggers a sync on a user's account with their GitHub account.
1228
+ #
1229
+ # POST <code>/user/{user.id}/sync</code>
1230
+ #
1231
+ # Template Variable Type Description
1232
+ # user.id Integer Value uniquely identifying the user.
1233
+ #
1234
+ # Example:POST /user/119240/sync
1235
+ #
1236
+ # **Current**
1237
+ #
1238
+ # This will return information about the current user.
1239
+ #
1240
+ # GET <code>/user</code>
1241
+ #
1242
+ # Query Parameter Type Description
1243
+ # include [String] List of attributes to eager load.
1244
+ #
1245
+ # Example:GET /user
1246
+ #
1247
+ # @note sync feature may not be permitted
1248
+ # @note POST requests require an authorization token set in the headers. See: {h}
1249
+ #
1250
+ # @param user_id [String, Integer] optional user id
1251
+ # @param sync [Boolean] optional argument for syncing your Travis CI account with Github
1252
+ # @raise [TypeError] if given user id is not a number
1253
+ # @return [Success, RequestError]
1254
+ def user(user_id = nil, sync = false)
1255
+ return get("#{without_repo}/user") if !user_id && !sync
1256
+ raise TypeError, 'Integer expected for user id' unless /^\d+$/.match? user_id.to_s
1257
+
1258
+ if sync
1259
+ get("#{without_repo}/user/#{user_id}/sync")
1260
+ else
1261
+ get("#{without_repo}/user/#{user_id}")
1262
+ end
1263
+ end
1264
+
1265
+ private # @private
1266
+
1267
+ def get(url, raw_reply = false)
1268
+ Trav3::GET.call(self, url, raw_reply)
1269
+ end
1270
+
1271
+ def initial_defaults
1272
+ defaults(limit: 25)
1273
+ h('Content-Type': 'application/json')
1274
+ h('Accept': 'application/json')
1275
+ h('Travis-API-Version': 3)
1276
+ end
1277
+
1278
+ def opts
1279
+ @options
1280
+ end
1281
+
1282
+ def post(url, fields = {})
1283
+ Trav3::POST.call(self, url, fields)
1284
+ end
1285
+
1286
+ def repo_slug_or_id?(repo)
1287
+ Regexp.new(/(^\d+$)|(^\w+(?:\/|%2F){1}\w+$)/).match? repo
1288
+ end
1289
+
1290
+ def repository_name
1291
+ @repo
1292
+ end
1293
+
1294
+ def sanitize_repo_name(repo)
1295
+ repo.to_s.gsub(/\//, '%2F')
939
1296
  end
940
1297
 
941
1298
  def username
942
1299
  @repo[/.*?(?=(?:\/|%2F)|$)/]
943
1300
  end
1301
+
1302
+ def with_repo
1303
+ "#{api_endpoint}/repo/#{@repo}"
1304
+ end
1305
+
1306
+ def without_repo
1307
+ api_endpoint
1308
+ end
944
1309
  end
1310
+ # rubocop:enable Metrics/ClassLength
945
1311
  end