lib/rdstation/authentication.rb in rdstation-ruby-client-1.1.0 vs lib/rdstation/authentication.rb in rdstation-ruby-client-1.2.0
- old
+ new
@@ -33,23 +33,19 @@
# Raises RDStation::Error::ExpiredCodeGrant if the code has expired
# Raises RDStation::Error::InvalidCredentials if the client_id, client_secret
# or code is invalid.
def authenticate(code)
response = post_to_auth_endpoint(code: code)
- parsed_body = JSON.parse(response.body)
- return parsed_body unless parsed_body['errors']
- RDStation::ErrorHandler.new(response).raise_errors
+ ApiResponse.build(response)
end
#
# param refresh_token
# parameter sent by RDStation after authenticate
#
def update_access_token(refresh_token)
response = post_to_auth_endpoint(refresh_token: refresh_token)
- parsed_body = JSON.parse(response.body)
- return parsed_body unless parsed_body['errors']
- RDStation::ErrorHandler.new(response).raise_errors
+ ApiResponse.build(response)
end
private
def post_to_auth_endpoint(params)