perata-sdk 0.1.1 → 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.
data/lib/perata/models.rb CHANGED
@@ -3,89 +3,1544 @@
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
+
74
+ # BenefitGrant is a resource of Peráta's API.
75
+ class BenefitGrant < Model
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
77
+
78
+ # @return [String]
79
+ attr_reader :benefit_id
80
+
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")]
86
+ attr_reader :benefit_type
87
+
88
+ # @return [String]
89
+ attr_reader :created_at
90
+
91
+ # @return [String]
92
+ attr_reader :customer_id
93
+
94
+ # @return [String]
95
+ attr_reader :granted_at
96
+
97
+ # @return [String]
98
+ attr_reader :id
99
+
100
+ # @return [Boolean]
101
+ attr_reader :is_granted
102
+
103
+ # @return [Boolean]
104
+ attr_reader :is_revoked
105
+
106
+ # O que a concessão informa, conforme o tipo, sem credenciais.
107
+ # @return [Hash{String => Object}]
108
+ attr_reader :properties
109
+
110
+ # @return [String, nil]
111
+ attr_reader :revoked_at
112
+
113
+ # @return [String ("granted", "revoked")]
114
+ attr_reader :status
115
+
116
+ def initialize(benefit_id:, benefit_metadata:, benefit_type:, created_at:, customer_id:, granted_at:, id:, is_granted:, is_revoked:, properties:, revoked_at:, status:)
117
+ @benefit_id = benefit_id
118
+ @benefit_metadata = benefit_metadata
119
+ @benefit_type = benefit_type
120
+ @created_at = created_at
121
+ @customer_id = customer_id
122
+ @granted_at = granted_at
123
+ @id = id
124
+ @is_granted = is_granted
125
+ @is_revoked = is_revoked
126
+ @properties = properties
127
+ @revoked_at = revoked_at
128
+ @status = status
129
+ freeze
130
+ end
131
+
132
+ # Builds a BenefitGrant from the API's JSON.
133
+ def self.from_hash(data)
134
+ new(
135
+ benefit_id: data.fetch("benefit_id"),
136
+ benefit_metadata: data.fetch("benefit_metadata"),
137
+ benefit_type: data.fetch("benefit_type"),
138
+ created_at: data.fetch("created_at"),
139
+ customer_id: data.fetch("customer_id"),
140
+ granted_at: data.fetch("granted_at"),
141
+ id: data.fetch("id"),
142
+ is_granted: data.fetch("is_granted"),
143
+ is_revoked: data.fetch("is_revoked"),
144
+ properties: data.fetch("properties"),
145
+ revoked_at: data["revoked_at"],
146
+ status: data.fetch("status")
147
+ )
148
+ end
149
+ end
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
+
6
204
  # Card is a resource of Peráta's API.
7
205
  class Card < Model
8
206
  MEMBERS = %i[brand exp_month exp_year last4].freeze
9
207
 
10
208
  # @return [String]
11
- attr_reader :brand
209
+ attr_reader :brand
210
+
211
+ # @return [Integer, nil]
212
+ attr_reader :exp_month
213
+
214
+ # @return [Integer, nil]
215
+ attr_reader :exp_year
216
+
217
+ # @return [String, nil]
218
+ attr_reader :last4
219
+
220
+ def initialize(brand:, exp_month:, exp_year:, last4:)
221
+ @brand = brand
222
+ @exp_month = exp_month
223
+ @exp_year = exp_year
224
+ @last4 = last4
225
+ freeze
226
+ end
227
+
228
+ # Builds a Card from the API's JSON.
229
+ def self.from_hash(data)
230
+ new(
231
+ brand: data.fetch("brand"),
232
+ exp_month: data["exp_month"],
233
+ exp_year: data["exp_year"],
234
+ last4: data["last4"]
235
+ )
236
+ end
237
+ end
238
+
239
+ # Checkout is a resource of Peráta's API.
240
+ class Checkout < Model
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
253
+
254
+ # @return [String]
255
+ attr_reader :id
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
+
261
+ # @return [String]
262
+ attr_reader :price_id
263
+
264
+ # @return [String]
265
+ attr_reader :product_id
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
+
278
+ # Endereço para onde o comprador é enviado.
279
+ # @return [String]
280
+ attr_reader :url
281
+
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
286
+ @id = id
287
+ @label = label
288
+ @price_id = price_id
289
+ @product_id = product_id
290
+ @quantity = quantity
291
+ @status = status
292
+ @success_url = success_url
293
+ @url = url
294
+ freeze
295
+ end
296
+
297
+ # Builds a Checkout from the API's JSON.
298
+ def self.from_hash(data)
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"],
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"),
435
+ price_id: data.fetch("price_id"),
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"],
444
+ url: data.fetch("url")
445
+ )
446
+ end
447
+ end
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
+
474
+ # Customer is a resource of Peráta's API.
475
+ class Customer < Model
476
+ MEMBERS = %i[created_at email external_id id name status].freeze
477
+
478
+ # @return [String]
479
+ attr_reader :created_at
480
+
481
+ # @return [String]
482
+ attr_reader :email
483
+
484
+ # @return [String]
485
+ attr_reader :external_id
486
+
487
+ # @return [String]
488
+ attr_reader :id
489
+
490
+ # @return [String]
491
+ attr_reader :name
492
+
493
+ # @return [String ("active", "archived")]
494
+ attr_reader :status
495
+
496
+ def initialize(created_at:, email:, external_id:, id:, name:, status:)
497
+ @created_at = created_at
498
+ @email = email
499
+ @external_id = external_id
500
+ @id = id
501
+ @name = name
502
+ @status = status
503
+ freeze
504
+ end
505
+
506
+ # Builds a Customer from the API's JSON.
507
+ def self.from_hash(data)
508
+ new(
509
+ created_at: data.fetch("created_at"),
510
+ email: data.fetch("email"),
511
+ external_id: data.fetch("external_id"),
512
+ id: data.fetch("id"),
513
+ name: data.fetch("name"),
514
+ status: data.fetch("status")
515
+ )
516
+ end
517
+ end
518
+
519
+ # CustomerSession is a resource of Peráta's API.
520
+ class CustomerSession < Model
521
+ MEMBERS = %i[customer_portal_url expires_at token].freeze
522
+
523
+ # Endereço que abre o portal do cliente já autenticado.
524
+ # @return [String]
525
+ attr_reader :customer_portal_url
526
+
527
+ # @return [String]
528
+ attr_reader :expires_at
529
+
530
+ # Sessão do portal do cliente, já autenticada.
531
+ # @return [String]
532
+ attr_reader :token
533
+
534
+ def initialize(customer_portal_url:, expires_at:, token:)
535
+ @customer_portal_url = customer_portal_url
536
+ @expires_at = expires_at
537
+ @token = token
538
+ freeze
539
+ end
540
+
541
+ # Builds a CustomerSession from the API's JSON.
542
+ def self.from_hash(data)
543
+ new(
544
+ customer_portal_url: data.fetch("customer_portal_url"),
545
+ expires_at: data.fetch("expires_at"),
546
+ token: data.fetch("token")
547
+ )
548
+ end
549
+ end
550
+
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
554
+
555
+ # As assinaturas ativas ou em teste do cliente.
556
+ # @return [Array<Subscription>]
557
+ attr_reader :active_subscriptions
558
+
559
+ # @return [String]
560
+ attr_reader :created_at
561
+
562
+ # @return [String]
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
571
+
572
+ # @return [String]
573
+ attr_reader :id
574
+
575
+ # @return [String]
576
+ attr_reader :name
577
+
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
1255
+
1256
+ # @return [String, nil]
1257
+ attr_reader :paid_at
1258
+
1259
+ # card, pix ou boleto; vazio quando o pagamento não foi achado.
1260
+ # @return [String]
1261
+ attr_reader :payment_method
1262
+
1263
+ # @return [String]
1264
+ attr_reader :product_name
1265
+
1266
+ # @return [Integer]
1267
+ attr_reader :refunded_cents
1268
+
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:)
1273
+ @amount_cents = amount_cents
1274
+ @currency = currency
1275
+ @customer_email = customer_email
1276
+ @customer_name = customer_name
1277
+ @discount_cents = discount_cents
1278
+ @installment_interest_cents = installment_interest_cents
1279
+ @installments = installments
1280
+ @number = number
1281
+ @order_id = order_id
1282
+ @paid_at = paid_at
1283
+ @payment_method = payment_method
1284
+ @product_name = product_name
1285
+ @refunded_cents = refunded_cents
1286
+ @total_cents = total_cents
1287
+ freeze
1288
+ end
1289
+
1290
+ # Builds a OrderReceipt from the API's JSON.
1291
+ def self.from_hash(data)
1292
+ new(
1293
+ amount_cents: data.fetch("amount_cents"),
1294
+ currency: data.fetch("currency"),
1295
+ customer_email: data.fetch("customer_email"),
1296
+ customer_name: data.fetch("customer_name"),
1297
+ discount_cents: data.fetch("discount_cents"),
1298
+ installment_interest_cents: data.fetch("installment_interest_cents"),
1299
+ installments: data.fetch("installments"),
1300
+ number: data.fetch("number"),
1301
+ order_id: data.fetch("order_id"),
1302
+ paid_at: data["paid_at"],
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")
1307
+ )
1308
+ end
1309
+ end
1310
+
1311
+ # Pagination is a resource of Peráta's API.
1312
+ class Pagination < Model
1313
+ MEMBERS = %i[max_page total_count].freeze
1314
+
1315
+ # @return [Integer]
1316
+ attr_reader :max_page
1317
+
1318
+ # @return [Integer]
1319
+ attr_reader :total_count
1320
+
1321
+ def initialize(max_page:, total_count:)
1322
+ @max_page = max_page
1323
+ @total_count = total_count
1324
+ freeze
1325
+ end
1326
+
1327
+ # Builds a Pagination from the API's JSON.
1328
+ def self.from_hash(data)
1329
+ new(
1330
+ max_page: data.fetch("max_page"),
1331
+ total_count: data.fetch("total_count")
1332
+ )
1333
+ end
1334
+ end
1335
+
1336
+ # Payment is a resource of Peráta's API.
1337
+ class Payment < Model
1338
+ MEMBERS = %i[amount_cents captured_cents checkout_id created_at currency customer_id id installment_amount_cents installment_interest_cents installments method refunded_cents state].freeze
1339
+
1340
+ # @return [Integer]
1341
+ attr_reader :amount_cents
1342
+
1343
+ # @return [Integer]
1344
+ attr_reader :captured_cents
1345
+
1346
+ # @return [String]
1347
+ attr_reader :checkout_id
1348
+
1349
+ # @return [String]
1350
+ attr_reader :created_at
1351
+
1352
+ # @return [String ("BRL")]
1353
+ attr_reader :currency
1354
+
1355
+ # @return [String]
1356
+ attr_reader :customer_id
1357
+
1358
+ # @return [String]
1359
+ attr_reader :id
1360
+
1361
+ # Valor de uma parcela; 0 à vista.
1362
+ # @return [Integer]
1363
+ attr_reader :installment_amount_cents
1364
+
1365
+ # Juros do parcelamento dentro de amount_cents.
1366
+ # @return [Integer]
1367
+ attr_reader :installment_interest_cents
1368
+
1369
+ # Em quantas parcelas o cartão de crédito foi cobrado; 1 à vista.
1370
+ # @return [Integer]
1371
+ attr_reader :installments
1372
+
1373
+ # @return [String ("card", "pix", "boleto")]
1374
+ attr_reader :method
1375
+
1376
+ # @return [Integer]
1377
+ attr_reader :refunded_cents
1378
+
1379
+ # @return [String ("unknown", "pending", "authorized", "captured", "refused", "canceled", "refunded", "partially_refunded")]
1380
+ attr_reader :state
1381
+
1382
+ def initialize(amount_cents:, captured_cents:, checkout_id:, created_at:, currency:, customer_id:, id:, installment_amount_cents:, installment_interest_cents:, installments:, method:, refunded_cents:, state:)
1383
+ @amount_cents = amount_cents
1384
+ @captured_cents = captured_cents
1385
+ @checkout_id = checkout_id
1386
+ @created_at = created_at
1387
+ @currency = currency
1388
+ @customer_id = customer_id
1389
+ @id = id
1390
+ @installment_amount_cents = installment_amount_cents
1391
+ @installment_interest_cents = installment_interest_cents
1392
+ @installments = installments
1393
+ @method = method
1394
+ @refunded_cents = refunded_cents
1395
+ @state = state
1396
+ freeze
1397
+ end
1398
+
1399
+ # Builds a Payment from the API's JSON.
1400
+ def self.from_hash(data)
1401
+ new(
1402
+ amount_cents: data.fetch("amount_cents"),
1403
+ captured_cents: data.fetch("captured_cents"),
1404
+ checkout_id: data.fetch("checkout_id"),
1405
+ created_at: data.fetch("created_at"),
1406
+ currency: data.fetch("currency"),
1407
+ customer_id: data.fetch("customer_id"),
1408
+ id: data.fetch("id"),
1409
+ installment_amount_cents: data.fetch("installment_amount_cents"),
1410
+ installment_interest_cents: data.fetch("installment_interest_cents"),
1411
+ installments: data.fetch("installments"),
1412
+ method: data.fetch("method"),
1413
+ refunded_cents: data.fetch("refunded_cents"),
1414
+ state: data.fetch("state")
1415
+ )
1416
+ end
1417
+ end
1418
+
1419
+ # PaymentMethod is a resource of Peráta's API.
1420
+ class PaymentMethod < Model
1421
+ MEMBERS = %i[card created_at customer_id id type].freeze
1422
+
1423
+ # @return [Card]
1424
+ attr_reader :card
1425
+
1426
+ # @return [String]
1427
+ attr_reader :created_at
12
1428
 
13
- # @return [Integer, nil]
14
- attr_reader :exp_month
1429
+ # @return [String]
1430
+ attr_reader :customer_id
15
1431
 
16
- # @return [Integer, nil]
17
- attr_reader :exp_year
1432
+ # @return [String]
1433
+ attr_reader :id
18
1434
 
19
- # @return [String, nil]
20
- attr_reader :last4
1435
+ # @return [String ("card")]
1436
+ attr_reader :type
21
1437
 
22
- def initialize(brand:, exp_month:, exp_year:, last4:)
23
- @brand = brand
24
- @exp_month = exp_month
25
- @exp_year = exp_year
26
- @last4 = last4
1438
+ def initialize(card:, created_at:, customer_id:, id:, type:)
1439
+ @card = card
1440
+ @created_at = created_at
1441
+ @customer_id = customer_id
1442
+ @id = id
1443
+ @type = type
27
1444
  freeze
28
1445
  end
29
1446
 
30
- # Builds a Card from the API's JSON.
1447
+ # Builds a PaymentMethod from the API's JSON.
31
1448
  def self.from_hash(data)
32
1449
  new(
33
- brand: data.fetch("brand"),
34
- exp_month: data["exp_month"],
35
- exp_year: data["exp_year"],
36
- last4: data["last4"]
1450
+ card: Card.from_hash(data.fetch("card")),
1451
+ created_at: data.fetch("created_at"),
1452
+ customer_id: data.fetch("customer_id"),
1453
+ id: data.fetch("id"),
1454
+ type: data.fetch("type")
37
1455
  )
38
1456
  end
39
1457
  end
40
1458
 
41
- # Checkout is a resource of Peráta's API.
42
- class Checkout < Model
43
- MEMBERS = %i[id price_id product_id url].freeze
1459
+ # PaymentMethodDetached is a resource of Peráta's API.
1460
+ class PaymentMethodDetached < Model
1461
+ MEMBERS = %i[detached id].freeze
1462
+
1463
+ # @return [Boolean]
1464
+ attr_reader :detached
44
1465
 
45
1466
  # @return [String]
46
1467
  attr_reader :id
47
1468
 
1469
+ def initialize(detached:, id:)
1470
+ @detached = detached
1471
+ @id = id
1472
+ freeze
1473
+ end
1474
+
1475
+ # Builds a PaymentMethodDetached from the API's JSON.
1476
+ def self.from_hash(data)
1477
+ new(
1478
+ detached: data.fetch("detached"),
1479
+ id: data.fetch("id")
1480
+ )
1481
+ end
1482
+ end
1483
+
1484
+ # Price is a resource of Peráta's API.
1485
+ class Price < Model
1486
+ MEMBERS = %i[amount_cents currency id interval product_id status type].freeze
1487
+
1488
+ # Valor em centavos.
1489
+ # @return [Integer]
1490
+ attr_reader :amount_cents
1491
+
1492
+ # @return [String ("BRL")]
1493
+ attr_reader :currency
1494
+
48
1495
  # @return [String]
49
- attr_reader :price_id
1496
+ attr_reader :id
1497
+
1498
+ # @return [String ("none", "month", "year")]
1499
+ attr_reader :interval
50
1500
 
51
1501
  # @return [String]
52
1502
  attr_reader :product_id
53
1503
 
54
- # Endereço para onde o comprador é enviado.
55
- # @return [String]
56
- attr_reader :url
1504
+ # @return [String ("active", "archived")]
1505
+ attr_reader :status
1506
+
1507
+ # @return [String ("one_time", "recurring")]
1508
+ attr_reader :type
57
1509
 
58
- def initialize(id:, price_id:, product_id:, url:)
1510
+ def initialize(amount_cents:, currency:, id:, interval:, product_id:, status:, type:)
1511
+ @amount_cents = amount_cents
1512
+ @currency = currency
59
1513
  @id = id
60
- @price_id = price_id
1514
+ @interval = interval
61
1515
  @product_id = product_id
62
- @url = url
1516
+ @status = status
1517
+ @type = type
63
1518
  freeze
64
1519
  end
65
1520
 
66
- # Builds a Checkout from the API's JSON.
1521
+ # Builds a Price from the API's JSON.
67
1522
  def self.from_hash(data)
68
1523
  new(
1524
+ amount_cents: data.fetch("amount_cents"),
1525
+ currency: data.fetch("currency"),
69
1526
  id: data.fetch("id"),
70
- price_id: data.fetch("price_id"),
1527
+ interval: data.fetch("interval"),
71
1528
  product_id: data.fetch("product_id"),
72
- url: data.fetch("url")
1529
+ status: data.fetch("status"),
1530
+ type: data.fetch("type")
73
1531
  )
74
1532
  end
75
1533
  end
76
1534
 
77
- # Customer is a resource of Peráta's API.
78
- class Customer < Model
79
- MEMBERS = %i[created_at email external_id id name status].freeze
1535
+ # Product is a resource of Peráta's API.
1536
+ class Product < Model
1537
+ MEMBERS = %i[created_at description id name status].freeze
80
1538
 
81
1539
  # @return [String]
82
1540
  attr_reader :created_at
83
1541
 
84
1542
  # @return [String]
85
- attr_reader :email
86
-
87
- # @return [String]
88
- attr_reader :external_id
1543
+ attr_reader :description
89
1544
 
90
1545
  # @return [String]
91
1546
  attr_reader :id
@@ -96,22 +1551,20 @@ module Perata
96
1551
  # @return [String ("active", "archived")]
97
1552
  attr_reader :status
98
1553
 
99
- def initialize(created_at:, email:, external_id:, id:, name:, status:)
1554
+ def initialize(created_at:, description:, id:, name:, status:)
100
1555
  @created_at = created_at
101
- @email = email
102
- @external_id = external_id
1556
+ @description = description
103
1557
  @id = id
104
1558
  @name = name
105
1559
  @status = status
106
1560
  freeze
107
1561
  end
108
1562
 
109
- # Builds a Customer from the API's JSON.
1563
+ # Builds a Product from the API's JSON.
110
1564
  def self.from_hash(data)
111
1565
  new(
112
1566
  created_at: data.fetch("created_at"),
113
- email: data.fetch("email"),
114
- external_id: data.fetch("external_id"),
1567
+ description: data.fetch("description"),
115
1568
  id: data.fetch("id"),
116
1569
  name: data.fetch("name"),
117
1570
  status: data.fetch("status")
@@ -119,24 +1572,72 @@ module Perata
119
1572
  end
120
1573
  end
121
1574
 
122
- # Order is a resource of Peráta's API.
123
- class Order < Model
124
- MEMBERS = %i[amount_cents currency customer_id id paid_at price_id product_id status].freeze
1575
+ # Refund is a resource of Peráta's API.
1576
+ class Refund < Model
1577
+ MEMBERS = %i[amount_cents id payment_id status].freeze
1578
+
1579
+ # @return [Integer]
1580
+ attr_reader :amount_cents
1581
+
1582
+ # @return [String]
1583
+ attr_reader :id
1584
+
1585
+ # @return [String]
1586
+ attr_reader :payment_id
1587
+
1588
+ # @return [String ("requested", "pending", "unknown", "succeeded", "failed", "canceled")]
1589
+ attr_reader :status
1590
+
1591
+ def initialize(amount_cents:, id:, payment_id:, status:)
1592
+ @amount_cents = amount_cents
1593
+ @id = id
1594
+ @payment_id = payment_id
1595
+ @status = status
1596
+ freeze
1597
+ end
1598
+
1599
+ # Builds a Refund from the API's JSON.
1600
+ def self.from_hash(data)
1601
+ new(
1602
+ amount_cents: data.fetch("amount_cents"),
1603
+ id: data.fetch("id"),
1604
+ payment_id: data.fetch("payment_id"),
1605
+ status: data.fetch("status")
1606
+ )
1607
+ end
1608
+ end
1609
+
1610
+ # Subscription is a resource of Peráta's API.
1611
+ class Subscription < Model
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
125
1613
 
126
1614
  # @return [Integer]
127
1615
  attr_reader :amount_cents
128
1616
 
1617
+ # @return [Boolean]
1618
+ attr_reader :cancel_at_period_end
1619
+
129
1620
  # @return [String ("BRL")]
130
1621
  attr_reader :currency
131
1622
 
1623
+ # @return [String]
1624
+ attr_reader :current_period_end
1625
+
1626
+ # @return [String]
1627
+ attr_reader :current_period_start
1628
+
132
1629
  # @return [String]
133
1630
  attr_reader :customer_id
134
1631
 
135
1632
  # @return [String]
136
1633
  attr_reader :id
137
1634
 
138
- # @return [String, nil]
139
- attr_reader :paid_at
1635
+ # @return [String]
1636
+ attr_reader :interval
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
140
1641
 
141
1642
  # @return [String]
142
1643
  attr_reader :price_id
@@ -144,73 +1645,118 @@ module Perata
144
1645
  # @return [String]
145
1646
  attr_reader :product_id
146
1647
 
147
- # @return [String ("open", "confirmed", "succeeded", "failed", "expired")]
1648
+ # @return [String ("trialing", "active", "past_due", "paused", "canceled")]
148
1649
  attr_reader :status
149
1650
 
150
- def initialize(amount_cents:, currency:, customer_id:, id:, paid_at:, price_id:, product_id:, status:)
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:)
151
1658
  @amount_cents = amount_cents
1659
+ @cancel_at_period_end = cancel_at_period_end
152
1660
  @currency = currency
1661
+ @current_period_end = current_period_end
1662
+ @current_period_start = current_period_start
153
1663
  @customer_id = customer_id
154
1664
  @id = id
155
- @paid_at = paid_at
1665
+ @interval = interval
1666
+ @metadata = metadata
156
1667
  @price_id = price_id
157
1668
  @product_id = product_id
158
1669
  @status = status
1670
+ @trial_end = trial_end
1671
+ @trial_start = trial_start
159
1672
  freeze
160
1673
  end
161
1674
 
162
- # Builds a Order from the API's JSON.
1675
+ # Builds a Subscription from the API's JSON.
163
1676
  def self.from_hash(data)
164
1677
  new(
165
1678
  amount_cents: data.fetch("amount_cents"),
1679
+ cancel_at_period_end: data.fetch("cancel_at_period_end"),
166
1680
  currency: data.fetch("currency"),
1681
+ current_period_end: data.fetch("current_period_end"),
1682
+ current_period_start: data.fetch("current_period_start"),
167
1683
  customer_id: data.fetch("customer_id"),
168
1684
  id: data.fetch("id"),
169
- paid_at: data["paid_at"],
1685
+ interval: data.fetch("interval"),
1686
+ metadata: data.fetch("metadata"),
170
1687
  price_id: data.fetch("price_id"),
171
1688
  product_id: data.fetch("product_id"),
172
- status: data.fetch("status")
1689
+ status: data.fetch("status"),
1690
+ trial_end: data["trial_end"],
1691
+ trial_start: data["trial_start"]
173
1692
  )
174
1693
  end
175
1694
  end
176
1695
 
177
- # Pagination is a resource of Peráta's API.
178
- class Pagination < Model
179
- MEMBERS = %i[max_page total_count].freeze
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
180
1699
 
181
- # @return [Integer]
182
- attr_reader :max_page
1700
+ # @return [String]
1701
+ attr_reader :created_at
183
1702
 
184
- # @return [Integer]
185
- attr_reader :total_count
1703
+ # @return [String]
1704
+ attr_reader :description
186
1705
 
187
- def initialize(max_page:, total_count:)
188
- @max_page = max_page
189
- @total_count = total_count
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
190
1733
  freeze
191
1734
  end
192
1735
 
193
- # Builds a Pagination from the API's JSON.
1736
+ # Builds a WebhookBenefit from the API's JSON.
194
1737
  def self.from_hash(data)
195
1738
  new(
196
- max_page: data.fetch("max_page"),
197
- total_count: data.fetch("total_count")
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")
198
1747
  )
199
1748
  end
200
1749
  end
201
1750
 
202
- # Payment is a resource of Peráta's API.
203
- class Payment < Model
204
- MEMBERS = %i[amount_cents captured_cents checkout_id created_at currency customer_id id method refunded_cents state].freeze
1751
+ # WebhookCheckout is a resource of Peráta's API.
1752
+ class WebhookCheckout < Model
1753
+ MEMBERS = %i[amount_cents checkout_link_id created_at currency customer_id discount_cents expires_at id price_id product_id status total_cents].freeze
205
1754
 
206
1755
  # @return [Integer]
207
1756
  attr_reader :amount_cents
208
1757
 
209
- # @return [Integer]
210
- attr_reader :captured_cents
211
-
212
- # @return [String]
213
- attr_reader :checkout_id
1758
+ # @return [String, nil]
1759
+ attr_reader :checkout_link_id
214
1760
 
215
1761
  # @return [String]
216
1762
  attr_reader :created_at
@@ -218,309 +1764,447 @@ module Perata
218
1764
  # @return [String ("BRL")]
219
1765
  attr_reader :currency
220
1766
 
1767
+ # Nulo até o comprador confirmar.
1768
+ # @return [String, nil]
1769
+ attr_reader :customer_id
1770
+
1771
+ # @return [Integer]
1772
+ attr_reader :discount_cents
1773
+
221
1774
  # @return [String]
222
- attr_reader :customer_id
1775
+ attr_reader :expires_at
223
1776
 
224
1777
  # @return [String]
225
1778
  attr_reader :id
226
1779
 
227
- # @return [String ("card", "pix", "boleto")]
228
- attr_reader :method
1780
+ # @return [String]
1781
+ attr_reader :price_id
229
1782
 
230
- # @return [Integer]
231
- attr_reader :refunded_cents
1783
+ # @return [String]
1784
+ attr_reader :product_id
232
1785
 
233
- # @return [String ("unknown", "pending", "authorized", "captured", "refused", "canceled", "refunded", "partially_refunded")]
234
- attr_reader :state
1786
+ # @return [String ("open", "confirmed", "succeeded", "failed", "expired")]
1787
+ attr_reader :status
1788
+
1789
+ # @return [Integer]
1790
+ attr_reader :total_cents
235
1791
 
236
- def initialize(amount_cents:, captured_cents:, checkout_id:, created_at:, currency:, customer_id:, id:, method:, refunded_cents:, state:)
1792
+ def initialize(amount_cents:, checkout_link_id:, created_at:, currency:, customer_id:, discount_cents:, expires_at:, id:, price_id:, product_id:, status:, total_cents:)
237
1793
  @amount_cents = amount_cents
238
- @captured_cents = captured_cents
239
- @checkout_id = checkout_id
1794
+ @checkout_link_id = checkout_link_id
240
1795
  @created_at = created_at
241
1796
  @currency = currency
242
1797
  @customer_id = customer_id
1798
+ @discount_cents = discount_cents
1799
+ @expires_at = expires_at
243
1800
  @id = id
244
- @method = method
245
- @refunded_cents = refunded_cents
246
- @state = state
1801
+ @price_id = price_id
1802
+ @product_id = product_id
1803
+ @status = status
1804
+ @total_cents = total_cents
247
1805
  freeze
248
1806
  end
249
1807
 
250
- # Builds a Payment from the API's JSON.
1808
+ # Builds a WebhookCheckout from the API's JSON.
251
1809
  def self.from_hash(data)
252
1810
  new(
253
1811
  amount_cents: data.fetch("amount_cents"),
254
- captured_cents: data.fetch("captured_cents"),
255
- checkout_id: data.fetch("checkout_id"),
1812
+ checkout_link_id: data["checkout_link_id"],
256
1813
  created_at: data.fetch("created_at"),
257
1814
  currency: data.fetch("currency"),
258
- customer_id: data.fetch("customer_id"),
1815
+ customer_id: data["customer_id"],
1816
+ discount_cents: data.fetch("discount_cents"),
1817
+ expires_at: data.fetch("expires_at"),
259
1818
  id: data.fetch("id"),
260
- method: data.fetch("method"),
261
- refunded_cents: data.fetch("refunded_cents"),
262
- state: data.fetch("state")
1819
+ price_id: data.fetch("price_id"),
1820
+ product_id: data.fetch("product_id"),
1821
+ status: data.fetch("status"),
1822
+ total_cents: data.fetch("total_cents")
263
1823
  )
264
1824
  end
265
1825
  end
266
1826
 
267
- # PaymentMethod is a resource of Peráta's API.
268
- class PaymentMethod < Model
269
- MEMBERS = %i[card created_at customer_id id type].freeze
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
270
1830
 
271
- # @return [Card]
272
- attr_reader :card
1831
+ # @return [Integer]
1832
+ attr_reader :attempts
273
1833
 
274
1834
  # @return [String]
275
1835
  attr_reader :created_at
276
1836
 
277
1837
  # @return [String]
278
- attr_reader :customer_id
1838
+ attr_reader :endpoint_id
1839
+
1840
+ # @return [String]
1841
+ attr_reader :event_id
1842
+
1843
+ # @return [String]
1844
+ attr_reader :event_type
279
1845
 
280
1846
  # @return [String]
281
1847
  attr_reader :id
282
1848
 
283
- # @return [String ("card")]
284
- attr_reader :type
1849
+ # @return [String, nil]
1850
+ attr_reader :last_attempt_at
285
1851
 
286
- def initialize(card:, created_at:, customer_id:, id:, type:)
287
- @card = card
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
288
1871
  @created_at = created_at
289
- @customer_id = customer_id
1872
+ @endpoint_id = endpoint_id
1873
+ @event_id = event_id
1874
+ @event_type = event_type
290
1875
  @id = id
291
- @type = type
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
292
1882
  freeze
293
1883
  end
294
1884
 
295
- # Builds a PaymentMethod from the API's JSON.
1885
+ # Builds a WebhookDelivery from the API's JSON.
296
1886
  def self.from_hash(data)
297
1887
  new(
298
- card: Card.from_hash(data.fetch("card")),
1888
+ attempts: data.fetch("attempts"),
299
1889
  created_at: data.fetch("created_at"),
300
- customer_id: data.fetch("customer_id"),
1890
+ endpoint_id: data.fetch("endpoint_id"),
1891
+ event_id: data.fetch("event_id"),
1892
+ event_type: data.fetch("event_type"),
301
1893
  id: data.fetch("id"),
302
- type: data.fetch("type")
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")
303
1900
  )
304
1901
  end
305
1902
  end
306
1903
 
307
- # PaymentMethodDetached is a resource of Peráta's API.
308
- class PaymentMethodDetached < Model
309
- MEMBERS = %i[detached id].freeze
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
310
1907
 
311
- # @return [Boolean]
312
- attr_reader :detached
1908
+ # Valor fixo em centavos, quando o tipo é fixed.
1909
+ # @return [Integer]
1910
+ attr_reader :amount_cents
313
1911
 
314
- # @return [String]
315
- attr_reader :id
1912
+ # Percentual em pontos-base, quando o tipo é percentage.
1913
+ # @return [Integer]
1914
+ attr_reader :basis_points
316
1915
 
317
- def initialize(detached:, id:)
318
- @detached = detached
319
- @id = id
320
- freeze
321
- end
1916
+ # @return [String, nil]
1917
+ attr_reader :code
322
1918
 
323
- # Builds a PaymentMethodDetached from the API's JSON.
324
- def self.from_hash(data)
325
- new(
326
- detached: data.fetch("detached"),
327
- id: data.fetch("id")
328
- )
329
- end
330
- end
1919
+ # @return [String]
1920
+ attr_reader :created_at
331
1921
 
332
- # Price is a resource of Peráta's API.
333
- class Price < Model
334
- MEMBERS = %i[amount_cents currency id interval product_id status type].freeze
1922
+ # @return [String]
1923
+ attr_reader :currency
1924
+
1925
+ # @return [String ("once", "forever", "repeating")]
1926
+ attr_reader :duration
335
1927
 
336
- # Valor em centavos.
337
1928
  # @return [Integer]
338
- attr_reader :amount_cents
1929
+ attr_reader :duration_in_months
339
1930
 
340
- # @return [String ("BRL")]
341
- attr_reader :currency
1931
+ # @return [String, nil]
1932
+ attr_reader :ends_at
342
1933
 
343
1934
  # @return [String]
344
1935
  attr_reader :id
345
1936
 
346
- # @return [String ("none", "month", "year")]
347
- attr_reader :interval
1937
+ # @return [Integer, nil]
1938
+ attr_reader :max_redemptions
348
1939
 
349
1940
  # @return [String]
350
- attr_reader :product_id
1941
+ attr_reader :modified_at
351
1942
 
352
- # @return [String ("active", "archived")]
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")]
353
1953
  attr_reader :status
354
1954
 
355
- # @return [String ("one_time", "recurring")]
1955
+ # @return [String ("percentage", "fixed")]
356
1956
  attr_reader :type
357
1957
 
358
- def initialize(amount_cents:, currency:, id:, interval:, product_id:, status:, type:)
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:)
359
1959
  @amount_cents = amount_cents
1960
+ @basis_points = basis_points
1961
+ @code = code
1962
+ @created_at = created_at
360
1963
  @currency = currency
1964
+ @duration = duration
1965
+ @duration_in_months = duration_in_months
1966
+ @ends_at = ends_at
361
1967
  @id = id
362
- @interval = interval
363
- @product_id = product_id
1968
+ @max_redemptions = max_redemptions
1969
+ @modified_at = modified_at
1970
+ @name = name
1971
+ @redemptions_count = redemptions_count
1972
+ @starts_at = starts_at
364
1973
  @status = status
365
1974
  @type = type
366
1975
  freeze
367
1976
  end
368
1977
 
369
- # Builds a Price from the API's JSON.
1978
+ # Builds a WebhookDiscount from the API's JSON.
370
1979
  def self.from_hash(data)
371
1980
  new(
372
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"),
373
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"],
374
1989
  id: data.fetch("id"),
375
- interval: data.fetch("interval"),
376
- product_id: data.fetch("product_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"),
377
1995
  status: data.fetch("status"),
378
1996
  type: data.fetch("type")
379
1997
  )
380
1998
  end
381
1999
  end
382
2000
 
383
- # Product is a resource of Peráta's API.
384
- class Product < Model
385
- MEMBERS = %i[created_at description id name status].freeze
2001
+ # WebhookDispute is a resource of Peráta's API.
2002
+ class WebhookDispute < Model
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
2004
+
2005
+ # Valor contestado, em centavos.
2006
+ # @return [Integer]
2007
+ attr_reader :amount_cents
2008
+
2009
+ # @return [String ("BRL")]
2010
+ attr_reader :currency
2011
+
2012
+ # @return [String, nil]
2013
+ attr_reader :customer_id
2014
+
2015
+ # @return [String, nil]
2016
+ attr_reader :decided_at
2017
+
2018
+ # Prazo da defesa.
2019
+ # @return [String, nil]
2020
+ attr_reader :due_by
386
2021
 
387
2022
  # @return [String]
388
- attr_reader :created_at
2023
+ attr_reader :id
2024
+
2025
+ # @return [String, nil]
2026
+ attr_reader :invoice_id
389
2027
 
390
2028
  # @return [String]
391
- attr_reader :description
2029
+ attr_reader :opened_at
392
2030
 
2031
+ # O PaymentId da venda contestada na Cielo.
393
2032
  # @return [String]
394
- attr_reader :id
2033
+ attr_reader :payment_id
395
2034
 
2035
+ # O número do caso na Cielo.
396
2036
  # @return [String]
397
- attr_reader :name
2037
+ attr_reader :provider_dispute_id
398
2038
 
399
- # @return [String ("active", "archived")]
2039
+ # O motivo nas palavras da Cielo.
2040
+ # @return [String]
2041
+ attr_reader :provider_reason
2042
+
2043
+ # Motivo, do conjunto fechado; unknown quando a adquirente não informou.
2044
+ # @return [String]
2045
+ attr_reader :reason
2046
+
2047
+ # @return [String ("operator", "cielo_chargeback")]
2048
+ attr_reader :source
2049
+
2050
+ # @return [String ("opened", "needs_evidence", "submitted", "under_review", "won", "lost", "closed")]
400
2051
  attr_reader :status
401
2052
 
402
- def initialize(created_at:, description:, id:, name:, status:)
403
- @created_at = created_at
404
- @description = description
2053
+ def initialize(amount_cents:, currency:, customer_id:, decided_at:, due_by:, id:, invoice_id:, opened_at:, payment_id:, provider_dispute_id:, provider_reason:, reason:, source:, status:)
2054
+ @amount_cents = amount_cents
2055
+ @currency = currency
2056
+ @customer_id = customer_id
2057
+ @decided_at = decided_at
2058
+ @due_by = due_by
405
2059
  @id = id
406
- @name = name
2060
+ @invoice_id = invoice_id
2061
+ @opened_at = opened_at
2062
+ @payment_id = payment_id
2063
+ @provider_dispute_id = provider_dispute_id
2064
+ @provider_reason = provider_reason
2065
+ @reason = reason
2066
+ @source = source
407
2067
  @status = status
408
2068
  freeze
409
2069
  end
410
2070
 
411
- # Builds a Product from the API's JSON.
2071
+ # Builds a WebhookDispute from the API's JSON.
412
2072
  def self.from_hash(data)
413
2073
  new(
414
- created_at: data.fetch("created_at"),
415
- description: data.fetch("description"),
2074
+ amount_cents: data.fetch("amount_cents"),
2075
+ currency: data.fetch("currency"),
2076
+ customer_id: data["customer_id"],
2077
+ decided_at: data["decided_at"],
2078
+ due_by: data["due_by"],
416
2079
  id: data.fetch("id"),
417
- name: data.fetch("name"),
2080
+ invoice_id: data["invoice_id"],
2081
+ opened_at: data.fetch("opened_at"),
2082
+ payment_id: data.fetch("payment_id"),
2083
+ provider_dispute_id: data.fetch("provider_dispute_id"),
2084
+ provider_reason: data.fetch("provider_reason"),
2085
+ reason: data.fetch("reason"),
2086
+ source: data.fetch("source"),
418
2087
  status: data.fetch("status")
419
2088
  )
420
2089
  end
421
2090
  end
422
2091
 
423
- # Refund is a resource of Peráta's API.
424
- class Refund < Model
425
- MEMBERS = %i[amount_cents id payment_id status].freeze
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
426
2095
 
427
2096
  # @return [Integer]
428
- attr_reader :amount_cents
2097
+ attr_reader :consecutive_failures
429
2098
 
430
2099
  # @return [String]
431
- attr_reader :id
2100
+ attr_reader :created_at
432
2101
 
2102
+ # Como o lojista chama o endpoint; sem ele, o domínio do endereço.
433
2103
  # @return [String]
434
- attr_reader :payment_id
2104
+ attr_reader :description
435
2105
 
436
- # @return [String ("requested", "pending", "unknown", "succeeded", "failed", "canceled")]
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")]
437
2118
  attr_reader :status
438
2119
 
439
- def initialize(amount_cents:, id:, payment_id:, status:)
440
- @amount_cents = amount_cents
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
441
2130
  @id = id
442
- @payment_id = payment_id
443
2131
  @status = status
2132
+ @url = url
444
2133
  freeze
445
2134
  end
446
2135
 
447
- # Builds a Refund from the API's JSON.
2136
+ # Builds a WebhookEndpoint from the API's JSON.
448
2137
  def self.from_hash(data)
449
2138
  new(
450
- amount_cents: data.fetch("amount_cents"),
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"),
451
2144
  id: data.fetch("id"),
452
- payment_id: data.fetch("payment_id"),
453
- status: data.fetch("status")
2145
+ status: data.fetch("status"),
2146
+ url: data.fetch("url")
454
2147
  )
455
2148
  end
456
2149
  end
457
2150
 
458
- # Subscription is a resource of Peráta's API.
459
- class Subscription < Model
460
- 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
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
461
2154
 
462
2155
  # @return [Integer]
463
- attr_reader :amount_cents
464
-
465
- # @return [Boolean]
466
- attr_reader :cancel_at_period_end
467
-
468
- # @return [String ("BRL")]
469
- attr_reader :currency
2156
+ attr_reader :consecutive_failures
470
2157
 
471
2158
  # @return [String]
472
- attr_reader :current_period_end
2159
+ attr_reader :created_at
473
2160
 
474
2161
  # @return [String]
475
- attr_reader :current_period_start
2162
+ attr_reader :description
476
2163
 
477
- # @return [String]
478
- attr_reader :customer_id
2164
+ # @return [Array<String>]
2165
+ attr_reader :events
2166
+
2167
+ # @return [String ("raw", "discord", "slack")]
2168
+ attr_reader :format
479
2169
 
480
2170
  # @return [String]
481
2171
  attr_reader :id
482
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.
483
2174
  # @return [String]
484
- attr_reader :interval
2175
+ attr_reader :secret
485
2176
 
486
- # @return [String]
487
- attr_reader :price_id
2177
+ # @return [String ("active", "disabled")]
2178
+ attr_reader :status
488
2179
 
489
2180
  # @return [String]
490
- attr_reader :product_id
491
-
492
- # @return [String ("trialing", "active", "past_due", "paused", "canceled")]
493
- attr_reader :status
2181
+ attr_reader :url
494
2182
 
495
- def initialize(amount_cents:, cancel_at_period_end:, currency:, current_period_end:, current_period_start:, customer_id:, id:, interval:, price_id:, product_id:, status:)
496
- @amount_cents = amount_cents
497
- @cancel_at_period_end = cancel_at_period_end
498
- @currency = currency
499
- @current_period_end = current_period_end
500
- @current_period_start = current_period_start
501
- @customer_id = customer_id
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
502
2189
  @id = id
503
- @interval = interval
504
- @price_id = price_id
505
- @product_id = product_id
2190
+ @secret = secret
506
2191
  @status = status
2192
+ @url = url
507
2193
  freeze
508
2194
  end
509
2195
 
510
- # Builds a Subscription from the API's JSON.
2196
+ # Builds a WebhookEndpointCreated from the API's JSON.
511
2197
  def self.from_hash(data)
512
2198
  new(
513
- amount_cents: data.fetch("amount_cents"),
514
- cancel_at_period_end: data.fetch("cancel_at_period_end"),
515
- currency: data.fetch("currency"),
516
- current_period_end: data.fetch("current_period_end"),
517
- current_period_start: data.fetch("current_period_start"),
518
- customer_id: data.fetch("customer_id"),
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"),
519
2204
  id: data.fetch("id"),
520
- interval: data.fetch("interval"),
521
- price_id: data.fetch("price_id"),
522
- product_id: data.fetch("product_id"),
523
- status: data.fetch("status")
2205
+ secret: data.fetch("secret"),
2206
+ status: data.fetch("status"),
2207
+ url: data.fetch("url")
524
2208
  )
525
2209
  end
526
2210
  end