Class: BitbucketClient
- Inherits:
-
Object
- Object
- BitbucketClient
- Includes:
- HTTParty
- Defined in:
- lib/pronto/clients/bitbucket_client.rb
Instance Method Summary collapse
- #approve_pull_request(slug, pull_id) ⇒ Object
- #commit_comments(slug, sha) ⇒ Object
- #create_commit_comment(slug, sha, body, path, position) ⇒ Object
- #create_pull_comment(slug, pull_id, body, path, position) ⇒ Object
-
#initialize(username, password) ⇒ BitbucketClient
constructor
A new instance of BitbucketClient.
- #pull_comments(slug, pull_id) ⇒ Object
- #pull_requests(slug) ⇒ Object
- #unapprove_pull_request(slug, pull_id) ⇒ Object
Constructor Details
#initialize(username, password) ⇒ BitbucketClient
Returns a new instance of BitbucketClient.
9 10 11 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 9 def initialize(username, password) self.class.basic_auth(username, password) end |
Instance Method Details
#approve_pull_request(slug, pull_id) ⇒ Object
47 48 49 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 47 def approve_pull_request(slug, pull_id) self.class.post("/#{slug}/pullrequests/#{pull_id}/approve") end |
#commit_comments(slug, sha) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 13 def commit_comments(slug, sha) response = get("/#{slug}/commit/#{sha}/comments?pagelen=100") result = parse_comments(openstruct(response)) while (response['next']) response = get response['next'] result.concat(parse_comments(openstruct(response))) end result end |
#create_commit_comment(slug, sha, body, path, position) ⇒ Object
23 24 25 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 23 def create_commit_comment(slug, sha, body, path, position) post("/#{slug}/commit/#{sha}/comments", body, path, position) end |
#create_pull_comment(slug, pull_id, body, path, position) ⇒ Object
43 44 45 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 43 def create_pull_comment(slug, pull_id, body, path, position) post("/#{slug}/pullrequests/#{pull_id}/comments", body, path, position) end |
#pull_comments(slug, pull_id) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 27 def pull_comments(slug, pull_id) response = get("/#{slug}/pullrequests/#{pull_id}/comments?pagelen=100") parse_comments(openstruct(response)) result = parse_comments(openstruct(response)) while (response['next']) response = get response['next'] result.concat(parse_comments(openstruct(response))) end result end |
#pull_requests(slug) ⇒ Object
38 39 40 41 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 38 def pull_requests(slug) response = get("/#{slug}/pullrequests?state=OPEN") openstruct(response) end |
#unapprove_pull_request(slug, pull_id) ⇒ Object
51 52 53 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 51 def unapprove_pull_request(slug, pull_id) self.class.delete("/#{slug}/pullrequests/#{pull_id}/approve") end |