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/models.rb
CHANGED
|
@@ -3,14 +3,86 @@
|
|
|
3
3
|
# Code generated by sdk/generator. DO NOT EDIT.
|
|
4
4
|
|
|
5
5
|
module Perata
|
|
6
|
+
# Benefit is a resource of Peráta's API.
|
|
7
|
+
class Benefit < Model
|
|
8
|
+
MEMBERS = %i[created_at description id metadata modified_at name properties status type visibility].freeze
|
|
9
|
+
|
|
10
|
+
# @return [String]
|
|
11
|
+
attr_reader :created_at
|
|
12
|
+
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_reader :description
|
|
15
|
+
|
|
16
|
+
# @return [String]
|
|
17
|
+
attr_reader :id
|
|
18
|
+
|
|
19
|
+
# Metadados do lojista: pares chave e valor (texto, número ou booleano); no tipo feature_flag, os valores da flag.
|
|
20
|
+
# @return [Hash{String => Object}]
|
|
21
|
+
attr_reader :metadata
|
|
22
|
+
|
|
23
|
+
# @return [String]
|
|
24
|
+
attr_reader :modified_at
|
|
25
|
+
|
|
26
|
+
# Como o benefício aparece nos produtos e para o cliente.
|
|
27
|
+
# @return [String]
|
|
28
|
+
attr_reader :name
|
|
29
|
+
|
|
30
|
+
# Os campos do tipo do benefício.
|
|
31
|
+
# @return [Hash{String => Object}]
|
|
32
|
+
attr_reader :properties
|
|
33
|
+
|
|
34
|
+
# @return [String ("active", "archived")]
|
|
35
|
+
attr_reader :status
|
|
36
|
+
|
|
37
|
+
# @return [String ("custom", "license_key", "downloadable", "feature_flag", "meter_credit", "discord", "github_repository")]
|
|
38
|
+
attr_reader :type
|
|
39
|
+
|
|
40
|
+
# @return [String ("public", "private")]
|
|
41
|
+
attr_reader :visibility
|
|
42
|
+
|
|
43
|
+
def initialize(created_at:, description:, id:, metadata:, modified_at:, name:, properties:, status:, type:, visibility:)
|
|
44
|
+
@created_at = created_at
|
|
45
|
+
@description = description
|
|
46
|
+
@id = id
|
|
47
|
+
@metadata = metadata
|
|
48
|
+
@modified_at = modified_at
|
|
49
|
+
@name = name
|
|
50
|
+
@properties = properties
|
|
51
|
+
@status = status
|
|
52
|
+
@type = type
|
|
53
|
+
@visibility = visibility
|
|
54
|
+
freeze
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Builds a Benefit from the API's JSON.
|
|
58
|
+
def self.from_hash(data)
|
|
59
|
+
new(
|
|
60
|
+
created_at: data.fetch("created_at"),
|
|
61
|
+
description: data.fetch("description"),
|
|
62
|
+
id: data.fetch("id"),
|
|
63
|
+
metadata: data.fetch("metadata"),
|
|
64
|
+
modified_at: data.fetch("modified_at"),
|
|
65
|
+
name: data.fetch("name"),
|
|
66
|
+
properties: data.fetch("properties"),
|
|
67
|
+
status: data.fetch("status"),
|
|
68
|
+
type: data.fetch("type"),
|
|
69
|
+
visibility: data.fetch("visibility")
|
|
70
|
+
)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
6
74
|
# BenefitGrant is a resource of Peráta's API.
|
|
7
75
|
class BenefitGrant < Model
|
|
8
|
-
MEMBERS = %i[benefit_id benefit_type created_at customer_id granted_at id is_granted is_revoked revoked_at status].freeze
|
|
76
|
+
MEMBERS = %i[benefit_id benefit_metadata benefit_type created_at customer_id granted_at id is_granted is_revoked properties revoked_at status].freeze
|
|
9
77
|
|
|
10
78
|
# @return [String]
|
|
11
79
|
attr_reader :benefit_id
|
|
12
80
|
|
|
13
|
-
#
|
|
81
|
+
# Os metadados do benefício: os valores de uma feature flag.
|
|
82
|
+
# @return [Hash{String => Object}]
|
|
83
|
+
attr_reader :benefit_metadata
|
|
84
|
+
|
|
85
|
+
# @return [String ("custom", "license_key", "downloadable", "feature_flag", "meter_credit", "discord", "github_repository")]
|
|
14
86
|
attr_reader :benefit_type
|
|
15
87
|
|
|
16
88
|
# @return [String]
|
|
@@ -31,14 +103,19 @@ module Perata
|
|
|
31
103
|
# @return [Boolean]
|
|
32
104
|
attr_reader :is_revoked
|
|
33
105
|
|
|
106
|
+
# O que a concessão informa, conforme o tipo, sem credenciais.
|
|
107
|
+
# @return [Hash{String => Object}]
|
|
108
|
+
attr_reader :properties
|
|
109
|
+
|
|
34
110
|
# @return [String, nil]
|
|
35
111
|
attr_reader :revoked_at
|
|
36
112
|
|
|
37
113
|
# @return [String ("granted", "revoked")]
|
|
38
114
|
attr_reader :status
|
|
39
115
|
|
|
40
|
-
def initialize(benefit_id:, benefit_type:, created_at:, customer_id:, granted_at:, id:, is_granted:, is_revoked:, revoked_at:, status:)
|
|
116
|
+
def initialize(benefit_id:, benefit_metadata:, benefit_type:, created_at:, customer_id:, granted_at:, id:, is_granted:, is_revoked:, properties:, revoked_at:, status:)
|
|
41
117
|
@benefit_id = benefit_id
|
|
118
|
+
@benefit_metadata = benefit_metadata
|
|
42
119
|
@benefit_type = benefit_type
|
|
43
120
|
@created_at = created_at
|
|
44
121
|
@customer_id = customer_id
|
|
@@ -46,6 +123,7 @@ module Perata
|
|
|
46
123
|
@id = id
|
|
47
124
|
@is_granted = is_granted
|
|
48
125
|
@is_revoked = is_revoked
|
|
126
|
+
@properties = properties
|
|
49
127
|
@revoked_at = revoked_at
|
|
50
128
|
@status = status
|
|
51
129
|
freeze
|
|
@@ -55,6 +133,7 @@ module Perata
|
|
|
55
133
|
def self.from_hash(data)
|
|
56
134
|
new(
|
|
57
135
|
benefit_id: data.fetch("benefit_id"),
|
|
136
|
+
benefit_metadata: data.fetch("benefit_metadata"),
|
|
58
137
|
benefit_type: data.fetch("benefit_type"),
|
|
59
138
|
created_at: data.fetch("created_at"),
|
|
60
139
|
customer_id: data.fetch("customer_id"),
|
|
@@ -62,12 +141,66 @@ module Perata
|
|
|
62
141
|
id: data.fetch("id"),
|
|
63
142
|
is_granted: data.fetch("is_granted"),
|
|
64
143
|
is_revoked: data.fetch("is_revoked"),
|
|
144
|
+
properties: data.fetch("properties"),
|
|
65
145
|
revoked_at: data["revoked_at"],
|
|
66
146
|
status: data.fetch("status")
|
|
67
147
|
)
|
|
68
148
|
end
|
|
69
149
|
end
|
|
70
150
|
|
|
151
|
+
# BillingAddress is a resource of Peráta's API.
|
|
152
|
+
class BillingAddress < Model
|
|
153
|
+
MEMBERS = %i[city country district line1 line2 postal_code state].freeze
|
|
154
|
+
|
|
155
|
+
# @return [String]
|
|
156
|
+
attr_reader :city
|
|
157
|
+
|
|
158
|
+
# @return [String]
|
|
159
|
+
attr_reader :country
|
|
160
|
+
|
|
161
|
+
# Bairro.
|
|
162
|
+
# @return [String]
|
|
163
|
+
attr_reader :district
|
|
164
|
+
|
|
165
|
+
# @return [String]
|
|
166
|
+
attr_reader :line1
|
|
167
|
+
|
|
168
|
+
# @return [String]
|
|
169
|
+
attr_reader :line2
|
|
170
|
+
|
|
171
|
+
# CEP, só dígitos.
|
|
172
|
+
# @return [String]
|
|
173
|
+
attr_reader :postal_code
|
|
174
|
+
|
|
175
|
+
# UF.
|
|
176
|
+
# @return [String]
|
|
177
|
+
attr_reader :state
|
|
178
|
+
|
|
179
|
+
def initialize(city:, country:, district:, line1:, line2:, postal_code:, state:)
|
|
180
|
+
@city = city
|
|
181
|
+
@country = country
|
|
182
|
+
@district = district
|
|
183
|
+
@line1 = line1
|
|
184
|
+
@line2 = line2
|
|
185
|
+
@postal_code = postal_code
|
|
186
|
+
@state = state
|
|
187
|
+
freeze
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Builds a BillingAddress from the API's JSON.
|
|
191
|
+
def self.from_hash(data)
|
|
192
|
+
new(
|
|
193
|
+
city: data.fetch("city"),
|
|
194
|
+
country: data.fetch("country"),
|
|
195
|
+
district: data.fetch("district"),
|
|
196
|
+
line1: data.fetch("line1"),
|
|
197
|
+
line2: data.fetch("line2"),
|
|
198
|
+
postal_code: data.fetch("postal_code"),
|
|
199
|
+
state: data.fetch("state")
|
|
200
|
+
)
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
71
204
|
# Card is a resource of Peráta's API.
|
|
72
205
|
class Card < Model
|
|
73
206
|
MEMBERS = %i[brand exp_month exp_year last4].freeze
|
|
@@ -105,25 +238,58 @@ module Perata
|
|
|
105
238
|
|
|
106
239
|
# Checkout is a resource of Peráta's API.
|
|
107
240
|
class Checkout < Model
|
|
108
|
-
MEMBERS = %i[id price_id product_id url].freeze
|
|
241
|
+
MEMBERS = %i[cancel_url created_at expires_at id label price_id product_id quantity status success_url url].freeze
|
|
242
|
+
|
|
243
|
+
# Endereço https para onde o comprador volta se desistir; vazio sem ele.
|
|
244
|
+
# @return [String]
|
|
245
|
+
attr_reader :cancel_url
|
|
246
|
+
|
|
247
|
+
# @return [String]
|
|
248
|
+
attr_reader :created_at
|
|
249
|
+
|
|
250
|
+
# Quando o checkout deixa de abrir sessões; nulo sem prazo.
|
|
251
|
+
# @return [String, nil]
|
|
252
|
+
attr_reader :expires_at
|
|
109
253
|
|
|
110
254
|
# @return [String]
|
|
111
255
|
attr_reader :id
|
|
112
256
|
|
|
257
|
+
# Como o lojista chama o checkout nas próprias telas; o comprador não vê.
|
|
258
|
+
# @return [String]
|
|
259
|
+
attr_reader :label
|
|
260
|
+
|
|
113
261
|
# @return [String]
|
|
114
262
|
attr_reader :price_id
|
|
115
263
|
|
|
116
264
|
# @return [String]
|
|
117
265
|
attr_reader :product_id
|
|
118
266
|
|
|
267
|
+
# @return [Integer]
|
|
268
|
+
attr_reader :quantity
|
|
269
|
+
|
|
270
|
+
# active abre sessões de compra; archived saiu de circulação.
|
|
271
|
+
# @return [String ("active", "archived")]
|
|
272
|
+
attr_reader :status
|
|
273
|
+
|
|
274
|
+
# Endereço https para onde o comprador volta depois de pagar; vazio sem ele.
|
|
275
|
+
# @return [String]
|
|
276
|
+
attr_reader :success_url
|
|
277
|
+
|
|
119
278
|
# Endereço para onde o comprador é enviado.
|
|
120
279
|
# @return [String]
|
|
121
280
|
attr_reader :url
|
|
122
281
|
|
|
123
|
-
def initialize(id:, price_id:, product_id:, url:)
|
|
282
|
+
def initialize(cancel_url:, created_at:, expires_at:, id:, label:, price_id:, product_id:, quantity:, status:, success_url:, url:)
|
|
283
|
+
@cancel_url = cancel_url
|
|
284
|
+
@created_at = created_at
|
|
285
|
+
@expires_at = expires_at
|
|
124
286
|
@id = id
|
|
287
|
+
@label = label
|
|
125
288
|
@price_id = price_id
|
|
126
289
|
@product_id = product_id
|
|
290
|
+
@quantity = quantity
|
|
291
|
+
@status = status
|
|
292
|
+
@success_url = success_url
|
|
127
293
|
@url = url
|
|
128
294
|
freeze
|
|
129
295
|
end
|
|
@@ -131,14 +297,180 @@ module Perata
|
|
|
131
297
|
# Builds a Checkout from the API's JSON.
|
|
132
298
|
def self.from_hash(data)
|
|
133
299
|
new(
|
|
300
|
+
cancel_url: data.fetch("cancel_url"),
|
|
301
|
+
created_at: data.fetch("created_at"),
|
|
302
|
+
expires_at: data["expires_at"],
|
|
303
|
+
id: data.fetch("id"),
|
|
304
|
+
label: data.fetch("label"),
|
|
305
|
+
price_id: data.fetch("price_id"),
|
|
306
|
+
product_id: data.fetch("product_id"),
|
|
307
|
+
quantity: data.fetch("quantity"),
|
|
308
|
+
status: data.fetch("status"),
|
|
309
|
+
success_url: data.fetch("success_url"),
|
|
310
|
+
url: data.fetch("url")
|
|
311
|
+
)
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# CheckoutLink is a resource of Peráta's API.
|
|
316
|
+
class CheckoutLink < Model
|
|
317
|
+
MEMBERS = %i[allow_discount_codes cancel_url capture_mode created_at discount_id expires_at id label max_installments metadata modified_at price_id product_id products quantity require_billing_address status success_url trial_interval trial_interval_count url].freeze
|
|
318
|
+
|
|
319
|
+
# Se o comprador pode digitar um código de desconto.
|
|
320
|
+
# @return [Boolean]
|
|
321
|
+
attr_reader :allow_discount_codes
|
|
322
|
+
|
|
323
|
+
# Endereço https para onde o comprador volta se desistir; vazio sem ele.
|
|
324
|
+
# @return [String]
|
|
325
|
+
attr_reader :cancel_url
|
|
326
|
+
|
|
327
|
+
# manual segura a venda no cartão para o lojista capturar depois.
|
|
328
|
+
# @return [String ("automatic", "manual")]
|
|
329
|
+
attr_reader :capture_mode
|
|
330
|
+
|
|
331
|
+
# @return [String]
|
|
332
|
+
attr_reader :created_at
|
|
333
|
+
|
|
334
|
+
# O desconto fixado no link; nulo sem ele.
|
|
335
|
+
# @return [String, nil]
|
|
336
|
+
attr_reader :discount_id
|
|
337
|
+
|
|
338
|
+
# Quando o link deixa de abrir checkouts; nulo sem prazo.
|
|
339
|
+
# @return [String, nil]
|
|
340
|
+
attr_reader :expires_at
|
|
341
|
+
|
|
342
|
+
# @return [String]
|
|
343
|
+
attr_reader :id
|
|
344
|
+
|
|
345
|
+
# Como o lojista chama o link nas próprias telas; o comprador não vê.
|
|
346
|
+
# @return [String]
|
|
347
|
+
attr_reader :label
|
|
348
|
+
|
|
349
|
+
# O máximo de parcelas no cartão de crédito; 0 segue o que a organização definiu.
|
|
350
|
+
# @return [Integer]
|
|
351
|
+
attr_reader :max_installments
|
|
352
|
+
|
|
353
|
+
# Metadados do lojista: pares chave e valor (texto, número ou booleano); objeto vazio quando não há.
|
|
354
|
+
# @return [Hash{String => Object}]
|
|
355
|
+
attr_reader :metadata
|
|
356
|
+
|
|
357
|
+
# @return [String]
|
|
358
|
+
attr_reader :modified_at
|
|
359
|
+
|
|
360
|
+
# O preço do primeiro produto.
|
|
361
|
+
# @return [String]
|
|
362
|
+
attr_reader :price_id
|
|
363
|
+
|
|
364
|
+
# O primeiro produto do link.
|
|
365
|
+
# @return [String]
|
|
366
|
+
attr_reader :product_id
|
|
367
|
+
|
|
368
|
+
# Os produtos que o link vende, na ordem em que o comprador os vê.
|
|
369
|
+
# @return [Array<CheckoutLinkProduct>]
|
|
370
|
+
attr_reader :products
|
|
371
|
+
|
|
372
|
+
# @return [Integer]
|
|
373
|
+
attr_reader :quantity
|
|
374
|
+
|
|
375
|
+
# @return [Boolean]
|
|
376
|
+
attr_reader :require_billing_address
|
|
377
|
+
|
|
378
|
+
# @return [String ("active", "archived")]
|
|
379
|
+
attr_reader :status
|
|
380
|
+
|
|
381
|
+
# Endereço https para onde o comprador volta depois de pagar; vazio sem ele.
|
|
382
|
+
# @return [String]
|
|
383
|
+
attr_reader :success_url
|
|
384
|
+
|
|
385
|
+
# O período de teste gratuito do link, no lugar do produto; nulo mantém o do produto.
|
|
386
|
+
# @return [String ("day", "week", "month", "year"), nil]
|
|
387
|
+
attr_reader :trial_interval
|
|
388
|
+
|
|
389
|
+
# @return [Integer, nil]
|
|
390
|
+
attr_reader :trial_interval_count
|
|
391
|
+
|
|
392
|
+
# Endereço para onde o comprador é enviado.
|
|
393
|
+
# @return [String]
|
|
394
|
+
attr_reader :url
|
|
395
|
+
|
|
396
|
+
def initialize(allow_discount_codes:, cancel_url:, capture_mode:, created_at:, discount_id:, expires_at:, id:, label:, max_installments:, metadata:, modified_at:, price_id:, product_id:, products:, quantity:, require_billing_address:, status:, success_url:, trial_interval:, trial_interval_count:, url:)
|
|
397
|
+
@allow_discount_codes = allow_discount_codes
|
|
398
|
+
@cancel_url = cancel_url
|
|
399
|
+
@capture_mode = capture_mode
|
|
400
|
+
@created_at = created_at
|
|
401
|
+
@discount_id = discount_id
|
|
402
|
+
@expires_at = expires_at
|
|
403
|
+
@id = id
|
|
404
|
+
@label = label
|
|
405
|
+
@max_installments = max_installments
|
|
406
|
+
@metadata = metadata
|
|
407
|
+
@modified_at = modified_at
|
|
408
|
+
@price_id = price_id
|
|
409
|
+
@product_id = product_id
|
|
410
|
+
@products = products
|
|
411
|
+
@quantity = quantity
|
|
412
|
+
@require_billing_address = require_billing_address
|
|
413
|
+
@status = status
|
|
414
|
+
@success_url = success_url
|
|
415
|
+
@trial_interval = trial_interval
|
|
416
|
+
@trial_interval_count = trial_interval_count
|
|
417
|
+
@url = url
|
|
418
|
+
freeze
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
# Builds a CheckoutLink from the API's JSON.
|
|
422
|
+
def self.from_hash(data)
|
|
423
|
+
new(
|
|
424
|
+
allow_discount_codes: data.fetch("allow_discount_codes"),
|
|
425
|
+
cancel_url: data.fetch("cancel_url"),
|
|
426
|
+
capture_mode: data.fetch("capture_mode"),
|
|
427
|
+
created_at: data.fetch("created_at"),
|
|
428
|
+
discount_id: data["discount_id"],
|
|
429
|
+
expires_at: data["expires_at"],
|
|
134
430
|
id: data.fetch("id"),
|
|
431
|
+
label: data.fetch("label"),
|
|
432
|
+
max_installments: data.fetch("max_installments"),
|
|
433
|
+
metadata: data.fetch("metadata"),
|
|
434
|
+
modified_at: data.fetch("modified_at"),
|
|
135
435
|
price_id: data.fetch("price_id"),
|
|
136
436
|
product_id: data.fetch("product_id"),
|
|
437
|
+
products: data.fetch("products").map { |item| CheckoutLinkProduct.from_hash(item) },
|
|
438
|
+
quantity: data.fetch("quantity"),
|
|
439
|
+
require_billing_address: data.fetch("require_billing_address"),
|
|
440
|
+
status: data.fetch("status"),
|
|
441
|
+
success_url: data.fetch("success_url"),
|
|
442
|
+
trial_interval: data["trial_interval"],
|
|
443
|
+
trial_interval_count: data["trial_interval_count"],
|
|
137
444
|
url: data.fetch("url")
|
|
138
445
|
)
|
|
139
446
|
end
|
|
140
447
|
end
|
|
141
448
|
|
|
449
|
+
# CheckoutLinkProduct is a resource of Peráta's API.
|
|
450
|
+
class CheckoutLinkProduct < Model
|
|
451
|
+
MEMBERS = %i[price_id product_id].freeze
|
|
452
|
+
|
|
453
|
+
# @return [String]
|
|
454
|
+
attr_reader :price_id
|
|
455
|
+
|
|
456
|
+
# @return [String]
|
|
457
|
+
attr_reader :product_id
|
|
458
|
+
|
|
459
|
+
def initialize(price_id:, product_id:)
|
|
460
|
+
@price_id = price_id
|
|
461
|
+
@product_id = product_id
|
|
462
|
+
freeze
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
# Builds a CheckoutLinkProduct from the API's JSON.
|
|
466
|
+
def self.from_hash(data)
|
|
467
|
+
new(
|
|
468
|
+
price_id: data.fetch("price_id"),
|
|
469
|
+
product_id: data.fetch("product_id")
|
|
470
|
+
)
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
|
|
142
474
|
# Customer is a resource of Peráta's API.
|
|
143
475
|
class Customer < Model
|
|
144
476
|
MEMBERS = %i[created_at email external_id id name status].freeze
|
|
@@ -216,69 +548,762 @@ module Perata
|
|
|
216
548
|
end
|
|
217
549
|
end
|
|
218
550
|
|
|
219
|
-
#
|
|
220
|
-
class
|
|
221
|
-
MEMBERS = %i[
|
|
551
|
+
# CustomerState is a resource of Peráta's API.
|
|
552
|
+
class CustomerState < Model
|
|
553
|
+
MEMBERS = %i[active_subscriptions created_at email external_id granted_benefits id name status].freeze
|
|
222
554
|
|
|
223
|
-
#
|
|
224
|
-
|
|
555
|
+
# As assinaturas ativas ou em teste do cliente.
|
|
556
|
+
# @return [Array<Subscription>]
|
|
557
|
+
attr_reader :active_subscriptions
|
|
225
558
|
|
|
226
|
-
# @return [String
|
|
227
|
-
attr_reader :
|
|
559
|
+
# @return [String]
|
|
560
|
+
attr_reader :created_at
|
|
228
561
|
|
|
229
562
|
# @return [String]
|
|
230
|
-
attr_reader :
|
|
563
|
+
attr_reader :email
|
|
564
|
+
|
|
565
|
+
# @return [String]
|
|
566
|
+
attr_reader :external_id
|
|
567
|
+
|
|
568
|
+
# Os benefícios que o cliente tem agora.
|
|
569
|
+
# @return [Array<CustomerStateBenefitGrant>]
|
|
570
|
+
attr_reader :granted_benefits
|
|
231
571
|
|
|
232
572
|
# @return [String]
|
|
233
573
|
attr_reader :id
|
|
234
574
|
|
|
235
|
-
#
|
|
236
|
-
|
|
237
|
-
attr_reader :installment_interest_cents
|
|
575
|
+
# @return [String]
|
|
576
|
+
attr_reader :name
|
|
238
577
|
|
|
239
|
-
#
|
|
240
|
-
|
|
241
|
-
|
|
578
|
+
# @return [String ("active", "archived")]
|
|
579
|
+
attr_reader :status
|
|
580
|
+
|
|
581
|
+
def initialize(active_subscriptions:, created_at:, email:, external_id:, granted_benefits:, id:, name:, status:)
|
|
582
|
+
@active_subscriptions = active_subscriptions
|
|
583
|
+
@created_at = created_at
|
|
584
|
+
@email = email
|
|
585
|
+
@external_id = external_id
|
|
586
|
+
@granted_benefits = granted_benefits
|
|
587
|
+
@id = id
|
|
588
|
+
@name = name
|
|
589
|
+
@status = status
|
|
590
|
+
freeze
|
|
591
|
+
end
|
|
592
|
+
|
|
593
|
+
# Builds a CustomerState from the API's JSON.
|
|
594
|
+
def self.from_hash(data)
|
|
595
|
+
new(
|
|
596
|
+
active_subscriptions: data.fetch("active_subscriptions").map { |item| Subscription.from_hash(item) },
|
|
597
|
+
created_at: data.fetch("created_at"),
|
|
598
|
+
email: data.fetch("email"),
|
|
599
|
+
external_id: data.fetch("external_id"),
|
|
600
|
+
granted_benefits: data.fetch("granted_benefits").map { |item| CustomerStateBenefitGrant.from_hash(item) },
|
|
601
|
+
id: data.fetch("id"),
|
|
602
|
+
name: data.fetch("name"),
|
|
603
|
+
status: data.fetch("status")
|
|
604
|
+
)
|
|
605
|
+
end
|
|
606
|
+
end
|
|
607
|
+
|
|
608
|
+
# CustomerStateBenefitGrant is a resource of Peráta's API.
|
|
609
|
+
class CustomerStateBenefitGrant < Model
|
|
610
|
+
MEMBERS = %i[benefit_id benefit_metadata benefit_type granted_at id properties].freeze
|
|
611
|
+
|
|
612
|
+
# @return [String]
|
|
613
|
+
attr_reader :benefit_id
|
|
614
|
+
|
|
615
|
+
# Os metadados do benefício: os valores de uma feature flag.
|
|
616
|
+
# @return [Hash{String => Object}]
|
|
617
|
+
attr_reader :benefit_metadata
|
|
618
|
+
|
|
619
|
+
# @return [String ("custom", "license_key", "downloadable", "feature_flag", "meter_credit", "discord", "github_repository")]
|
|
620
|
+
attr_reader :benefit_type
|
|
621
|
+
|
|
622
|
+
# @return [String]
|
|
623
|
+
attr_reader :granted_at
|
|
624
|
+
|
|
625
|
+
# A concessão.
|
|
626
|
+
# @return [String]
|
|
627
|
+
attr_reader :id
|
|
628
|
+
|
|
629
|
+
# O que a concessão informa, conforme o tipo.
|
|
630
|
+
# @return [Hash{String => Object}]
|
|
631
|
+
attr_reader :properties
|
|
632
|
+
|
|
633
|
+
def initialize(benefit_id:, benefit_metadata:, benefit_type:, granted_at:, id:, properties:)
|
|
634
|
+
@benefit_id = benefit_id
|
|
635
|
+
@benefit_metadata = benefit_metadata
|
|
636
|
+
@benefit_type = benefit_type
|
|
637
|
+
@granted_at = granted_at
|
|
638
|
+
@id = id
|
|
639
|
+
@properties = properties
|
|
640
|
+
freeze
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
# Builds a CustomerStateBenefitGrant from the API's JSON.
|
|
644
|
+
def self.from_hash(data)
|
|
645
|
+
new(
|
|
646
|
+
benefit_id: data.fetch("benefit_id"),
|
|
647
|
+
benefit_metadata: data.fetch("benefit_metadata"),
|
|
648
|
+
benefit_type: data.fetch("benefit_type"),
|
|
649
|
+
granted_at: data.fetch("granted_at"),
|
|
650
|
+
id: data.fetch("id"),
|
|
651
|
+
properties: data.fetch("properties")
|
|
652
|
+
)
|
|
653
|
+
end
|
|
654
|
+
end
|
|
655
|
+
|
|
656
|
+
# Discount is a resource of Peráta's API.
|
|
657
|
+
class Discount < Model
|
|
658
|
+
MEMBERS = %i[amount_cents basis_points code created_at currency duration duration_in_months ends_at id max_redemptions max_redemptions_per_customer modified_at name product_ids redemptions_count starts_at status type].freeze
|
|
659
|
+
|
|
660
|
+
# O valor fixo em centavos; 0 em um desconto percentual.
|
|
661
|
+
# @return [Integer]
|
|
662
|
+
attr_reader :amount_cents
|
|
663
|
+
|
|
664
|
+
# O percentual em centésimos de ponto percentual, 10000 é 100%; 0 em um desconto fixo.
|
|
665
|
+
# @return [Integer]
|
|
666
|
+
attr_reader :basis_points
|
|
667
|
+
|
|
668
|
+
# O código que o cliente digita no checkout; nulo quando o desconto só se aplica por um link de checkout ou pela API.
|
|
669
|
+
# @return [String, nil]
|
|
670
|
+
attr_reader :code
|
|
671
|
+
|
|
672
|
+
# @return [String]
|
|
673
|
+
attr_reader :created_at
|
|
674
|
+
|
|
675
|
+
# @return [String ("BRL")]
|
|
676
|
+
attr_reader :currency
|
|
677
|
+
|
|
678
|
+
# Em uma assinatura: só na primeira fatura, por duration_in_months meses ou para sempre.
|
|
679
|
+
# @return [String ("once", "repeating", "forever")]
|
|
680
|
+
attr_reader :duration
|
|
681
|
+
|
|
682
|
+
# Os meses de um desconto repeating; 0 nos outros.
|
|
683
|
+
# @return [Integer]
|
|
684
|
+
attr_reader :duration_in_months
|
|
685
|
+
|
|
686
|
+
# Depois de quando deixa de valer; nulo sem fim.
|
|
687
|
+
# @return [String, nil]
|
|
688
|
+
attr_reader :ends_at
|
|
689
|
+
|
|
690
|
+
# @return [String]
|
|
691
|
+
attr_reader :id
|
|
692
|
+
|
|
693
|
+
# Quantas vezes o desconto pode ser usado no total; nulo sem limite.
|
|
694
|
+
# @return [Integer, nil]
|
|
695
|
+
attr_reader :max_redemptions
|
|
696
|
+
|
|
697
|
+
# Quantas vezes um mesmo cliente pode usá-lo, de 1 a 100; nulo sem limite.
|
|
698
|
+
# @return [Integer, nil]
|
|
699
|
+
attr_reader :max_redemptions_per_customer
|
|
700
|
+
|
|
701
|
+
# @return [String]
|
|
702
|
+
attr_reader :modified_at
|
|
703
|
+
|
|
704
|
+
# Mostrado ao cliente quando o desconto é aplicado.
|
|
705
|
+
# @return [String]
|
|
706
|
+
attr_reader :name
|
|
707
|
+
|
|
708
|
+
# Os produtos a que o desconto se aplica; vazio, todos os do catálogo.
|
|
709
|
+
# @return [Array<String>]
|
|
710
|
+
attr_reader :product_ids
|
|
711
|
+
|
|
712
|
+
# @return [Integer]
|
|
713
|
+
attr_reader :redemptions_count
|
|
714
|
+
|
|
715
|
+
# A partir de quando o desconto vale.
|
|
716
|
+
# @return [String]
|
|
717
|
+
attr_reader :starts_at
|
|
718
|
+
|
|
719
|
+
# @return [String ("active", "expired", "exhausted")]
|
|
720
|
+
attr_reader :status
|
|
721
|
+
|
|
722
|
+
# @return [String ("percentage", "fixed")]
|
|
723
|
+
attr_reader :type
|
|
724
|
+
|
|
725
|
+
def initialize(amount_cents:, basis_points:, code:, created_at:, currency:, duration:, duration_in_months:, ends_at:, id:, max_redemptions:, max_redemptions_per_customer:, modified_at:, name:, product_ids:, redemptions_count:, starts_at:, status:, type:)
|
|
726
|
+
@amount_cents = amount_cents
|
|
727
|
+
@basis_points = basis_points
|
|
728
|
+
@code = code
|
|
729
|
+
@created_at = created_at
|
|
730
|
+
@currency = currency
|
|
731
|
+
@duration = duration
|
|
732
|
+
@duration_in_months = duration_in_months
|
|
733
|
+
@ends_at = ends_at
|
|
734
|
+
@id = id
|
|
735
|
+
@max_redemptions = max_redemptions
|
|
736
|
+
@max_redemptions_per_customer = max_redemptions_per_customer
|
|
737
|
+
@modified_at = modified_at
|
|
738
|
+
@name = name
|
|
739
|
+
@product_ids = product_ids
|
|
740
|
+
@redemptions_count = redemptions_count
|
|
741
|
+
@starts_at = starts_at
|
|
742
|
+
@status = status
|
|
743
|
+
@type = type
|
|
744
|
+
freeze
|
|
745
|
+
end
|
|
746
|
+
|
|
747
|
+
# Builds a Discount from the API's JSON.
|
|
748
|
+
def self.from_hash(data)
|
|
749
|
+
new(
|
|
750
|
+
amount_cents: data.fetch("amount_cents"),
|
|
751
|
+
basis_points: data.fetch("basis_points"),
|
|
752
|
+
code: data["code"],
|
|
753
|
+
created_at: data.fetch("created_at"),
|
|
754
|
+
currency: data.fetch("currency"),
|
|
755
|
+
duration: data.fetch("duration"),
|
|
756
|
+
duration_in_months: data.fetch("duration_in_months"),
|
|
757
|
+
ends_at: data["ends_at"],
|
|
758
|
+
id: data.fetch("id"),
|
|
759
|
+
max_redemptions: data["max_redemptions"],
|
|
760
|
+
max_redemptions_per_customer: data["max_redemptions_per_customer"],
|
|
761
|
+
modified_at: data.fetch("modified_at"),
|
|
762
|
+
name: data.fetch("name"),
|
|
763
|
+
product_ids: data.fetch("product_ids"),
|
|
764
|
+
redemptions_count: data.fetch("redemptions_count"),
|
|
765
|
+
starts_at: data.fetch("starts_at"),
|
|
766
|
+
status: data.fetch("status"),
|
|
767
|
+
type: data.fetch("type")
|
|
768
|
+
)
|
|
769
|
+
end
|
|
770
|
+
end
|
|
771
|
+
|
|
772
|
+
# Dispute is a resource of Peráta's API.
|
|
773
|
+
class Dispute < Model
|
|
774
|
+
MEMBERS = %i[amount_cents currency customer_id decided_at due_by id invoice_id opened_at order_id payment_id provider_dispute_id provider_reason reason source status].freeze
|
|
775
|
+
|
|
776
|
+
# Valor contestado, em centavos.
|
|
777
|
+
# @return [Integer]
|
|
778
|
+
attr_reader :amount_cents
|
|
779
|
+
|
|
780
|
+
# @return [String ("BRL")]
|
|
781
|
+
attr_reader :currency
|
|
782
|
+
|
|
783
|
+
# @return [String, nil]
|
|
784
|
+
attr_reader :customer_id
|
|
785
|
+
|
|
786
|
+
# @return [String, nil]
|
|
787
|
+
attr_reader :decided_at
|
|
788
|
+
|
|
789
|
+
# Prazo da defesa.
|
|
790
|
+
# @return [String, nil]
|
|
791
|
+
attr_reader :due_by
|
|
792
|
+
|
|
793
|
+
# @return [String]
|
|
794
|
+
attr_reader :id
|
|
795
|
+
|
|
796
|
+
# @return [String, nil]
|
|
797
|
+
attr_reader :invoice_id
|
|
798
|
+
|
|
799
|
+
# @return [String]
|
|
800
|
+
attr_reader :opened_at
|
|
801
|
+
|
|
802
|
+
# O pedido que a venda contestada pagou; nulo quando não é de um checkout.
|
|
803
|
+
# @return [String, nil]
|
|
804
|
+
attr_reader :order_id
|
|
805
|
+
|
|
806
|
+
# O PaymentId da venda contestada na Cielo.
|
|
807
|
+
# @return [String]
|
|
808
|
+
attr_reader :payment_id
|
|
809
|
+
|
|
810
|
+
# O número do caso na Cielo.
|
|
811
|
+
# @return [String]
|
|
812
|
+
attr_reader :provider_dispute_id
|
|
813
|
+
|
|
814
|
+
# O motivo nas palavras da Cielo.
|
|
815
|
+
# @return [String]
|
|
816
|
+
attr_reader :provider_reason
|
|
817
|
+
|
|
818
|
+
# Motivo, do conjunto fechado; unknown quando a adquirente não informou.
|
|
819
|
+
# @return [String]
|
|
820
|
+
attr_reader :reason
|
|
821
|
+
|
|
822
|
+
# @return [String ("operator", "cielo_chargeback")]
|
|
823
|
+
attr_reader :source
|
|
824
|
+
|
|
825
|
+
# @return [String ("opened", "needs_evidence", "submitted", "under_review", "won", "lost", "closed")]
|
|
826
|
+
attr_reader :status
|
|
827
|
+
|
|
828
|
+
def initialize(amount_cents:, currency:, customer_id:, decided_at:, due_by:, id:, invoice_id:, opened_at:, order_id:, payment_id:, provider_dispute_id:, provider_reason:, reason:, source:, status:)
|
|
829
|
+
@amount_cents = amount_cents
|
|
830
|
+
@currency = currency
|
|
831
|
+
@customer_id = customer_id
|
|
832
|
+
@decided_at = decided_at
|
|
833
|
+
@due_by = due_by
|
|
834
|
+
@id = id
|
|
835
|
+
@invoice_id = invoice_id
|
|
836
|
+
@opened_at = opened_at
|
|
837
|
+
@order_id = order_id
|
|
838
|
+
@payment_id = payment_id
|
|
839
|
+
@provider_dispute_id = provider_dispute_id
|
|
840
|
+
@provider_reason = provider_reason
|
|
841
|
+
@reason = reason
|
|
842
|
+
@source = source
|
|
843
|
+
@status = status
|
|
844
|
+
freeze
|
|
845
|
+
end
|
|
846
|
+
|
|
847
|
+
# Builds a Dispute from the API's JSON.
|
|
848
|
+
def self.from_hash(data)
|
|
849
|
+
new(
|
|
850
|
+
amount_cents: data.fetch("amount_cents"),
|
|
851
|
+
currency: data.fetch("currency"),
|
|
852
|
+
customer_id: data["customer_id"],
|
|
853
|
+
decided_at: data["decided_at"],
|
|
854
|
+
due_by: data["due_by"],
|
|
855
|
+
id: data.fetch("id"),
|
|
856
|
+
invoice_id: data["invoice_id"],
|
|
857
|
+
opened_at: data.fetch("opened_at"),
|
|
858
|
+
order_id: data["order_id"],
|
|
859
|
+
payment_id: data.fetch("payment_id"),
|
|
860
|
+
provider_dispute_id: data.fetch("provider_dispute_id"),
|
|
861
|
+
provider_reason: data.fetch("provider_reason"),
|
|
862
|
+
reason: data.fetch("reason"),
|
|
863
|
+
source: data.fetch("source"),
|
|
864
|
+
status: data.fetch("status")
|
|
865
|
+
)
|
|
866
|
+
end
|
|
867
|
+
end
|
|
868
|
+
|
|
869
|
+
# Event is a resource of Peráta's API.
|
|
870
|
+
class Event < Model
|
|
871
|
+
MEMBERS = %i[cached_tokens cost_currency cost_micro_cents customer_id external_id id input_tokens llm_model llm_vendor name output_tokens parent_id received_at source_id timestamp].freeze
|
|
872
|
+
|
|
873
|
+
# @return [Integer]
|
|
874
|
+
attr_reader :cached_tokens
|
|
875
|
+
|
|
876
|
+
# @return [String]
|
|
877
|
+
attr_reader :cost_currency
|
|
878
|
+
|
|
879
|
+
# O custo da chamada em milionésimos de centavo.
|
|
880
|
+
# @return [Integer]
|
|
881
|
+
attr_reader :cost_micro_cents
|
|
882
|
+
|
|
883
|
+
# @return [String]
|
|
884
|
+
attr_reader :customer_id
|
|
885
|
+
|
|
886
|
+
# O identificador do evento no sistema da origem.
|
|
887
|
+
# @return [String]
|
|
888
|
+
attr_reader :external_id
|
|
889
|
+
|
|
890
|
+
# @return [String]
|
|
891
|
+
attr_reader :id
|
|
892
|
+
|
|
893
|
+
# @return [Integer]
|
|
894
|
+
attr_reader :input_tokens
|
|
895
|
+
|
|
896
|
+
# @return [String]
|
|
897
|
+
attr_reader :llm_model
|
|
898
|
+
|
|
899
|
+
# @return [String]
|
|
900
|
+
attr_reader :llm_vendor
|
|
901
|
+
|
|
902
|
+
# @return [String ("token_usage")]
|
|
903
|
+
attr_reader :name
|
|
904
|
+
|
|
905
|
+
# @return [Integer]
|
|
906
|
+
attr_reader :output_tokens
|
|
907
|
+
|
|
908
|
+
# O evento de que este é filho; nulo na raiz.
|
|
909
|
+
# @return [String, nil]
|
|
910
|
+
attr_reader :parent_id
|
|
911
|
+
|
|
912
|
+
# @return [String]
|
|
913
|
+
attr_reader :received_at
|
|
914
|
+
|
|
915
|
+
# A origem que enviou o evento.
|
|
916
|
+
# @return [String]
|
|
917
|
+
attr_reader :source_id
|
|
918
|
+
|
|
919
|
+
# Quando o evento aconteceu.
|
|
920
|
+
# @return [String]
|
|
921
|
+
attr_reader :timestamp
|
|
922
|
+
|
|
923
|
+
def initialize(cached_tokens:, cost_currency:, cost_micro_cents:, customer_id:, external_id:, id:, input_tokens:, llm_model:, llm_vendor:, name:, output_tokens:, parent_id:, received_at:, source_id:, timestamp:)
|
|
924
|
+
@cached_tokens = cached_tokens
|
|
925
|
+
@cost_currency = cost_currency
|
|
926
|
+
@cost_micro_cents = cost_micro_cents
|
|
927
|
+
@customer_id = customer_id
|
|
928
|
+
@external_id = external_id
|
|
929
|
+
@id = id
|
|
930
|
+
@input_tokens = input_tokens
|
|
931
|
+
@llm_model = llm_model
|
|
932
|
+
@llm_vendor = llm_vendor
|
|
933
|
+
@name = name
|
|
934
|
+
@output_tokens = output_tokens
|
|
935
|
+
@parent_id = parent_id
|
|
936
|
+
@received_at = received_at
|
|
937
|
+
@source_id = source_id
|
|
938
|
+
@timestamp = timestamp
|
|
939
|
+
freeze
|
|
940
|
+
end
|
|
941
|
+
|
|
942
|
+
# Builds a Event from the API's JSON.
|
|
943
|
+
def self.from_hash(data)
|
|
944
|
+
new(
|
|
945
|
+
cached_tokens: data.fetch("cached_tokens"),
|
|
946
|
+
cost_currency: data.fetch("cost_currency"),
|
|
947
|
+
cost_micro_cents: data.fetch("cost_micro_cents"),
|
|
948
|
+
customer_id: data.fetch("customer_id"),
|
|
949
|
+
external_id: data.fetch("external_id"),
|
|
950
|
+
id: data.fetch("id"),
|
|
951
|
+
input_tokens: data.fetch("input_tokens"),
|
|
952
|
+
llm_model: data.fetch("llm_model"),
|
|
953
|
+
llm_vendor: data.fetch("llm_vendor"),
|
|
954
|
+
name: data.fetch("name"),
|
|
955
|
+
output_tokens: data.fetch("output_tokens"),
|
|
956
|
+
parent_id: data["parent_id"],
|
|
957
|
+
received_at: data.fetch("received_at"),
|
|
958
|
+
source_id: data.fetch("source_id"),
|
|
959
|
+
timestamp: data.fetch("timestamp")
|
|
960
|
+
)
|
|
961
|
+
end
|
|
962
|
+
end
|
|
963
|
+
|
|
964
|
+
# Meter is a resource of Peráta's API.
|
|
965
|
+
class Meter < Model
|
|
966
|
+
MEMBERS = %i[aggregation archived_at created_at filter id modified_at name unit].freeze
|
|
967
|
+
|
|
968
|
+
# @return [MeterAggregation]
|
|
969
|
+
attr_reader :aggregation
|
|
970
|
+
|
|
971
|
+
# Quando o medidor foi arquivado; nulo se está ativo.
|
|
972
|
+
# @return [String, nil]
|
|
973
|
+
attr_reader :archived_at
|
|
974
|
+
|
|
975
|
+
# @return [String]
|
|
976
|
+
attr_reader :created_at
|
|
977
|
+
|
|
978
|
+
# Os eventos que o medidor conta: grupos de condições, em conjunction and ou or, sobre name, timestamp ou metadata.<chave>.
|
|
979
|
+
# @return [Hash{String => Object}]
|
|
980
|
+
attr_reader :filter
|
|
981
|
+
|
|
982
|
+
# @return [String]
|
|
983
|
+
attr_reader :id
|
|
984
|
+
|
|
985
|
+
# @return [String]
|
|
986
|
+
attr_reader :modified_at
|
|
987
|
+
|
|
988
|
+
# @return [String]
|
|
989
|
+
attr_reader :name
|
|
990
|
+
|
|
991
|
+
# @return [MeterUnit]
|
|
992
|
+
attr_reader :unit
|
|
993
|
+
|
|
994
|
+
def initialize(aggregation:, archived_at:, created_at:, filter:, id:, modified_at:, name:, unit:)
|
|
995
|
+
@aggregation = aggregation
|
|
996
|
+
@archived_at = archived_at
|
|
997
|
+
@created_at = created_at
|
|
998
|
+
@filter = filter
|
|
999
|
+
@id = id
|
|
1000
|
+
@modified_at = modified_at
|
|
1001
|
+
@name = name
|
|
1002
|
+
@unit = unit
|
|
1003
|
+
freeze
|
|
1004
|
+
end
|
|
1005
|
+
|
|
1006
|
+
# Builds a Meter from the API's JSON.
|
|
1007
|
+
def self.from_hash(data)
|
|
1008
|
+
new(
|
|
1009
|
+
aggregation: MeterAggregation.from_hash(data.fetch("aggregation")),
|
|
1010
|
+
archived_at: data["archived_at"],
|
|
1011
|
+
created_at: data.fetch("created_at"),
|
|
1012
|
+
filter: data.fetch("filter"),
|
|
1013
|
+
id: data.fetch("id"),
|
|
1014
|
+
modified_at: data.fetch("modified_at"),
|
|
1015
|
+
name: data.fetch("name"),
|
|
1016
|
+
unit: MeterUnit.from_hash(data.fetch("unit"))
|
|
1017
|
+
)
|
|
1018
|
+
end
|
|
1019
|
+
end
|
|
1020
|
+
|
|
1021
|
+
# MeterAggregation is a resource of Peráta's API.
|
|
1022
|
+
class MeterAggregation < Model
|
|
1023
|
+
MEMBERS = %i[func property].freeze
|
|
1024
|
+
|
|
1025
|
+
# @return [String ("count", "sum", "avg", "min", "max", "unique")]
|
|
1026
|
+
attr_reader :func
|
|
1027
|
+
|
|
1028
|
+
# A propriedade do evento que as funções, menos count, leem; vazia no count.
|
|
1029
|
+
# @return [String]
|
|
1030
|
+
attr_reader :property
|
|
1031
|
+
|
|
1032
|
+
def initialize(func:, property:)
|
|
1033
|
+
@func = func
|
|
1034
|
+
@property = property
|
|
1035
|
+
freeze
|
|
1036
|
+
end
|
|
1037
|
+
|
|
1038
|
+
# Builds a MeterAggregation from the API's JSON.
|
|
1039
|
+
def self.from_hash(data)
|
|
1040
|
+
new(
|
|
1041
|
+
func: data.fetch("func"),
|
|
1042
|
+
property: data.fetch("property")
|
|
1043
|
+
)
|
|
1044
|
+
end
|
|
1045
|
+
end
|
|
1046
|
+
|
|
1047
|
+
# MeterUnit is a resource of Peráta's API.
|
|
1048
|
+
class MeterUnit < Model
|
|
1049
|
+
MEMBERS = %i[label multiplier type].freeze
|
|
1050
|
+
|
|
1051
|
+
# @return [String]
|
|
1052
|
+
attr_reader :label
|
|
1053
|
+
|
|
1054
|
+
# Por quantas unidades o preço é mostrado.
|
|
1055
|
+
# @return [Integer]
|
|
1056
|
+
attr_reader :multiplier
|
|
1057
|
+
|
|
1058
|
+
# @return [String ("scalar", "token", "custom")]
|
|
1059
|
+
attr_reader :type
|
|
1060
|
+
|
|
1061
|
+
def initialize(label:, multiplier:, type:)
|
|
1062
|
+
@label = label
|
|
1063
|
+
@multiplier = multiplier
|
|
1064
|
+
@type = type
|
|
1065
|
+
freeze
|
|
1066
|
+
end
|
|
1067
|
+
|
|
1068
|
+
# Builds a MeterUnit from the API's JSON.
|
|
1069
|
+
def self.from_hash(data)
|
|
1070
|
+
new(
|
|
1071
|
+
label: data.fetch("label"),
|
|
1072
|
+
multiplier: data.fetch("multiplier"),
|
|
1073
|
+
type: data.fetch("type")
|
|
1074
|
+
)
|
|
1075
|
+
end
|
|
1076
|
+
end
|
|
1077
|
+
|
|
1078
|
+
# Order is a resource of Peráta's API.
|
|
1079
|
+
class Order < Model
|
|
1080
|
+
MEMBERS = %i[amount_cents currency customer_id id installment_interest_cents installments paid_at price_id product_id status].freeze
|
|
1081
|
+
|
|
1082
|
+
# @return [Integer]
|
|
1083
|
+
attr_reader :amount_cents
|
|
1084
|
+
|
|
1085
|
+
# @return [String ("BRL")]
|
|
1086
|
+
attr_reader :currency
|
|
1087
|
+
|
|
1088
|
+
# @return [String]
|
|
1089
|
+
attr_reader :customer_id
|
|
1090
|
+
|
|
1091
|
+
# @return [String]
|
|
1092
|
+
attr_reader :id
|
|
1093
|
+
|
|
1094
|
+
# Juros do parcelamento pagos pelo comprador, cobrados além de amount_cents.
|
|
1095
|
+
# @return [Integer]
|
|
1096
|
+
attr_reader :installment_interest_cents
|
|
1097
|
+
|
|
1098
|
+
# Em quantas parcelas o cartão de crédito foi cobrado; 1 à vista.
|
|
1099
|
+
# @return [Integer]
|
|
1100
|
+
attr_reader :installments
|
|
1101
|
+
|
|
1102
|
+
# @return [String, nil]
|
|
1103
|
+
attr_reader :paid_at
|
|
1104
|
+
|
|
1105
|
+
# @return [String]
|
|
1106
|
+
attr_reader :price_id
|
|
1107
|
+
|
|
1108
|
+
# @return [String]
|
|
1109
|
+
attr_reader :product_id
|
|
1110
|
+
|
|
1111
|
+
# @return [String ("open", "confirmed", "succeeded", "failed", "expired")]
|
|
1112
|
+
attr_reader :status
|
|
1113
|
+
|
|
1114
|
+
def initialize(amount_cents:, currency:, customer_id:, id:, installment_interest_cents:, installments:, paid_at:, price_id:, product_id:, status:)
|
|
1115
|
+
@amount_cents = amount_cents
|
|
1116
|
+
@currency = currency
|
|
1117
|
+
@customer_id = customer_id
|
|
1118
|
+
@id = id
|
|
1119
|
+
@installment_interest_cents = installment_interest_cents
|
|
1120
|
+
@installments = installments
|
|
1121
|
+
@paid_at = paid_at
|
|
1122
|
+
@price_id = price_id
|
|
1123
|
+
@product_id = product_id
|
|
1124
|
+
@status = status
|
|
1125
|
+
freeze
|
|
1126
|
+
end
|
|
1127
|
+
|
|
1128
|
+
# Builds a Order from the API's JSON.
|
|
1129
|
+
def self.from_hash(data)
|
|
1130
|
+
new(
|
|
1131
|
+
amount_cents: data.fetch("amount_cents"),
|
|
1132
|
+
currency: data.fetch("currency"),
|
|
1133
|
+
customer_id: data.fetch("customer_id"),
|
|
1134
|
+
id: data.fetch("id"),
|
|
1135
|
+
installment_interest_cents: data.fetch("installment_interest_cents"),
|
|
1136
|
+
installments: data.fetch("installments"),
|
|
1137
|
+
paid_at: data["paid_at"],
|
|
1138
|
+
price_id: data.fetch("price_id"),
|
|
1139
|
+
product_id: data.fetch("product_id"),
|
|
1140
|
+
status: data.fetch("status")
|
|
1141
|
+
)
|
|
1142
|
+
end
|
|
1143
|
+
end
|
|
1144
|
+
|
|
1145
|
+
# OrderInvoice is a resource of Peráta's API.
|
|
1146
|
+
class OrderInvoice < Model
|
|
1147
|
+
MEMBERS = %i[address amount_cents billing_name currency discount_cents generated_at number order_id product_name tax_id tax_id_kind total_cents].freeze
|
|
1148
|
+
|
|
1149
|
+
# @return [BillingAddress]
|
|
1150
|
+
attr_reader :address
|
|
1151
|
+
|
|
1152
|
+
# @return [Integer]
|
|
1153
|
+
attr_reader :amount_cents
|
|
1154
|
+
|
|
1155
|
+
# @return [String]
|
|
1156
|
+
attr_reader :billing_name
|
|
1157
|
+
|
|
1158
|
+
# @return [String ("BRL")]
|
|
1159
|
+
attr_reader :currency
|
|
1160
|
+
|
|
1161
|
+
# @return [Integer]
|
|
1162
|
+
attr_reader :discount_cents
|
|
1163
|
+
|
|
1164
|
+
# @return [String]
|
|
1165
|
+
attr_reader :generated_at
|
|
1166
|
+
|
|
1167
|
+
# Número da fatura, na série da organização (PREFIXO-0001).
|
|
1168
|
+
# @return [String]
|
|
1169
|
+
attr_reader :number
|
|
1170
|
+
|
|
1171
|
+
# @return [String]
|
|
1172
|
+
attr_reader :order_id
|
|
1173
|
+
|
|
1174
|
+
# @return [String]
|
|
1175
|
+
attr_reader :product_name
|
|
1176
|
+
|
|
1177
|
+
# CPF ou CNPJ, só dígitos.
|
|
1178
|
+
# @return [String]
|
|
1179
|
+
attr_reader :tax_id
|
|
1180
|
+
|
|
1181
|
+
# cpf ou cnpj; vazio sem documento.
|
|
1182
|
+
# @return [String]
|
|
1183
|
+
attr_reader :tax_id_kind
|
|
1184
|
+
|
|
1185
|
+
# @return [Integer]
|
|
1186
|
+
attr_reader :total_cents
|
|
1187
|
+
|
|
1188
|
+
def initialize(address:, amount_cents:, billing_name:, currency:, discount_cents:, generated_at:, number:, order_id:, product_name:, tax_id:, tax_id_kind:, total_cents:)
|
|
1189
|
+
@address = address
|
|
1190
|
+
@amount_cents = amount_cents
|
|
1191
|
+
@billing_name = billing_name
|
|
1192
|
+
@currency = currency
|
|
1193
|
+
@discount_cents = discount_cents
|
|
1194
|
+
@generated_at = generated_at
|
|
1195
|
+
@number = number
|
|
1196
|
+
@order_id = order_id
|
|
1197
|
+
@product_name = product_name
|
|
1198
|
+
@tax_id = tax_id
|
|
1199
|
+
@tax_id_kind = tax_id_kind
|
|
1200
|
+
@total_cents = total_cents
|
|
1201
|
+
freeze
|
|
1202
|
+
end
|
|
1203
|
+
|
|
1204
|
+
# Builds a OrderInvoice from the API's JSON.
|
|
1205
|
+
def self.from_hash(data)
|
|
1206
|
+
new(
|
|
1207
|
+
address: BillingAddress.from_hash(data.fetch("address")),
|
|
1208
|
+
amount_cents: data.fetch("amount_cents"),
|
|
1209
|
+
billing_name: data.fetch("billing_name"),
|
|
1210
|
+
currency: data.fetch("currency"),
|
|
1211
|
+
discount_cents: data.fetch("discount_cents"),
|
|
1212
|
+
generated_at: data.fetch("generated_at"),
|
|
1213
|
+
number: data.fetch("number"),
|
|
1214
|
+
order_id: data.fetch("order_id"),
|
|
1215
|
+
product_name: data.fetch("product_name"),
|
|
1216
|
+
tax_id: data.fetch("tax_id"),
|
|
1217
|
+
tax_id_kind: data.fetch("tax_id_kind"),
|
|
1218
|
+
total_cents: data.fetch("total_cents")
|
|
1219
|
+
)
|
|
1220
|
+
end
|
|
1221
|
+
end
|
|
1222
|
+
|
|
1223
|
+
# OrderReceipt is a resource of Peráta's API.
|
|
1224
|
+
class OrderReceipt < Model
|
|
1225
|
+
MEMBERS = %i[amount_cents currency customer_email customer_name discount_cents installment_interest_cents installments number order_id paid_at payment_method product_name refunded_cents total_cents].freeze
|
|
1226
|
+
|
|
1227
|
+
# @return [Integer]
|
|
1228
|
+
attr_reader :amount_cents
|
|
1229
|
+
|
|
1230
|
+
# @return [String ("BRL")]
|
|
1231
|
+
attr_reader :currency
|
|
1232
|
+
|
|
1233
|
+
# @return [String]
|
|
1234
|
+
attr_reader :customer_email
|
|
1235
|
+
|
|
1236
|
+
# @return [String]
|
|
1237
|
+
attr_reader :customer_name
|
|
1238
|
+
|
|
1239
|
+
# @return [Integer]
|
|
1240
|
+
attr_reader :discount_cents
|
|
1241
|
+
|
|
1242
|
+
# @return [Integer]
|
|
1243
|
+
attr_reader :installment_interest_cents
|
|
1244
|
+
|
|
1245
|
+
# Em quantas parcelas o cartão de crédito foi cobrado; 1 à vista.
|
|
1246
|
+
# @return [Integer]
|
|
1247
|
+
attr_reader :installments
|
|
1248
|
+
|
|
1249
|
+
# Número do pedido na série da organização; vazio antes de ter um.
|
|
1250
|
+
# @return [String]
|
|
1251
|
+
attr_reader :number
|
|
1252
|
+
|
|
1253
|
+
# @return [String]
|
|
1254
|
+
attr_reader :order_id
|
|
242
1255
|
|
|
243
1256
|
# @return [String, nil]
|
|
244
1257
|
attr_reader :paid_at
|
|
245
1258
|
|
|
1259
|
+
# card, pix ou boleto; vazio quando o pagamento não foi achado.
|
|
246
1260
|
# @return [String]
|
|
247
|
-
attr_reader :
|
|
1261
|
+
attr_reader :payment_method
|
|
248
1262
|
|
|
249
1263
|
# @return [String]
|
|
250
|
-
attr_reader :
|
|
1264
|
+
attr_reader :product_name
|
|
251
1265
|
|
|
252
|
-
# @return [
|
|
253
|
-
attr_reader :
|
|
1266
|
+
# @return [Integer]
|
|
1267
|
+
attr_reader :refunded_cents
|
|
254
1268
|
|
|
255
|
-
|
|
1269
|
+
# @return [Integer]
|
|
1270
|
+
attr_reader :total_cents
|
|
1271
|
+
|
|
1272
|
+
def initialize(amount_cents:, currency:, customer_email:, customer_name:, discount_cents:, installment_interest_cents:, installments:, number:, order_id:, paid_at:, payment_method:, product_name:, refunded_cents:, total_cents:)
|
|
256
1273
|
@amount_cents = amount_cents
|
|
257
1274
|
@currency = currency
|
|
258
|
-
@
|
|
259
|
-
@
|
|
1275
|
+
@customer_email = customer_email
|
|
1276
|
+
@customer_name = customer_name
|
|
1277
|
+
@discount_cents = discount_cents
|
|
260
1278
|
@installment_interest_cents = installment_interest_cents
|
|
261
1279
|
@installments = installments
|
|
1280
|
+
@number = number
|
|
1281
|
+
@order_id = order_id
|
|
262
1282
|
@paid_at = paid_at
|
|
263
|
-
@
|
|
264
|
-
@
|
|
265
|
-
@
|
|
1283
|
+
@payment_method = payment_method
|
|
1284
|
+
@product_name = product_name
|
|
1285
|
+
@refunded_cents = refunded_cents
|
|
1286
|
+
@total_cents = total_cents
|
|
266
1287
|
freeze
|
|
267
1288
|
end
|
|
268
1289
|
|
|
269
|
-
# Builds a
|
|
1290
|
+
# Builds a OrderReceipt from the API's JSON.
|
|
270
1291
|
def self.from_hash(data)
|
|
271
1292
|
new(
|
|
272
1293
|
amount_cents: data.fetch("amount_cents"),
|
|
273
1294
|
currency: data.fetch("currency"),
|
|
274
|
-
|
|
275
|
-
|
|
1295
|
+
customer_email: data.fetch("customer_email"),
|
|
1296
|
+
customer_name: data.fetch("customer_name"),
|
|
1297
|
+
discount_cents: data.fetch("discount_cents"),
|
|
276
1298
|
installment_interest_cents: data.fetch("installment_interest_cents"),
|
|
277
1299
|
installments: data.fetch("installments"),
|
|
1300
|
+
number: data.fetch("number"),
|
|
1301
|
+
order_id: data.fetch("order_id"),
|
|
278
1302
|
paid_at: data["paid_at"],
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
1303
|
+
payment_method: data.fetch("payment_method"),
|
|
1304
|
+
product_name: data.fetch("product_name"),
|
|
1305
|
+
refunded_cents: data.fetch("refunded_cents"),
|
|
1306
|
+
total_cents: data.fetch("total_cents")
|
|
282
1307
|
)
|
|
283
1308
|
end
|
|
284
1309
|
end
|
|
@@ -584,7 +1609,7 @@ module Perata
|
|
|
584
1609
|
|
|
585
1610
|
# Subscription is a resource of Peráta's API.
|
|
586
1611
|
class Subscription < Model
|
|
587
|
-
MEMBERS = %i[amount_cents cancel_at_period_end currency current_period_end current_period_start customer_id id interval price_id product_id status].freeze
|
|
1612
|
+
MEMBERS = %i[amount_cents cancel_at_period_end currency current_period_end current_period_start customer_id id interval metadata price_id product_id status trial_end trial_start].freeze
|
|
588
1613
|
|
|
589
1614
|
# @return [Integer]
|
|
590
1615
|
attr_reader :amount_cents
|
|
@@ -610,6 +1635,10 @@ module Perata
|
|
|
610
1635
|
# @return [String]
|
|
611
1636
|
attr_reader :interval
|
|
612
1637
|
|
|
1638
|
+
# Metadados do lojista: pares chave e valor (texto, número ou booleano); objeto vazio quando não há.
|
|
1639
|
+
# @return [Hash{String => Object}]
|
|
1640
|
+
attr_reader :metadata
|
|
1641
|
+
|
|
613
1642
|
# @return [String]
|
|
614
1643
|
attr_reader :price_id
|
|
615
1644
|
|
|
@@ -619,7 +1648,13 @@ module Perata
|
|
|
619
1648
|
# @return [String ("trialing", "active", "past_due", "paused", "canceled")]
|
|
620
1649
|
attr_reader :status
|
|
621
1650
|
|
|
622
|
-
|
|
1651
|
+
# @return [String, nil]
|
|
1652
|
+
attr_reader :trial_end
|
|
1653
|
+
|
|
1654
|
+
# @return [String, nil]
|
|
1655
|
+
attr_reader :trial_start
|
|
1656
|
+
|
|
1657
|
+
def initialize(amount_cents:, cancel_at_period_end:, currency:, current_period_end:, current_period_start:, customer_id:, id:, interval:, metadata:, price_id:, product_id:, status:, trial_end:, trial_start:)
|
|
623
1658
|
@amount_cents = amount_cents
|
|
624
1659
|
@cancel_at_period_end = cancel_at_period_end
|
|
625
1660
|
@currency = currency
|
|
@@ -628,9 +1663,12 @@ module Perata
|
|
|
628
1663
|
@customer_id = customer_id
|
|
629
1664
|
@id = id
|
|
630
1665
|
@interval = interval
|
|
1666
|
+
@metadata = metadata
|
|
631
1667
|
@price_id = price_id
|
|
632
1668
|
@product_id = product_id
|
|
633
1669
|
@status = status
|
|
1670
|
+
@trial_end = trial_end
|
|
1671
|
+
@trial_start = trial_start
|
|
634
1672
|
freeze
|
|
635
1673
|
end
|
|
636
1674
|
|
|
@@ -645,9 +1683,67 @@ module Perata
|
|
|
645
1683
|
customer_id: data.fetch("customer_id"),
|
|
646
1684
|
id: data.fetch("id"),
|
|
647
1685
|
interval: data.fetch("interval"),
|
|
1686
|
+
metadata: data.fetch("metadata"),
|
|
648
1687
|
price_id: data.fetch("price_id"),
|
|
649
1688
|
product_id: data.fetch("product_id"),
|
|
650
|
-
status: data.fetch("status")
|
|
1689
|
+
status: data.fetch("status"),
|
|
1690
|
+
trial_end: data["trial_end"],
|
|
1691
|
+
trial_start: data["trial_start"]
|
|
1692
|
+
)
|
|
1693
|
+
end
|
|
1694
|
+
end
|
|
1695
|
+
|
|
1696
|
+
# WebhookBenefit is a resource of Peráta's API.
|
|
1697
|
+
class WebhookBenefit < Model
|
|
1698
|
+
MEMBERS = %i[created_at description id modified_at name status type visibility].freeze
|
|
1699
|
+
|
|
1700
|
+
# @return [String]
|
|
1701
|
+
attr_reader :created_at
|
|
1702
|
+
|
|
1703
|
+
# @return [String]
|
|
1704
|
+
attr_reader :description
|
|
1705
|
+
|
|
1706
|
+
# @return [String]
|
|
1707
|
+
attr_reader :id
|
|
1708
|
+
|
|
1709
|
+
# @return [String]
|
|
1710
|
+
attr_reader :modified_at
|
|
1711
|
+
|
|
1712
|
+
# @return [String]
|
|
1713
|
+
attr_reader :name
|
|
1714
|
+
|
|
1715
|
+
# @return [String ("active", "archived")]
|
|
1716
|
+
attr_reader :status
|
|
1717
|
+
|
|
1718
|
+
# @return [String]
|
|
1719
|
+
attr_reader :type
|
|
1720
|
+
|
|
1721
|
+
# @return [String ("public", "private")]
|
|
1722
|
+
attr_reader :visibility
|
|
1723
|
+
|
|
1724
|
+
def initialize(created_at:, description:, id:, modified_at:, name:, status:, type:, visibility:)
|
|
1725
|
+
@created_at = created_at
|
|
1726
|
+
@description = description
|
|
1727
|
+
@id = id
|
|
1728
|
+
@modified_at = modified_at
|
|
1729
|
+
@name = name
|
|
1730
|
+
@status = status
|
|
1731
|
+
@type = type
|
|
1732
|
+
@visibility = visibility
|
|
1733
|
+
freeze
|
|
1734
|
+
end
|
|
1735
|
+
|
|
1736
|
+
# Builds a WebhookBenefit from the API's JSON.
|
|
1737
|
+
def self.from_hash(data)
|
|
1738
|
+
new(
|
|
1739
|
+
created_at: data.fetch("created_at"),
|
|
1740
|
+
description: data.fetch("description"),
|
|
1741
|
+
id: data.fetch("id"),
|
|
1742
|
+
modified_at: data.fetch("modified_at"),
|
|
1743
|
+
name: data.fetch("name"),
|
|
1744
|
+
status: data.fetch("status"),
|
|
1745
|
+
type: data.fetch("type"),
|
|
1746
|
+
visibility: data.fetch("visibility")
|
|
651
1747
|
)
|
|
652
1748
|
end
|
|
653
1749
|
end
|
|
@@ -728,6 +1824,180 @@ module Perata
|
|
|
728
1824
|
end
|
|
729
1825
|
end
|
|
730
1826
|
|
|
1827
|
+
# WebhookDelivery is a resource of Peráta's API.
|
|
1828
|
+
class WebhookDelivery < Model
|
|
1829
|
+
MEMBERS = %i[attempts created_at endpoint_id event_id event_type id last_attempt_at last_error max_attempts next_attempt_at response_status status].freeze
|
|
1830
|
+
|
|
1831
|
+
# @return [Integer]
|
|
1832
|
+
attr_reader :attempts
|
|
1833
|
+
|
|
1834
|
+
# @return [String]
|
|
1835
|
+
attr_reader :created_at
|
|
1836
|
+
|
|
1837
|
+
# @return [String]
|
|
1838
|
+
attr_reader :endpoint_id
|
|
1839
|
+
|
|
1840
|
+
# @return [String]
|
|
1841
|
+
attr_reader :event_id
|
|
1842
|
+
|
|
1843
|
+
# @return [String]
|
|
1844
|
+
attr_reader :event_type
|
|
1845
|
+
|
|
1846
|
+
# @return [String]
|
|
1847
|
+
attr_reader :id
|
|
1848
|
+
|
|
1849
|
+
# @return [String, nil]
|
|
1850
|
+
attr_reader :last_attempt_at
|
|
1851
|
+
|
|
1852
|
+
# @return [String]
|
|
1853
|
+
attr_reader :last_error
|
|
1854
|
+
|
|
1855
|
+
# @return [Integer]
|
|
1856
|
+
attr_reader :max_attempts
|
|
1857
|
+
|
|
1858
|
+
# @return [String, nil]
|
|
1859
|
+
attr_reader :next_attempt_at
|
|
1860
|
+
|
|
1861
|
+
# O status HTTP da última resposta; nulo quando não houve.
|
|
1862
|
+
# @return [Integer, nil]
|
|
1863
|
+
attr_reader :response_status
|
|
1864
|
+
|
|
1865
|
+
# pending enquanto é repetida; exhausted quando todas as tentativas falharam.
|
|
1866
|
+
# @return [String ("pending", "succeeded", "exhausted")]
|
|
1867
|
+
attr_reader :status
|
|
1868
|
+
|
|
1869
|
+
def initialize(attempts:, created_at:, endpoint_id:, event_id:, event_type:, id:, last_attempt_at:, last_error:, max_attempts:, next_attempt_at:, response_status:, status:)
|
|
1870
|
+
@attempts = attempts
|
|
1871
|
+
@created_at = created_at
|
|
1872
|
+
@endpoint_id = endpoint_id
|
|
1873
|
+
@event_id = event_id
|
|
1874
|
+
@event_type = event_type
|
|
1875
|
+
@id = id
|
|
1876
|
+
@last_attempt_at = last_attempt_at
|
|
1877
|
+
@last_error = last_error
|
|
1878
|
+
@max_attempts = max_attempts
|
|
1879
|
+
@next_attempt_at = next_attempt_at
|
|
1880
|
+
@response_status = response_status
|
|
1881
|
+
@status = status
|
|
1882
|
+
freeze
|
|
1883
|
+
end
|
|
1884
|
+
|
|
1885
|
+
# Builds a WebhookDelivery from the API's JSON.
|
|
1886
|
+
def self.from_hash(data)
|
|
1887
|
+
new(
|
|
1888
|
+
attempts: data.fetch("attempts"),
|
|
1889
|
+
created_at: data.fetch("created_at"),
|
|
1890
|
+
endpoint_id: data.fetch("endpoint_id"),
|
|
1891
|
+
event_id: data.fetch("event_id"),
|
|
1892
|
+
event_type: data.fetch("event_type"),
|
|
1893
|
+
id: data.fetch("id"),
|
|
1894
|
+
last_attempt_at: data["last_attempt_at"],
|
|
1895
|
+
last_error: data.fetch("last_error"),
|
|
1896
|
+
max_attempts: data.fetch("max_attempts"),
|
|
1897
|
+
next_attempt_at: data["next_attempt_at"],
|
|
1898
|
+
response_status: data["response_status"],
|
|
1899
|
+
status: data.fetch("status")
|
|
1900
|
+
)
|
|
1901
|
+
end
|
|
1902
|
+
end
|
|
1903
|
+
|
|
1904
|
+
# WebhookDiscount is a resource of Peráta's API.
|
|
1905
|
+
class WebhookDiscount < Model
|
|
1906
|
+
MEMBERS = %i[amount_cents basis_points code created_at currency duration duration_in_months ends_at id max_redemptions modified_at name redemptions_count starts_at status type].freeze
|
|
1907
|
+
|
|
1908
|
+
# Valor fixo em centavos, quando o tipo é fixed.
|
|
1909
|
+
# @return [Integer]
|
|
1910
|
+
attr_reader :amount_cents
|
|
1911
|
+
|
|
1912
|
+
# Percentual em pontos-base, quando o tipo é percentage.
|
|
1913
|
+
# @return [Integer]
|
|
1914
|
+
attr_reader :basis_points
|
|
1915
|
+
|
|
1916
|
+
# @return [String, nil]
|
|
1917
|
+
attr_reader :code
|
|
1918
|
+
|
|
1919
|
+
# @return [String]
|
|
1920
|
+
attr_reader :created_at
|
|
1921
|
+
|
|
1922
|
+
# @return [String]
|
|
1923
|
+
attr_reader :currency
|
|
1924
|
+
|
|
1925
|
+
# @return [String ("once", "forever", "repeating")]
|
|
1926
|
+
attr_reader :duration
|
|
1927
|
+
|
|
1928
|
+
# @return [Integer]
|
|
1929
|
+
attr_reader :duration_in_months
|
|
1930
|
+
|
|
1931
|
+
# @return [String, nil]
|
|
1932
|
+
attr_reader :ends_at
|
|
1933
|
+
|
|
1934
|
+
# @return [String]
|
|
1935
|
+
attr_reader :id
|
|
1936
|
+
|
|
1937
|
+
# @return [Integer, nil]
|
|
1938
|
+
attr_reader :max_redemptions
|
|
1939
|
+
|
|
1940
|
+
# @return [String]
|
|
1941
|
+
attr_reader :modified_at
|
|
1942
|
+
|
|
1943
|
+
# @return [String]
|
|
1944
|
+
attr_reader :name
|
|
1945
|
+
|
|
1946
|
+
# @return [Integer]
|
|
1947
|
+
attr_reader :redemptions_count
|
|
1948
|
+
|
|
1949
|
+
# @return [String]
|
|
1950
|
+
attr_reader :starts_at
|
|
1951
|
+
|
|
1952
|
+
# @return [String ("active", "expired", "exhausted", "archived")]
|
|
1953
|
+
attr_reader :status
|
|
1954
|
+
|
|
1955
|
+
# @return [String ("percentage", "fixed")]
|
|
1956
|
+
attr_reader :type
|
|
1957
|
+
|
|
1958
|
+
def initialize(amount_cents:, basis_points:, code:, created_at:, currency:, duration:, duration_in_months:, ends_at:, id:, max_redemptions:, modified_at:, name:, redemptions_count:, starts_at:, status:, type:)
|
|
1959
|
+
@amount_cents = amount_cents
|
|
1960
|
+
@basis_points = basis_points
|
|
1961
|
+
@code = code
|
|
1962
|
+
@created_at = created_at
|
|
1963
|
+
@currency = currency
|
|
1964
|
+
@duration = duration
|
|
1965
|
+
@duration_in_months = duration_in_months
|
|
1966
|
+
@ends_at = ends_at
|
|
1967
|
+
@id = id
|
|
1968
|
+
@max_redemptions = max_redemptions
|
|
1969
|
+
@modified_at = modified_at
|
|
1970
|
+
@name = name
|
|
1971
|
+
@redemptions_count = redemptions_count
|
|
1972
|
+
@starts_at = starts_at
|
|
1973
|
+
@status = status
|
|
1974
|
+
@type = type
|
|
1975
|
+
freeze
|
|
1976
|
+
end
|
|
1977
|
+
|
|
1978
|
+
# Builds a WebhookDiscount from the API's JSON.
|
|
1979
|
+
def self.from_hash(data)
|
|
1980
|
+
new(
|
|
1981
|
+
amount_cents: data.fetch("amount_cents"),
|
|
1982
|
+
basis_points: data.fetch("basis_points"),
|
|
1983
|
+
code: data["code"],
|
|
1984
|
+
created_at: data.fetch("created_at"),
|
|
1985
|
+
currency: data.fetch("currency"),
|
|
1986
|
+
duration: data.fetch("duration"),
|
|
1987
|
+
duration_in_months: data.fetch("duration_in_months"),
|
|
1988
|
+
ends_at: data["ends_at"],
|
|
1989
|
+
id: data.fetch("id"),
|
|
1990
|
+
max_redemptions: data["max_redemptions"],
|
|
1991
|
+
modified_at: data.fetch("modified_at"),
|
|
1992
|
+
name: data.fetch("name"),
|
|
1993
|
+
redemptions_count: data.fetch("redemptions_count"),
|
|
1994
|
+
starts_at: data.fetch("starts_at"),
|
|
1995
|
+
status: data.fetch("status"),
|
|
1996
|
+
type: data.fetch("type")
|
|
1997
|
+
)
|
|
1998
|
+
end
|
|
1999
|
+
end
|
|
2000
|
+
|
|
731
2001
|
# WebhookDispute is a resource of Peráta's API.
|
|
732
2002
|
class WebhookDispute < Model
|
|
733
2003
|
MEMBERS = %i[amount_cents currency customer_id decided_at due_by id invoice_id opened_at payment_id provider_dispute_id provider_reason reason source status].freeze
|
|
@@ -818,4 +2088,124 @@ module Perata
|
|
|
818
2088
|
)
|
|
819
2089
|
end
|
|
820
2090
|
end
|
|
2091
|
+
|
|
2092
|
+
# WebhookEndpoint is a resource of Peráta's API.
|
|
2093
|
+
class WebhookEndpoint < Model
|
|
2094
|
+
MEMBERS = %i[consecutive_failures created_at description events format id status url].freeze
|
|
2095
|
+
|
|
2096
|
+
# @return [Integer]
|
|
2097
|
+
attr_reader :consecutive_failures
|
|
2098
|
+
|
|
2099
|
+
# @return [String]
|
|
2100
|
+
attr_reader :created_at
|
|
2101
|
+
|
|
2102
|
+
# Como o lojista chama o endpoint; sem ele, o domínio do endereço.
|
|
2103
|
+
# @return [String]
|
|
2104
|
+
attr_reader :description
|
|
2105
|
+
|
|
2106
|
+
# Os eventos de que o endpoint é avisado, em ordem alfabética.
|
|
2107
|
+
# @return [Array<String>]
|
|
2108
|
+
attr_reader :events
|
|
2109
|
+
|
|
2110
|
+
# O corpo da mensagem; o que o endereço indica quando não é dito.
|
|
2111
|
+
# @return [String ("raw", "discord", "slack")]
|
|
2112
|
+
attr_reader :format
|
|
2113
|
+
|
|
2114
|
+
# @return [String]
|
|
2115
|
+
attr_reader :id
|
|
2116
|
+
|
|
2117
|
+
# @return [String ("active", "disabled")]
|
|
2118
|
+
attr_reader :status
|
|
2119
|
+
|
|
2120
|
+
# Endereço https para onde as mensagens são enviadas.
|
|
2121
|
+
# @return [String]
|
|
2122
|
+
attr_reader :url
|
|
2123
|
+
|
|
2124
|
+
def initialize(consecutive_failures:, created_at:, description:, events:, format:, id:, status:, url:)
|
|
2125
|
+
@consecutive_failures = consecutive_failures
|
|
2126
|
+
@created_at = created_at
|
|
2127
|
+
@description = description
|
|
2128
|
+
@events = events
|
|
2129
|
+
@format = format
|
|
2130
|
+
@id = id
|
|
2131
|
+
@status = status
|
|
2132
|
+
@url = url
|
|
2133
|
+
freeze
|
|
2134
|
+
end
|
|
2135
|
+
|
|
2136
|
+
# Builds a WebhookEndpoint from the API's JSON.
|
|
2137
|
+
def self.from_hash(data)
|
|
2138
|
+
new(
|
|
2139
|
+
consecutive_failures: data.fetch("consecutive_failures"),
|
|
2140
|
+
created_at: data.fetch("created_at"),
|
|
2141
|
+
description: data.fetch("description"),
|
|
2142
|
+
events: data.fetch("events"),
|
|
2143
|
+
format: data.fetch("format"),
|
|
2144
|
+
id: data.fetch("id"),
|
|
2145
|
+
status: data.fetch("status"),
|
|
2146
|
+
url: data.fetch("url")
|
|
2147
|
+
)
|
|
2148
|
+
end
|
|
2149
|
+
end
|
|
2150
|
+
|
|
2151
|
+
# WebhookEndpointCreated is a resource of Peráta's API.
|
|
2152
|
+
class WebhookEndpointCreated < Model
|
|
2153
|
+
MEMBERS = %i[consecutive_failures created_at description events format id secret status url].freeze
|
|
2154
|
+
|
|
2155
|
+
# @return [Integer]
|
|
2156
|
+
attr_reader :consecutive_failures
|
|
2157
|
+
|
|
2158
|
+
# @return [String]
|
|
2159
|
+
attr_reader :created_at
|
|
2160
|
+
|
|
2161
|
+
# @return [String]
|
|
2162
|
+
attr_reader :description
|
|
2163
|
+
|
|
2164
|
+
# @return [Array<String>]
|
|
2165
|
+
attr_reader :events
|
|
2166
|
+
|
|
2167
|
+
# @return [String ("raw", "discord", "slack")]
|
|
2168
|
+
attr_reader :format
|
|
2169
|
+
|
|
2170
|
+
# @return [String]
|
|
2171
|
+
attr_reader :id
|
|
2172
|
+
|
|
2173
|
+
# O segredo (whsec_…) com que as mensagens são assinadas. Só esta resposta o traz; na repetição da criação sob a mesma Idempotency-Key vem vazio.
|
|
2174
|
+
# @return [String]
|
|
2175
|
+
attr_reader :secret
|
|
2176
|
+
|
|
2177
|
+
# @return [String ("active", "disabled")]
|
|
2178
|
+
attr_reader :status
|
|
2179
|
+
|
|
2180
|
+
# @return [String]
|
|
2181
|
+
attr_reader :url
|
|
2182
|
+
|
|
2183
|
+
def initialize(consecutive_failures:, created_at:, description:, events:, format:, id:, secret:, status:, url:)
|
|
2184
|
+
@consecutive_failures = consecutive_failures
|
|
2185
|
+
@created_at = created_at
|
|
2186
|
+
@description = description
|
|
2187
|
+
@events = events
|
|
2188
|
+
@format = format
|
|
2189
|
+
@id = id
|
|
2190
|
+
@secret = secret
|
|
2191
|
+
@status = status
|
|
2192
|
+
@url = url
|
|
2193
|
+
freeze
|
|
2194
|
+
end
|
|
2195
|
+
|
|
2196
|
+
# Builds a WebhookEndpointCreated from the API's JSON.
|
|
2197
|
+
def self.from_hash(data)
|
|
2198
|
+
new(
|
|
2199
|
+
consecutive_failures: data.fetch("consecutive_failures"),
|
|
2200
|
+
created_at: data.fetch("created_at"),
|
|
2201
|
+
description: data.fetch("description"),
|
|
2202
|
+
events: data.fetch("events"),
|
|
2203
|
+
format: data.fetch("format"),
|
|
2204
|
+
id: data.fetch("id"),
|
|
2205
|
+
secret: data.fetch("secret"),
|
|
2206
|
+
status: data.fetch("status"),
|
|
2207
|
+
url: data.fetch("url")
|
|
2208
|
+
)
|
|
2209
|
+
end
|
|
2210
|
+
end
|
|
821
2211
|
end
|