class BankOfBaku::Client
Private Instance Methods
handle_response(response)
click to toggle source
# File lib/bank_of_baku/client.rb, line 25 def handle_response(response) raise HTTPResponseError, "HTTP request failed: #{response.code}" unless response.success? response = JSON.parse response.body error_klass = case response['errorCode'] when '1' then RegisteredOrder when '2' then DeclinedOrder when '3' then InvalidCurrency when '4' then MissingParameter when '5' then InvalidParameterValue when '6' then UnregisteredOrder when '7' then GatewayError end raise error_klass, response['errorMessage'] if error_klass response end
run_request(action, options)
click to toggle source
# File lib/bank_of_baku/client.rb, line 12 def run_request(action, options) request = Typhoeus::Request.new( "#{BankOfBaku.endpoint}/#{action}", BankOfBaku.typhoeus_options.merge( method: :post, followlocation: true, headers: { 'User-Agent' => BankOfBaku.user_agent }, body: BankOfBaku.credentials.merge(options) ) ) handle_response(request.run) end