Sha256: 0855221e4c72db58770a04c7c50a8d12e67ede8a7ff53760abb73c8202dd735e

Contents?: true

Size: 1017 Bytes

Versions: 8

Compression:

Stored size: 1017 Bytes

Contents

module Braintree
  class ExchangeRateQuoteGateway
    def initialize(gateway)
      @gateway = gateway
    end

    DEFINITION = <<-GRAPHQL
      mutation GenerateExchangeRateQuoteInput($input: GenerateExchangeRateQuoteInput!) {
        generateExchangeRateQuote(input: $input) {
          quotes {
            id
            baseAmount {value, currencyCode}
            quoteAmount {value, currencyCode}
            exchangeRate
            tradeRate
            expiresAt
            refreshesAt
          }
        }
      }
    GRAPHQL

    def generate(params)
      response = @gateway.config.graphql_client.query(DEFINITION, {input: params})

      if response.has_key?(:data) && response[:data][:generateExchangeRateQuote]
        response[:data][:generateExchangeRateQuote]
      elsif response[:errors]
        ErrorResult.new(@gateway, response[:errors])
      else
        raise UnexpectedError, "expected :generateExchangeRateQuote or :api_error_response in GraphQL response"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
braintree-4.23.0 lib/braintree/exchange_rate_quote_gateway.rb
braintree-4.22.0 lib/braintree/exchange_rate_quote_gateway.rb
braintree-4.21.0 lib/braintree/exchange_rate_quote_gateway.rb
braintree-4.20.0 lib/braintree/exchange_rate_quote_gateway.rb
braintree-4.19.0 lib/braintree/exchange_rate_quote_gateway.rb
braintree-4.18.0 lib/braintree/exchange_rate_quote_gateway.rb
braintree-4.17.0 lib/braintree/exchange_rate_quote_gateway.rb
braintree-4.16.0 lib/braintree/exchange_rate_quote_gateway.rb