Skip to content

Commit

Permalink
Raise error for unauthenticated request
Browse files Browse the repository at this point in the history
  • Loading branch information
harrylewis committed Mar 8, 2024
1 parent 628f789 commit 03b1f5c
Show file tree
Hide file tree
Showing 2 changed files with 294 additions and 212 deletions.
26 changes: 20 additions & 6 deletions lib/bambora/v1/reports/merchants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,31 @@ class Merchants
def self.get(merchant_id, options = {})
credentials = options[:credentials]

Bambora::Rest::JSONClient
.new(base_url: 'https://api.na.bambora.com', merchant_id: credentials.merchant_id)
.get(path: "/v1/reports/merchants/#{merchant_id}", api_key: credentials.reporting_passcode)
response =
Bambora::Rest::JSONClient
.new(base_url: 'https://api.na.bambora.com', merchant_id: credentials.merchant_id)
.get(path: "/v1/reports/merchants/#{merchant_id}", api_key: credentials.reporting_passcode)

if response == { code: 21, category: 4, message: 'Authentication failed' }
raise InvalidAuthenticationError, response
end

response
end

def self.get_all(options = {})
credentials = options[:credentials]

Bambora::Rest::JSONClient
.new(base_url: 'https://api.na.bambora.com', merchant_id: credentials.merchant_id)
.get(path: '/v1/reports/merchants', api_key: credentials.reporting_passcode)
response =
Bambora::Rest::JSONClient
.new(base_url: 'https://api.na.bambora.com', merchant_id: credentials.merchant_id)
.get(path: '/v1/reports/merchants', api_key: credentials.reporting_passcode)

if response == { code: 21, category: 4, message: 'Authentication failed' }
raise InvalidAuthenticationError, response
end

response
end
end
end
Expand Down
Loading

0 comments on commit 03b1f5c

Please sign in to comment.