lib/tops_connect/client.rb in tops_connect-0.5.0 vs lib/tops_connect/client.rb in tops_connect-0.6.0

- old
+ new

@@ -9,10 +9,11 @@ attr_reader :community_id, :community_api_key headers 'Content-Type' => 'application/json' + # TODO: Sandbox uses /sandbox/api/v2, Broad uses /v2/broad/api base_uri 'https://topsconnectapi.azure-api.net/v2' def initialize(community_id, community_api_key) authorization = Base64.strict_encode64 [ TopsConnect.configuration.client_id, @@ -71,15 +72,13 @@ protected def raise_exception(response) case response.code - when 404 - raise TopsConnect::NotFoundError, response - when 400..499 - raise TopsConnect::ClientError, response + when 404 then raise TopsConnect::NotFoundError, response + when 400..499 then raise TopsConnect::ClientError, response when 500..599 - message = response.parsed_response&.dig('Message') || '' + message = TopsConnect::ApiError.error_message(response.parsed_response) # These errors can largely be ignored - it's not our fault raise TopsConnect::TimeoutError, response if message['Timeout expired'] raise TopsConnect::InternalError, response