Sha256: 82eafd3ecbebed038997002cc85e42416211913aee0a0b1a83645e90443df4b0

Contents?: true

Size: 566 Bytes

Versions: 11

Compression:

Stored size: 566 Bytes

Contents

require "faraday"

module Danger
  class CircleAPI
    attr_accessor :circle_token

    def initialize(circle_token = nil)
      self.circle_token = circle_token
    end

    def client
      @client ||= Faraday.new(url: "https://circleci.com/api/v1")
    end

    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
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
danger-2.1.4 lib/danger/ci_source/circle_api.rb
danger-2.1.3 lib/danger/ci_source/circle_api.rb
danger-2.1.2 lib/danger/ci_source/circle_api.rb
danger-2.1.1 lib/danger/ci_source/circle_api.rb
danger-2.1.0 lib/danger/ci_source/circle_api.rb
danger-2.0.1 lib/danger/ci_source/circle_api.rb
danger-2.0.0 lib/danger/ci_source/circle_api.rb
danger-0.10.1 lib/danger/ci_source/circle_api.rb
danger-0.10.0 lib/danger/ci_source/circle_api.rb
danger-0.9.1 lib/danger/ci_source/circle_api.rb
danger-0.9.0 lib/danger/ci_source/circle_api.rb