Class: Geet::Github::PR

Inherits:
AbstractIssue show all
Defined in:
lib/geet/github/pr.rb

Instance Attribute Summary

Attributes inherited from AbstractIssue

#link, #number, #title

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractIssue

#add_labels, #assign_users, #edit, #initialize

Constructor Details

This class inherits a constructor from Geet::Github::AbstractIssue

Class Method Details

.create(title, description, head, api_interface) ⇒ 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)
  api_path = 'pulls'

  if api_interface.upstream?
     = Geet::Github::Account.new(api_interface)
    head = "#{.authenticated_user}:#{head}"
  end

  request_data = { title: title, body: description, head: head, base: 'master' }

  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

.list(api_interface, head: nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/geet/github/pr.rb', line 30

def self.list(api_interface, head: nil)
  api_path = 'pulls'
  request_params = { head: head } if head

  response = api_interface.send_request(api_path, params: request_params, multipage: true)

  response.map do |issue_data|
    number = issue_data.fetch('number')
    title = issue_data.fetch('title')
    link = issue_data.fetch('html_url')

    new(number, api_interface, title, link)
  end
end

Instance Method Details

#mergeObject



47
48
49
50
51
# File 'lib/geet/github/pr.rb', line 47

def merge
  api_path = "pulls/#{number}/merge"

  @api_interface.send_request(api_path, http_method: :put)
end

#request_review(reviewers) ⇒ Object



53
54
55
56
57
58
# File 'lib/geet/github/pr.rb', line 53

def request_review(reviewers)
  api_path = "pulls/#{number}/requested_reviewers"
  request_data = { reviewers: reviewers }

  @api_interface.send_request(api_path, data: request_data)
end