Class: BitbucketClient
- Inherits:
-
Object
- Object
- BitbucketClient
- Includes:
- HTTParty
- Defined in:
- lib/pronto/clients/bitbucket_client.rb
Instance Method Summary collapse
- #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.
- #openstruct(response) ⇒ Object
- #pull_comments(slug, pr_id) ⇒ Object
- #pull_requests(slug) ⇒ Object
Constructor Details
#initialize(username, password) ⇒ BitbucketClient
Returns a new instance of BitbucketClient.
5 6 7 8 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 5 def initialize(username, password) credentials = { username: username, password: password } @headers = { basic_auth: credentials } end |
Instance Method Details
#commit_comments(slug, sha) ⇒ Object
10 11 12 13 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 10 def commit_comments(slug, sha) response = self.class.get("/#{slug}/changesets/#{sha}/comments", @headers) openstruct(response.parsed_response) end |
#create_commit_comment(slug, sha, body, path, position) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 15 def create_commit_comment(slug, sha, body, path, position) = { body: { content: body, line_to: position, filename: path } } .merge!(@headers) self.class.post("/#{slug}/changesets/#{sha}/comments", ) end |
#create_pull_comment(slug, pull_id, body, path, position) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 40 def create_pull_comment(slug, pull_id, body, path, position) = { body: { content: body, line_to: position, filename: path } } .merge!(@headers) self.class.post("/#{slug}/pullrequests/#{pull_id}/comments", ) end |
#openstruct(response) ⇒ Object
52 53 54 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 52 def openstruct(response) response.map { |r| OpenStruct.new(r) } end |
#pull_comments(slug, pr_id) ⇒ Object
27 28 29 30 31 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 27 def pull_comments(slug, pr_id) url = "/#{slug}/pullrequests/#{pr_id}/comments" response = self.class.get(url, @headers) openstruct(response.parsed_response) end |
#pull_requests(slug) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/pronto/clients/bitbucket_client.rb', line 33 def pull_requests(slug) base = 'https://api.bitbucket.org/2.0/repositories' url = "#{base}/#{slug}/pullrequests?state=OPEN" response = self.class.get(url, @headers) openstruct(response.parsed_response['values']) end |