tinybucket2 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +86 -0
- data/Gemfile +32 -0
- data/LICENSE +21 -0
- data/README.md +387 -0
- data/Rakefile +47 -0
- data/lib/faraday_middleware/follow_oauth_redirects.rb +71 -0
- data/lib/tinybucket.rb +76 -0
- data/lib/tinybucket/api.rb +26 -0
- data/lib/tinybucket/api/base_api.rb +44 -0
- data/lib/tinybucket/api/branch_restrictions_api.rb +51 -0
- data/lib/tinybucket/api/branches_api.rb +48 -0
- data/lib/tinybucket/api/build_status_api.rb +69 -0
- data/lib/tinybucket/api/comments_api.rb +81 -0
- data/lib/tinybucket/api/commits_api.rb +97 -0
- data/lib/tinybucket/api/diff_api.rb +40 -0
- data/lib/tinybucket/api/helper.rb +27 -0
- data/lib/tinybucket/api/helper/api_helper.rb +39 -0
- data/lib/tinybucket/api/helper/branch_restrictions_helper.rb +29 -0
- data/lib/tinybucket/api/helper/branches_helper.rb +29 -0
- data/lib/tinybucket/api/helper/build_status_helper.rb +46 -0
- data/lib/tinybucket/api/helper/comments_helper.rb +51 -0
- data/lib/tinybucket/api/helper/commits_helper.rb +42 -0
- data/lib/tinybucket/api/helper/diff_helper.rb +31 -0
- data/lib/tinybucket/api/helper/issues_helper.rb +29 -0
- data/lib/tinybucket/api/helper/projects_helper.rb +28 -0
- data/lib/tinybucket/api/helper/pull_requests_helper.rb +58 -0
- data/lib/tinybucket/api/helper/repo_helper.rb +31 -0
- data/lib/tinybucket/api/helper/repos_helper.rb +23 -0
- data/lib/tinybucket/api/helper/team_helper.rb +45 -0
- data/lib/tinybucket/api/helper/user_helper.rb +33 -0
- data/lib/tinybucket/api/issues_api.rb +48 -0
- data/lib/tinybucket/api/projects_api.rb +26 -0
- data/lib/tinybucket/api/pull_requests_api.rb +117 -0
- data/lib/tinybucket/api/repo_api.rb +56 -0
- data/lib/tinybucket/api/repos_api.rb +28 -0
- data/lib/tinybucket/api/team_api.rb +91 -0
- data/lib/tinybucket/api/user_api.rb +66 -0
- data/lib/tinybucket/api_factory.rb +21 -0
- data/lib/tinybucket/client.rb +107 -0
- data/lib/tinybucket/config.rb +10 -0
- data/lib/tinybucket/connection.rb +84 -0
- data/lib/tinybucket/constants.rb +7 -0
- data/lib/tinybucket/enumerator.rb +47 -0
- data/lib/tinybucket/error.rb +12 -0
- data/lib/tinybucket/error/base_error.rb +14 -0
- data/lib/tinybucket/error/conflict.rb +8 -0
- data/lib/tinybucket/error/not_found.rb +8 -0
- data/lib/tinybucket/error/service_error.rb +26 -0
- data/lib/tinybucket/iterator.rb +79 -0
- data/lib/tinybucket/model.rb +25 -0
- data/lib/tinybucket/model/base.rb +45 -0
- data/lib/tinybucket/model/branch.rb +48 -0
- data/lib/tinybucket/model/branch_restriction.rb +46 -0
- data/lib/tinybucket/model/build_status.rb +57 -0
- data/lib/tinybucket/model/comment.rb +67 -0
- data/lib/tinybucket/model/commit.rb +114 -0
- data/lib/tinybucket/model/concerns.rb +19 -0
- data/lib/tinybucket/model/concerns/acceptable_attributes.rb +34 -0
- data/lib/tinybucket/model/concerns/api_callable.rb +21 -0
- data/lib/tinybucket/model/concerns/enumerable.rb +20 -0
- data/lib/tinybucket/model/concerns/reloadable.rb +41 -0
- data/lib/tinybucket/model/concerns/repository_keys.rb +45 -0
- data/lib/tinybucket/model/error_response.rb +24 -0
- data/lib/tinybucket/model/issue.rb +48 -0
- data/lib/tinybucket/model/page.rb +45 -0
- data/lib/tinybucket/model/profile.rb +70 -0
- data/lib/tinybucket/model/project.rb +44 -0
- data/lib/tinybucket/model/pull_request.rb +160 -0
- data/lib/tinybucket/model/repository.rb +219 -0
- data/lib/tinybucket/model/team.rb +96 -0
- data/lib/tinybucket/null_logger.rb +37 -0
- data/lib/tinybucket/parser.rb +15 -0
- data/lib/tinybucket/parser/collection_parser.rb +17 -0
- data/lib/tinybucket/parser/object_parser.rb +17 -0
- data/lib/tinybucket/request.rb +59 -0
- data/lib/tinybucket/resource.rb +75 -0
- data/lib/tinybucket/resource/base.rb +35 -0
- data/lib/tinybucket/resource/branch_restrictions.rb +47 -0
- data/lib/tinybucket/resource/branches.rb +35 -0
- data/lib/tinybucket/resource/commit/base.rb +14 -0
- data/lib/tinybucket/resource/commit/build_statuses.rb +50 -0
- data/lib/tinybucket/resource/commit/comments.rb +34 -0
- data/lib/tinybucket/resource/commits.rb +46 -0
- data/lib/tinybucket/resource/forks.rb +24 -0
- data/lib/tinybucket/resource/issues.rb +35 -0
- data/lib/tinybucket/resource/projects.rb +49 -0
- data/lib/tinybucket/resource/pull_request/base.rb +20 -0
- data/lib/tinybucket/resource/pull_request/comments.rb +32 -0
- data/lib/tinybucket/resource/pull_request/commits.rb +19 -0
- data/lib/tinybucket/resource/pull_requests.rb +50 -0
- data/lib/tinybucket/resource/repos.rb +40 -0
- data/lib/tinybucket/resource/team/base.rb +24 -0
- data/lib/tinybucket/resource/team/followers.rb +15 -0
- data/lib/tinybucket/resource/team/following.rb +15 -0
- data/lib/tinybucket/resource/team/members.rb +15 -0
- data/lib/tinybucket/resource/team/repos.rb +15 -0
- data/lib/tinybucket/resource/teams.rb +22 -0
- data/lib/tinybucket/resource/user/base.rb +26 -0
- data/lib/tinybucket/resource/user/followers.rb +15 -0
- data/lib/tinybucket/resource/user/following.rb +15 -0
- data/lib/tinybucket/resource/user/repos.rb +15 -0
- data/lib/tinybucket/resource/watchers.rb +24 -0
- data/lib/tinybucket/response.rb +9 -0
- data/lib/tinybucket/response/handler.rb +23 -0
- data/lib/tinybucket/version.rb +5 -0
- data/tinybucket.gemspec +30 -0
- metadata +248 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Model
|
5
|
+
class Project < Base
|
6
|
+
acceptable_attributes \
|
7
|
+
:type, :description, :links, :uuid, :created_on,
|
8
|
+
:key, :updated_on, :is_private, :name, :owner
|
9
|
+
|
10
|
+
# Update this project
|
11
|
+
#
|
12
|
+
# @param _params [Hash]
|
13
|
+
# @raise [NotImplementedError] to be implemented
|
14
|
+
def update(_params)
|
15
|
+
raise NotImplementedError
|
16
|
+
end
|
17
|
+
|
18
|
+
# Destroy this project
|
19
|
+
#
|
20
|
+
# @raise [NotImplementedError] to be implemented.
|
21
|
+
def destroy
|
22
|
+
raise NotImplementedError
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get repositories
|
26
|
+
#
|
27
|
+
# @return [Tinybucket::Resource::Repos]
|
28
|
+
def repos
|
29
|
+
repos_resource
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def owner_name
|
35
|
+
raise 'This project is not loaded yet.' if (owner.nil? || owner['username'].nil?)
|
36
|
+
owner['username']
|
37
|
+
end
|
38
|
+
|
39
|
+
def repos_resource
|
40
|
+
Tinybucket::Resource::Repos.new(owner_name, q: %(project.key="#{key}"))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Model
|
5
|
+
# PullRequest
|
6
|
+
#
|
7
|
+
# @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests
|
8
|
+
# pullrequest Resource
|
9
|
+
#
|
10
|
+
# @!attribute [rw] state
|
11
|
+
# @return [String]
|
12
|
+
# @!attribute [rw] description
|
13
|
+
# @return [String]
|
14
|
+
# @!attribute [rw] links
|
15
|
+
# @return [Hash]
|
16
|
+
# @!attribute [rw] title
|
17
|
+
# @return [String]
|
18
|
+
# @!attribute [rw] task_count
|
19
|
+
# @return [Fixnum]
|
20
|
+
# @!attribute [rw] comment_count
|
21
|
+
# @return [Fixnum]
|
22
|
+
# @!attribute [rw] close_source_branch
|
23
|
+
# @return [true, false]
|
24
|
+
# @!attribute [rw] destination
|
25
|
+
# @return [Hash]
|
26
|
+
# @!attribute [rw] reason
|
27
|
+
# @return [String]
|
28
|
+
# @!attribute [rw] id
|
29
|
+
# @return [Fixnum]
|
30
|
+
# @!attribute [rw] source
|
31
|
+
# @return [Hash]
|
32
|
+
# @!attribute [rw] created_on
|
33
|
+
# @return [String]
|
34
|
+
# @!attribute [rw] author
|
35
|
+
# @return [Hash]
|
36
|
+
# @!attribute [rw] updated_on
|
37
|
+
# @return [String]
|
38
|
+
# @!attribute [rw] merge_commit
|
39
|
+
# @return [Hash]
|
40
|
+
# @!attribute [rw] closed_by
|
41
|
+
# @return [Hash]
|
42
|
+
# @!attribute [rw] reviewers
|
43
|
+
# @return [Array]
|
44
|
+
# @!attribute [rw] participants
|
45
|
+
# @return [Array]
|
46
|
+
# @!attribute [rw] uuid
|
47
|
+
# @return [NillClass]
|
48
|
+
# @!attribute [rw] type
|
49
|
+
# @return [String]
|
50
|
+
class PullRequest < Base
|
51
|
+
include Tinybucket::Model::Concerns::RepositoryKeys
|
52
|
+
include Tinybucket::Constants
|
53
|
+
|
54
|
+
acceptable_attributes \
|
55
|
+
:state, :description, :links, :title, :task_count, :comment_count,
|
56
|
+
:close_source_branch, :destination, :reason, :id, :source,
|
57
|
+
:created_on, :author, :updated_on, :merge_commit, :closed_by,
|
58
|
+
:reviewers, :participants, :uuid, :type
|
59
|
+
|
60
|
+
# Update this pull request.
|
61
|
+
#
|
62
|
+
# @todo to be implemented.
|
63
|
+
# @raise [NotImplementedError] to be implemented.
|
64
|
+
def update(_params)
|
65
|
+
raise NotImplementedError
|
66
|
+
end
|
67
|
+
|
68
|
+
# Decline or reject this pull request.
|
69
|
+
#
|
70
|
+
# @param options [Hash]
|
71
|
+
# @return [true,false]
|
72
|
+
def decline(options = {})
|
73
|
+
pull_request_api.decline(id, options)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Give approval on this pull request.
|
77
|
+
#
|
78
|
+
# @param options [Hash]
|
79
|
+
# @return [true, false]
|
80
|
+
def approve(options = {})
|
81
|
+
pull_request_api.approve(id, options)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Revoke approval on this pull request.
|
85
|
+
#
|
86
|
+
# @param options [Hash]
|
87
|
+
# @return [true, false]
|
88
|
+
def unapprove(options = {})
|
89
|
+
pull_request_api.unapprove(id, options)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Get commits associated with this pull request.
|
93
|
+
#
|
94
|
+
# @param options [Hash]
|
95
|
+
# @return [Tinybucket::Resource::PullRequest::Commits]
|
96
|
+
def commits(options = {})
|
97
|
+
commits_resource(options)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Get comments on this pull request.
|
101
|
+
#
|
102
|
+
# @param options [Hash]
|
103
|
+
# @return [Tinybucket::Resource::PullRequest::Comments]
|
104
|
+
def comments(options = {})
|
105
|
+
comments_resource(options)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Get the specific comment on this pull request.
|
109
|
+
#
|
110
|
+
# @param comment_id [String]
|
111
|
+
# @param options [Hash]
|
112
|
+
# @return [Tinybucket::Model::Comment]
|
113
|
+
def comment(comment_id, options = {})
|
114
|
+
comments_resource.find(comment_id, options)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Get the diff for this pull request.
|
118
|
+
#
|
119
|
+
# @param options [Hash]
|
120
|
+
# @return [String] diff as raw text.
|
121
|
+
def diff(options = {})
|
122
|
+
pull_request_api.diff(id, options)
|
123
|
+
end
|
124
|
+
|
125
|
+
# Accept and merge this pull request.
|
126
|
+
#
|
127
|
+
# @param options [Hash]
|
128
|
+
# @return [true, false]
|
129
|
+
def merge(options = {})
|
130
|
+
pull_request_api.merge(id, options)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Get activities on this pull requests.
|
134
|
+
#
|
135
|
+
def activities(_options = {})
|
136
|
+
raise NotImplementedError
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
def commits_resource(options = {})
|
142
|
+
Tinybucket::Resource::PullRequest::Commits.new(self, options)
|
143
|
+
end
|
144
|
+
|
145
|
+
def comments_resource(options = {})
|
146
|
+
Tinybucket::Resource::PullRequest::Comments.new(self, options)
|
147
|
+
end
|
148
|
+
|
149
|
+
def pull_request_api
|
150
|
+
raise ArgumentError, MISSING_REPOSITORY_KEY unless repo_keys?
|
151
|
+
|
152
|
+
create_api('PullRequests', repo_keys)
|
153
|
+
end
|
154
|
+
|
155
|
+
def load_model
|
156
|
+
pull_request_api.find(id)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1,219 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Model
|
5
|
+
# Repository
|
6
|
+
#
|
7
|
+
# @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories
|
8
|
+
# Repository Endpoint
|
9
|
+
#
|
10
|
+
# @!attribute [rw] scm
|
11
|
+
# @return [String]
|
12
|
+
# @!attribute [rw] has_wiki
|
13
|
+
# @return [true, false]
|
14
|
+
# @!attribute [rw] description
|
15
|
+
# @return [String]
|
16
|
+
# @!attribute [rw] links
|
17
|
+
# @return [Hash]
|
18
|
+
# @!attribute [rw] updated_on
|
19
|
+
# @return [String]
|
20
|
+
# @!attribute [rw] fork_policy
|
21
|
+
# @return [String]
|
22
|
+
# @!attribute [rw] created_on
|
23
|
+
# @return [String]
|
24
|
+
# @!attribute [rw] owner
|
25
|
+
# @return [Hash]
|
26
|
+
# @!attribute [rw] size
|
27
|
+
# @return [Fixnum]
|
28
|
+
# @!attribute [rw] parent
|
29
|
+
# @return [Hash, NillClass]
|
30
|
+
# @!attribute [rw] uuid
|
31
|
+
# @return [String]
|
32
|
+
# @!attribute [rw] has_issues
|
33
|
+
# @return [true, false]
|
34
|
+
# @!attribute [rw] is_private
|
35
|
+
# @return [true, false]
|
36
|
+
# @!attribute [rw] full_name
|
37
|
+
# @return [String]
|
38
|
+
# @!attribute [rw] name
|
39
|
+
# @return [String]
|
40
|
+
# @!attribute [rw] language
|
41
|
+
# @return [String]
|
42
|
+
# @!attribute [rw] website
|
43
|
+
# @return [String]
|
44
|
+
# @!attribute [rw] type
|
45
|
+
# @return [String]
|
46
|
+
# @!attribute [rw] project
|
47
|
+
# @return [Hash]
|
48
|
+
class Repository < Base
|
49
|
+
include Tinybucket::Model::Concerns::RepositoryKeys
|
50
|
+
|
51
|
+
acceptable_attributes \
|
52
|
+
:scm, :has_wiki, :description, :links, :updated_on,
|
53
|
+
:fork_policy, :created_on, :owner, :size, :parent, :uuid,
|
54
|
+
:has_issues, :is_private, :full_name, :name, :language,
|
55
|
+
:website, :type, :project
|
56
|
+
|
57
|
+
def initialize(json)
|
58
|
+
super(json)
|
59
|
+
|
60
|
+
return unless full_name && full_name.split('/').size == 2
|
61
|
+
@repo_owner, @repo_slug = full_name.split('/')
|
62
|
+
end
|
63
|
+
|
64
|
+
# Remove this repository
|
65
|
+
#
|
66
|
+
# @todo to be implemented.
|
67
|
+
# @raise [NotImplementedError] to be implemented.
|
68
|
+
def destroy
|
69
|
+
raise NotImplementedError
|
70
|
+
end
|
71
|
+
|
72
|
+
# Get pull requests on thie repository.
|
73
|
+
#
|
74
|
+
# @param options [Hash]
|
75
|
+
# @return [Tinybucket::Enumerator] an enumerator to enumerate
|
76
|
+
# pull requests as {Tinybucket::Model::PullRequest} instance.
|
77
|
+
def pull_requests(options = {})
|
78
|
+
pull_requests_resource(options)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Get the specific pull request on this repository.
|
82
|
+
#
|
83
|
+
# @param pullrequest_id [String]
|
84
|
+
# @param options [Hash]
|
85
|
+
# @return [Tinybucket::Model::PullRequest]
|
86
|
+
def pull_request(pullrequest_id, options = {})
|
87
|
+
pull_requests_resource.find(pullrequest_id, options)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Get watchers on this repository.
|
91
|
+
#
|
92
|
+
# @param options [Hash]
|
93
|
+
# @return [Tinybucket::Resource::Watchers]
|
94
|
+
def watchers(options = {})
|
95
|
+
watchers_resource(options)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Get repository forks.
|
99
|
+
#
|
100
|
+
# @param options [Hash]
|
101
|
+
# @return [Tinybucket::Resource::Forks]
|
102
|
+
def forks(options = {})
|
103
|
+
forks_resource(options)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Get commits on this repository.
|
107
|
+
#
|
108
|
+
# @param options [Hash]
|
109
|
+
# @return [Tinybucket::Resource::Commits]
|
110
|
+
def commits(options = {})
|
111
|
+
commits_resource(options)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Get the specific commit on this repository.
|
115
|
+
#
|
116
|
+
# @param revision [String]
|
117
|
+
# @param options [Hash]
|
118
|
+
# @return [Tinybucket::Model::Commit]
|
119
|
+
def commit(revision, options = {})
|
120
|
+
commits_resource.find(revision, options)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Get branches on this repository
|
124
|
+
#
|
125
|
+
# @param options [Hash]
|
126
|
+
# @return [Tinybucket::Resource::Branches]
|
127
|
+
def branches(options = {})
|
128
|
+
branches_resource(options)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Get the specific branch on this repository.
|
132
|
+
#
|
133
|
+
# @param branch [String]
|
134
|
+
# @param options [Hash]
|
135
|
+
# @return [Tinybucket::Model::Branches]
|
136
|
+
def branch(branch, options = {})
|
137
|
+
branches_resource.find(branch, options)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Get the branch restriction information associated with this repository.
|
141
|
+
#
|
142
|
+
# @param options [Hash]
|
143
|
+
# @return [Tinybucket::Resource::BranchRestrictions]
|
144
|
+
def branch_restrictions(options = {})
|
145
|
+
branch_restrictions_resource(options)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Get the specific branch restriction information on this repository.
|
149
|
+
#
|
150
|
+
# @param restriction_id [String]
|
151
|
+
# @param options [Hash]
|
152
|
+
# @return [Tinybucket::Model::BranchRestriction]
|
153
|
+
def branch_restriction(restriction_id, options = {})
|
154
|
+
branch_restrictions_resource.find(restriction_id, options)
|
155
|
+
end
|
156
|
+
|
157
|
+
# Get the diff for this repository.
|
158
|
+
#
|
159
|
+
# @param spec [String] A specification such as a branch name,
|
160
|
+
# revision, or commit SHA.
|
161
|
+
# @param options [Hash]
|
162
|
+
# @return [String] diff as raw text.
|
163
|
+
def diff(spec, options = {})
|
164
|
+
diff_api.find(spec, options)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Get the patch for the specification.
|
168
|
+
#
|
169
|
+
# @param spec [String] A specification such as a branch name,
|
170
|
+
# revision, or commit SHA.
|
171
|
+
# @return [String] patch as raw text.
|
172
|
+
def patch(spec, options = {})
|
173
|
+
diff_api.find_patch(spec, options)
|
174
|
+
end
|
175
|
+
|
176
|
+
private
|
177
|
+
|
178
|
+
def branch_restrictions_resource(options = {})
|
179
|
+
Tinybucket::Resource::BranchRestrictions.new(self, options)
|
180
|
+
end
|
181
|
+
|
182
|
+
def branches_resource(options = {})
|
183
|
+
Tinybucket::Resource::Branches.new(self, options)
|
184
|
+
end
|
185
|
+
|
186
|
+
def commits_resource(options = {})
|
187
|
+
Tinybucket::Resource::Commits.new(self, options)
|
188
|
+
end
|
189
|
+
|
190
|
+
def hooks_resource(options = {})
|
191
|
+
Tinybucket::Resource::Hooks.new(self, options)
|
192
|
+
end
|
193
|
+
|
194
|
+
def pull_requests_resource(options = {})
|
195
|
+
Tinybucket::Resource::PullRequests.new(self, options)
|
196
|
+
end
|
197
|
+
|
198
|
+
def watchers_resource(options = {})
|
199
|
+
Tinybucket::Resource::Watchers.new(self, options)
|
200
|
+
end
|
201
|
+
|
202
|
+
def forks_resource(options = {})
|
203
|
+
Tinybucket::Resource::Forks.new(self, options)
|
204
|
+
end
|
205
|
+
|
206
|
+
def repo_api
|
207
|
+
create_api('Repo', repo_keys)
|
208
|
+
end
|
209
|
+
|
210
|
+
def diff_api
|
211
|
+
create_api('Diff', repo_keys)
|
212
|
+
end
|
213
|
+
|
214
|
+
def load_model
|
215
|
+
repo_api.find()
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Model
|
5
|
+
# Team
|
6
|
+
#
|
7
|
+
# @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/teams
|
8
|
+
# teams Endpoint
|
9
|
+
#
|
10
|
+
# @!attribute [rw] username
|
11
|
+
# @return [String]
|
12
|
+
# @!attribute [rw] kind
|
13
|
+
# @return [String, NillClass]
|
14
|
+
# @!attribute [rw] website
|
15
|
+
# @return [String, NillClass]
|
16
|
+
# @!attribute [rw] display_name
|
17
|
+
# @return [String]
|
18
|
+
# @!attribute [rw] uuid
|
19
|
+
# @return [String]
|
20
|
+
# @!attribute [rw] links
|
21
|
+
# @return [Hash]
|
22
|
+
# @!attribute [rw] created_on
|
23
|
+
# @return [String]
|
24
|
+
# @!attribute [rw] location
|
25
|
+
# @return [String, NillClass]
|
26
|
+
# @!attribute [rw] type
|
27
|
+
# @return [String]
|
28
|
+
class Team < Base
|
29
|
+
acceptable_attributes \
|
30
|
+
:username, :kind, :website, :display_name, :uuid,
|
31
|
+
:links, :created_on, :location, :type
|
32
|
+
|
33
|
+
# Get this team's members.
|
34
|
+
#
|
35
|
+
# @param options [Hash]
|
36
|
+
# @return [Tinybucket::Resource::Team::Members]
|
37
|
+
def members(options = {})
|
38
|
+
Tinybucket::Resource::Team::Members.new(username, options)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Get this team's followers.
|
42
|
+
#
|
43
|
+
# @param options [Hash]
|
44
|
+
# @return [Tinybucket::Resource::Team::Followers]
|
45
|
+
def followers(options = {})
|
46
|
+
Tinybucket::Resource::Team::Followers.new(username, options)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Get users which this team is following.
|
50
|
+
#
|
51
|
+
# @param options [Hash]
|
52
|
+
# @return [Tinybucket::Resource::Team::Following]
|
53
|
+
def following(options = {})
|
54
|
+
Tinybucket::Resource::Team::Following.new(username, options)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Get projects
|
58
|
+
#
|
59
|
+
# @param options [Hash]
|
60
|
+
# @return [Tinybucket::Resource::Team::Project]
|
61
|
+
def projects(options = {})
|
62
|
+
projects_resource(options)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Get the project
|
66
|
+
#
|
67
|
+
# @param project_key [String]
|
68
|
+
# @return [Tinybucket::Model::Project]
|
69
|
+
def project(project_key, options = {})
|
70
|
+
projects_resource().find(project_key, options)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Get this team's repositories.
|
74
|
+
#
|
75
|
+
# @param options [Hash]
|
76
|
+
# @return [Tinybucket::Resource::Team::Repos]
|
77
|
+
def repos(options = {})
|
78
|
+
Tinybucket::Resource::Team::Repos.new(username, options)
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def projects_resource(options = {})
|
84
|
+
Tinybucket::Resource::Projects.new(username, options)
|
85
|
+
end
|
86
|
+
|
87
|
+
def team_api
|
88
|
+
create_api('Team')
|
89
|
+
end
|
90
|
+
|
91
|
+
def load_model
|
92
|
+
team_api.find(username)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|