Class: CleoQualityReview::GitHubClient
- Inherits:
-
Object
- Object
- CleoQualityReview::GitHubClient
- Defined in:
- lib/cleo_quality_review/github_client.rb
Overview
Thin authenticated HTTP client for the GitHub REST API
Defined Under Namespace
Classes: Response
Constant Summary collapse
- API_VERSION =
"2022-11-28"- DEFAULT_API_URL =
"https://api.github.com"
Instance Method Summary collapse
-
#get(path) ⇒ Response
Perform an authenticated GET request.
-
#initialize(token:, api_url: DEFAULT_API_URL) ⇒ GitHubClient
constructor
A new instance of GitHubClient.
-
#post(path, body) ⇒ Response
Perform an authenticated POST request.
Constructor Details
#initialize(token:, api_url: DEFAULT_API_URL) ⇒ GitHubClient
Returns a new instance of GitHubClient.
32 33 34 35 |
# File 'lib/cleo_quality_review/github_client.rb', line 32 def initialize(token:, api_url: DEFAULT_API_URL) @token = token @api_url = api_url.to_s.strip.empty? ? DEFAULT_API_URL : api_url end |
Instance Method Details
#get(path) ⇒ Response
Perform an authenticated GET request
41 42 43 |
# File 'lib/cleo_quality_review/github_client.rb', line 41 def get(path) request_json(:get, uri_for(path)) end |
#post(path, body) ⇒ Response
Perform an authenticated POST request
50 51 52 |
# File 'lib/cleo_quality_review/github_client.rb', line 50 def post(path, body) request_json(:post, uri_for(path), body) end |