Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/adyen/services/balancePlatform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
require_relative 'balancePlatform/payment_instrument_groups_api'
require_relative 'balancePlatform/payment_instruments_api'
require_relative 'balancePlatform/platform_api'
require_relative 'balancePlatform/sca_association_management_api'
require_relative 'balancePlatform/sca_device_management_api'
require_relative 'balancePlatform/transaction_rules_api'
require_relative 'balancePlatform/transfer_limits_balance_account_level_api'
require_relative 'balancePlatform/transfer_limits_balance_platform_level_api'
Expand Down Expand Up @@ -89,6 +91,14 @@ def platform_api
@platform_api ||= Adyen::PlatformApi.new(@client, @version)
end

def sca_association_management_api
@sca_association_management_api ||= Adyen::SCAAssociationManagementApi.new(@client, @version)
end

def sca_device_management_api
@sca_device_management_api ||= Adyen::SCADeviceManagementApi.new(@client, @version)
end

def transaction_rules_api
@transaction_rules_api ||= Adyen::TransactionRulesApi.new(@client, @version)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require_relative '../service'
module Adyen

# NOTE: This class is auto generated by OpenAPI Generator
# Ref: https://openapi-generator.tech
#
# Do not edit the class manually.
class SCAAssociationManagementApi < Service
attr_accessor :service, :version

def initialize(client, version = DEFAULT_VERSION)
super(client, version, 'BalancePlatform')
end

# Approve a pending approval association
def approve_association(request, headers: {})
endpoint = '/scaAssociations'.gsub(/{.+?}/, '%s')

Check failure on line 17 in lib/adyen/services/balancePlatform/sca_association_management_api.rb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "/scaAssociations" 3 times.

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-ruby-api-library&issues=AZq6RJc40C4CwrwAv9MD&open=AZq6RJc40C4CwrwAv9MD&pullRequest=329
endpoint = endpoint.gsub(%r{^/}, '')
endpoint = format(endpoint)
Comment on lines +17 to +19

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The construction of the endpoint string is overly complex for a static path. It can be simplified to a single string assignment, which improves readability and is more idiomatic in Ruby. This simplification can be applied to the other methods in this file (list_associations on lines 27-29 and remove_association on lines 37-39) as well.

      endpoint = 'scaAssociations'


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line contains trailing whitespace. It's a good practice to remove it to maintain a clean codebase. This issue is also present on line 40 in this file, and on lines 20, 30, and 40 in lib/adyen/services/balancePlatform/sca_device_management_api.rb.

action = { method: 'patch', url: endpoint }
@client.call_adyen_api(@service, action, request, headers, @version)
end

# Get a list of devices associated with an entity
def list_associations(headers: {}, query_params: {})
endpoint = '/scaAssociations'.gsub(/{.+?}/, '%s')
endpoint = endpoint.gsub(%r{^/}, '')
endpoint = format(endpoint)
endpoint += create_query_string(query_params)
action = { method: 'get', url: endpoint }
@client.call_adyen_api(@service, action, {}, headers, @version)
end

# Delete association to devices
def remove_association(request, headers: {})
endpoint = '/scaAssociations'.gsub(/{.+?}/, '%s')
endpoint = endpoint.gsub(%r{^/}, '')
endpoint = format(endpoint)

action = { method: 'delete', url: endpoint }
@client.call_adyen_api(@service, action, request, headers, @version)
end

end
end
46 changes: 46 additions & 0 deletions lib/adyen/services/balancePlatform/sca_device_management_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require_relative '../service'
module Adyen

# NOTE: This class is auto generated by OpenAPI Generator
# Ref: https://openapi-generator.tech
#
# Do not edit the class manually.
class SCADeviceManagementApi < Service
attr_accessor :service, :version

def initialize(client, version = DEFAULT_VERSION)
super(client, version, 'BalancePlatform')
end

# Begin SCA device registration
def begin_sca_device_registration(request, headers: {})
endpoint = '/scaDevices'.gsub(/{.+?}/, '%s')
endpoint = endpoint.gsub(%r{^/}, '')
endpoint = format(endpoint)
Comment on lines +17 to +19

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The construction of the endpoint string for this static path is overly complex. It can be simplified to a single string assignment for better readability and more idiomatic code.

      endpoint = 'scaDevices'


action = { method: 'post', url: endpoint }
@client.call_adyen_api(@service, action, request, headers, @version)
end

# Finish registration process for a SCA device
def finish_sca_device_registration(request, device_id, headers: {})
endpoint = '/scaDevices/{deviceId}'.gsub(/{.+?}/, '%s')
endpoint = endpoint.gsub(%r{^/}, '')
endpoint = format(endpoint, device_id)
Comment on lines +27 to +29

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This endpoint construction with a path parameter can be made more readable and idiomatic by using Ruby's string interpolation instead of gsub and format. This simplification can also be applied to the submit_sca_association method on lines 37-39.

      endpoint = "scaDevices/#{device_id}"


action = { method: 'patch', url: endpoint }
@client.call_adyen_api(@service, action, request, headers, @version)
end

# Create a new SCA association for a device
def submit_sca_association(request, device_id, headers: {})
endpoint = '/scaDevices/{deviceId}/scaAssociations'.gsub(/{.+?}/, '%s')
endpoint = endpoint.gsub(%r{^/}, '')
endpoint = format(endpoint, device_id)

action = { method: 'post', url: endpoint }
@client.call_adyen_api(@service, action, request, headers, @version)
end

end
end