lib/washbullet/client.rb in washbullet-0.3.1 vs lib/washbullet/client.rb in washbullet-0.4.0

- old
+ new

@@ -1,10 +1,10 @@ require 'faraday' require 'mime/types' require 'washbullet/api' -require 'washbullet/basic_authentication' +require 'washbullet/authorization' require 'washbullet/http_exception' require 'washbullet/parse_json' require 'washbullet/request' require 'washbullet/version' @@ -19,35 +19,35 @@ def initialize(api_key) @api_key = api_key end - def middleware - @middleware ||= Faraday::RackBuilder.new do |f| - f.request :multipart - f.request :url_encoded + private - f.use Washbullet::BasicAuthentication, @api_key, '' - f.use Washbullet::ParseJSON - f.use Washbullet::HttpException - - f.adapter :net_http - end + def connection + @connection ||= Faraday.new(ENDPOINT, connection_options) end def connection_options @connection_options ||= { - :builder => middleware, - :headers => { - :accept => 'application/json', - :user_agent => "Washbullet Ruby Gem #{Washbullet::VERSION}", + builder: middleware, + headers: { + accept: 'application/json', + user_agent: "Washbullet Ruby Gem #{Washbullet::VERSION}" } } end - private + def middleware + @middleware ||= Faraday::RackBuilder.new do |f| + f.request :multipart + f.request :url_encoded - def connection - @connection ||= Faraday.new(ENDPOINT, connection_options) + f.use Washbullet::Authorization, 'Bearer', api_key + f.use Washbullet::ParseJSON + f.use Washbullet::HttpException + + f.adapter :net_http + end end end end