perata-sdk 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/README.md +15 -8
- data/lib/perata/client.rb +50 -0
- data/lib/perata/models.rb +1428 -38
- data/lib/perata/params.rb +626 -2
- data/lib/perata/services.rb +519 -19
- data/lib/perata/version.rb +1 -1
- data/lib/perata/webhooks.rb +19 -1
- metadata +1 -1
data/lib/perata/params.rb
CHANGED
|
@@ -3,6 +3,239 @@
|
|
|
3
3
|
# Code generated by sdk/generator. DO NOT EDIT.
|
|
4
4
|
|
|
5
5
|
module Perata
|
|
6
|
+
# The body of benefits:create.
|
|
7
|
+
class BenefitsCreateParams < Params
|
|
8
|
+
MEMBERS = %i[description metadata name properties type visibility].freeze
|
|
9
|
+
|
|
10
|
+
# @return [String, nil]
|
|
11
|
+
attr_reader :description
|
|
12
|
+
|
|
13
|
+
# Até 50 pares; valor em texto, número ou booleano. No feature_flag, os valores da flag.
|
|
14
|
+
# @return [Hash{String => Object}, nil]
|
|
15
|
+
attr_reader :metadata
|
|
16
|
+
|
|
17
|
+
# Como o benefício aparece nos produtos e para o cliente; até 80 caracteres.
|
|
18
|
+
# @return [String]
|
|
19
|
+
attr_reader :name
|
|
20
|
+
|
|
21
|
+
# Os campos do tipo. custom: note. license_key: prefix, expires_in, expires_unit (day, month, year), activation_limit, customer_can_deactivate, usage_limit. meter_credit: meter_id, units, rollover. feature_flag: nenhum.
|
|
22
|
+
# @return [Hash{String => Object}, nil]
|
|
23
|
+
attr_reader :properties
|
|
24
|
+
|
|
25
|
+
# @return [String ("custom", "license_key", "feature_flag", "meter_credit")]
|
|
26
|
+
attr_reader :type
|
|
27
|
+
|
|
28
|
+
# @return [String ("public", "private"), nil]
|
|
29
|
+
attr_reader :visibility
|
|
30
|
+
|
|
31
|
+
def initialize(description: nil, metadata: nil, name:, properties: nil, type:, visibility: nil)
|
|
32
|
+
@description = description
|
|
33
|
+
@metadata = metadata
|
|
34
|
+
@name = name
|
|
35
|
+
@properties = properties
|
|
36
|
+
@type = type
|
|
37
|
+
@visibility = visibility
|
|
38
|
+
freeze
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# The body as the API reads it.
|
|
42
|
+
def to_wire
|
|
43
|
+
wire = {}
|
|
44
|
+
wire["description"] = @description unless @description.nil?
|
|
45
|
+
wire["metadata"] = Perata.wire(@metadata) unless @metadata.nil?
|
|
46
|
+
wire["name"] = @name
|
|
47
|
+
wire["properties"] = Perata.wire(@properties) unless @properties.nil?
|
|
48
|
+
wire["type"] = @type
|
|
49
|
+
wire["visibility"] = @visibility unless @visibility.nil?
|
|
50
|
+
wire
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# The body of benefits:update.
|
|
55
|
+
class BenefitsUpdateParams < Params
|
|
56
|
+
MEMBERS = %i[metadata name properties visibility].freeze
|
|
57
|
+
|
|
58
|
+
# Substitui os metadados; {} os limpa.
|
|
59
|
+
# @return [Hash{String => Object}, nil]
|
|
60
|
+
attr_reader :metadata
|
|
61
|
+
|
|
62
|
+
# @return [String, nil]
|
|
63
|
+
attr_reader :name
|
|
64
|
+
|
|
65
|
+
# Os campos do tipo, aplicados sobre os guardados; o que ficar de fora não muda.
|
|
66
|
+
# @return [Hash{String => Object}, nil]
|
|
67
|
+
attr_reader :properties
|
|
68
|
+
|
|
69
|
+
# @return [String ("public", "private"), nil]
|
|
70
|
+
attr_reader :visibility
|
|
71
|
+
|
|
72
|
+
def initialize(metadata: nil, name: nil, properties: nil, visibility: nil)
|
|
73
|
+
@metadata = metadata
|
|
74
|
+
@name = name
|
|
75
|
+
@properties = properties
|
|
76
|
+
@visibility = visibility
|
|
77
|
+
freeze
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# The body as the API reads it.
|
|
81
|
+
def to_wire
|
|
82
|
+
wire = {}
|
|
83
|
+
wire["metadata"] = Perata.wire(@metadata) unless @metadata.nil?
|
|
84
|
+
wire["name"] = @name unless @name.nil?
|
|
85
|
+
wire["properties"] = Perata.wire(@properties) unless @properties.nil?
|
|
86
|
+
wire["visibility"] = @visibility unless @visibility.nil?
|
|
87
|
+
wire
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# The body of checkout-links:create.
|
|
92
|
+
class CheckoutLinksCreateParams < Params
|
|
93
|
+
MEMBERS = %i[allow_discount_codes cancel_url capture_mode discount_id expires_at label max_installments metadata price_id price_ids product_id quantity require_billing_address success_url trial_interval trial_interval_count].freeze
|
|
94
|
+
|
|
95
|
+
# @return [Boolean, nil]
|
|
96
|
+
attr_reader :allow_discount_codes
|
|
97
|
+
|
|
98
|
+
# @return [String, nil]
|
|
99
|
+
attr_reader :cancel_url
|
|
100
|
+
|
|
101
|
+
# @return [String ("automatic", "manual"), nil]
|
|
102
|
+
attr_reader :capture_mode
|
|
103
|
+
|
|
104
|
+
# Desconto fixado no link.
|
|
105
|
+
# @return [String, nil]
|
|
106
|
+
attr_reader :discount_id
|
|
107
|
+
|
|
108
|
+
# Data e hora RFC 3339 no futuro.
|
|
109
|
+
# @return [String, nil]
|
|
110
|
+
attr_reader :expires_at
|
|
111
|
+
|
|
112
|
+
# @return [String, nil]
|
|
113
|
+
attr_reader :label
|
|
114
|
+
|
|
115
|
+
# De 0 a 12; 0 segue a organização.
|
|
116
|
+
# @return [Integer, nil]
|
|
117
|
+
attr_reader :max_installments
|
|
118
|
+
|
|
119
|
+
# Até 50 pares; valor em texto, número ou booleano.
|
|
120
|
+
# @return [Hash{String => Object}, nil]
|
|
121
|
+
attr_reader :metadata
|
|
122
|
+
|
|
123
|
+
# @return [String, nil]
|
|
124
|
+
attr_reader :price_id
|
|
125
|
+
|
|
126
|
+
# Um preço de cada produto, na ordem em que o comprador os vê; até 20.
|
|
127
|
+
# @return [Array<String>, nil]
|
|
128
|
+
attr_reader :price_ids
|
|
129
|
+
|
|
130
|
+
# Com price_id, o produto que o link vende; ou use price_ids.
|
|
131
|
+
# @return [String, nil]
|
|
132
|
+
attr_reader :product_id
|
|
133
|
+
|
|
134
|
+
# @return [Integer, nil]
|
|
135
|
+
attr_reader :quantity
|
|
136
|
+
|
|
137
|
+
# @return [Boolean, nil]
|
|
138
|
+
attr_reader :require_billing_address
|
|
139
|
+
|
|
140
|
+
# @return [String, nil]
|
|
141
|
+
attr_reader :success_url
|
|
142
|
+
|
|
143
|
+
# @return [String ("day", "week", "month", "year"), nil]
|
|
144
|
+
attr_reader :trial_interval
|
|
145
|
+
|
|
146
|
+
# @return [Integer, nil]
|
|
147
|
+
attr_reader :trial_interval_count
|
|
148
|
+
|
|
149
|
+
def initialize(allow_discount_codes: nil, cancel_url: nil, capture_mode: nil, discount_id: nil, expires_at: nil, label: nil, max_installments: nil, metadata: nil, price_id: nil, price_ids: nil, product_id: nil, quantity: nil, require_billing_address: nil, success_url: nil, trial_interval: nil, trial_interval_count: nil)
|
|
150
|
+
@allow_discount_codes = allow_discount_codes
|
|
151
|
+
@cancel_url = cancel_url
|
|
152
|
+
@capture_mode = capture_mode
|
|
153
|
+
@discount_id = discount_id
|
|
154
|
+
@expires_at = expires_at
|
|
155
|
+
@label = label
|
|
156
|
+
@max_installments = max_installments
|
|
157
|
+
@metadata = metadata
|
|
158
|
+
@price_id = price_id
|
|
159
|
+
@price_ids = price_ids
|
|
160
|
+
@product_id = product_id
|
|
161
|
+
@quantity = quantity
|
|
162
|
+
@require_billing_address = require_billing_address
|
|
163
|
+
@success_url = success_url
|
|
164
|
+
@trial_interval = trial_interval
|
|
165
|
+
@trial_interval_count = trial_interval_count
|
|
166
|
+
freeze
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# The body as the API reads it.
|
|
170
|
+
def to_wire
|
|
171
|
+
wire = {}
|
|
172
|
+
wire["allow_discount_codes"] = @allow_discount_codes unless @allow_discount_codes.nil?
|
|
173
|
+
wire["cancel_url"] = @cancel_url unless @cancel_url.nil?
|
|
174
|
+
wire["capture_mode"] = @capture_mode unless @capture_mode.nil?
|
|
175
|
+
wire["discount_id"] = @discount_id unless @discount_id.nil?
|
|
176
|
+
wire["expires_at"] = @expires_at unless @expires_at.nil?
|
|
177
|
+
wire["label"] = @label unless @label.nil?
|
|
178
|
+
wire["max_installments"] = @max_installments unless @max_installments.nil?
|
|
179
|
+
wire["metadata"] = Perata.wire(@metadata) unless @metadata.nil?
|
|
180
|
+
wire["price_id"] = @price_id unless @price_id.nil?
|
|
181
|
+
wire["price_ids"] = Perata.wire(@price_ids) unless @price_ids.nil?
|
|
182
|
+
wire["product_id"] = @product_id unless @product_id.nil?
|
|
183
|
+
wire["quantity"] = @quantity unless @quantity.nil?
|
|
184
|
+
wire["require_billing_address"] = @require_billing_address unless @require_billing_address.nil?
|
|
185
|
+
wire["success_url"] = @success_url unless @success_url.nil?
|
|
186
|
+
wire["trial_interval"] = @trial_interval unless @trial_interval.nil?
|
|
187
|
+
wire["trial_interval_count"] = @trial_interval_count unless @trial_interval_count.nil?
|
|
188
|
+
wire
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# The body of checkout-links:update.
|
|
193
|
+
class CheckoutLinksUpdateParams < Params
|
|
194
|
+
MEMBERS = %i[cancel_url label metadata price_ids require_billing_address success_url].freeze
|
|
195
|
+
|
|
196
|
+
# @return [String, nil]
|
|
197
|
+
attr_reader :cancel_url
|
|
198
|
+
|
|
199
|
+
# @return [String, nil]
|
|
200
|
+
attr_reader :label
|
|
201
|
+
|
|
202
|
+
# Substitui os metadados; {} os limpa.
|
|
203
|
+
# @return [Hash{String => Object}, nil]
|
|
204
|
+
attr_reader :metadata
|
|
205
|
+
|
|
206
|
+
# Substitui os produtos do link.
|
|
207
|
+
# @return [Array<String>, nil]
|
|
208
|
+
attr_reader :price_ids
|
|
209
|
+
|
|
210
|
+
# @return [Boolean, nil]
|
|
211
|
+
attr_reader :require_billing_address
|
|
212
|
+
|
|
213
|
+
# @return [String, nil]
|
|
214
|
+
attr_reader :success_url
|
|
215
|
+
|
|
216
|
+
def initialize(cancel_url: nil, label: nil, metadata: nil, price_ids: nil, require_billing_address: nil, success_url: nil)
|
|
217
|
+
@cancel_url = cancel_url
|
|
218
|
+
@label = label
|
|
219
|
+
@metadata = metadata
|
|
220
|
+
@price_ids = price_ids
|
|
221
|
+
@require_billing_address = require_billing_address
|
|
222
|
+
@success_url = success_url
|
|
223
|
+
freeze
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# The body as the API reads it.
|
|
227
|
+
def to_wire
|
|
228
|
+
wire = {}
|
|
229
|
+
wire["cancel_url"] = @cancel_url unless @cancel_url.nil?
|
|
230
|
+
wire["label"] = @label unless @label.nil?
|
|
231
|
+
wire["metadata"] = Perata.wire(@metadata) unless @metadata.nil?
|
|
232
|
+
wire["price_ids"] = Perata.wire(@price_ids) unless @price_ids.nil?
|
|
233
|
+
wire["require_billing_address"] = @require_billing_address unless @require_billing_address.nil?
|
|
234
|
+
wire["success_url"] = @success_url unless @success_url.nil?
|
|
235
|
+
wire
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
6
239
|
# The body of checkouts:create.
|
|
7
240
|
class CheckoutsCreateParams < Params
|
|
8
241
|
MEMBERS = %i[cancel_url label price_id product_id quantity success_url].freeze
|
|
@@ -48,15 +281,52 @@ module Perata
|
|
|
48
281
|
end
|
|
49
282
|
end
|
|
50
283
|
|
|
284
|
+
# The body of checkouts:update.
|
|
285
|
+
class CheckoutsUpdateParams < Params
|
|
286
|
+
MEMBERS = %i[cancel_url label success_url].freeze
|
|
287
|
+
|
|
288
|
+
# Endereço https; vazio retira.
|
|
289
|
+
# @return [String, nil]
|
|
290
|
+
attr_reader :cancel_url
|
|
291
|
+
|
|
292
|
+
# @return [String, nil]
|
|
293
|
+
attr_reader :label
|
|
294
|
+
|
|
295
|
+
# Endereço https; vazio retira.
|
|
296
|
+
# @return [String, nil]
|
|
297
|
+
attr_reader :success_url
|
|
298
|
+
|
|
299
|
+
def initialize(cancel_url: nil, label: nil, success_url: nil)
|
|
300
|
+
@cancel_url = cancel_url
|
|
301
|
+
@label = label
|
|
302
|
+
@success_url = success_url
|
|
303
|
+
freeze
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
# The body as the API reads it.
|
|
307
|
+
def to_wire
|
|
308
|
+
wire = {}
|
|
309
|
+
wire["cancel_url"] = @cancel_url unless @cancel_url.nil?
|
|
310
|
+
wire["label"] = @label unless @label.nil?
|
|
311
|
+
wire["success_url"] = @success_url unless @success_url.nil?
|
|
312
|
+
wire
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
51
316
|
# The body of customer-sessions:create.
|
|
52
317
|
class CustomerSessionsCreateParams < Params
|
|
53
|
-
MEMBERS = %i[customer_id].freeze
|
|
318
|
+
MEMBERS = %i[customer_id return_url].freeze
|
|
54
319
|
|
|
55
320
|
# @return [String]
|
|
56
321
|
attr_reader :customer_id
|
|
57
322
|
|
|
58
|
-
|
|
323
|
+
# Optional https address of your app the portal offers to go back to.
|
|
324
|
+
# @return [String, nil]
|
|
325
|
+
attr_reader :return_url
|
|
326
|
+
|
|
327
|
+
def initialize(customer_id:, return_url: nil)
|
|
59
328
|
@customer_id = customer_id
|
|
329
|
+
@return_url = return_url
|
|
60
330
|
freeze
|
|
61
331
|
end
|
|
62
332
|
|
|
@@ -64,6 +334,7 @@ module Perata
|
|
|
64
334
|
def to_wire
|
|
65
335
|
wire = {}
|
|
66
336
|
wire["customer_id"] = @customer_id
|
|
337
|
+
wire["return_url"] = @return_url unless @return_url.nil?
|
|
67
338
|
wire
|
|
68
339
|
end
|
|
69
340
|
end
|
|
@@ -98,6 +369,220 @@ module Perata
|
|
|
98
369
|
end
|
|
99
370
|
end
|
|
100
371
|
|
|
372
|
+
# The body of customers:update.
|
|
373
|
+
class CustomersUpdateParams < Params
|
|
374
|
+
MEMBERS = %i[email external_id name].freeze
|
|
375
|
+
|
|
376
|
+
# @return [String, nil]
|
|
377
|
+
attr_reader :email
|
|
378
|
+
|
|
379
|
+
# Só pode ser definido uma vez.
|
|
380
|
+
# @return [String, nil]
|
|
381
|
+
attr_reader :external_id
|
|
382
|
+
|
|
383
|
+
# @return [String, nil]
|
|
384
|
+
attr_reader :name
|
|
385
|
+
|
|
386
|
+
def initialize(email: nil, external_id: nil, name: nil)
|
|
387
|
+
@email = email
|
|
388
|
+
@external_id = external_id
|
|
389
|
+
@name = name
|
|
390
|
+
freeze
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
# The body as the API reads it.
|
|
394
|
+
def to_wire
|
|
395
|
+
wire = {}
|
|
396
|
+
wire["email"] = @email unless @email.nil?
|
|
397
|
+
wire["external_id"] = @external_id unless @external_id.nil?
|
|
398
|
+
wire["name"] = @name unless @name.nil?
|
|
399
|
+
wire
|
|
400
|
+
end
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
# The body of discounts:create.
|
|
404
|
+
class DiscountsCreateParams < Params
|
|
405
|
+
MEMBERS = %i[amount_cents basis_points code duration duration_in_months ends_at max_redemptions max_redemptions_per_customer name product_ids starts_at type].freeze
|
|
406
|
+
|
|
407
|
+
# Em centavos, obrigatório no tipo fixed.
|
|
408
|
+
# @return [Integer, nil]
|
|
409
|
+
attr_reader :amount_cents
|
|
410
|
+
|
|
411
|
+
# De 1 a 10000, obrigatório no tipo percentage.
|
|
412
|
+
# @return [Integer, nil]
|
|
413
|
+
attr_reader :basis_points
|
|
414
|
+
|
|
415
|
+
# Até 64 letras, números, hífens ou sublinhados; sem ele o desconto só se aplica por um link de checkout ou pela API.
|
|
416
|
+
# @return [String, nil]
|
|
417
|
+
attr_reader :code
|
|
418
|
+
|
|
419
|
+
# @return [String ("once", "repeating", "forever")]
|
|
420
|
+
attr_reader :duration
|
|
421
|
+
|
|
422
|
+
# De 1 a 120, só no duration repeating.
|
|
423
|
+
# @return [Integer, nil]
|
|
424
|
+
attr_reader :duration_in_months
|
|
425
|
+
|
|
426
|
+
# Data e hora RFC 3339, depois de starts_at.
|
|
427
|
+
# @return [String, nil]
|
|
428
|
+
attr_reader :ends_at
|
|
429
|
+
|
|
430
|
+
# @return [Integer, nil]
|
|
431
|
+
attr_reader :max_redemptions
|
|
432
|
+
|
|
433
|
+
# @return [Integer, nil]
|
|
434
|
+
attr_reader :max_redemptions_per_customer
|
|
435
|
+
|
|
436
|
+
# @return [String]
|
|
437
|
+
attr_reader :name
|
|
438
|
+
|
|
439
|
+
# Os produtos do desconto; vazio, todos.
|
|
440
|
+
# @return [Array<String>, nil]
|
|
441
|
+
attr_reader :product_ids
|
|
442
|
+
|
|
443
|
+
# Data e hora RFC 3339; agora, se omitida.
|
|
444
|
+
# @return [String, nil]
|
|
445
|
+
attr_reader :starts_at
|
|
446
|
+
|
|
447
|
+
# @return [String ("percentage", "fixed")]
|
|
448
|
+
attr_reader :type
|
|
449
|
+
|
|
450
|
+
def initialize(amount_cents: nil, basis_points: nil, code: nil, duration:, duration_in_months: nil, ends_at: nil, max_redemptions: nil, max_redemptions_per_customer: nil, name:, product_ids: nil, starts_at: nil, type:)
|
|
451
|
+
@amount_cents = amount_cents
|
|
452
|
+
@basis_points = basis_points
|
|
453
|
+
@code = code
|
|
454
|
+
@duration = duration
|
|
455
|
+
@duration_in_months = duration_in_months
|
|
456
|
+
@ends_at = ends_at
|
|
457
|
+
@max_redemptions = max_redemptions
|
|
458
|
+
@max_redemptions_per_customer = max_redemptions_per_customer
|
|
459
|
+
@name = name
|
|
460
|
+
@product_ids = product_ids
|
|
461
|
+
@starts_at = starts_at
|
|
462
|
+
@type = type
|
|
463
|
+
freeze
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
# The body as the API reads it.
|
|
467
|
+
def to_wire
|
|
468
|
+
wire = {}
|
|
469
|
+
wire["amount_cents"] = @amount_cents unless @amount_cents.nil?
|
|
470
|
+
wire["basis_points"] = @basis_points unless @basis_points.nil?
|
|
471
|
+
wire["code"] = @code unless @code.nil?
|
|
472
|
+
wire["duration"] = @duration
|
|
473
|
+
wire["duration_in_months"] = @duration_in_months unless @duration_in_months.nil?
|
|
474
|
+
wire["ends_at"] = @ends_at unless @ends_at.nil?
|
|
475
|
+
wire["max_redemptions"] = @max_redemptions unless @max_redemptions.nil?
|
|
476
|
+
wire["max_redemptions_per_customer"] = @max_redemptions_per_customer unless @max_redemptions_per_customer.nil?
|
|
477
|
+
wire["name"] = @name
|
|
478
|
+
wire["product_ids"] = Perata.wire(@product_ids) unless @product_ids.nil?
|
|
479
|
+
wire["starts_at"] = @starts_at unless @starts_at.nil?
|
|
480
|
+
wire["type"] = @type
|
|
481
|
+
wire
|
|
482
|
+
end
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
# The body of discounts:update.
|
|
486
|
+
class DiscountsUpdateParams < Params
|
|
487
|
+
MEMBERS = %i[amount_cents basis_points code duration_in_months ends_at max_redemptions max_redemptions_per_customer name product_ids starts_at].freeze
|
|
488
|
+
|
|
489
|
+
# @return [Integer, nil]
|
|
490
|
+
attr_reader :amount_cents
|
|
491
|
+
|
|
492
|
+
# @return [Integer, nil]
|
|
493
|
+
attr_reader :basis_points
|
|
494
|
+
|
|
495
|
+
# null tira o código.
|
|
496
|
+
# @return [String, nil]
|
|
497
|
+
attr_reader :code
|
|
498
|
+
|
|
499
|
+
# @return [Integer, nil]
|
|
500
|
+
attr_reader :duration_in_months
|
|
501
|
+
|
|
502
|
+
# null tira o fim.
|
|
503
|
+
# @return [String, nil]
|
|
504
|
+
attr_reader :ends_at
|
|
505
|
+
|
|
506
|
+
# null tira o limite.
|
|
507
|
+
# @return [Integer, nil]
|
|
508
|
+
attr_reader :max_redemptions
|
|
509
|
+
|
|
510
|
+
# null tira o limite.
|
|
511
|
+
# @return [Integer, nil]
|
|
512
|
+
attr_reader :max_redemptions_per_customer
|
|
513
|
+
|
|
514
|
+
# @return [String, nil]
|
|
515
|
+
attr_reader :name
|
|
516
|
+
|
|
517
|
+
# Substitui os produtos do desconto.
|
|
518
|
+
# @return [Array<String>, nil]
|
|
519
|
+
attr_reader :product_ids
|
|
520
|
+
|
|
521
|
+
# @return [String, nil]
|
|
522
|
+
attr_reader :starts_at
|
|
523
|
+
|
|
524
|
+
def initialize(amount_cents: nil, basis_points: nil, code: nil, duration_in_months: nil, ends_at: nil, max_redemptions: nil, max_redemptions_per_customer: nil, name: nil, product_ids: nil, starts_at: nil)
|
|
525
|
+
@amount_cents = amount_cents
|
|
526
|
+
@basis_points = basis_points
|
|
527
|
+
@code = code
|
|
528
|
+
@duration_in_months = duration_in_months
|
|
529
|
+
@ends_at = ends_at
|
|
530
|
+
@max_redemptions = max_redemptions
|
|
531
|
+
@max_redemptions_per_customer = max_redemptions_per_customer
|
|
532
|
+
@name = name
|
|
533
|
+
@product_ids = product_ids
|
|
534
|
+
@starts_at = starts_at
|
|
535
|
+
freeze
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
# The body as the API reads it.
|
|
539
|
+
def to_wire
|
|
540
|
+
wire = {}
|
|
541
|
+
wire["amount_cents"] = @amount_cents unless @amount_cents.nil?
|
|
542
|
+
wire["basis_points"] = @basis_points unless @basis_points.nil?
|
|
543
|
+
wire["code"] = @code unless @code.nil?
|
|
544
|
+
wire["duration_in_months"] = @duration_in_months unless @duration_in_months.nil?
|
|
545
|
+
wire["ends_at"] = @ends_at unless @ends_at.nil?
|
|
546
|
+
wire["max_redemptions"] = @max_redemptions unless @max_redemptions.nil?
|
|
547
|
+
wire["max_redemptions_per_customer"] = @max_redemptions_per_customer unless @max_redemptions_per_customer.nil?
|
|
548
|
+
wire["name"] = @name unless @name.nil?
|
|
549
|
+
wire["product_ids"] = Perata.wire(@product_ids) unless @product_ids.nil?
|
|
550
|
+
wire["starts_at"] = @starts_at unless @starts_at.nil?
|
|
551
|
+
wire
|
|
552
|
+
end
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
# The body of customers:update_external.
|
|
556
|
+
class CustomersUpdateExternalParams < Params
|
|
557
|
+
MEMBERS = %i[email external_id name].freeze
|
|
558
|
+
|
|
559
|
+
# @return [String, nil]
|
|
560
|
+
attr_reader :email
|
|
561
|
+
|
|
562
|
+
# Só pode ser definido uma vez.
|
|
563
|
+
# @return [String, nil]
|
|
564
|
+
attr_reader :external_id
|
|
565
|
+
|
|
566
|
+
# @return [String, nil]
|
|
567
|
+
attr_reader :name
|
|
568
|
+
|
|
569
|
+
def initialize(email: nil, external_id: nil, name: nil)
|
|
570
|
+
@email = email
|
|
571
|
+
@external_id = external_id
|
|
572
|
+
@name = name
|
|
573
|
+
freeze
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
# The body as the API reads it.
|
|
577
|
+
def to_wire
|
|
578
|
+
wire = {}
|
|
579
|
+
wire["email"] = @email unless @email.nil?
|
|
580
|
+
wire["external_id"] = @external_id unless @external_id.nil?
|
|
581
|
+
wire["name"] = @name unless @name.nil?
|
|
582
|
+
wire
|
|
583
|
+
end
|
|
584
|
+
end
|
|
585
|
+
|
|
101
586
|
# The body of prices:create.
|
|
102
587
|
class PricesCreateParams < Params
|
|
103
588
|
MEMBERS = %i[amount_cents interval product_id type].freeze
|
|
@@ -158,6 +643,31 @@ module Perata
|
|
|
158
643
|
end
|
|
159
644
|
end
|
|
160
645
|
|
|
646
|
+
# The body of products:update.
|
|
647
|
+
class ProductsUpdateParams < Params
|
|
648
|
+
MEMBERS = %i[description name].freeze
|
|
649
|
+
|
|
650
|
+
# @return [String, nil]
|
|
651
|
+
attr_reader :description
|
|
652
|
+
|
|
653
|
+
# @return [String, nil]
|
|
654
|
+
attr_reader :name
|
|
655
|
+
|
|
656
|
+
def initialize(description: nil, name: nil)
|
|
657
|
+
@description = description
|
|
658
|
+
@name = name
|
|
659
|
+
freeze
|
|
660
|
+
end
|
|
661
|
+
|
|
662
|
+
# The body as the API reads it.
|
|
663
|
+
def to_wire
|
|
664
|
+
wire = {}
|
|
665
|
+
wire["description"] = @description unless @description.nil?
|
|
666
|
+
wire["name"] = @name unless @name.nil?
|
|
667
|
+
wire
|
|
668
|
+
end
|
|
669
|
+
end
|
|
670
|
+
|
|
161
671
|
# The body of refunds:create.
|
|
162
672
|
class RefundsCreateParams < Params
|
|
163
673
|
MEMBERS = %i[amount_cents note payment_id reason].freeze
|
|
@@ -193,6 +703,39 @@ module Perata
|
|
|
193
703
|
end
|
|
194
704
|
end
|
|
195
705
|
|
|
706
|
+
# The body of subscriptions:update.
|
|
707
|
+
class SubscriptionsUpdateParams < Params
|
|
708
|
+
MEMBERS = %i[price_id proration_behavior quantity].freeze
|
|
709
|
+
|
|
710
|
+
# O preço recorrente para onde a assinatura vai.
|
|
711
|
+
# @return [String]
|
|
712
|
+
attr_reader :price_id
|
|
713
|
+
|
|
714
|
+
# prorate (padrão): rateia o resto do período no próximo valor cobrado; invoice: cobra a diferença agora; next_period: troca no fim do período; reset: cobra o período inteiro do novo plano agora e reinicia o ciclo.
|
|
715
|
+
# @return [String ("prorate", "invoice", "next_period", "reset"), nil]
|
|
716
|
+
attr_reader :proration_behavior
|
|
717
|
+
|
|
718
|
+
# A nova quantidade; omitida, fica a atual.
|
|
719
|
+
# @return [Integer, nil]
|
|
720
|
+
attr_reader :quantity
|
|
721
|
+
|
|
722
|
+
def initialize(price_id:, proration_behavior: nil, quantity: nil)
|
|
723
|
+
@price_id = price_id
|
|
724
|
+
@proration_behavior = proration_behavior
|
|
725
|
+
@quantity = quantity
|
|
726
|
+
freeze
|
|
727
|
+
end
|
|
728
|
+
|
|
729
|
+
# The body as the API reads it.
|
|
730
|
+
def to_wire
|
|
731
|
+
wire = {}
|
|
732
|
+
wire["price_id"] = @price_id
|
|
733
|
+
wire["proration_behavior"] = @proration_behavior unless @proration_behavior.nil?
|
|
734
|
+
wire["quantity"] = @quantity unless @quantity.nil?
|
|
735
|
+
wire
|
|
736
|
+
end
|
|
737
|
+
end
|
|
738
|
+
|
|
196
739
|
# The body of subscriptions:cancel.
|
|
197
740
|
class SubscriptionsCancelParams < Params
|
|
198
741
|
MEMBERS = %i[at_period_end reason].freeze
|
|
@@ -217,4 +760,85 @@ module Perata
|
|
|
217
760
|
wire
|
|
218
761
|
end
|
|
219
762
|
end
|
|
763
|
+
|
|
764
|
+
# The body of webhooks:create_endpoint.
|
|
765
|
+
class WebhooksCreateEndpointParams < Params
|
|
766
|
+
MEMBERS = %i[description events format url].freeze
|
|
767
|
+
|
|
768
|
+
# Sem ele, o domínio do endereço. Único por organização e ambiente.
|
|
769
|
+
# @return [String, nil]
|
|
770
|
+
attr_reader :description
|
|
771
|
+
|
|
772
|
+
# Os eventos de que o endpoint é avisado, da lista de eventos deste documento; sem eles, nenhum é enviado.
|
|
773
|
+
# @return [Array<String>, nil]
|
|
774
|
+
attr_reader :events
|
|
775
|
+
|
|
776
|
+
# Sem ele, o que o endereço indica.
|
|
777
|
+
# @return [String ("raw", "discord", "slack"), nil]
|
|
778
|
+
attr_reader :format
|
|
779
|
+
|
|
780
|
+
# Endereço https público; endereços internos são recusados.
|
|
781
|
+
# @return [String]
|
|
782
|
+
attr_reader :url
|
|
783
|
+
|
|
784
|
+
def initialize(description: nil, events: nil, format: nil, url:)
|
|
785
|
+
@description = description
|
|
786
|
+
@events = events
|
|
787
|
+
@format = format
|
|
788
|
+
@url = url
|
|
789
|
+
freeze
|
|
790
|
+
end
|
|
791
|
+
|
|
792
|
+
# The body as the API reads it.
|
|
793
|
+
def to_wire
|
|
794
|
+
wire = {}
|
|
795
|
+
wire["description"] = @description unless @description.nil?
|
|
796
|
+
wire["events"] = Perata.wire(@events) unless @events.nil?
|
|
797
|
+
wire["format"] = @format unless @format.nil?
|
|
798
|
+
wire["url"] = @url
|
|
799
|
+
wire
|
|
800
|
+
end
|
|
801
|
+
end
|
|
802
|
+
|
|
803
|
+
# The body of webhooks:update_endpoint.
|
|
804
|
+
class WebhooksUpdateEndpointParams < Params
|
|
805
|
+
MEMBERS = %i[description enabled events format url].freeze
|
|
806
|
+
|
|
807
|
+
# @return [String, nil]
|
|
808
|
+
attr_reader :description
|
|
809
|
+
|
|
810
|
+
# false desliga o envio, e as entregas esperam; true o religa.
|
|
811
|
+
# @return [Boolean, nil]
|
|
812
|
+
attr_reader :enabled
|
|
813
|
+
|
|
814
|
+
# Substitui os eventos.
|
|
815
|
+
# @return [Array<String>, nil]
|
|
816
|
+
attr_reader :events
|
|
817
|
+
|
|
818
|
+
# @return [String ("raw", "discord", "slack"), nil]
|
|
819
|
+
attr_reader :format
|
|
820
|
+
|
|
821
|
+
# @return [String, nil]
|
|
822
|
+
attr_reader :url
|
|
823
|
+
|
|
824
|
+
def initialize(description: nil, enabled: nil, events: nil, format: nil, url: nil)
|
|
825
|
+
@description = description
|
|
826
|
+
@enabled = enabled
|
|
827
|
+
@events = events
|
|
828
|
+
@format = format
|
|
829
|
+
@url = url
|
|
830
|
+
freeze
|
|
831
|
+
end
|
|
832
|
+
|
|
833
|
+
# The body as the API reads it.
|
|
834
|
+
def to_wire
|
|
835
|
+
wire = {}
|
|
836
|
+
wire["description"] = @description unless @description.nil?
|
|
837
|
+
wire["enabled"] = @enabled unless @enabled.nil?
|
|
838
|
+
wire["events"] = Perata.wire(@events) unless @events.nil?
|
|
839
|
+
wire["format"] = @format unless @format.nil?
|
|
840
|
+
wire["url"] = @url unless @url.nil?
|
|
841
|
+
wire
|
|
842
|
+
end
|
|
843
|
+
end
|
|
220
844
|
end
|