Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitbucket deprecated its API v1.0: update all endpoints to API v2.0 #352

Merged
merged 11 commits into from
Sep 19, 2019
26 changes: 21 additions & 5 deletions lib/pronto/clients/bitbucket_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(username, password)

def commit_comments(slug, sha)
response = get("/#{slug}/changesets/#{sha}/comments")
openstruct(response['values'])
parse_comments(openstruct(response['values']))
end

def create_commit_comment(slug, sha, body, path, position)
Expand All @@ -17,7 +17,7 @@ def create_commit_comment(slug, sha, body, path, position)

def pull_comments(slug, pull_id)
response = get("/#{slug}/pullrequests/#{pull_id}/comments")
openstruct(response['values'])
parse_comments(openstruct(response['values']))
end

def pull_requests(slug)
Expand All @@ -43,12 +43,28 @@ def openstruct(response)
response.map { |r| OpenStruct.new(r) }
end

def parse_comments(values)
values.each do |value|
value.content = value.content['raw']
value.line_to = value.inline['to']
value.filename = value.inline['path']
end
values
end

def post(url, body, path, position)
options = {
body: {
content: body,
line_to: position,
filename: path
content: {
raw: body
},
inline: {
to: position,
path: path
}
}.to_json,
headers: {
'Content-Type': 'application/json'
}
}
self.class.post(url, options)
Expand Down