Class: Dude::CodeManagement::Github::CreatePullRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/dude/code_management/github/create_pull_request.rb

Instance Method Summary collapse

Instance Method Details

#call(client, issue:, owner:, repo:, params:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dude/code_management/github/create_pull_request.rb', line 9

def call(client, issue:, owner:, repo:, params:)
  @issue = issue
  @owner = owner
  @repo = repo
  @params = params

  return unless issue

  response = client.post("https://api.github.com/repos/#{owner}/#{repo}/pulls", body.to_json)
  res = JSON.parse(response.body)

  return github_error if res['errors'] && !res['errors'].empty?

  url = res['html_url']
  puts "Pull request has been created: #{url}"
end