conekta 6.0.3 → 6.0.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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -5
  3. data/VERSION +1 -1
  4. data/config-ruby.json +1 -1
  5. data/docs/ChargeRequest.md +1 -1
  6. data/docs/ChargeRequestPaymentMethod.md +39 -18
  7. data/docs/ChargeResponse.md +6 -6
  8. data/docs/ChargesApi.md +1 -1
  9. data/docs/ChargesDataResponse.md +6 -6
  10. data/docs/Checkout.md +2 -0
  11. data/docs/CreateCustomerPaymentMethodsRequest.md +4 -4
  12. data/docs/CustomerPaymentMethodsRequest.md +4 -4
  13. data/docs/OrderRefundRequest.md +2 -2
  14. data/docs/OrderRequest.md +1 -1
  15. data/docs/PaymentMethodBankTransfer.md +3 -1
  16. data/docs/PaymentMethodCard.md +12 -10
  17. data/docs/PaymentMethodCardRequest.md +12 -2
  18. data/docs/PaymentMethodCash.md +3 -1
  19. data/docs/PaymentMethodGeneralRequest.md +32 -0
  20. data/docs/PaymentMethodTokenRequest.md +20 -0
  21. data/docs/PaymentMethodsApi.md +1 -1
  22. data/docs/SubscriptionResponse.md +2 -0
  23. data/lib/conekta/models/charge_request.rb +1 -0
  24. data/lib/conekta/models/charge_request_payment_method.rb +74 -239
  25. data/lib/conekta/models/charge_response.rb +4 -0
  26. data/lib/conekta/models/charges_data_response.rb +4 -0
  27. data/lib/conekta/models/checkout.rb +11 -1
  28. data/lib/conekta/models/create_customer_payment_methods_request.rb +2 -2
  29. data/lib/conekta/models/customer_payment_methods_request.rb +2 -2
  30. data/lib/conekta/models/order_refund_request.rb +2 -0
  31. data/lib/conekta/models/order_request.rb +1 -1
  32. data/lib/conekta/models/payment_method_bank_transfer.rb +14 -5
  33. data/lib/conekta/models/payment_method_card.rb +22 -4
  34. data/lib/conekta/models/payment_method_card_request.rb +174 -12
  35. data/lib/conekta/models/payment_method_cash.rb +13 -4
  36. data/lib/conekta/models/payment_method_general_request.rb +291 -0
  37. data/lib/conekta/models/payment_method_token_request.rb +246 -0
  38. data/lib/conekta/models/subscription_response.rb +11 -1
  39. data/lib/conekta/version.rb +1 -1
  40. data/lib/conekta.rb +2 -0
  41. data/spec/api/charges_api_spec.rb +18 -10
  42. data/spec/api/customers_api_spec.rb +10 -4
  43. data/spec/api/orders_api_spec.rb +6 -6
  44. metadata +27 -23
@@ -0,0 +1,246 @@
1
+ =begin
2
+ #Conekta API
3
+
4
+ #Conekta sdk
5
+
6
+ The version of the OpenAPI document: 2.1.0
7
+ Contact: engineering@conekta.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Conekta
17
+ class PaymentMethodTokenRequest
18
+ # Type of payment method
19
+ attr_accessor :type
20
+
21
+ # Token id that will be used to create a \"card\" type payment method. See the (subscriptions)[https://developers.conekta.com/v2.1.0/reference/createsubscription] tutorial for more information on how to tokenize cards.
22
+ attr_accessor :token_id
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'type' => :'type',
28
+ :'token_id' => :'token_id'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'type' => :'String',
41
+ :'token_id' => :'String'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # List of class defined in allOf (OpenAPI v3)
52
+ def self.openapi_all_of
53
+ [
54
+ :'CustomerPaymentMethodRequest'
55
+ ]
56
+ end
57
+
58
+ # Initializes the object
59
+ # @param [Hash] attributes Model attributes in the form of hash
60
+ def initialize(attributes = {})
61
+ if (!attributes.is_a?(Hash))
62
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Conekta::PaymentMethodTokenRequest` initialize method"
63
+ end
64
+
65
+ # check to see if the attribute exists and convert string to symbol for hash key
66
+ attributes = attributes.each_with_object({}) { |(k, v), h|
67
+ if (!self.class.attribute_map.key?(k.to_sym))
68
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Conekta::PaymentMethodTokenRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
69
+ end
70
+ h[k.to_sym] = v
71
+ }
72
+
73
+ if attributes.key?(:'type')
74
+ self.type = attributes[:'type']
75
+ else
76
+ self.type = nil
77
+ end
78
+
79
+ if attributes.key?(:'token_id')
80
+ self.token_id = attributes[:'token_id']
81
+ else
82
+ self.token_id = nil
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
90
+ invalid_properties = Array.new
91
+ if @type.nil?
92
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
93
+ end
94
+
95
+ if @token_id.nil?
96
+ invalid_properties.push('invalid value for "token_id", token_id cannot be nil.')
97
+ end
98
+
99
+ invalid_properties
100
+ end
101
+
102
+ # Check to see if the all the properties in the model are valid
103
+ # @return true if the model is valid
104
+ def valid?
105
+ warn '[DEPRECATED] the `valid?` method is obsolete'
106
+ return false if @type.nil?
107
+ return false if @token_id.nil?
108
+ true
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ type == o.type &&
117
+ token_id == o.token_id
118
+ end
119
+
120
+ # @see the `==` method
121
+ # @param [Object] Object to be compared
122
+ def eql?(o)
123
+ self == o
124
+ end
125
+
126
+ # Calculates hash code according to all attributes.
127
+ # @return [Integer] Hash code
128
+ def hash
129
+ [type, token_id].hash
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def self.build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ attributes = attributes.transform_keys(&:to_sym)
138
+ transformed_hash = {}
139
+ openapi_types.each_pair do |key, type|
140
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
141
+ transformed_hash["#{key}"] = nil
142
+ elsif type =~ /\AArray<(.*)>/i
143
+ # check to ensure the input is an array given that the attribute
144
+ # is documented as an array but the input is not
145
+ if attributes[attribute_map[key]].is_a?(Array)
146
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
147
+ end
148
+ elsif !attributes[attribute_map[key]].nil?
149
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
150
+ end
151
+ end
152
+ new(transformed_hash)
153
+ end
154
+
155
+ # Deserializes the data based on type
156
+ # @param string type Data type
157
+ # @param string value Value to be deserialized
158
+ # @return [Object] Deserialized data
159
+ def self._deserialize(type, value)
160
+ case type.to_sym
161
+ when :Time
162
+ Time.parse(value)
163
+ when :Date
164
+ Date.parse(value)
165
+ when :String
166
+ value.to_s
167
+ when :Integer
168
+ value.to_i
169
+ when :Float
170
+ value.to_f
171
+ when :Boolean
172
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
173
+ true
174
+ else
175
+ false
176
+ end
177
+ when :Object
178
+ # generic object (usually a Hash), return directly
179
+ value
180
+ when /\AArray<(?<inner_type>.+)>\z/
181
+ inner_type = Regexp.last_match[:inner_type]
182
+ value.map { |v| _deserialize(inner_type, v) }
183
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
184
+ k_type = Regexp.last_match[:k_type]
185
+ v_type = Regexp.last_match[:v_type]
186
+ {}.tap do |hash|
187
+ value.each do |k, v|
188
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
189
+ end
190
+ end
191
+ else # model
192
+ # models (e.g. Pet) or oneOf
193
+ klass = Conekta.const_get(type)
194
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
195
+ end
196
+ end
197
+
198
+ # Returns the string representation of the object
199
+ # @return [String] String presentation of the object
200
+ def to_s
201
+ to_hash.to_s
202
+ end
203
+
204
+ # to_body is an alias to to_hash (backward compatibility)
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_body
207
+ to_hash
208
+ end
209
+
210
+ # Returns the object in the form of hash
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_hash
213
+ hash = {}
214
+ self.class.attribute_map.each_pair do |attr, param|
215
+ value = self.send(attr)
216
+ if value.nil?
217
+ is_nullable = self.class.openapi_nullable.include?(attr)
218
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
219
+ end
220
+
221
+ hash[param] = _to_hash(value)
222
+ end
223
+ hash
224
+ end
225
+
226
+ # Outputs non-array value in the form of hash
227
+ # For object, use to_hash. Otherwise, just return the value
228
+ # @param [Object] value Any valid value
229
+ # @return [Hash] Returns the value in the form of hash
230
+ def _to_hash(value)
231
+ if value.is_a?(Array)
232
+ value.compact.map { |v| _to_hash(v) }
233
+ elsif value.is_a?(Hash)
234
+ {}.tap do |hash|
235
+ value.each { |k, v| hash[k] = _to_hash(v) }
236
+ end
237
+ elsif value.respond_to? :to_hash
238
+ value.to_hash
239
+ else
240
+ value
241
+ end
242
+ end
243
+
244
+ end
245
+
246
+ end
@@ -22,6 +22,9 @@ module Conekta
22
22
 
23
23
  attr_accessor :canceled_at
24
24
 
25
+ # Reason for cancellation. This field appears when the subscription status is 'canceled'.
26
+ attr_accessor :canceled_reason
27
+
25
28
  attr_accessor :card_id
26
29
 
27
30
  attr_accessor :charge_id
@@ -56,6 +59,7 @@ module Conekta
56
59
  :'billing_cycle_start' => :'billing_cycle_start',
57
60
  :'billing_cycle_end' => :'billing_cycle_end',
58
61
  :'canceled_at' => :'canceled_at',
62
+ :'canceled_reason' => :'canceled_reason',
59
63
  :'card_id' => :'card_id',
60
64
  :'charge_id' => :'charge_id',
61
65
  :'created_at' => :'created_at',
@@ -84,6 +88,7 @@ module Conekta
84
88
  :'billing_cycle_start' => :'Integer',
85
89
  :'billing_cycle_end' => :'Integer',
86
90
  :'canceled_at' => :'Integer',
91
+ :'canceled_reason' => :'String',
87
92
  :'card_id' => :'String',
88
93
  :'charge_id' => :'String',
89
94
  :'created_at' => :'Integer',
@@ -141,6 +146,10 @@ module Conekta
141
146
  self.canceled_at = attributes[:'canceled_at']
142
147
  end
143
148
 
149
+ if attributes.key?(:'canceled_reason')
150
+ self.canceled_reason = attributes[:'canceled_reason']
151
+ end
152
+
144
153
  if attributes.key?(:'card_id')
145
154
  self.card_id = attributes[:'card_id']
146
155
  end
@@ -221,6 +230,7 @@ module Conekta
221
230
  billing_cycle_start == o.billing_cycle_start &&
222
231
  billing_cycle_end == o.billing_cycle_end &&
223
232
  canceled_at == o.canceled_at &&
233
+ canceled_reason == o.canceled_reason &&
224
234
  card_id == o.card_id &&
225
235
  charge_id == o.charge_id &&
226
236
  created_at == o.created_at &&
@@ -246,7 +256,7 @@ module Conekta
246
256
  # Calculates hash code according to all attributes.
247
257
  # @return [Integer] Hash code
248
258
  def hash
249
- [billing_cycle_start, billing_cycle_end, canceled_at, card_id, charge_id, created_at, customer_custom_reference, customer_id, id, last_billing_cycle_order_id, object, paused_at, plan_id, status, subscription_start, trial_start, trial_end].hash
259
+ [billing_cycle_start, billing_cycle_end, canceled_at, canceled_reason, card_id, charge_id, created_at, customer_custom_reference, customer_id, id, last_billing_cycle_order_id, object, paused_at, plan_id, status, subscription_start, trial_start, trial_end].hash
250
260
  end
251
261
 
252
262
  # Builds the object from hash
@@ -11,5 +11,5 @@ Generator version: 7.5.0
11
11
  =end
12
12
 
13
13
  module Conekta
14
- VERSION = '6.0.3'
14
+ VERSION = '6.0.4'
15
15
  end
data/lib/conekta.rb CHANGED
@@ -136,9 +136,11 @@ require 'conekta/models/payment_method_card_response'
136
136
  require 'conekta/models/payment_method_cash'
137
137
  require 'conekta/models/payment_method_cash_request'
138
138
  require 'conekta/models/payment_method_cash_response'
139
+ require 'conekta/models/payment_method_general_request'
139
140
  require 'conekta/models/payment_method_response'
140
141
  require 'conekta/models/payment_method_spei_recurrent'
141
142
  require 'conekta/models/payment_method_spei_request'
143
+ require 'conekta/models/payment_method_token_request'
142
144
  require 'conekta/models/payout'
143
145
  require 'conekta/models/payout_method'
144
146
  require 'conekta/models/payout_order'
@@ -75,12 +75,16 @@ describe 'ChargesApi' do
75
75
  describe 'orders_create_charge test' do
76
76
  it 'card' do
77
77
  id = 'ord_2tVKxbhNzfUnGjnXG'
78
+
79
+ payment_method_data = {
80
+ type: 'card',
81
+ token_id: 'ttest5214'
82
+ }
83
+
84
+ payment_method = Conekta::ChargeRequestPaymentMethod.build(payment_method_data)
78
85
  charge_request = Conekta::ChargeRequest.new({
79
86
  amount: 40000,
80
- payment_method: Conekta::ChargeRequestPaymentMethod.new({
81
- type: 'card',
82
- token_id: 'tok_2tVKyGpobEKAR3xVH'
83
- })
87
+ payment_method: payment_method
84
88
  })
85
89
  response = @api_instance.orders_create_charge(id, charge_request)
86
90
 
@@ -95,11 +99,13 @@ describe 'ChargesApi' do
95
99
 
96
100
  it 'cash' do
97
101
  id = "ord_2tVL8dT1Hm3y3YiaN"
102
+ payment_method_data = {
103
+ type: 'cash',
104
+ }
105
+ payment_method = Conekta::ChargeRequestPaymentMethod.build(payment_method_data)
98
106
  charge_request = Conekta::ChargeRequest.new({
99
107
  amount: 40000,
100
- payment_method: Conekta::ChargeRequestPaymentMethod.new({
101
- type: 'cash',
102
- })
108
+ payment_method: payment_method
103
109
  })
104
110
  response = @api_instance.orders_create_charge(id,charge_request)
105
111
 
@@ -117,11 +123,13 @@ describe 'ChargesApi' do
117
123
  end
118
124
  it 'spei' do
119
125
  id = "ord_2tVLUFrQBB4HKz1zj"
126
+ payment_method_data = {
127
+ type: 'spei',
128
+ }
129
+ payment_method = Conekta::ChargeRequestPaymentMethod.build(payment_method_data)
120
130
  charge_request = Conekta::ChargeRequest.new({
121
131
  amount: 40000,
122
- payment_method: Conekta::ChargeRequestPaymentMethod.new({
123
- type: 'spei',
124
- })
132
+ payment_method: payment_method
125
133
  })
126
134
  response = @api_instance.orders_create_charge(id,charge_request)
127
135
 
@@ -265,11 +265,17 @@ describe 'CustomersApi' do
265
265
  })
266
266
 
267
267
  payment_sources = Array.new(1)
268
+ payment_method_data = {
269
+ type: 'card',
270
+ cvc: '123',
271
+ exp_month: '12',
272
+ exp_year: '2025',
273
+ name: 'John Doe',
274
+ number: '4242424242424242',
275
+ customer_ip_address: '127.0.0.1'
276
+ }
268
277
  payment_sources[0] =
269
- Conekta::PaymentMethodCardRequest.new({
270
- type: 'card',
271
- token_id: 'tok_2tXyExrU6U7yiaTto'
272
- })
278
+ Conekta::PaymentMethodCardRequest.new(payment_method_data)
273
279
  shipping_contacts = Array.new(1)
274
280
  shipping_contacts[0] = Conekta::CustomerShippingContacts.new({
275
281
  address: Conekta::CustomerShippingContactsAddress.new({
@@ -83,14 +83,14 @@ describe 'OrdersApi' do
83
83
  unit_price: 1555
84
84
  })
85
85
  ]
86
+ payment_method_data = {
87
+ expires_at: unix_timestamp,
88
+ type: 'cash'
89
+ }
86
90
  charges = Array.new(1)
91
+ payment_method = Conekta::ChargeRequestPaymentMethod.build(payment_method_data)
87
92
  charges[0] = Conekta::ChargeRequest.new({ amount: 1555,
88
- payment_method: Conekta::ChargeRequestPaymentMethod.new(
89
- {
90
- expires_at: unix_timestamp,
91
- type: 'cash'
92
- }
93
- )
93
+ payment_method: Conekta::ChargeRequestPaymentMethod.build(payment_method_data)
94
94
  })
95
95
  request = Conekta::OrderRequest.new(
96
96
  {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conekta
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.3
4
+ version: 6.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conekta
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-29 00:00:00.000000000 Z
11
+ date: 2024-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -228,9 +228,11 @@ files:
228
228
  - docs/PaymentMethodCash.md
229
229
  - docs/PaymentMethodCashRequest.md
230
230
  - docs/PaymentMethodCashResponse.md
231
+ - docs/PaymentMethodGeneralRequest.md
231
232
  - docs/PaymentMethodResponse.md
232
233
  - docs/PaymentMethodSpeiRecurrent.md
233
234
  - docs/PaymentMethodSpeiRequest.md
235
+ - docs/PaymentMethodTokenRequest.md
234
236
  - docs/PaymentMethodsApi.md
235
237
  - docs/Payout.md
236
238
  - docs/PayoutMethod.md
@@ -479,10 +481,12 @@ files:
479
481
  - lib/conekta/models/payment_method_cash_request_all_of.rb
480
482
  - lib/conekta/models/payment_method_cash_response.rb
481
483
  - lib/conekta/models/payment_method_cash_response_all_of.rb
484
+ - lib/conekta/models/payment_method_general_request.rb
482
485
  - lib/conekta/models/payment_method_response.rb
483
486
  - lib/conekta/models/payment_method_spei_recurrent.rb
484
487
  - lib/conekta/models/payment_method_spei_recurrent_all_of.rb
485
488
  - lib/conekta/models/payment_method_spei_request.rb
489
+ - lib/conekta/models/payment_method_token_request.rb
486
490
  - lib/conekta/models/payout.rb
487
491
  - lib/conekta/models/payout_method.rb
488
492
  - lib/conekta/models/payout_order.rb
@@ -577,7 +581,7 @@ homepage: https://www.conekta.com
577
581
  licenses:
578
582
  - MIT
579
583
  metadata: {}
580
- post_install_message:
584
+ post_install_message:
581
585
  rdoc_options: []
582
586
  require_paths:
583
587
  - lib
@@ -593,35 +597,35 @@ required_rubygems_version: !ruby/object:Gem::Requirement
593
597
  version: '0'
594
598
  requirements: []
595
599
  rubygems_version: 3.3.27
596
- signing_key:
600
+ signing_key:
597
601
  specification_version: 4
598
602
  summary: This library provides https://api.conekta.io operations
599
603
  test_files:
600
- - spec/api/webhook_keys_api_spec.rb
601
- - spec/api/charges_api_spec.rb
602
- - spec/api/transfers_api_spec.rb
603
- - spec/api/api_keys_api_spec.rb
604
- - spec/api/orders_api_spec.rb
604
+ - spec/api/transactions_api_spec.rb
605
605
  - spec/api/payment_methods_api_spec.rb
606
- - spec/api/payment_link_api_spec.rb
607
- - spec/api/balances_api_spec.rb
608
- - spec/api/plans_api_spec.rb
609
- - spec/api/logs_api_spec.rb
610
- - spec/api/products_api_spec.rb
606
+ - spec/api/customers_api_spec.rb
607
+ - spec/api/events_api_spec.rb
608
+ - spec/api/api_keys_api_spec.rb
609
+ - spec/api/taxes_api_spec.rb
611
610
  - spec/api/base_test.rb
611
+ - spec/api/transfers_api_spec.rb
612
+ - spec/api/subscriptions_api_spec.rb
613
+ - spec/api/webhooks_api_spec.rb
614
+ - spec/api/charges_api_spec.rb
615
+ - spec/api/orders_api_spec.rb
612
616
  - spec/api/shipping_contacts_api_spec.rb
613
617
  - spec/api/discounts_api_spec.rb
614
- - spec/api/subscriptions_api_spec.rb
615
- - spec/api/tokens_api_spec.rb
616
- - spec/api/events_api_spec.rb
618
+ - spec/api/payment_link_api_spec.rb
617
619
  - spec/api/payout_orders_api_spec.rb
618
- - spec/api/webhooks_api_spec.rb
619
- - spec/api/antifraud_api_spec.rb
620
620
  - spec/api/companies_api_spec.rb
621
- - spec/api/transactions_api_spec.rb
622
- - spec/api/taxes_api_spec.rb
621
+ - spec/api/products_api_spec.rb
622
+ - spec/api/tokens_api_spec.rb
623
+ - spec/api/logs_api_spec.rb
624
+ - spec/api/plans_api_spec.rb
623
625
  - spec/api/shippings_api_spec.rb
624
- - spec/api/customers_api_spec.rb
626
+ - spec/api/antifraud_api_spec.rb
627
+ - spec/api/balances_api_spec.rb
628
+ - spec/api/webhook_keys_api_spec.rb
625
629
  - spec/api_client_spec.rb
626
630
  - spec/configuration_spec.rb
627
631
  - spec/spec_helper.rb