bk-apimatic-sdk 1.0.0

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 (140) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +203 -0
  4. data/bin/console +15 -0
  5. data/lib/boku_direct_payments_api/api_helper.rb +10 -0
  6. data/lib/boku_direct_payments_api/client.rb +99 -0
  7. data/lib/boku_direct_payments_api/configuration.rb +168 -0
  8. data/lib/boku_direct_payments_api/controllers/account_resources_controller.rb +45 -0
  9. data/lib/boku_direct_payments_api/controllers/base_controller.rb +60 -0
  10. data/lib/boku_direct_payments_api/controllers/charge_controller.rb +247 -0
  11. data/lib/boku_direct_payments_api/controllers/config_resources_controller.rb +50 -0
  12. data/lib/boku_direct_payments_api/controllers/consumer_registration_controller.rb +428 -0
  13. data/lib/boku_direct_payments_api/controllers/forex_controller.rb +38 -0
  14. data/lib/boku_direct_payments_api/controllers/fund_check_controller.rb +39 -0
  15. data/lib/boku_direct_payments_api/controllers/refund_controller.rb +80 -0
  16. data/lib/boku_direct_payments_api/controllers/seller_of_record_controller.rb +69 -0
  17. data/lib/boku_direct_payments_api/exceptions/api_exception.rb +21 -0
  18. data/lib/boku_direct_payments_api/http/http_call_back.rb +10 -0
  19. data/lib/boku_direct_payments_api/http/http_method_enum.rb +10 -0
  20. data/lib/boku_direct_payments_api/http/http_request.rb +10 -0
  21. data/lib/boku_direct_payments_api/http/http_response.rb +10 -0
  22. data/lib/boku_direct_payments_api/http/proxy_settings.rb +22 -0
  23. data/lib/boku_direct_payments_api/models/account_profile.rb +122 -0
  24. data/lib/boku_direct_payments_api/models/account_profile_attribute.rb +90 -0
  25. data/lib/boku_direct_payments_api/models/account_profile_request.rb +131 -0
  26. data/lib/boku_direct_payments_api/models/account_profile_response.rb +104 -0
  27. data/lib/boku_direct_payments_api/models/account_profile_response_record.rb +142 -0
  28. data/lib/boku_direct_payments_api/models/account_profile_result_status_enum.rb +47 -0
  29. data/lib/boku_direct_payments_api/models/account_profile_selector.rb +132 -0
  30. data/lib/boku_direct_payments_api/models/base_model.rb +110 -0
  31. data/lib/boku_direct_payments_api/models/begin_single_charge_request.rb +360 -0
  32. data/lib/boku_direct_payments_api/models/begin_single_charge_request_hosted.rb +110 -0
  33. data/lib/boku_direct_payments_api/models/begin_single_charge_request_qr_info.rb +74 -0
  34. data/lib/boku_direct_payments_api/models/begin_single_charge_response.rb +254 -0
  35. data/lib/boku_direct_payments_api/models/begin_single_charge_response_hosted.rb +90 -0
  36. data/lib/boku_direct_payments_api/models/begin_single_charge_response_qr_info.rb +85 -0
  37. data/lib/boku_direct_payments_api/models/business_details.rb +209 -0
  38. data/lib/boku_direct_payments_api/models/cancel_optin_request.rb +123 -0
  39. data/lib/boku_direct_payments_api/models/cancel_optin_response.rb +143 -0
  40. data/lib/boku_direct_payments_api/models/carrier_gw.rb +82 -0
  41. data/lib/boku_direct_payments_api/models/charge.rb +288 -0
  42. data/lib/boku_direct_payments_api/models/charge_msisdn_request.rb +233 -0
  43. data/lib/boku_direct_payments_api/models/charge_plus_optin_request.rb +390 -0
  44. data/lib/boku_direct_payments_api/models/charge_plus_optin_request_hosted.rb +96 -0
  45. data/lib/boku_direct_payments_api/models/charge_plus_optin_response.rb +278 -0
  46. data/lib/boku_direct_payments_api/models/charge_plus_optin_response_hosted.rb +75 -0
  47. data/lib/boku_direct_payments_api/models/charge_request.rb +332 -0
  48. data/lib/boku_direct_payments_api/models/charge_response.rb +253 -0
  49. data/lib/boku_direct_payments_api/models/charge_status_enum.rb +43 -0
  50. data/lib/boku_direct_payments_api/models/check_eligibility_request.rb +117 -0
  51. data/lib/boku_direct_payments_api/models/check_eligibility_response.rb +116 -0
  52. data/lib/boku_direct_payments_api/models/client_call.rb +91 -0
  53. data/lib/boku_direct_payments_api/models/confirm_optin_request.rb +141 -0
  54. data/lib/boku_direct_payments_api/models/confirm_optin_response.rb +211 -0
  55. data/lib/boku_direct_payments_api/models/confirm_verify_device_request.rb +161 -0
  56. data/lib/boku_direct_payments_api/models/confirm_verify_device_response.rb +137 -0
  57. data/lib/boku_direct_payments_api/models/eligibility_status_enum.rb +40 -0
  58. data/lib/boku_direct_payments_api/models/forex_request.rb +97 -0
  59. data/lib/boku_direct_payments_api/models/forex_response.rb +127 -0
  60. data/lib/boku_direct_payments_api/models/fund_check_request.rb +132 -0
  61. data/lib/boku_direct_payments_api/models/fund_check_response.rb +89 -0
  62. data/lib/boku_direct_payments_api/models/invalid_request_field.rb +93 -0
  63. data/lib/boku_direct_payments_api/models/mandate_constraint.rb +92 -0
  64. data/lib/boku_direct_payments_api/models/mandate_period_enum.rb +48 -0
  65. data/lib/boku_direct_payments_api/models/mcc_mnc_mapping.rb +85 -0
  66. data/lib/boku_direct_payments_api/models/method_enum.rb +36 -0
  67. data/lib/boku_direct_payments_api/models/msisdn_network_request.rb +97 -0
  68. data/lib/boku_direct_payments_api/models/msisdn_network_response.rb +116 -0
  69. data/lib/boku_direct_payments_api/models/network_info.rb +84 -0
  70. data/lib/boku_direct_payments_api/models/network_info_network.rb +168 -0
  71. data/lib/boku_direct_payments_api/models/optin_accept_networks.rb +87 -0
  72. data/lib/boku_direct_payments_api/models/optin_info.rb +99 -0
  73. data/lib/boku_direct_payments_api/models/optin_info_optin_network.rb +104 -0
  74. data/lib/boku_direct_payments_api/models/optin_info_optin_types.rb +128 -0
  75. data/lib/boku_direct_payments_api/models/optin_network.rb +115 -0
  76. data/lib/boku_direct_payments_api/models/optin_purpose_enum.rb +62 -0
  77. data/lib/boku_direct_payments_api/models/optin_request.rb +338 -0
  78. data/lib/boku_direct_payments_api/models/optin_request_hosted.rb +110 -0
  79. data/lib/boku_direct_payments_api/models/optin_request_qr_info.rb +75 -0
  80. data/lib/boku_direct_payments_api/models/optin_response.rb +220 -0
  81. data/lib/boku_direct_payments_api/models/optin_response_hosted.rb +87 -0
  82. data/lib/boku_direct_payments_api/models/optin_response_qr_info.rb +85 -0
  83. data/lib/boku_direct_payments_api/models/optin_state.rb +164 -0
  84. data/lib/boku_direct_payments_api/models/optin_status_enum.rb +51 -0
  85. data/lib/boku_direct_payments_api/models/optin_terms.rb +214 -0
  86. data/lib/boku_direct_payments_api/models/optin_type_enum.rb +45 -0
  87. data/lib/boku_direct_payments_api/models/payment_method_status_enum.rb +44 -0
  88. data/lib/boku_direct_payments_api/models/period.rb +89 -0
  89. data/lib/boku_direct_payments_api/models/period_unit_enum.rb +46 -0
  90. data/lib/boku_direct_payments_api/models/query_charge_request.rb +149 -0
  91. data/lib/boku_direct_payments_api/models/query_charge_response.rb +101 -0
  92. data/lib/boku_direct_payments_api/models/query_optin_request.rb +104 -0
  93. data/lib/boku_direct_payments_api/models/query_optin_response.rb +129 -0
  94. data/lib/boku_direct_payments_api/models/query_refund_request.rb +122 -0
  95. data/lib/boku_direct_payments_api/models/query_refund_response.rb +101 -0
  96. data/lib/boku_direct_payments_api/models/refund.rb +249 -0
  97. data/lib/boku_direct_payments_api/models/refund_charge_notification.rb +88 -0
  98. data/lib/boku_direct_payments_api/models/refund_charge_request.rb +231 -0
  99. data/lib/boku_direct_payments_api/models/refund_charge_response.rb +203 -0
  100. data/lib/boku_direct_payments_api/models/refund_status_enum.rb +43 -0
  101. data/lib/boku_direct_payments_api/models/refund_type_enum.rb +36 -0
  102. data/lib/boku_direct_payments_api/models/register_payment_method_request.rb +152 -0
  103. data/lib/boku_direct_payments_api/models/register_payment_method_response.rb +172 -0
  104. data/lib/boku_direct_payments_api/models/register_seller_of_record_request.rb +118 -0
  105. data/lib/boku_direct_payments_api/models/register_seller_of_record_response.rb +156 -0
  106. data/lib/boku_direct_payments_api/models/resend_otp_request.rb +167 -0
  107. data/lib/boku_direct_payments_api/models/resend_otp_response.rb +118 -0
  108. data/lib/boku_direct_payments_api/models/result.rb +154 -0
  109. data/lib/boku_direct_payments_api/models/result_status_enum.rb +36 -0
  110. data/lib/boku_direct_payments_api/models/reversal.rb +89 -0
  111. data/lib/boku_direct_payments_api/models/reverse_charge_request.rb +104 -0
  112. data/lib/boku_direct_payments_api/models/reverse_charge_response.rb +157 -0
  113. data/lib/boku_direct_payments_api/models/seller_of_record.rb +76 -0
  114. data/lib/boku_direct_payments_api/models/seller_of_record_status_enum.rb +44 -0
  115. data/lib/boku_direct_payments_api/models/send_sms.rb +89 -0
  116. data/lib/boku_direct_payments_api/models/settlement.rb +126 -0
  117. data/lib/boku_direct_payments_api/models/silent_mo.rb +78 -0
  118. data/lib/boku_direct_payments_api/models/status_enum.rb +40 -0
  119. data/lib/boku_direct_payments_api/models/subscription.rb +105 -0
  120. data/lib/boku_direct_payments_api/models/timeout.rb +75 -0
  121. data/lib/boku_direct_payments_api/models/type_enum.rb +36 -0
  122. data/lib/boku_direct_payments_api/models/validate_optin_request.rb +179 -0
  123. data/lib/boku_direct_payments_api/models/validate_optin_response.rb +195 -0
  124. data/lib/boku_direct_payments_api/models/verify_device_request.rb +135 -0
  125. data/lib/boku_direct_payments_api/models/verify_device_response.rb +137 -0
  126. data/lib/boku_direct_payments_api/utilities/date_time_helper.rb +11 -0
  127. data/lib/boku_direct_payments_api/utilities/file_wrapper.rb +28 -0
  128. data/lib/boku_direct_payments_api/utilities/xml_utilities.rb +12 -0
  129. data/lib/boku_direct_payments_api.rb +166 -0
  130. data/test/controllers/controller_test_base.rb +23 -0
  131. data/test/controllers/test_account_resources_controller.rb +44 -0
  132. data/test/controllers/test_charge_controller.rb +159 -0
  133. data/test/controllers/test_config_resources_controller.rb +47 -0
  134. data/test/controllers/test_consumer_registration_controller.rb +262 -0
  135. data/test/controllers/test_forex_controller.rb +40 -0
  136. data/test/controllers/test_fund_check_controller.rb +41 -0
  137. data/test/controllers/test_refund_controller.rb +76 -0
  138. data/test/controllers/test_seller_of_record_controller.rb +72 -0
  139. data/test/http_response_catcher.rb +19 -0
  140. metadata +255 -0
@@ -0,0 +1,214 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ module BokuDirectPaymentsApi
8
+ # Content defining the specific terms and conditions associated with this
9
+ # opt-in. This may include pricing details or user consent requirements
10
+ # presented to the end user during the opt-in flow.
11
+ class OptinTerms < BaseModel
12
+ SKIP = Object.new
13
+ private_constant :SKIP
14
+
15
+ # Purpose of the Opt-In
16
+ # Defines the behavioral scope and validity of an opt-in. The value
17
+ # determines how long the user’s authorization remains valid and under what
18
+ # conditions it may be reused.
19
+ # Supported Values:
20
+ # - standing-approval: Default opt-in behavior. Valid for subsequent charges
21
+ # until explicitly revoked by the user.
22
+ # - single-transaction: Valid for a single charge only. Any attempt to reuse
23
+ # this opt-in will result in an error.
24
+ # - subscription: Valid for recurring charges as part of a single
25
+ # subscription. Remains valid until revoked.
26
+ # - standing-approval-mandate: Valid for transaction behaviors defined by
27
+ # the user for a specific processing bank and merchant. Must be used in
28
+ # conjunction with mandate-constraints.
29
+ # - subscription-mandate: Valid for subsequent charges until revoked. It
30
+ # indicates that the mandate will be used for recurring charges as part of a
31
+ # single subscription. Must be used with Mandate Constraints and requires a
32
+ # Product SKU, which must match between opt-in and charge.
33
+ # @return [OptinPurposeEnum]
34
+ attr_accessor :optin_purpose
35
+
36
+ # Total charge amount, inclusive of tax.
37
+ # - If provided and `optin-purpose` is set to `single-transaction`, the
38
+ # subsequent charge must match this exact amount.
39
+ #
40
+ # - If omitted or if `optin-purpose` is not `single-transaction`, any valid
41
+ # amount may be used in the subsequent charge.
42
+ # @return [Float]
43
+ attr_accessor :amount
44
+
45
+ # Three-letter currency code as defined by ISO 4217.
46
+ # @return [String]
47
+ attr_accessor :currency
48
+
49
+ # Defines transaction behavior constraints associated with a mandate. This
50
+ # field is used to specify conditions under which transactions may be
51
+ # processed.
52
+ # Applicable only when `optin-purpose` is set to `standing-approval-mandate`
53
+ # or `subscription-mandate`and `optin-type` is set to `hosted`.
54
+ # @return [Array[MandateConstraint]]
55
+ attr_accessor :mandate_constraints
56
+
57
+ # A merchant-defined identifier for the subscription product. Required only
58
+ # when the optin purpose is 'subscription-mandate'. The SKU used in the
59
+ # charge request must match the one provided during optin.
60
+ # @return [String]
61
+ attr_accessor :product_sku
62
+
63
+ # Time this opt-in will be valid until in UTC time zone (`"YYYY-MM-DD
64
+ # hh:mm:ss"`) for `"single-transaction"`, `"subscription"`, and
65
+ # `"subscription-mandate"` opt-in purposes.
66
+ # **Single Transaction**
67
+ # - If present, opt-in will be valid between time of request and specified
68
+ # time.
69
+ # - If absent, opt-in will be valid between time of request and time of
70
+ # request + 24 hours.
71
+ # **Subscription**
72
+ # - If present, opt-in will be valid until specified time. _While optional,
73
+ # this field is required for some payment methods_.
74
+ # **Subscription-Mandate**
75
+ # - If present, opt-in will be valid until specified time.
76
+ # - NOTE: Enforcement of mandate expiry is the responsibility of the
77
+ # issuer. Boku does not proactively cancel the opt-in or block charges after
78
+ # this date, but any charge attempted post-expiry will typically be declined
79
+ # by the issuer and surfaced as a failed transaction.
80
+ # This element is not applicable to `"standing-approval"` opt-in purpose.
81
+ # @return [DateTime]
82
+ attr_accessor :valid_through
83
+
84
+ # A mapping from model property names to API property names.
85
+ def self.names
86
+ @_hash = {} if @_hash.nil?
87
+ @_hash['optin_purpose'] = 'optin-purpose'
88
+ @_hash['amount'] = 'amount'
89
+ @_hash['currency'] = 'currency'
90
+ @_hash['mandate_constraints'] = 'mandate-constraints'
91
+ @_hash['product_sku'] = 'product-sku'
92
+ @_hash['valid_through'] = 'valid-through'
93
+ @_hash
94
+ end
95
+
96
+ # An array for optional fields
97
+ def self.optionals
98
+ %w[
99
+ amount
100
+ currency
101
+ mandate_constraints
102
+ product_sku
103
+ valid_through
104
+ ]
105
+ end
106
+
107
+ # An array for nullable fields
108
+ def self.nullables
109
+ []
110
+ end
111
+
112
+ def initialize(optin_purpose = nil, amount = SKIP, currency = SKIP,
113
+ mandate_constraints = SKIP, product_sku = SKIP,
114
+ valid_through = SKIP)
115
+ @optin_purpose = optin_purpose
116
+ @amount = amount unless amount == SKIP
117
+ @currency = currency unless currency == SKIP
118
+ @mandate_constraints = mandate_constraints unless mandate_constraints == SKIP
119
+ @product_sku = product_sku unless product_sku == SKIP
120
+ @valid_through = valid_through unless valid_through == SKIP
121
+ end
122
+
123
+ # Creates an instance of the object from a hash.
124
+ def self.from_hash(hash)
125
+ return nil unless hash
126
+
127
+ # Extract variables from the hash.
128
+ optin_purpose = hash.key?('optin-purpose') ? hash['optin-purpose'] : nil
129
+ amount = hash.key?('amount') ? hash['amount'] : SKIP
130
+ currency = hash.key?('currency') ? hash['currency'] : SKIP
131
+ # Parameter is an array, so we need to iterate through it
132
+ mandate_constraints = nil
133
+ unless hash['mandate-constraints'].nil?
134
+ mandate_constraints = []
135
+ hash['mandate-constraints'].each do |structure|
136
+ mandate_constraints << (MandateConstraint.from_hash(structure) if structure)
137
+ end
138
+ end
139
+
140
+ mandate_constraints = SKIP unless hash.key?('mandate-constraints')
141
+ product_sku = hash.key?('product-sku') ? hash['product-sku'] : SKIP
142
+ valid_through = if hash.key?('valid-through')
143
+ (DateTimeHelper.from_rfc3339(hash['valid-through']) if hash['valid-through'])
144
+ else
145
+ SKIP
146
+ end
147
+
148
+ # Create object from extracted values.
149
+ OptinTerms.new(optin_purpose,
150
+ amount,
151
+ currency,
152
+ mandate_constraints,
153
+ product_sku,
154
+ valid_through)
155
+ end
156
+
157
+ def to_custom_valid_through
158
+ DateTimeHelper.to_rfc3339(valid_through)
159
+ end
160
+
161
+ def self.from_element(root)
162
+ optin_purpose = XmlUtilities.from_element(root, 'optin-purpose', String)
163
+ amount = XmlUtilities.from_element(root, 'amount', Float)
164
+ currency = XmlUtilities.from_element(root, 'currency', String)
165
+ mandate_constraints = XmlUtilities.from_element_to_array(
166
+ root, 'mandate-constraint', MandateConstraint,
167
+ wrapping_element_name: 'mandate-constraints'
168
+ )
169
+ product_sku = XmlUtilities.from_element(root, 'product-sku', String)
170
+ valid_through = XmlUtilities.from_element(root, 'valid-through', String,
171
+ datetime_format: 'rfc3339')
172
+
173
+ new(optin_purpose,
174
+ amount,
175
+ currency,
176
+ mandate_constraints,
177
+ product_sku,
178
+ valid_through)
179
+ end
180
+
181
+ def to_xml_element(doc, root_name)
182
+ root = doc.create_element(root_name)
183
+
184
+ XmlUtilities.add_as_subelement(doc, root, 'optin-purpose', optin_purpose)
185
+ XmlUtilities.add_as_subelement(doc, root, 'amount', amount)
186
+ XmlUtilities.add_as_subelement(doc, root, 'currency', currency)
187
+ XmlUtilities.add_array_as_subelement(
188
+ doc, root, 'mandate-constraint', mandate_constraints,
189
+ wrapping_element_name: 'mandate-constraints'
190
+ )
191
+ XmlUtilities.add_as_subelement(doc, root, 'product-sku', product_sku)
192
+ XmlUtilities.add_as_subelement(doc, root, 'valid-through', valid_through,
193
+ datetime_format: 'rfc3339')
194
+
195
+ root
196
+ end
197
+
198
+ # Provides a human-readable string representation of the object.
199
+ def to_s
200
+ class_name = self.class.name.split('::').last
201
+ "<#{class_name} optin_purpose: #{@optin_purpose}, amount: #{@amount}, currency:"\
202
+ " #{@currency}, mandate_constraints: #{@mandate_constraints}, product_sku: #{@product_sku},"\
203
+ " valid_through: #{@valid_through}>"
204
+ end
205
+
206
+ # Provides a debugging-friendly string with detailed object information.
207
+ def inspect
208
+ class_name = self.class.name.split('::').last
209
+ "<#{class_name} optin_purpose: #{@optin_purpose.inspect}, amount: #{@amount.inspect},"\
210
+ " currency: #{@currency.inspect}, mandate_constraints: #{@mandate_constraints.inspect},"\
211
+ " product_sku: #{@product_sku.inspect}, valid_through: #{@valid_through.inspect}>"
212
+ end
213
+ end
214
+ end
@@ -0,0 +1,45 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module BokuDirectPaymentsApi
7
+ # Specifies which method to use to perform the opt-in.
8
+ class OptinTypeEnum
9
+ OPTIN_TYPE_ENUM = [
10
+ # Sends a one-time PIN to the consumer via SMS, confirmed via
11
+ # `confirm-optin`.
12
+ OTP = 'otp'.freeze,
13
+
14
+ # Verifies the consumer via a ping through the carrier gateway.
15
+ CARRIERGW = 'carrier-gw'.freeze,
16
+
17
+ # Redirects the consumer to an issuer-provided UI for verification.
18
+ HOSTED = 'hosted'.freeze,
19
+
20
+ # Verifies the consumer by sending a silent SMS from the device.
21
+ SILENTMO = 'silent-mo'.freeze
22
+ ].freeze
23
+
24
+ def self.validate(value)
25
+ return false if value.nil?
26
+
27
+ OPTIN_TYPE_ENUM.include?(value)
28
+ end
29
+
30
+ def self.from_value(value, default_value = OTP)
31
+ return default_value if value.nil?
32
+
33
+ str = value.to_s.strip
34
+
35
+ case str.downcase
36
+ when 'otp' then OTP
37
+ when 'carriergw' then CARRIERGW
38
+ when 'hosted' then HOSTED
39
+ when 'silentmo' then SILENTMO
40
+ else
41
+ default_value
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,44 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module BokuDirectPaymentsApi
7
+ # The status of Payment Method
8
+ class PaymentMethodStatusEnum
9
+ PAYMENT_METHOD_STATUS_ENUM = [
10
+ # TODO: Write general description for PENDING
11
+ PENDING = 'pending'.freeze,
12
+
13
+ # TODO: Write general description for APPROVED
14
+ APPROVED = 'approved'.freeze,
15
+
16
+ # TODO: Write general description for REJECTED
17
+ REJECTED = 'rejected'.freeze,
18
+
19
+ # TODO: Write general description for SUSPENDED
20
+ SUSPENDED = 'suspended'.freeze
21
+ ].freeze
22
+
23
+ def self.validate(value)
24
+ return false if value.nil?
25
+
26
+ PAYMENT_METHOD_STATUS_ENUM.include?(value)
27
+ end
28
+
29
+ def self.from_value(value, default_value = PENDING)
30
+ return default_value if value.nil?
31
+
32
+ str = value.to_s.strip
33
+
34
+ case str.downcase
35
+ when 'pending' then PENDING
36
+ when 'approved' then APPROVED
37
+ when 'rejected' then REJECTED
38
+ when 'suspended' then SUSPENDED
39
+ else
40
+ default_value
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,89 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module BokuDirectPaymentsApi
7
+ # The period of the subscription (at which interval the consumer is being
8
+ # charged)
9
+ class Period < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # The count of units in the period
14
+ # @return [Integer]
15
+ attr_accessor :count
16
+
17
+ # A period is comprised of a unit of time (day, week, month, year) and a
18
+ # count (how many units per period).
19
+ # For example, to define a "3 month" period one would set the unit as
20
+ # "month" and the count as "3".
21
+ # @return [PeriodUnitEnum]
22
+ attr_accessor :unit
23
+
24
+ # A mapping from model property names to API property names.
25
+ def self.names
26
+ @_hash = {} if @_hash.nil?
27
+ @_hash['count'] = 'count'
28
+ @_hash['unit'] = 'unit'
29
+ @_hash
30
+ end
31
+
32
+ # An array for optional fields
33
+ def self.optionals
34
+ []
35
+ end
36
+
37
+ # An array for nullable fields
38
+ def self.nullables
39
+ []
40
+ end
41
+
42
+ def initialize(count = nil, unit = nil)
43
+ @count = count
44
+ @unit = unit
45
+ end
46
+
47
+ # Creates an instance of the object from a hash.
48
+ def self.from_hash(hash)
49
+ return nil unless hash
50
+
51
+ # Extract variables from the hash.
52
+ count = hash.key?('count') ? hash['count'] : nil
53
+ unit = hash.key?('unit') ? hash['unit'] : nil
54
+
55
+ # Create object from extracted values.
56
+ Period.new(count,
57
+ unit)
58
+ end
59
+
60
+ def self.from_element(root)
61
+ count = XmlUtilities.from_attribute(root, 'count', Integer)
62
+ unit = XmlUtilities.from_attribute(root, 'unit', String)
63
+
64
+ new(count,
65
+ unit)
66
+ end
67
+
68
+ def to_xml_element(doc, root_name)
69
+ root = doc.create_element(root_name)
70
+
71
+ XmlUtilities.add_as_attribute(root, 'count', count)
72
+ XmlUtilities.add_as_attribute(root, 'unit', unit)
73
+
74
+ root
75
+ end
76
+
77
+ # Provides a human-readable string representation of the object.
78
+ def to_s
79
+ class_name = self.class.name.split('::').last
80
+ "<#{class_name} count: #{@count}, unit: #{@unit}>"
81
+ end
82
+
83
+ # Provides a debugging-friendly string with detailed object information.
84
+ def inspect
85
+ class_name = self.class.name.split('::').last
86
+ "<#{class_name} count: #{@count.inspect}, unit: #{@unit.inspect}>"
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,46 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module BokuDirectPaymentsApi
7
+ # A period is comprised of a unit of time (day, week, month, year) and a count
8
+ # (how many units per period). For example, to define a "3 month" period one
9
+ # would set the unit as "month" and the count as "3".
10
+ class PeriodUnitEnum
11
+ PERIOD_UNIT_ENUM = [
12
+ # TODO: Write general description for DAY
13
+ DAY = 'day'.freeze,
14
+
15
+ # TODO: Write general description for WEEK
16
+ WEEK = 'week'.freeze,
17
+
18
+ # TODO: Write general description for MONTH
19
+ MONTH = 'month'.freeze,
20
+
21
+ # TODO: Write general description for YEAR
22
+ YEAR = 'year'.freeze
23
+ ].freeze
24
+
25
+ def self.validate(value)
26
+ return false if value.nil?
27
+
28
+ PERIOD_UNIT_ENUM.include?(value)
29
+ end
30
+
31
+ def self.from_value(value, default_value = DAY)
32
+ return default_value if value.nil?
33
+
34
+ str = value.to_s.strip
35
+
36
+ case str.downcase
37
+ when 'day' then DAY
38
+ when 'week' then WEEK
39
+ when 'month' then MONTH
40
+ when 'year' then YEAR
41
+ else
42
+ default_value
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,149 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module BokuDirectPaymentsApi
7
+ # 'query-charge' Request
8
+ class QueryChargeRequest < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Country code within which to search for charges
13
+ # @return [String]
14
+ attr_accessor :country
15
+
16
+ # Boku-assigned merchant ID.
17
+ # @return [String]
18
+ attr_accessor :merchant_id
19
+
20
+ # The charge-id returned from the original charge response.
21
+ # Will match only a single transaction.
22
+ # Required if merchant-request-id or merchant-transaction-id are not
23
+ # provided. Do not include if merchant-request-id or merchant-transaction-id
24
+ # are provided.
25
+ # @return [String]
26
+ attr_accessor :charge_id
27
+
28
+ # The merchant-request-id of the original charge request.
29
+ # Will match only a single transaction.
30
+ # **Note:** merchant-request-id is only valid within 24 hours of the
31
+ # original charge request. After this time, it will return no results.
32
+ # Required if charge-id or merchant-transaction-id are not provided. Do not
33
+ # include if charge-id or merchant-transaction-id are provided.
34
+ # @return [String]
35
+ attr_accessor :merchant_request_id
36
+
37
+ # Merchant-assigned transaction ID supplied in the original charge request.
38
+ # May match multiple transactions in the case where the merchant reuses
39
+ # merchant-transaction-ids across different request IDs, as Boku does not
40
+ # enforce uniqueness on this value.
41
+ # Required if charge-id or merchant-request-id are not provided. Do not
42
+ # include if merchant-request-id or charge-id are provided.
43
+ # @return [String]
44
+ attr_accessor :merchant_transaction_id
45
+
46
+ # A mapping from model property names to API property names.
47
+ def self.names
48
+ @_hash = {} if @_hash.nil?
49
+ @_hash['country'] = 'country'
50
+ @_hash['merchant_id'] = 'merchant-id'
51
+ @_hash['charge_id'] = 'charge-id'
52
+ @_hash['merchant_request_id'] = 'merchant-request-id'
53
+ @_hash['merchant_transaction_id'] = 'merchant-transaction-id'
54
+ @_hash
55
+ end
56
+
57
+ # An array for optional fields
58
+ def self.optionals
59
+ %w[
60
+ charge_id
61
+ merchant_request_id
62
+ merchant_transaction_id
63
+ ]
64
+ end
65
+
66
+ # An array for nullable fields
67
+ def self.nullables
68
+ []
69
+ end
70
+
71
+ def initialize(country = nil, merchant_id = nil, charge_id = SKIP,
72
+ merchant_request_id = SKIP, merchant_transaction_id = SKIP)
73
+ @country = country
74
+ @merchant_id = merchant_id
75
+ @charge_id = charge_id unless charge_id == SKIP
76
+ @merchant_request_id = merchant_request_id unless merchant_request_id == SKIP
77
+ @merchant_transaction_id = merchant_transaction_id unless merchant_transaction_id == SKIP
78
+ end
79
+
80
+ # Creates an instance of the object from a hash.
81
+ def self.from_hash(hash)
82
+ return nil unless hash
83
+
84
+ # Extract variables from the hash.
85
+ country = hash.key?('country') ? hash['country'] : nil
86
+ merchant_id = hash.key?('merchant-id') ? hash['merchant-id'] : nil
87
+ charge_id = hash.key?('charge-id') ? hash['charge-id'] : SKIP
88
+ merchant_request_id =
89
+ hash.key?('merchant-request-id') ? hash['merchant-request-id'] : SKIP
90
+ merchant_transaction_id =
91
+ hash.key?('merchant-transaction-id') ? hash['merchant-transaction-id'] : SKIP
92
+
93
+ # Create object from extracted values.
94
+ QueryChargeRequest.new(country,
95
+ merchant_id,
96
+ charge_id,
97
+ merchant_request_id,
98
+ merchant_transaction_id)
99
+ end
100
+
101
+ def self.from_element(root)
102
+ country = XmlUtilities.from_element(root, 'country', String)
103
+ merchant_id = XmlUtilities.from_element(root, 'merchant-id', String)
104
+ charge_id = XmlUtilities.from_element(root, 'charge-id', String)
105
+ merchant_request_id = XmlUtilities.from_element(root,
106
+ 'merchant-request-id',
107
+ String)
108
+ merchant_transaction_id = XmlUtilities.from_element(
109
+ root, 'merchant-transaction-id', String
110
+ )
111
+
112
+ new(country,
113
+ merchant_id,
114
+ charge_id,
115
+ merchant_request_id,
116
+ merchant_transaction_id)
117
+ end
118
+
119
+ def to_xml_element(doc, root_name)
120
+ root = doc.create_element(root_name)
121
+
122
+ XmlUtilities.add_as_subelement(doc, root, 'country', country)
123
+ XmlUtilities.add_as_subelement(doc, root, 'merchant-id', merchant_id)
124
+ XmlUtilities.add_as_subelement(doc, root, 'charge-id', charge_id)
125
+ XmlUtilities.add_as_subelement(doc, root, 'merchant-request-id',
126
+ merchant_request_id)
127
+ XmlUtilities.add_as_subelement(doc, root, 'merchant-transaction-id',
128
+ merchant_transaction_id)
129
+
130
+ root
131
+ end
132
+
133
+ # Provides a human-readable string representation of the object.
134
+ def to_s
135
+ class_name = self.class.name.split('::').last
136
+ "<#{class_name} country: #{@country}, merchant_id: #{@merchant_id}, charge_id:"\
137
+ " #{@charge_id}, merchant_request_id: #{@merchant_request_id}, merchant_transaction_id:"\
138
+ " #{@merchant_transaction_id}>"
139
+ end
140
+
141
+ # Provides a debugging-friendly string with detailed object information.
142
+ def inspect
143
+ class_name = self.class.name.split('::').last
144
+ "<#{class_name} country: #{@country.inspect}, merchant_id: #{@merchant_id.inspect},"\
145
+ " charge_id: #{@charge_id.inspect}, merchant_request_id: #{@merchant_request_id.inspect},"\
146
+ " merchant_transaction_id: #{@merchant_transaction_id.inspect}>"
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,101 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module BokuDirectPaymentsApi
7
+ # QueryChargeResponse Model.
8
+ class QueryChargeResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # The 'result' element is defined in every response type. It is used to
13
+ # convey the outcome of an API request.
14
+ # @return [Result]
15
+ attr_accessor :result
16
+
17
+ # The 'result' element is defined in every response type. It is used to
18
+ # convey the outcome of an API request.
19
+ # @return [Array[Charge]]
20
+ attr_accessor :charges
21
+
22
+ # A mapping from model property names to API property names.
23
+ def self.names
24
+ @_hash = {} if @_hash.nil?
25
+ @_hash['result'] = 'result'
26
+ @_hash['charges'] = 'charges'
27
+ @_hash
28
+ end
29
+
30
+ # An array for optional fields
31
+ def self.optionals
32
+ %w[
33
+ charges
34
+ ]
35
+ end
36
+
37
+ # An array for nullable fields
38
+ def self.nullables
39
+ []
40
+ end
41
+
42
+ def initialize(result = nil, charges = SKIP)
43
+ @result = result
44
+ @charges = charges unless charges == SKIP
45
+ end
46
+
47
+ # Creates an instance of the object from a hash.
48
+ def self.from_hash(hash)
49
+ return nil unless hash
50
+
51
+ # Extract variables from the hash.
52
+ result = Result.from_hash(hash['result']) if hash['result']
53
+ # Parameter is an array, so we need to iterate through it
54
+ charges = nil
55
+ unless hash['charges'].nil?
56
+ charges = []
57
+ hash['charges'].each do |structure|
58
+ charges << (Charge.from_hash(structure) if structure)
59
+ end
60
+ end
61
+
62
+ charges = SKIP unless hash.key?('charges')
63
+
64
+ # Create object from extracted values.
65
+ QueryChargeResponse.new(result,
66
+ charges)
67
+ end
68
+
69
+ def self.from_element(root)
70
+ result = XmlUtilities.from_element(root, 'result', Result)
71
+ charges = XmlUtilities.from_element_to_array(
72
+ root, 'charge', Charge, wrapping_element_name: 'charges'
73
+ )
74
+
75
+ new(result,
76
+ charges)
77
+ end
78
+
79
+ def to_xml_element(doc, root_name)
80
+ root = doc.create_element(root_name)
81
+
82
+ XmlUtilities.add_as_subelement(doc, root, 'result', result)
83
+ XmlUtilities.add_array_as_subelement(doc, root, 'charge', charges,
84
+ wrapping_element_name: 'charges')
85
+
86
+ root
87
+ end
88
+
89
+ # Provides a human-readable string representation of the object.
90
+ def to_s
91
+ class_name = self.class.name.split('::').last
92
+ "<#{class_name} result: #{@result}, charges: #{@charges}>"
93
+ end
94
+
95
+ # Provides a debugging-friendly string with detailed object information.
96
+ def inspect
97
+ class_name = self.class.name.split('::').last
98
+ "<#{class_name} result: #{@result.inspect}, charges: #{@charges.inspect}>"
99
+ end
100
+ end
101
+ end