Method: Geet::Github::PR.create

Defined in:
lib/geet/github/pr.rb

.create(title, description, head, api_interface, base, draft: false) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/geet/github/pr.rb', line 11

def self.create(title, description, head, api_interface, base, draft: false)
  api_path = 'pulls'

  if api_interface.upstream?
    authenticated_user = Geet::Github::User.authenticated(api_interface).username
    head = "#{authenticated_user}:#{head}"
  end

  request_data = { title: title, body: description, head: head, base: base, draft: draft }

  response = api_interface.send_request(api_path, data: request_data)

  number, title, link = response.fetch_values('number', 'title', 'html_url')

  new(number, api_interface, title, link)
end