-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f18d293
commit 3a883be
Showing
28 changed files
with
708 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Braintree | ||
class ExchangeRate | ||
include BaseModule # :nodoc: | ||
|
||
def initialize(gateway, attributes) # :nodoc: | ||
set_instance_variables_from_hash(attributes) | ||
end | ||
|
||
def self.generate(exchange_rate_quote_request) | ||
Configuration.gateway.exchange_rate_quote.generate(exchange_rate_quote_request) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Braintree | ||
class ExchangeRateQuote | ||
include BaseModule # :nodoc: | ||
|
||
attr_reader :attrs | ||
attr_reader :base_amount | ||
attr_reader :exchange_rate | ||
attr_reader :expires_at | ||
attr_reader :id | ||
attr_reader :quote_amount | ||
attr_reader :refreshes_at | ||
attr_reader :trade_rate | ||
|
||
def initialize(attributes) # :nodoc: | ||
@attrs = attributes.keys | ||
set_instance_variables_from_hash(attributes) | ||
end | ||
|
||
def inspect # :nodoc: | ||
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" } | ||
"#<#{self.class} #{inspected_attributes.join(" ")}>" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module Braintree | ||
class ExchangeRateQuoteGateway # :nodoc | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Braintree | ||
class ExchangeRateQuoteInput | ||
include BaseModule # :nodoc: | ||
|
||
attr_reader :attrs | ||
attr_reader :base_currency | ||
attr_reader :base_amount | ||
attr_reader :markup | ||
attr_reader :quote_currency | ||
|
||
def initialize(attributes) # :nodoc: | ||
@attrs = attributes.keys | ||
set_instance_variables_from_hash(attributes) | ||
end | ||
|
||
def inspect # :nodoc: | ||
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" } | ||
"#<#{self.class} #{inspected_attributes.join(" ")}>" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Braintree | ||
class ExchangeRateQuoteRequest | ||
include BaseModule # :nodoc: | ||
|
||
attr_reader :quotes | ||
|
||
def initialize(attributes) # :nodoc: | ||
@attrs = attributes.keys | ||
set_instance_variables_from_hash(attributes) | ||
@quotes = (@quotes || []).map { |quote_hash| ExchangeRateQuoteInput.new(quote_hash) } | ||
end | ||
|
||
def inspect # :nodoc: | ||
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" } | ||
"#<#{self.class} #{inspected_attributes.join(" ")}>" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Braintree | ||
class ExchangeRateQuoteResponse | ||
include BaseModule # :nodoc: | ||
|
||
attr_reader :quotes | ||
|
||
def initialize(attributes) # :nodoc: | ||
@attrs = attributes.keys | ||
set_instance_variables_from_hash(attributes) | ||
@quotes = (@quotes || []).map { |quote_hash| ExchangeRateQuote.new(quote_hash) } | ||
end | ||
|
||
def inspect # :nodoc: | ||
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" } | ||
"#<#{self.class} #{inspected_attributes.join(" ")}>" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Braintree | ||
class RiskData | ||
class LiabilityShift | ||
include BaseModule | ||
|
||
attr_reader :responsible_party | ||
attr_reader :conditions | ||
|
||
def initialize(attributes) | ||
set_instance_variables_from_hash attributes unless attributes.nil? | ||
end | ||
|
||
def inspect | ||
attr_order = [:responsible_party, :conditions] | ||
formatted_attrs = attr_order.map do |attr| | ||
"#{attr}: #{send(attr).inspect}" | ||
end | ||
"#<LiabilityShift #{formatted_attrs.join(", ")}>" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Braintree | ||
module Version | ||
Major = 4 | ||
Minor = 7 | ||
Minor = 8 | ||
Tiny = 0 | ||
|
||
String = "#{Major}.#{Minor}.#{Tiny}" | ||
|
Oops, something went wrong.