Class: GemXray::Editors::GithubApiClient
- Inherits:
-
Object
- Object
- GemXray::Editors::GithubApiClient
- Defined in:
- lib/gemxray/editors/github_api_client.rb
Constant Summary collapse
- API_BASE =
URI("https://api.github.com").freeze
Instance Method Summary collapse
- #create_pull_request(base:, head:, title:, body:, labels:, reviewers:) ⇒ Object
-
#initialize(token:, repository:) ⇒ GithubApiClient
constructor
A new instance of GithubApiClient.
Constructor Details
#initialize(token:, repository:) ⇒ GithubApiClient
Returns a new instance of GithubApiClient.
12 13 14 15 |
# File 'lib/gemxray/editors/github_api_client.rb', line 12 def initialize(token:, repository:) @token = token @repository = repository end |
Instance Method Details
#create_pull_request(base:, head:, title:, body:, labels:, reviewers:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gemxray/editors/github_api_client.rb', line 17 def create_pull_request(base:, head:, title:, body:, labels:, reviewers:) pr = post_json("/repos/#{repository}/pulls", { title: title, head: head, base: base, body: body }) issue_number = pr.fetch("number") post_json("/repos/#{repository}/issues/#{issue_number}/labels", { labels: labels }) unless labels.empty? post_json("/repos/#{repository}/pulls/#{issue_number}/requested_reviewers", { reviewers: reviewers }) unless reviewers.empty? pr.fetch("html_url") end |