digital_femsa 1.0.0 → 1.1.1
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.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +104 -0
- data/Makefile +14 -0
- data/README.md +28 -33
- data/VERSION +1 -1
- data/config-ruby.json +1 -1
- data/digital_femsa.gemspec +1 -1
- data/docs/ApiKeyCreateResponse.md +1 -1
- data/docs/ApiKeyRequest.md +2 -2
- data/docs/ApiKeyResponseOnDelete.md +2 -2
- data/docs/ApiKeysApi.md +10 -10
- data/docs/BalanceResponse.md +8 -8
- data/docs/BalancesApi.md +1 -1
- data/docs/ChargeOrderResponse.md +1 -1
- data/docs/ChargeOrderResponseChannel.md +24 -0
- data/docs/ChargeRequest.md +1 -1
- data/docs/ChargeRequestPaymentMethod.md +3 -3
- data/docs/ChargeResponse.md +9 -7
- data/docs/ChargeResponseChannel.md +3 -3
- data/docs/ChargeResponseRefundsData.md +5 -1
- data/docs/ChargesApi.md +16 -12
- data/docs/ChargesDataResponse.md +9 -7
- data/docs/Checkout.md +17 -15
- data/docs/CheckoutOrderTemplate.md +3 -3
- data/docs/CheckoutResponse.md +1 -1
- data/docs/CreateCustomerFiscalEntitiesResponse.md +2 -2
- data/docs/Customer.md +13 -19
- data/docs/CustomerAddress.md +2 -2
- data/docs/CustomerFiscalEntitiesDataResponse.md +2 -2
- data/docs/CustomerFiscalEntitiesRequest.md +3 -3
- data/docs/CustomerInfo.md +4 -4
- data/docs/CustomerPaymentMethodRequest.md +1 -1
- data/docs/CustomerResponse.md +17 -21
- data/docs/CustomerShippingContactsResponse.md +5 -5
- data/docs/CustomersApi.md +15 -15
- data/docs/CustomersResponse.md +1 -1
- data/docs/DeleteApiKeysResponse.md +1 -1
- data/docs/DiscountsApi.md +9 -9
- data/docs/EventsApi.md +2 -2
- data/docs/EventsResendResponse.md +1 -1
- data/docs/GetChargesResponse.md +4 -4
- data/docs/GetTransactionsResponse.md +1 -1
- data/docs/LogsApi.md +1 -1
- data/docs/OrderFiscalEntityRequest.md +4 -4
- data/docs/OrderRefundRequest.md +7 -5
- data/docs/OrderRequest.md +17 -19
- data/docs/OrderResponse.md +37 -35
- data/docs/OrderResponseChannel.md +24 -0
- data/docs/OrderResponseShippingContact.md +4 -4
- data/docs/OrderUpdateFiscalEntityRequest.md +1 -1
- data/docs/OrderUpdateRequest.md +19 -15
- data/docs/OrdersApi.md +16 -16
- data/docs/PaymentLinkApi.md +12 -82
- data/docs/PaymentMethodCash.md +4 -4
- data/docs/PaymentMethodCashRequest.md +2 -2
- data/docs/PaymentMethodsApi.md +5 -5
- data/docs/Product.md +10 -12
- data/docs/ProductDataResponse.md +9 -11
- data/docs/ProductOrderResponse.md +9 -11
- data/docs/ProductsApi.md +7 -7
- data/docs/ShippingContactsApi.md +9 -9
- data/docs/ShippingOrderResponse.md +5 -3
- data/docs/ShippingRequest.md +2 -0
- data/docs/ShippingsApi.md +7 -7
- data/docs/TaxesApi.md +7 -7
- data/docs/TransactionResponse.md +20 -14
- data/docs/TransactionsApi.md +6 -6
- data/docs/TransfersApi.md +10 -10
- data/docs/UpdateCustomer.md +17 -21
- data/docs/UpdateCustomerFiscalEntitiesResponse.md +2 -2
- data/docs/UpdateOrderTaxRequest.md +2 -2
- data/docs/UpdateProduct.md +7 -9
- data/docs/WebhookKeysApi.md +18 -14
- data/docs/WebhooksApi.md +28 -22
- data/lib/digital_femsa/api/api_keys_api.rb +8 -8
- data/lib/digital_femsa/api/balances_api.rb +2 -2
- data/lib/digital_femsa/api/charges_api.rb +13 -9
- data/lib/digital_femsa/api/customers_api.rb +12 -12
- data/lib/digital_femsa/api/discounts_api.rb +12 -12
- data/lib/digital_femsa/api/events_api.rb +4 -4
- data/lib/digital_femsa/api/logs_api.rb +2 -2
- data/lib/digital_femsa/api/orders_api.rb +20 -20
- data/lib/digital_femsa/api/payment_link_api.rb +10 -86
- data/lib/digital_femsa/api/payment_methods_api.rb +8 -8
- data/lib/digital_femsa/api/products_api.rb +10 -10
- data/lib/digital_femsa/api/shipping_contacts_api.rb +8 -8
- data/lib/digital_femsa/api/shippings_api.rb +10 -10
- data/lib/digital_femsa/api/taxes_api.rb +10 -10
- data/lib/digital_femsa/api/transactions_api.rb +6 -6
- data/lib/digital_femsa/api/transfers_api.rb +8 -8
- data/lib/digital_femsa/api/webhook_keys_api.rb +14 -10
- data/lib/digital_femsa/api/webhooks_api.rb +23 -16
- data/lib/digital_femsa/api_client.rb +9 -5
- data/lib/digital_femsa/models/api_key_create_response.rb +1 -1
- data/lib/digital_femsa/models/api_key_request.rb +36 -1
- data/lib/digital_femsa/models/balance_response.rb +9 -9
- data/lib/digital_femsa/models/charge_order_response.rb +1 -1
- data/lib/digital_femsa/models/{order_next_action_response.rb → charge_order_response_channel.rb} +34 -18
- data/lib/digital_femsa/models/charge_request_payment_method.rb +3 -2
- data/lib/digital_femsa/models/charge_response.rb +15 -4
- data/lib/digital_femsa/models/charge_response_refunds_data.rb +23 -4
- data/lib/digital_femsa/models/charge_update_request.rb +1 -1
- data/lib/digital_femsa/models/charges_data_response.rb +15 -4
- data/lib/digital_femsa/models/checkout.rb +97 -81
- data/lib/digital_femsa/models/checkout_order_template.rb +4 -4
- data/lib/digital_femsa/models/checkout_order_template_customer_info.rb +1 -1
- data/lib/digital_femsa/models/checkout_request.rb +1 -1
- data/lib/digital_femsa/models/checkout_response.rb +1 -1
- data/lib/digital_femsa/models/create_customer_fiscal_entities_response.rb +10 -10
- data/lib/digital_femsa/models/customer.rb +57 -95
- data/lib/digital_femsa/models/customer_address.rb +7 -0
- data/lib/digital_femsa/models/customer_fiscal_entities_data_response.rb +10 -10
- data/lib/digital_femsa/models/customer_fiscal_entities_request.rb +13 -13
- data/lib/digital_femsa/models/customer_info.rb +13 -20
- data/lib/digital_femsa/models/customer_payment_method_request.rb +2 -2
- data/lib/digital_femsa/models/customer_payment_sources_inner.rb +104 -0
- data/lib/digital_femsa/models/customer_response.rb +122 -113
- data/lib/digital_femsa/models/customer_shipping_contacts_response.rb +2 -0
- data/lib/digital_femsa/models/customers_response.rb +1 -0
- data/lib/digital_femsa/models/events_resend_response.rb +1 -1
- data/lib/digital_femsa/models/get_charges_response.rb +21 -21
- data/lib/digital_femsa/models/get_transactions_response.rb +1 -1
- data/lib/digital_femsa/models/log_response.rb +1 -1
- data/lib/digital_femsa/models/logs_response.rb +1 -1
- data/lib/digital_femsa/models/order_fiscal_entity_response.rb +1 -1
- data/lib/digital_femsa/models/order_refund_request.rb +59 -11
- data/lib/digital_femsa/models/order_request.rb +69 -79
- data/lib/digital_femsa/models/order_response.rb +187 -119
- data/lib/digital_femsa/models/{order_next_action_response_redirect_to_url.rb → order_response_channel.rb} +35 -19
- data/lib/digital_femsa/models/order_response_charges.rb +1 -1
- data/lib/digital_femsa/models/order_response_checkout.rb +1 -0
- data/lib/digital_femsa/models/order_response_customer_info.rb +1 -0
- data/lib/digital_femsa/models/order_response_shipping_contact.rb +3 -0
- data/lib/digital_femsa/models/order_update_fiscal_entity_request.rb +1 -1
- data/lib/digital_femsa/models/order_update_request.rb +106 -65
- data/lib/digital_femsa/models/payment_method_cash.rb +1 -1
- data/lib/digital_femsa/models/payment_method_cash_request.rb +2 -1
- data/lib/digital_femsa/models/product.rb +103 -95
- data/lib/digital_femsa/models/product_data_response.rb +103 -95
- data/lib/digital_femsa/models/product_order_response.rb +103 -95
- data/lib/digital_femsa/models/shipping_order_response.rb +11 -1
- data/lib/digital_femsa/models/shipping_request.rb +12 -1
- data/lib/digital_femsa/models/transaction_response.rb +172 -99
- data/lib/digital_femsa/models/transfers_response.rb +1 -1
- data/lib/digital_femsa/models/transfers_response_destination.rb +312 -0
- data/lib/digital_femsa/models/update_customer.rb +42 -85
- data/lib/digital_femsa/models/update_customer_fiscal_entities_response.rb +10 -10
- data/lib/digital_femsa/models/update_order_discount_lines_request.rb +34 -0
- data/lib/digital_femsa/models/update_order_tax_request.rb +2 -2
- data/lib/digital_femsa/models/update_payment_methods_amount.rb +105 -0
- data/lib/digital_femsa/models/update_payment_methods_expires_at.rb +105 -0
- data/lib/digital_femsa/models/update_product.rb +85 -58
- data/lib/digital_femsa/models/webhook_key_delete_response.rb +1 -1
- data/lib/digital_femsa/models/webhook_key_request.rb +1 -0
- data/lib/digital_femsa/models/webhook_key_response.rb +1 -1
- data/lib/digital_femsa/models/webhook_request.rb +248 -9
- data/lib/digital_femsa/models/webhook_response.rb +1 -1
- data/lib/digital_femsa/models/webhook_update_request.rb +1 -1
- data/lib/digital_femsa/version.rb +1 -1
- data/lib/digital_femsa.rb +2 -6
- data/spec/api/balances_api_spec.rb +24 -22
- data/spec/api/charges_api_spec.rb +92 -49
- data/spec/api/companies_api_spec.rb +57 -35
- data/spec/api/customers_api_spec.rb +115 -99
- data/spec/api/events_api_spec.rb +72 -48
- data/spec/api/generated_apis_coverage_spec.rb +94 -0
- data/spec/api/logs_api_spec.rb +57 -38
- data/spec/api/orders_api_spec.rb +134 -108
- data/spec/api/payment_link_api_spec.rb +91 -81
- data/spec/api/payment_methods_api_spec.rb +102 -65
- data/spec/api/transactions_api_spec.rb +63 -41
- data/spec/api/transfers_api_spec.rb +57 -38
- data/spec/api/webhook_keys_api_spec.rb +87 -68
- data/spec/api/webhooks_api_spec.rb +110 -79
- data/spec/api_client_spec.rb +259 -0
- data/spec/models/generated_models_coverage_spec.rb +152 -0
- data/spec/models/webhook_request_ssrf_protection_spec.rb +275 -0
- data/spec/spec_helper.rb +37 -0
- data/templates/ruby/api_client.mustache +8 -4
- metadata +40 -37
- data/docs/CustomerAntifraudInfo.md +0 -20
- data/docs/CustomerAntifraudInfoResponse.md +0 -20
- data/docs/OrderNextActionResponse.md +0 -20
- data/docs/OrderNextActionResponseRedirectToUrl.md +0 -20
- data/docs/SmsCheckoutRequest.md +0 -18
- data/docs/UpdateCustomerAntifraudInfo.md +0 -20
|
@@ -12,9 +12,10 @@ Generator version: 7.5.0
|
|
|
12
12
|
|
|
13
13
|
require 'date'
|
|
14
14
|
require 'time'
|
|
15
|
+
require 'uri'
|
|
15
16
|
|
|
16
17
|
module DigitalFemsa
|
|
17
|
-
# a webhook
|
|
18
|
+
# Parameters used to create or update a webhook.
|
|
18
19
|
class WebhookRequest
|
|
19
20
|
# Here you must place the URL of your Webhook remember that you must program what you will do with the events received. Also do not forget to handle the HTTPS protocol for greater security.
|
|
20
21
|
attr_accessor :url
|
|
@@ -86,9 +87,10 @@ module DigitalFemsa
|
|
|
86
87
|
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
|
87
88
|
end
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
begin
|
|
91
|
+
validate_url_safety(@url) if @url
|
|
92
|
+
rescue ArgumentError => e
|
|
93
|
+
invalid_properties.push(e.message)
|
|
92
94
|
end
|
|
93
95
|
|
|
94
96
|
if @synchronous.nil?
|
|
@@ -103,7 +105,11 @@ module DigitalFemsa
|
|
|
103
105
|
def valid?
|
|
104
106
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
105
107
|
return false if @url.nil?
|
|
106
|
-
|
|
108
|
+
begin
|
|
109
|
+
validate_url_safety(@url)
|
|
110
|
+
rescue ArgumentError
|
|
111
|
+
return false
|
|
112
|
+
end
|
|
107
113
|
return false if @synchronous.nil?
|
|
108
114
|
true
|
|
109
115
|
end
|
|
@@ -115,12 +121,245 @@ module DigitalFemsa
|
|
|
115
121
|
fail ArgumentError, 'url cannot be nil'
|
|
116
122
|
end
|
|
117
123
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
124
|
+
validate_url_safety(url)
|
|
125
|
+
@url = url
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
private
|
|
129
|
+
|
|
130
|
+
# Comprehensive URL validation to prevent SSRF attacks
|
|
131
|
+
# @param [String] url URL to validate
|
|
132
|
+
def validate_url_safety(url)
|
|
133
|
+
# Parse the URL to extract hostname
|
|
134
|
+
begin
|
|
135
|
+
uri = URI.parse(url)
|
|
136
|
+
hostname = uri.hostname
|
|
137
|
+
port = uri.port
|
|
138
|
+
|
|
139
|
+
# Ensure URL has a valid scheme (http/https)
|
|
140
|
+
unless uri.scheme =~ /\A(https?)\z/
|
|
141
|
+
fail ArgumentError, "invalid value for \"url\", must use http or https scheme"
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Block if hostname is nil or empty
|
|
145
|
+
if hostname.nil? || hostname.empty?
|
|
146
|
+
fail ArgumentError, "invalid value for \"url\", hostname cannot be empty"
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Block localhost variations and private IP ranges
|
|
150
|
+
if hostname_matches_restricted_patterns?(hostname)
|
|
151
|
+
fail ArgumentError, "invalid value for \"url\", hostname points to restricted network resource"
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Block ports commonly used for internal services
|
|
155
|
+
if port_matches_restricted_ports?(port)
|
|
156
|
+
fail ArgumentError, "invalid value for \"url\", port is not allowed"
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
rescue URI::InvalidURIError
|
|
160
|
+
fail ArgumentError, "invalid value for \"url\", must be a valid URL"
|
|
121
161
|
end
|
|
162
|
+
end
|
|
122
163
|
|
|
123
|
-
|
|
164
|
+
# Check if hostname matches restricted patterns
|
|
165
|
+
# @param [String] hostname Hostname to check
|
|
166
|
+
# @return [Boolean] true if hostname is restricted
|
|
167
|
+
def hostname_matches_restricted_patterns?(hostname)
|
|
168
|
+
# Convert to lowercase for case-insensitive comparison
|
|
169
|
+
hostname = hostname.downcase
|
|
170
|
+
|
|
171
|
+
# Block localhost variations
|
|
172
|
+
localhost_patterns = [
|
|
173
|
+
'localhost',
|
|
174
|
+
'127.0.0.1',
|
|
175
|
+
'127.0.0.0',
|
|
176
|
+
'0.0.0.0',
|
|
177
|
+
'::1',
|
|
178
|
+
'0:0:0:0:0:0:0:1',
|
|
179
|
+
'ip6-localhost',
|
|
180
|
+
'ip6-loopback'
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
# Block private IP ranges
|
|
184
|
+
private_ip_patterns = [
|
|
185
|
+
/^127\.\d+\.\d+\.\d+/, # 127.0.0.0/8 (loopback)
|
|
186
|
+
/^10\.\d+\.\d+\.\d+/, # 10.0.0.0/8
|
|
187
|
+
/^172\.(1[6-9]|2[0-9]|3[0-1])\.\d+\.\d+/, # 172.16.0.0/12
|
|
188
|
+
/^192\.168\.\d+\.\d+/, # 192.168.0.0/16
|
|
189
|
+
/^169\.254\.\d+\.\d+/, # 169.254.0.0/16 (link-local)
|
|
190
|
+
/^224\.\d+\.\d+\.\d+/, # 224.0.0.0/4 (multicast)
|
|
191
|
+
/^fc00:/, # fc00::/7 (IPv6 unique local)
|
|
192
|
+
/^fe80:/, # fe80::/10 (IPv6 link-local)
|
|
193
|
+
/^ff00:/ # ff00::/8 (IPv6 multicast)
|
|
194
|
+
]
|
|
195
|
+
|
|
196
|
+
# Block internal hostnames and services
|
|
197
|
+
internal_hostnames = [
|
|
198
|
+
'internal',
|
|
199
|
+
'intranet',
|
|
200
|
+
'corp',
|
|
201
|
+
'private',
|
|
202
|
+
'admin',
|
|
203
|
+
'management',
|
|
204
|
+
'api-gateway',
|
|
205
|
+
'database',
|
|
206
|
+
'cache',
|
|
207
|
+
'redis',
|
|
208
|
+
'mongo',
|
|
209
|
+
'mysql',
|
|
210
|
+
'postgres',
|
|
211
|
+
'elasticsearch',
|
|
212
|
+
'kibana',
|
|
213
|
+
'grafana',
|
|
214
|
+
'prometheus',
|
|
215
|
+
'consul',
|
|
216
|
+
'vault',
|
|
217
|
+
'etcd',
|
|
218
|
+
'zookeeper',
|
|
219
|
+
'kafka',
|
|
220
|
+
'rabbitmq'
|
|
221
|
+
]
|
|
222
|
+
|
|
223
|
+
# Check localhost patterns
|
|
224
|
+
return true if localhost_patterns.include?(hostname)
|
|
225
|
+
|
|
226
|
+
# Check private IP ranges
|
|
227
|
+
private_ip_patterns.each do |pattern|
|
|
228
|
+
return true if hostname.match?(pattern)
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
# Check internal hostnames (including subdomains)
|
|
232
|
+
internal_hostnames.each do |internal_name|
|
|
233
|
+
return true if hostname.include?(internal_name)
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# Check for common DNS rebinding services
|
|
237
|
+
dns_rebinding_domains = [
|
|
238
|
+
'xip.io',
|
|
239
|
+
'nip.io',
|
|
240
|
+
'sslip.io',
|
|
241
|
+
'localtest.me',
|
|
242
|
+
'vcap.me',
|
|
243
|
+
'localho.st',
|
|
244
|
+
'127-0-0-1.org.uk'
|
|
245
|
+
]
|
|
246
|
+
|
|
247
|
+
dns_rebinding_domains.each do |domain|
|
|
248
|
+
return true if hostname.end_with?(domain)
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Check if hostname resolves to private IP (basic check)
|
|
252
|
+
# Note: In production, you might want to add actual DNS resolution here
|
|
253
|
+
if hostname_resolves_to_private_ip?(hostname)
|
|
254
|
+
return true
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
false
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
# Check if port matches restricted ports
|
|
261
|
+
# @param [Integer] port Port to check
|
|
262
|
+
# @return [Boolean] true if port is restricted
|
|
263
|
+
def port_matches_restricted_ports?(port)
|
|
264
|
+
return false if port.nil? # Allow default ports
|
|
265
|
+
|
|
266
|
+
# Block ports commonly used for internal services
|
|
267
|
+
restricted_ports = [
|
|
268
|
+
22, # SSH
|
|
269
|
+
23, # Telnet
|
|
270
|
+
25, # SMTP
|
|
271
|
+
53, # DNS
|
|
272
|
+
135, # Windows RPC
|
|
273
|
+
139, # NetBIOS
|
|
274
|
+
445, # SMB
|
|
275
|
+
1433, # SQL Server
|
|
276
|
+
1521, # Oracle
|
|
277
|
+
2049, # NFS
|
|
278
|
+
2181, # Zookeeper
|
|
279
|
+
3306, # MySQL
|
|
280
|
+
3389, # RDP
|
|
281
|
+
5432, # PostgreSQL
|
|
282
|
+
5672, # RabbitMQ
|
|
283
|
+
5984, # CouchDB
|
|
284
|
+
6379, # Redis
|
|
285
|
+
6380, # Redis SSL
|
|
286
|
+
8080, # Common internal web services
|
|
287
|
+
8081, # Alternative web services
|
|
288
|
+
8443, # Alternative HTTPS
|
|
289
|
+
9000, # Common internal services
|
|
290
|
+
9042, # Cassandra
|
|
291
|
+
9092, # Kafka
|
|
292
|
+
9200, # Elasticsearch
|
|
293
|
+
9300, # Elasticsearch transport
|
|
294
|
+
11211, # Memcached
|
|
295
|
+
27017, # MongoDB
|
|
296
|
+
27018, # MongoDB shard
|
|
297
|
+
27019, # MongoDB config
|
|
298
|
+
5000, # Common internal services
|
|
299
|
+
5001, # Alternative services
|
|
300
|
+
6000, # Common internal services
|
|
301
|
+
7000, # Common internal services
|
|
302
|
+
7001, # WebLogic
|
|
303
|
+
8000, # Common internal services
|
|
304
|
+
8001, # Alternative services
|
|
305
|
+
8009, # AJP
|
|
306
|
+
8443, # Tomcat SSL
|
|
307
|
+
8888, # Common internal services
|
|
308
|
+
9001, # Common internal services
|
|
309
|
+
9090, # Common internal services
|
|
310
|
+
9091, # Common internal services
|
|
311
|
+
9093, # Common internal services
|
|
312
|
+
9999, # Common internal services
|
|
313
|
+
10000, # Common internal services
|
|
314
|
+
10001, # Common internal services
|
|
315
|
+
10002, # Common internal services
|
|
316
|
+
10003, # Common internal services
|
|
317
|
+
10004, # Common internal services
|
|
318
|
+
10005, # Common internal services
|
|
319
|
+
10006, # Common internal services
|
|
320
|
+
10007, # Common internal services
|
|
321
|
+
10008, # Common internal services
|
|
322
|
+
10009, # Common internal services
|
|
323
|
+
10010 # Common internal services
|
|
324
|
+
]
|
|
325
|
+
|
|
326
|
+
restricted_ports.include?(port)
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
# Basic check if hostname might resolve to private IP
|
|
330
|
+
# @param [String] hostname Hostname to check
|
|
331
|
+
# @return [Boolean] true if hostname might resolve to private IP
|
|
332
|
+
def hostname_resolves_to_private_ip?(hostname)
|
|
333
|
+
# This is a basic heuristic. In production, you might want to
|
|
334
|
+
# actually resolve the hostname and check the IP addresses.
|
|
335
|
+
|
|
336
|
+
# Check for common patterns that might resolve to internal IPs
|
|
337
|
+
suspicious_patterns = [
|
|
338
|
+
/^internal-/,
|
|
339
|
+
/^private-/,
|
|
340
|
+
/^intranet-/,
|
|
341
|
+
/^corp-/,
|
|
342
|
+
/^dev-/,
|
|
343
|
+
/^test-/,
|
|
344
|
+
/^staging-/,
|
|
345
|
+
/^admin-/,
|
|
346
|
+
/^db-/,
|
|
347
|
+
/^cache-/,
|
|
348
|
+
/^api-/,
|
|
349
|
+
/^service-/,
|
|
350
|
+
/^worker-/,
|
|
351
|
+
/^node-/,
|
|
352
|
+
/^server-/,
|
|
353
|
+
/^host-/,
|
|
354
|
+
/^vm-/,
|
|
355
|
+
/^container-/
|
|
356
|
+
]
|
|
357
|
+
|
|
358
|
+
suspicious_patterns.each do |pattern|
|
|
359
|
+
return true if hostname.match?(pattern)
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
false
|
|
124
363
|
end
|
|
125
364
|
|
|
126
365
|
# Checks equality by comparing each attribute.
|
|
@@ -14,7 +14,7 @@ require 'date'
|
|
|
14
14
|
require 'time'
|
|
15
15
|
|
|
16
16
|
module DigitalFemsa
|
|
17
|
-
#
|
|
17
|
+
# Parameters used to update a webhook. All fields are optional; send only the fields you want to change.
|
|
18
18
|
class WebhookUpdateRequest
|
|
19
19
|
# Here you must place the URL of your Webhook remember that you must program what you will do with the events received. Also do not forget to handle the HTTPS protocol for greater security.
|
|
20
20
|
attr_accessor :url
|
data/lib/digital_femsa.rb
CHANGED
|
@@ -25,6 +25,7 @@ require 'digital_femsa/models/api_key_update_request'
|
|
|
25
25
|
require 'digital_femsa/models/balance_common_field'
|
|
26
26
|
require 'digital_femsa/models/balance_response'
|
|
27
27
|
require 'digital_femsa/models/charge_order_response'
|
|
28
|
+
require 'digital_femsa/models/charge_order_response_channel'
|
|
28
29
|
require 'digital_femsa/models/charge_order_response_payment_method'
|
|
29
30
|
require 'digital_femsa/models/charge_request'
|
|
30
31
|
require 'digital_femsa/models/charge_request_payment_method'
|
|
@@ -50,8 +51,6 @@ require 'digital_femsa/models/create_customer_payment_methods_request'
|
|
|
50
51
|
require 'digital_femsa/models/create_customer_payment_methods_response'
|
|
51
52
|
require 'digital_femsa/models/customer'
|
|
52
53
|
require 'digital_femsa/models/customer_address'
|
|
53
|
-
require 'digital_femsa/models/customer_antifraud_info'
|
|
54
|
-
require 'digital_femsa/models/customer_antifraud_info_response'
|
|
55
54
|
require 'digital_femsa/models/customer_fiscal_entities_data_response'
|
|
56
55
|
require 'digital_femsa/models/customer_fiscal_entities_request'
|
|
57
56
|
require 'digital_femsa/models/customer_fiscal_entities_response'
|
|
@@ -103,12 +102,11 @@ require 'digital_femsa/models/order_discount_lines_request'
|
|
|
103
102
|
require 'digital_femsa/models/order_fiscal_entity_address_response'
|
|
104
103
|
require 'digital_femsa/models/order_fiscal_entity_request'
|
|
105
104
|
require 'digital_femsa/models/order_fiscal_entity_response'
|
|
106
|
-
require 'digital_femsa/models/order_next_action_response'
|
|
107
|
-
require 'digital_femsa/models/order_next_action_response_redirect_to_url'
|
|
108
105
|
require 'digital_femsa/models/order_refund_request'
|
|
109
106
|
require 'digital_femsa/models/order_request'
|
|
110
107
|
require 'digital_femsa/models/order_request_customer_info'
|
|
111
108
|
require 'digital_femsa/models/order_response'
|
|
109
|
+
require 'digital_femsa/models/order_response_channel'
|
|
112
110
|
require 'digital_femsa/models/order_response_charges'
|
|
113
111
|
require 'digital_femsa/models/order_response_checkout'
|
|
114
112
|
require 'digital_femsa/models/order_response_customer_info'
|
|
@@ -132,14 +130,12 @@ require 'digital_femsa/models/product_data_response'
|
|
|
132
130
|
require 'digital_femsa/models/product_order_response'
|
|
133
131
|
require 'digital_femsa/models/shipping_order_response'
|
|
134
132
|
require 'digital_femsa/models/shipping_request'
|
|
135
|
-
require 'digital_femsa/models/sms_checkout_request'
|
|
136
133
|
require 'digital_femsa/models/transaction_response'
|
|
137
134
|
require 'digital_femsa/models/transfer_destination_response'
|
|
138
135
|
require 'digital_femsa/models/transfer_method_response'
|
|
139
136
|
require 'digital_femsa/models/transfer_response'
|
|
140
137
|
require 'digital_femsa/models/transfers_response'
|
|
141
138
|
require 'digital_femsa/models/update_customer'
|
|
142
|
-
require 'digital_femsa/models/update_customer_antifraud_info'
|
|
143
139
|
require 'digital_femsa/models/update_customer_fiscal_entities_response'
|
|
144
140
|
require 'digital_femsa/models/update_customer_payment_methods_response'
|
|
145
141
|
require 'digital_femsa/models/update_order_discount_lines_request'
|
|
@@ -13,35 +13,37 @@ Generator version: 7.5.0
|
|
|
13
13
|
require 'spec_helper'
|
|
14
14
|
require 'json'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
before do
|
|
21
|
-
# run before each test
|
|
22
|
-
@api_instance = DigitalFemsa::BalancesApi.new
|
|
23
|
-
end
|
|
16
|
+
RSpec.describe DigitalFemsa::BalancesApi do
|
|
17
|
+
let(:config) { DigitalFemsa::Configuration.new }
|
|
18
|
+
let(:api_client) { instance_double(DigitalFemsa::ApiClient) }
|
|
19
|
+
let(:api_instance) { described_class.new(api_client) }
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
before do
|
|
22
|
+
allow(api_client).to receive(:config).and_return(config)
|
|
23
|
+
allow(api_client).to receive(:select_header_accept).and_return('application/vnd.app-v2.1.0+json')
|
|
27
24
|
end
|
|
28
25
|
|
|
29
26
|
describe 'test an instance of BalancesApi' do
|
|
30
|
-
it '
|
|
31
|
-
expect(
|
|
27
|
+
it 'creates an instance of BalancesApi' do
|
|
28
|
+
expect(api_instance).to be_instance_of(DigitalFemsa::BalancesApi)
|
|
32
29
|
end
|
|
33
30
|
end
|
|
34
31
|
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# @return [BalanceResponse]
|
|
41
|
-
describe 'get_balance test' do
|
|
42
|
-
it 'should work' do
|
|
43
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
32
|
+
describe '#get_balance_with_http_info' do
|
|
33
|
+
it 'raises for invalid accept_language' do
|
|
34
|
+
expect do
|
|
35
|
+
api_instance.get_balance_with_http_info(accept_language: 'fr')
|
|
36
|
+
end.to raise_error(ArgumentError, /invalid value for "accept_language"/)
|
|
44
37
|
end
|
|
45
|
-
end
|
|
46
38
|
|
|
39
|
+
it 'sends GET request to balance endpoint' do
|
|
40
|
+
expect(api_client).to receive(:call_api).with(:GET, '/balance', hash_including(
|
|
41
|
+
operation: :'BalancesApi.get_balance',
|
|
42
|
+
return_type: 'BalanceResponse'
|
|
43
|
+
)).and_return([:balance, 200, {}])
|
|
44
|
+
|
|
45
|
+
data = api_instance.get_balance(accept_language: 'es')
|
|
46
|
+
expect(data).to eq(:balance)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
47
49
|
end
|
|
@@ -13,68 +13,111 @@ Generator version: 7.5.0
|
|
|
13
13
|
require 'spec_helper'
|
|
14
14
|
require 'json'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
before do
|
|
21
|
-
# run before each test
|
|
22
|
-
@api_instance = DigitalFemsa::ChargesApi.new
|
|
23
|
-
end
|
|
16
|
+
RSpec.describe DigitalFemsa::ChargesApi do
|
|
17
|
+
let(:config) { DigitalFemsa::Configuration.new }
|
|
18
|
+
let(:api_client) { instance_double(DigitalFemsa::ApiClient) }
|
|
19
|
+
let(:api_instance) { described_class.new(api_client) }
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
before do
|
|
22
|
+
allow(api_client).to receive(:config).and_return(config)
|
|
23
|
+
allow(api_client).to receive(:select_header_accept).and_return('application/vnd.app-v2.1.0+json')
|
|
24
|
+
allow(api_client).to receive(:select_header_content_type).and_return('application/json')
|
|
25
|
+
allow(api_client).to receive(:object_to_http_body) { |value| value.to_json }
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
describe 'test an instance of ChargesApi' do
|
|
30
|
-
it '
|
|
31
|
-
expect(
|
|
29
|
+
it 'creates an instance of ChargesApi' do
|
|
30
|
+
expect(api_instance).to be_instance_of(DigitalFemsa::ChargesApi)
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# @option opts [Integer] :limit The numbers of items to return, the maximum value is 250
|
|
41
|
-
# @option opts [String] :search General order search, e.g. by mail, reference etc.
|
|
42
|
-
# @option opts [String] :_next next page
|
|
43
|
-
# @option opts [String] :previous previous page
|
|
44
|
-
# @return [GetChargesResponse]
|
|
45
|
-
describe 'get_charges test' do
|
|
46
|
-
it 'should work' do
|
|
47
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
34
|
+
describe '#get_charges_with_http_info' do
|
|
35
|
+
it 'raises for limit higher than 250' do
|
|
36
|
+
expect do
|
|
37
|
+
api_instance.get_charges_with_http_info(limit: 251)
|
|
38
|
+
end.to raise_error(ArgumentError, /must be smaller than or equal to 250/)
|
|
48
39
|
end
|
|
49
|
-
end
|
|
50
40
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
41
|
+
it 'raises for limit lower than 1' do
|
|
42
|
+
expect do
|
|
43
|
+
api_instance.get_charges_with_http_info(limit: 0)
|
|
44
|
+
end.to raise_error(ArgumentError, /must be greater than or equal to 1/)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'maps list filters into query params' do
|
|
48
|
+
expect(api_client).to receive(:call_api).with(:GET, '/charges', hash_including(
|
|
49
|
+
operation: :'ChargesApi.get_charges',
|
|
50
|
+
query_params: {
|
|
51
|
+
limit: 10,
|
|
52
|
+
next: 'next_token',
|
|
53
|
+
previous: 'prev_token',
|
|
54
|
+
search: 'ord_123'
|
|
55
|
+
},
|
|
56
|
+
return_type: 'GetChargesResponse'
|
|
57
|
+
)).and_return([:list, 200, {}])
|
|
58
|
+
|
|
59
|
+
data = api_instance.get_charges(
|
|
60
|
+
limit: 10,
|
|
61
|
+
_next: 'next_token',
|
|
62
|
+
previous: 'prev_token',
|
|
63
|
+
search: 'ord_123'
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
expect(data).to eq(:list)
|
|
63
67
|
end
|
|
64
68
|
end
|
|
65
69
|
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
describe '#orders_create_charge_with_http_info' do
|
|
71
|
+
it 'raises when id is missing' do
|
|
72
|
+
expect do
|
|
73
|
+
api_instance.orders_create_charge_with_http_info(nil, { amount: 1000 })
|
|
74
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'raises when charge_request is missing' do
|
|
78
|
+
expect do
|
|
79
|
+
api_instance.orders_create_charge_with_http_info('ord_123', nil)
|
|
80
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'charge_request'/)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'builds escaped path and sends charge payload' do
|
|
84
|
+
payload = { amount: 1500, currency: 'MXN' }
|
|
85
|
+
|
|
86
|
+
expect(api_client).to receive(:call_api).with(:POST, '/orders/ord%2F123/charges', hash_including(
|
|
87
|
+
operation: :'ChargesApi.orders_create_charge',
|
|
88
|
+
body: payload.to_json,
|
|
89
|
+
return_type: 'ChargeOrderResponse'
|
|
90
|
+
)).and_return([:created, 201, {}])
|
|
91
|
+
|
|
92
|
+
data = api_instance.orders_create_charge('ord/123', payload)
|
|
93
|
+
expect(data).to eq(:created)
|
|
77
94
|
end
|
|
78
95
|
end
|
|
79
96
|
|
|
97
|
+
describe '#update_charge_with_http_info' do
|
|
98
|
+
it 'raises when id is missing' do
|
|
99
|
+
expect do
|
|
100
|
+
api_instance.update_charge_with_http_info(nil, { reference_id: 'ref_1' })
|
|
101
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'raises when charge_update_request is missing' do
|
|
105
|
+
expect do
|
|
106
|
+
api_instance.update_charge_with_http_info('chg_123', nil)
|
|
107
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'charge_update_request'/)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'sends PUT request with serialized payload' do
|
|
111
|
+
payload = { reference_id: 'new_reference' }
|
|
112
|
+
|
|
113
|
+
expect(api_client).to receive(:call_api).with(:PUT, '/charges/chg_123', hash_including(
|
|
114
|
+
operation: :'ChargesApi.update_charge',
|
|
115
|
+
body: payload.to_json,
|
|
116
|
+
return_type: 'ChargeResponse'
|
|
117
|
+
)).and_return([:updated, 200, {}])
|
|
118
|
+
|
|
119
|
+
data = api_instance.update_charge('chg_123', payload)
|
|
120
|
+
expect(data).to eq(:updated)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
80
123
|
end
|