Skip to content

Commit

Permalink
Api Updates
Browse files Browse the repository at this point in the history
* Add reference property to Financial Actions query
* Add support for Forex (FX) rates API
* Remove marketplace from HostedPayments & PaymentLinks
  • Loading branch information
martinseco committed Apr 6, 2023
1 parent 52fedd7 commit 9f590ef
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 11 deletions.
3 changes: 3 additions & 0 deletions lib/checkout_sdk/financial/financial_actions_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ module Financial
# @return [String]
# @!attribute action_id
# @return [String]
# @!attribute reference
# @return [String]
# @!attribute limit
# @return [Integer]
# @!attribute pagination_token
# @return [String]
class FinancialActionsQuery
attr_accessor :payment_id,
:action_id,
:reference,
:limit,
:pagination_token
end
Expand Down
2 changes: 2 additions & 0 deletions lib/checkout_sdk/forex/forex.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# frozen_string_literal: true

require 'checkout_sdk/forex/quote_request'
require 'checkout_sdk/forex/forex_source'
require 'checkout_sdk/forex/rates_query_filter'
require 'checkout_sdk/forex/forex_client'
13 changes: 10 additions & 3 deletions lib/checkout_sdk/forex/forex_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
module CheckoutSdk
module Forex
class ForexClient < Client
FOREX = 'forex/quotes'
private_constant :FOREX
FOREX = 'forex'
QUOTES = 'quotes'
RATES = 'rates'
private_constant :FOREX, :QUOTES, :RATES

# @param [ApiClient] api_client
# @param [CheckoutConfiguration] configuration
Expand All @@ -14,7 +16,12 @@ def initialize(api_client, configuration)

# @param [Hash, QuoteRequest] quote_request
def request_quote(quote_request)
api_client.invoke_post(FOREX, sdk_authorization, quote_request)
api_client.invoke_post(build_path(FOREX, QUOTES), sdk_authorization, quote_request)
end

# @param [Hash, RatesQueryFilter] rates_query_filter
def get_rates(rates_query_filter)
api_client.invoke_get(build_path(FOREX, RATES), sdk_authorization, rates_query_filter)
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions lib/checkout_sdk/forex/forex_source.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

module CheckoutSdk
module Forex
module ForexSource
VISA = 'visa'
MASTERCARD = 'mastercard'
end
end
end
20 changes: 20 additions & 0 deletions lib/checkout_sdk/forex/rates_query_filter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module CheckoutSdk
module Forex
# @!attribute product
# @return [String]
# @!attribute source
# @return [String] {ForexSource}
# @!attribute currency_pairs
# @return [String]
# @!attribute process_channel_id
# @return [String]
class RatesQueryFilter
attr_accessor :product,
:source,
:currency_pairs,
:process_channel_id
end
end
end
4 changes: 0 additions & 4 deletions lib/checkout_sdk/payments/hosted/hosted_payments_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ module Payments
# @return [Time]
# @!attribute processing_channel_id
# @return [String] - Not available on Previous.
# @!attribute marketplace
# @deprecated Please use {#amount_allocations} instead
# @return [CheckoutSdk::Common::MarketplaceData] - Not available on Previous.
# @!attribute amount_allocations
# @return [Array(CheckoutSdk::Common::AmountAllocations)] - Not available on Previous.
class HostedPaymentsSession
Expand Down Expand Up @@ -80,7 +77,6 @@ class HostedPaymentsSession
:capture,
:capture_on,
:processing_channel_id,
:marketplace,
:amount_allocations
end
end
Expand Down
4 changes: 0 additions & 4 deletions lib/checkout_sdk/payments/links/payment_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ module Payments
# @return [String]
# @!attribute processing_channel_id
# @return [String] - Not available on Previous.
# @!attribute marketplace
# @deprecated Please use {#amount_allocations} instead
# @return [CheckoutSdk::Common::MarketplaceData] - Not available on Previous.
# @!attribute amount_allocations
# @return [Array(CheckoutSdk::Common::AmountAllocations)] - Not available on Previous.
# @!attribute expires_in
Expand Down Expand Up @@ -62,7 +59,6 @@ class PaymentLink
:reference,
:description,
:processing_channel_id,
:marketplace,
:amount_allocations,
:expires_in,
:customer,
Expand Down
22 changes: 22 additions & 0 deletions spec/checkout_sdk/forex/forex_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,26 @@
end
end
end

skip 'Skipping because processing_channel_id is invalid' do
describe '.get_rates' do
context 'when fetching rates with valid parameters' do
it 'retrieves valid rates' do
query = CheckoutSdk::Forex::RatesQueryFilter.new
query.product = 'card_payouts'
query.source = CheckoutSdk::Forex::ForexSource::VISA
query.currency_pairs = 'GBPEUR,USDNOK,JPNCAD'
query.process_channel_id = 'pc_abcdefghijklmnopqrstuvwxyz'

response = oauth_sdk.forex.get_rates(query)

assert_response response, %w[product
source
rates]
expect(response.product).to eq query.product
expect(response.source).to eq query.source
end
end
end
end
end

0 comments on commit 9f590ef

Please sign in to comment.