Class: Braintree::ExchangeRateQuoteGateway
- Inherits:
-
Object
- Object
- Braintree::ExchangeRateQuoteGateway
- Defined in:
- lib/braintree/exchange_rate_quote_gateway.rb
Constant Summary collapse
- DEFINITION =
<<-GRAPHQL mutation GenerateExchangeRateQuoteInput($input: GenerateExchangeRateQuoteInput!) { generateExchangeRateQuote(input: $input) { quotes { id baseAmount {value, currencyCode} quoteAmount {value, currencyCode} exchangeRate tradeRate expiresAt refreshesAt } } } GRAPHQL
Instance Method Summary collapse
- #generate(params) ⇒ Object
-
#initialize(gateway) ⇒ ExchangeRateQuoteGateway
constructor
A new instance of ExchangeRateQuoteGateway.
Constructor Details
#initialize(gateway) ⇒ ExchangeRateQuoteGateway
Returns a new instance of ExchangeRateQuoteGateway.
3 4 5 |
# File 'lib/braintree/exchange_rate_quote_gateway.rb', line 3 def initialize(gateway) @gateway = gateway end |
Instance Method Details
#generate(params) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/braintree/exchange_rate_quote_gateway.rb', line 23 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 |