lib/unsplash/connection.rb in unsplash-2.1.0 vs lib/unsplash/connection.rb in unsplash-3.0.0
- old
+ new
@@ -1,5 +1,7 @@
+require 'faraday/multipart'
+
module Unsplash #:nodoc:
# HTTP connection to and communication with the Unsplash API.
class Connection
include HTTParty
@@ -21,11 +23,10 @@
@application_access_key = Unsplash.configuration.application_access_key
@application_secret = Unsplash.configuration.application_secret
@api_version = version
@api_base_uri = api_base_uri
- oauth_base_uri = oauth_base_uri
@oauth = ::OAuth2::Client.new(@application_access_key, @application_secret, site: oauth_base_uri) do |http|
http.request :multipart
http.request :url_encoded
http.adapter :net_http
end
@@ -127,10 +128,10 @@
@oauth_token.public_send(verb, @api_base_uri + path, param_key => params, headers: headers)
else
self.class.public_send verb, path, query: params, headers: public_auth_header
end
rescue OAuth2::Error => e
- OpenStruct.new(headers: {}, status: 403, body: e.error_message(e.response.body))
+ OpenStruct.new(headers: {}, status: 403, body: e.message)
end
if response.headers["Warning"]
Unsplash.configuration.logger.warn response.headers["Warning"]
end