lib/buildbox/api.rb in buildbox-0.2 vs lib/buildbox/api.rb in buildbox-0.2.1

- old
+ new

@@ -4,14 +4,19 @@ require 'hashie/mash' module Buildbox class API def initialize(config = Buildbox.config) - @config = config + @config = config end - def worker(access_token: access_token, hostname: hostname) + def authenticate(api_key) + @api_key = api_key + get("user") + end + + def worker(access_token, hostname) put("workers/#{access_token}", :hostname => hostname) end def scheduled_builds(project) get(project.scheduled_builds_url).map { |build| Buildbox::Build.new(build) } @@ -23,9 +28,11 @@ 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