Class: Decidim::GithubManager::Poster
- Inherits:
-
Object
- Object
- Decidim::GithubManager::Poster
- Defined in:
- lib/decidim/github_manager/poster.rb
Overview
Allows to make POST requests to GitHub Rest API about Pull Requests
Instance Method Summary collapse
-
#call ⇒ Faraday::Response
Create the pull request or give error messages.
-
#initialize(token:, params:) ⇒ Poster
constructor
A new instance of Poster.
Constructor Details
#initialize(token:, params:) ⇒ Poster
Returns a new instance of Poster.
14 15 16 17 |
# File 'lib/decidim/github_manager/poster.rb', line 14 def initialize(token:, params:) @token = token @params = params end |
Instance Method Details
#call ⇒ Faraday::Response
Create the pull request or give error messages
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/decidim/github_manager/poster.rb', line 22 def call response = create_pull_request! pull_request_id = JSON.parse(response.body)["number"] unless pull_request_id puts "Pull request could not be created!" puts "Please make sure you have enabled the 'public_repo' scope for the access token" return end puts "Pull request created at https://github.com/decidim/decidim/pull/#{pull_request_id}" add_labels_to_issue!(pull_request_id) end |