Sha256: c0af749c2b7a3ecbfa472a0beb5e12b01dcfad7774dcf7586b93adbf08f468d3
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
require 'rubygems' require 'faraday' require 'faraday_middleware' require 'hashie/mash' module Buildbox class API def initialize(config = Buildbox.config) @config = config end def authenticate(api_key) @api_key = api_key get("user") end def agent(access_token, hostname) put("agents/#{access_token}", :hostname => hostname) end def scheduled_builds(project) get(project.scheduled_builds_url).map { |build| Buildbox::Build.new(build) } end def update_build(build) put(build.url, :state => build.state, :parts => build.parts) end private def connection @connection ||= Faraday.new(:url => @config.api_endpoint) do |faraday| faraday.basic_auth @api_key || @config.api_key, '' faraday.request :json faraday.response :logger, Buildbox.logger faraday.response :mashify # json needs to come after mashify as it needs to run before the mashify # middleware. faraday.response :json faraday.response :raise_error faraday.adapter Faraday.default_adapter end end def post(path, body = {}) connection.post(path) do |request| request.body = body end.body end def put(path, body = {}) connection.put(path) do |request| request.body = body end.body end def get(path) connection.get(path).body end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
buildbox-0.3.1 | lib/buildbox/api.rb |