Class: Danger::CircleAPI
- Inherits:
-
Object
- Object
- Danger::CircleAPI
- Defined in:
- lib/danger/ci_source/circle_api.rb
Instance Attribute Summary collapse
-
#circle_token ⇒ Object
Returns the value of attribute circle_token.
Instance Method Summary collapse
- #client ⇒ Object
- #fetch_build(repo_slug, build_number) ⇒ Object
-
#initialize(circle_token = nil) ⇒ CircleAPI
constructor
A new instance of CircleAPI.
Constructor Details
#initialize(circle_token = nil) ⇒ CircleAPI
Returns a new instance of CircleAPI.
7 8 9 |
# File 'lib/danger/ci_source/circle_api.rb', line 7 def initialize(circle_token = nil) self.circle_token = circle_token end |
Instance Attribute Details
#circle_token ⇒ Object
Returns the value of attribute circle_token.
5 6 7 |
# File 'lib/danger/ci_source/circle_api.rb', line 5 def circle_token @circle_token end |
Instance Method Details
#client ⇒ Object
11 12 13 |
# File 'lib/danger/ci_source/circle_api.rb', line 11 def client @client ||= Faraday.new(url: "https://circleci.com/api/v1") end |
#fetch_build(repo_slug, build_number) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/danger/ci_source/circle_api.rb', line 15 def fetch_build(repo_slug, build_number) url = "project/#{repo_slug}/#{build_number}" params = { "circle-token" => circle_token } response = client.get url, params, accept: "application/json" json = JSON.parse(response.body, symbolize_names: true) json end |