genesis_ruby 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -0
  3. data/Gemfile.lock +50 -41
  4. data/README.md +56 -0
  5. data/VERSION +1 -1
  6. data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/billing_api/order_by_fields.rb +33 -0
  7. data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/billing_api/response_fields.rb +67 -0
  8. data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/billing_api/transaction_types.rb +48 -0
  9. data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/externally_processed.rb +22 -0
  10. data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/processing_type.rb +22 -0
  11. data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/sca_exemptions.rb +25 -0
  12. data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/sort_directions.rb +24 -0
  13. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/iframe_targets.rb +26 -0
  14. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/payment_types.rb +3 -0
  15. data/lib/genesis_ruby/api/constants/transactions.rb +5 -0
  16. data/lib/genesis_ruby/api/mixins/requests/financial/bank_attributes.rb +26 -0
  17. data/lib/genesis_ruby/api/mixins/requests/financial/beneficiary_attributes.rb +38 -0
  18. data/lib/genesis_ruby/api/mixins/requests/financial/customer_account_attributes.rb +21 -0
  19. data/lib/genesis_ruby/api/mixins/requests/financial/online_banking_payments/payer_attributes.rb +65 -0
  20. data/lib/genesis_ruby/api/mixins/requests/non_financial/billing_api/sort_attributes.rb +18 -0
  21. data/lib/genesis_ruby/api/mixins/requests/non_financial/date_attributes.rb +64 -0
  22. data/lib/genesis_ruby/api/mixins/requests/non_financial/mode_attributes.rb +24 -0
  23. data/lib/genesis_ruby/api/mixins/requests/non_financial/paging_attributes.rb +33 -0
  24. data/lib/genesis_ruby/api/mixins/requests/non_financial/tokenization/card_data_attributes.rb +62 -0
  25. data/lib/genesis_ruby/api/mixins/requests/non_financial/tokenization/token_attributes.rb +23 -0
  26. data/lib/genesis_ruby/api/mixins/requests/non_financial/tokenization/tokenization_attributes.rb +51 -0
  27. data/lib/genesis_ruby/api/mixins/requests/restricted_setter.rb +18 -0
  28. data/lib/genesis_ruby/api/request.rb +15 -0
  29. data/lib/genesis_ruby/api/requests/base/consumer.rb +24 -0
  30. data/lib/genesis_ruby/api/requests/base/financial.rb +10 -1
  31. data/lib/genesis_ruby/api/requests/base/financials/credit_card.rb +5 -7
  32. data/lib/genesis_ruby/api/requests/base/financials/south_american_payments.rb +11 -14
  33. data/lib/genesis_ruby/api/requests/base/graphql.rb +60 -0
  34. data/lib/genesis_ruby/api/requests/base/reference.rb +2 -1
  35. data/lib/genesis_ruby/api/requests/financial/cards/bancontact.rb +8 -9
  36. data/lib/genesis_ruby/api/requests/financial/cash_payments/cash.rb +13 -14
  37. data/lib/genesis_ruby/api/requests/financial/cash_payments/pix.rb +23 -25
  38. data/lib/genesis_ruby/api/requests/financial/mobile/apple_pay.rb +18 -20
  39. data/lib/genesis_ruby/api/requests/financial/mobile/google_pay.rb +20 -24
  40. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/banco_do_brasil.rb +57 -0
  41. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/eps.rb +46 -0
  42. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/idebit/pay_in.rb +48 -0
  43. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/idebit/pay_out.rb +28 -0
  44. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/insta_debit/pay_in.rb +61 -0
  45. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/insta_debit/pay_out.rb +24 -0
  46. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/multibanco.rb +48 -0
  47. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/my_bank.rb +47 -0
  48. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/online_banking/pay_in.rb +17 -18
  49. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/online_banking/pay_out.rb +33 -38
  50. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/pay_u.rb +61 -0
  51. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/post_finance.rb +53 -0
  52. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/safety_pay.rb +57 -0
  53. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/sofort.rb +63 -0
  54. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/trustly_sale.rb +75 -0
  55. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/upi.rb +54 -0
  56. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/wechat.rb +50 -0
  57. data/lib/genesis_ruby/api/requests/financial/sdd/recurring/init_recurring_sale.rb +23 -0
  58. data/lib/genesis_ruby/api/requests/financial/sdd/recurring/recurring_sale.rb +28 -0
  59. data/lib/genesis_ruby/api/requests/financial/sdd/refund.rb +26 -0
  60. data/lib/genesis_ruby/api/requests/financial/sdd/sale.rb +57 -0
  61. data/lib/genesis_ruby/api/requests/financial/void.rb +12 -5
  62. data/lib/genesis_ruby/api/requests/financial/wallets/alipay.rb +46 -0
  63. data/lib/genesis_ruby/api/requests/financial/wallets/{pay_pay.rb → pay_pal.rb} +18 -20
  64. data/lib/genesis_ruby/api/requests/non_financial/billing_api/transactions.rb +203 -0
  65. data/lib/genesis_ruby/api/requests/non_financial/consumers/create.rb +44 -0
  66. data/lib/genesis_ruby/api/requests/non_financial/consumers/disable.rb +40 -0
  67. data/lib/genesis_ruby/api/requests/non_financial/consumers/enable.rb +40 -0
  68. data/lib/genesis_ruby/api/requests/non_financial/consumers/get_cards.rb +40 -0
  69. data/lib/genesis_ruby/api/requests/non_financial/consumers/retrieve.rb +40 -0
  70. data/lib/genesis_ruby/api/requests/non_financial/consumers/update.rb +45 -0
  71. data/lib/genesis_ruby/api/requests/non_financial/fraud/retrieval/date_range.rb +81 -0
  72. data/lib/genesis_ruby/api/requests/non_financial/fraud/retrieval/transaction.rb +52 -0
  73. data/lib/genesis_ruby/api/requests/non_financial/processed_transactions/date_range.rb +68 -0
  74. data/lib/genesis_ruby/api/requests/non_financial/processed_transactions/post_date_range.rb +72 -0
  75. data/lib/genesis_ruby/api/requests/non_financial/processed_transactions/transaction.rb +48 -0
  76. data/lib/genesis_ruby/api/requests/non_financial/reconcile/date_range.rb +2 -50
  77. data/lib/genesis_ruby/api/requests/non_financial/sca/checker.rb +77 -0
  78. data/lib/genesis_ruby/api/requests/non_financial/tokenization/cryptogram.rb +43 -0
  79. data/lib/genesis_ruby/api/requests/non_financial/tokenization/delete_token.rb +43 -0
  80. data/lib/genesis_ruby/api/requests/non_financial/tokenization/detokenize.rb +43 -0
  81. data/lib/genesis_ruby/api/requests/non_financial/tokenization/get_card.rb +43 -0
  82. data/lib/genesis_ruby/api/requests/non_financial/tokenization/tokenize.rb +45 -0
  83. data/lib/genesis_ruby/api/requests/non_financial/tokenization/update_token.rb +45 -0
  84. data/lib/genesis_ruby/api/requests/non_financial/tokenization/validate_token.rb +43 -0
  85. data/lib/genesis_ruby/builder.rb +5 -0
  86. data/lib/genesis_ruby/builders/graphql.rb +118 -0
  87. data/lib/genesis_ruby/configuration.rb +11 -2
  88. data/lib/genesis_ruby/dependencies.rb +3 -0
  89. data/lib/genesis_ruby/network/adapter/net_http_adapter.rb +20 -9
  90. data/lib/genesis_ruby/network/base_network.rb +1 -14
  91. data/lib/genesis_ruby/utils/formatters/response/formats/timestamp.rb +1 -1
  92. data/lib/genesis_ruby/utils/options/api_config.rb +19 -0
  93. data/lib/genesis_ruby/utils/options/network_adapter_config.rb +49 -14
  94. data/lib/genesis_ruby/utils/transactions/financial_types.rb +1 -1
  95. data/lib/genesis_ruby/utils/transactions/references/refundable_types.rb +1 -1
  96. data/lib/genesis_ruby/utils/transactions/wpf_types.rb +1 -1
  97. data/lib/genesis_ruby/version.rb +1 -1
  98. metadata +66 -4
@@ -0,0 +1,26 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module Financial
6
+ # Bank Attributes mixin
7
+ module BankAttributes
8
+
9
+ attr_reader :bic, :iban
10
+
11
+ # BIC parameter validation
12
+ def bic=(value)
13
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, min: 8, max: 11
14
+ end
15
+
16
+ # IBAN parameter validation
17
+ def iban=(value)
18
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 34
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,38 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module Financial
6
+ # The beneficiary parameters attributes
7
+ module BeneficiaryAttributes
8
+
9
+ attr_accessor :beneficiary_name
10
+ attr_reader :beneficiary_document_id, :beneficiary_pix_key
11
+
12
+ # The Document ID of the beneficiary, such as CPF or CNPJ for Brazilian entities
13
+ def beneficiary_document_id=(value)
14
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 14
15
+ end
16
+
17
+ # The PIX key associated with the beneficiary
18
+ def beneficiary_pix_key=(value)
19
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 36
20
+ end
21
+
22
+ protected
23
+
24
+ # Beneficiary parameters structure
25
+ def beneficiary_parameters_structure
26
+ {
27
+ name: beneficiary_name,
28
+ document_id: beneficiary_document_id,
29
+ pix_key: beneficiary_pix_key
30
+ }
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,21 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module Financial
6
+ # Customer Account Attributes
7
+ module CustomerAccountAttributes
8
+
9
+ attr_reader :customer_account_id
10
+
11
+ # Customer account id parameter validation
12
+ def customer_account_id=(value)
13
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 20
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,65 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module Financial
6
+ module OnlineBankingPayments
7
+ # Payer attributes
8
+ module PayerAttributes
9
+
10
+ attr_reader :payer_document_id, :payer_bank_code, :payer_bank_account_number,
11
+ :payer_bank_branch, :payer_bank_account_verification_digit,
12
+ :payer_bank_phone_number
13
+
14
+ # Payer document ID
15
+ def payer_document_id=(value)
16
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 16
17
+ end
18
+
19
+ # The bank code used to process the transaction
20
+ def payer_bank_code=(value)
21
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 12
22
+ end
23
+
24
+ # The payer's bank account number
25
+ def payer_bank_account_number=(value)
26
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 33
27
+ end
28
+
29
+ # The name of the bank branch where the account is held
30
+ def payer_bank_branch=(value)
31
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 11
32
+ end
33
+
34
+ # Single digit verification code assigned by the external provider,
35
+ # used to validate the bank account
36
+ def payer_bank_account_verification_digit=(value)
37
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 1
38
+ end
39
+
40
+ # The payer's bank contact phone number
41
+ def payer_bank_phone_number=(value)
42
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 11
43
+ end
44
+
45
+ protected
46
+
47
+ # Payer parameters structure
48
+ def payer_parameters_structure
49
+ {
50
+ document_id: payer_document_id,
51
+ bank_code: payer_bank_code,
52
+ bank_account_number: payer_bank_account_number,
53
+ bank_branch: payer_bank_branch,
54
+ bank_account_verification_digit: payer_bank_account_verification_digit,
55
+ bank_phone_number: payer_bank_phone_number
56
+ }
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,18 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module NonFinancial
6
+ module BillingApi
7
+ # Sort Attributes mixin
8
+ module SortAttributes
9
+
10
+ attr_accessor :sort_by_field, :sort_by_direction
11
+
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,64 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module NonFinancial
6
+ # Date Attributes mixin
7
+ module DateAttributes
8
+
9
+ # Start of the requested date range (time is optional)
10
+ def start_date
11
+ format = if start_date_time?
12
+ Api::Constants::DateTimeFormats::YYYY_MM_DD_H_I_S
13
+ else
14
+ Api::Constants::DateTimeFormats::YYYY_MM_DD_ISO_8601
15
+ end
16
+
17
+ @start_date&.strftime format
18
+ end
19
+
20
+ # Start of the requested date range (time is optional)
21
+ def start_date=(value)
22
+ self.start_date_time = Utils::Common.date_has_time? value
23
+
24
+ parse_date attribute: __method__, value: value, allow_empty: true
25
+ end
26
+
27
+ # Start of the requested date range (time is optional)
28
+ def end_date
29
+ format = if end_date_time?
30
+ Api::Constants::DateTimeFormats::YYYY_MM_DD_H_I_S
31
+ else
32
+ Api::Constants::DateTimeFormats::YYYY_MM_DD_ISO_8601
33
+ end
34
+
35
+ @end_date&.strftime format
36
+ end
37
+
38
+ # End of the requested date range (time is optional)
39
+ def end_date=(value)
40
+ self.end_date_time = Utils::Common.date_has_time? value
41
+
42
+ parse_date attribute: __method__, value: value, allow_empty: true
43
+ end
44
+
45
+ private
46
+
47
+ attr_accessor :start_date_time, :end_date_time
48
+
49
+ # Start Date has time within the given string
50
+ def start_date_time?
51
+ self.start_date_time ||= false
52
+ end
53
+
54
+ # End Date has time within the given string
55
+ def end_date_time?
56
+ self.end_date_time ||= false
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,24 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module NonFinancial
6
+ # Mode Attributes mixin
7
+ module ModeAttributes
8
+
9
+ attr_reader :mode
10
+
11
+ # Mode
12
+ def mode=(value)
13
+ allowed_options attribute: __method__,
14
+ allowed: %w(list),
15
+ value: value.to_s.downcase,
16
+ allow_empty: true
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module NonFinancial
6
+ # Paging Attributes mixin
7
+ module PagingAttributes
8
+
9
+ attr_reader :page, :per_page
10
+
11
+ # Page accessor
12
+ def page=(value)
13
+ parse_int attribute: __method__, value: value, allow_empty: true
14
+ end
15
+
16
+ # Per Page accessor
17
+ def per_page=(value)
18
+ parse_int attribute: __method__, value: value, allow_empty: true
19
+ end
20
+
21
+ protected
22
+
23
+ # Paging Response fields
24
+ def paging_query_fields
25
+ %w(page perPage pagesCount totalCount)
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,62 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module NonFinancial
6
+ module Tokenization
7
+ # Card Data Attributes mixin
8
+ module CardDataAttributes
9
+
10
+ attr_accessor :card_holder
11
+ attr_reader :card_number, :expiration_month, :expiration_year
12
+
13
+ # Complete credit/debit card number of customer
14
+ def card_number=(value)
15
+ limited_string attribute: __method__, value: value.to_s, min: 13, max: 19
16
+ end
17
+
18
+ # Expiration month as printed on credit card
19
+ def expiration_month=(value)
20
+ error_message = format(
21
+ 'Invalid value "%{value}" given for %{attribute}, should be in MM format',
22
+ value: value,
23
+ attribute: __method__
24
+ )
25
+
26
+ raise GenesisRuby::ParameterError, error_message unless value.nil? || value =~ /^(0[1-9]|1[0-2])$/
27
+
28
+ @expiration_month = value
29
+ end
30
+
31
+ # Expiration year as printed on credit card
32
+ def expiration_year=(value)
33
+ error_message = format(
34
+ 'Invalid value "%{value}" given for %{attribute}, should be in YYYY format',
35
+ value: value,
36
+ attribute: __method__
37
+ )
38
+
39
+ raise GenesisRuby::ParameterError, error_message unless value.nil? || value =~ /^(20)\d{2}$/
40
+
41
+ @expiration_year = value
42
+ end
43
+
44
+ protected
45
+
46
+ # Card Data Attributes Structure
47
+ def card_data_attributes_structure
48
+ {
49
+ card_number: card_number,
50
+ card_holder: card_holder,
51
+ expiration_month: expiration_month,
52
+ expiration_year: expiration_year
53
+ }
54
+ end
55
+
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,23 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module NonFinancial
6
+ module Tokenization
7
+ # Token Attributes mixin
8
+ module TokenAttributes
9
+
10
+ attr_reader :token
11
+
12
+ # Plain-text token value
13
+ def token=(value)
14
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 36
15
+ end
16
+
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,51 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module NonFinancial
6
+ module Tokenization
7
+ # Common Tokenization API Attributes mixin
8
+ module TokenizationAttributes
9
+
10
+ attr_accessor :token_type
11
+ attr_reader :consumer_id, :email
12
+
13
+ # Consumer unique reference
14
+ def consumer_id=(value)
15
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 10
16
+ end
17
+
18
+ # Consumer e-mail address
19
+ def email=(value)
20
+ error_message = format(
21
+ 'Invalid value given for %{attribute}',
22
+ attribute: __method__
23
+ )
24
+
25
+ raise GenesisRuby::ParameterError, error_message unless value.nil? || value =~ /\A.+@.+\..+\Z/
26
+
27
+ @email = value
28
+ end
29
+
30
+ protected
31
+
32
+ def tokenization_required_fields
33
+ %i[consumer_id email token_type]
34
+ end
35
+
36
+ # Tokenization Attributes Structure
37
+ def tokenization_attributes_structure
38
+ {
39
+ consumer_id: consumer_id,
40
+ email: email,
41
+ token_type: token_type
42
+ }
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -61,6 +61,24 @@ module GenesisRuby
61
61
  assign_instance_variable attribute, value.to_i
62
62
  end
63
63
 
64
+ # Parses given value by validating if an array is given
65
+ # Apply .to_s to every array value
66
+ def parse_array_of_strings(attribute:, value:, allowed: [], allow_empty: false)
67
+ raise InvalidArgumentError, "#{attribute} accepts only Array value." unless value.is_a?(Array)
68
+ raise InvalidArgumentError, "#{attribute} empty value not allowed!" if !allow_empty && value.empty?
69
+
70
+ parsed_value = value.map(&:to_s)
71
+
72
+ unless allowed.empty?
73
+ diff = parsed_value - allowed
74
+ message = "#{attribute} has invalid values #{diff.join(", ")}. Allowed: #{allowed.join(", ")}."
75
+
76
+ raise InvalidArgumentError, message unless diff.empty?
77
+ end
78
+
79
+ assign_instance_variable attribute, value
80
+ end
81
+
64
82
  private
65
83
 
66
84
  # Helper for assigning a attribute to the class instance
@@ -19,6 +19,9 @@ module GenesisRuby
19
19
  METHOD_GET = 'GET'.freeze
20
20
  METHOD_PUT = 'PUT'.freeze
21
21
 
22
+ AUTH_TYPE_BASIC = 'basic'.freeze
23
+ AUTH_TYPE_TOKEN = 'bearer'.freeze
24
+
22
25
  attr_reader :api_config
23
26
 
24
27
  def initialize(configuration, builder_interface = 'xml')
@@ -75,6 +78,11 @@ module GenesisRuby
75
78
  @api_config.load_get_config
76
79
  end
77
80
 
81
+ # Pre-defined GraphQL Request Configuration
82
+ def init_graphql_configuration
83
+ @api_config.load_graphql_config
84
+ end
85
+
78
86
  # Initializes Api EndPoint Url with request path & terminal token
79
87
  def init_api_gateway_configuration(options = { request_path: 'process', include_token: true })
80
88
  request_path = options.fetch :request_path, 'process'
@@ -101,6 +109,13 @@ module GenesisRuby
101
109
  )
102
110
  end
103
111
 
112
+ # Initializes API Service Configuration
113
+ def init_api_service_configuration(options = { request_path: 'graphql' })
114
+ request_path = options.fetch :request_path, 'graphql'
115
+
116
+ api_config.url = build_request_url({ subdomain: 'api_service', path: request_path })
117
+ end
118
+
104
119
  # Process Everything the variables set previously
105
120
  #
106
121
  # Step 1: Execute per-field actions
@@ -0,0 +1,24 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Requests
4
+ module Base
5
+ # Consumers API base request class
6
+ class Consumer < Versioned
7
+
8
+ def initialize(configuration, builder_interface = Builder::XML)
9
+ super configuration, builder_interface
10
+ end
11
+
12
+ protected
13
+
14
+ def populate_structure
15
+ super
16
+
17
+ @tree_structure = Hash["#{request_path}_request", request_structure]
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -6,6 +6,7 @@ module GenesisRuby
6
6
  class Financial < Request
7
7
 
8
8
  include Mixins::Requests::Financial::BaseAttributes
9
+ include Mixins::Requests::Financial::PaymentAttributes
9
10
 
10
11
  # Use Smart Router endpoint for the current request
11
12
  def use_smart_router
@@ -48,6 +49,7 @@ module GenesisRuby
48
49
  super
49
50
  end
50
51
 
52
+ # Populate the request structure
51
53
  def populate_structure
52
54
  self.tree_structure = {
53
55
  payment_transaction: {
@@ -55,7 +57,7 @@ module GenesisRuby
55
57
  transaction_id: transaction_id,
56
58
  usage: usage,
57
59
  remote_ip: remote_ip
58
- }.merge(payment_transaction_structure)
60
+ }.merge(payment_attributes_structure, payment_transaction_structure)
59
61
  }
60
62
  end
61
63
 
@@ -64,6 +66,13 @@ module GenesisRuby
64
66
  api_config.url = build_request_url({ subdomain: 'smart_router', path: 'transactions' })
65
67
  end
66
68
 
69
+ # Initialize Financial class validations
70
+ def init_field_validations
71
+ super
72
+
73
+ field_values.merge! currency: Api::Constants::Currencies::Iso4217.all.map(&:upcase)
74
+ end
75
+
67
76
  end
68
77
  end
69
78
  end
@@ -11,7 +11,6 @@ module GenesisRuby
11
11
  include Mixins::Requests::Financial::Cards::CreditCardAttributes
12
12
  include Mixins::Requests::Financial::Cards::TokenizationAttributes
13
13
  include Mixins::Requests::Financial::Cards::UcofAttributes
14
- include Mixins::Requests::Financial::PaymentAttributes
15
14
 
16
15
  attr_reader :scheme_tokenized
17
16
 
@@ -29,17 +28,16 @@ module GenesisRuby
29
28
 
30
29
  # Request Field validations
31
30
  def init_field_validations
31
+ super
32
+
32
33
  required_fields.push *%i[transaction_id amount currency]
33
- field_values.merge!(
34
- { currency: Api::Constants::Currencies::Iso4217.all.map(&:upcase) },
35
- credential_on_file_field_validations
36
- )
34
+ field_values.merge! credential_on_file_field_validations
37
35
  end
38
36
 
39
37
  # Credit Card attributes
40
38
  def payment_transaction_structure
41
- payment_attributes_structure.merge(
42
- credit_card_attributes_structure, tokenization_attributes_structure,
39
+ credit_card_attributes_structure.merge(
40
+ tokenization_attributes_structure,
43
41
  {
44
42
  account_owner: account_owner_attributes_structure,
45
43
  credential_on_file: credential_on_file,
@@ -9,7 +9,6 @@ module GenesisRuby
9
9
  include Api::Mixins::Requests::AddressInfoAttributes
10
10
  include Api::Mixins::Requests::Financial::AsyncAttributes
11
11
  include Api::Mixins::Requests::BirthDateAttributes
12
- include Api::Mixins::Requests::Financial::PaymentAttributes
13
12
  include Api::Mixins::Requests::Financial::ConsumerIdentifierAttributes
14
13
 
15
14
  # Billing Country custom accessor
@@ -36,19 +35,17 @@ module GenesisRuby
36
35
  end
37
36
 
38
37
  # South American payments
39
- def payment_transaction_structure # rubocop:disable Metrics/MethodLength
40
- payment_attributes_structure.merge(
41
- {
42
- return_success_url: return_success_url,
43
- return_failure_url: return_failure_url,
44
- consumer_reference: consumer_reference,
45
- national_id: national_id,
46
- birth_date: birth_date,
47
- customer_email: customer_email,
48
- billing_address: billing_address_parameters_structure,
49
- shipping_address: shipping_address_parameters_structure
50
- }
51
- )
38
+ def payment_transaction_structure
39
+ {
40
+ return_success_url: return_success_url,
41
+ return_failure_url: return_failure_url,
42
+ consumer_reference: consumer_reference,
43
+ national_id: national_id,
44
+ birth_date: birth_date,
45
+ customer_email: customer_email,
46
+ billing_address: billing_address_parameters_structure,
47
+ shipping_address: shipping_address_parameters_structure
48
+ }
52
49
  end
53
50
 
54
51
  end