perata-sdk 0.5.4 → 0.5.6
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 +68 -4
- data/lib/perata/client.rb +12 -1
- data/lib/perata/models.rb +308 -34
- data/lib/perata/params.rb +44 -16
- data/lib/perata/services.rb +651 -73
- data/lib/perata/version.rb +1 -1
- data/lib/perata/webhooks.rb +8 -3
- metadata +1 -1
data/lib/perata/models.rb
CHANGED
|
@@ -334,7 +334,7 @@ module Perata
|
|
|
334
334
|
|
|
335
335
|
# Checkout is a resource of Peráta's API.
|
|
336
336
|
class Checkout < Model
|
|
337
|
-
MEMBERS = %i[amount_cents cancel_url client_reference_id created_at expires_at id items label metadata price_id product_id quantity status success_url url].freeze
|
|
337
|
+
MEMBERS = %i[amount_cents cancel_url client_reference_id created_at discount_id expires_at id items label metadata price_id product_id quantity showcase_id status subscription_start_at success_url url].freeze
|
|
338
338
|
|
|
339
339
|
# O valor, em centavos, que o seu servidor fixou na criação; nulo quando é o comprador quem digita o valor.
|
|
340
340
|
# @return [Integer, nil]
|
|
@@ -351,6 +351,10 @@ module Perata
|
|
|
351
351
|
# @return [String]
|
|
352
352
|
attr_reader :created_at
|
|
353
353
|
|
|
354
|
+
# O desconto que o checkout aplica sozinho, como o seu servidor o enviou na criação; vazio sem ele. O comprador o vê no resumo e ele conta desde a primeira cobrança.
|
|
355
|
+
# @return [String]
|
|
356
|
+
attr_reader :discount_id
|
|
357
|
+
|
|
354
358
|
# Quando o checkout deixa de abrir sessões; nulo sem prazo.
|
|
355
359
|
# @return [String, nil]
|
|
356
360
|
attr_reader :expires_at
|
|
@@ -379,10 +383,18 @@ module Perata
|
|
|
379
383
|
# @return [Integer]
|
|
380
384
|
attr_reader :quantity
|
|
381
385
|
|
|
386
|
+
# O showcase a que pertence: o da chave de API que fez a chamada. Uma chave só alcança o seu showcase.
|
|
387
|
+
# @return [String]
|
|
388
|
+
attr_reader :showcase_id
|
|
389
|
+
|
|
382
390
|
# active abre sessões de compra; archived saiu de circulação.
|
|
383
391
|
# @return [String ("active", "archived")]
|
|
384
392
|
attr_reader :status
|
|
385
393
|
|
|
394
|
+
# O dia da primeira cobrança de uma assinatura que começa numa data (a meia-noite desse dia em São Paulo, com o fuso); nulo quando o checkout cobra na hora ou começa por um teste em dias. O cartão é guardado sem cobrança e a cobrança acontece nesse dia.
|
|
395
|
+
# @return [String, nil]
|
|
396
|
+
attr_reader :subscription_start_at
|
|
397
|
+
|
|
386
398
|
# Endereço https para onde o comprador volta depois de pagar; vazio sem ele.
|
|
387
399
|
# @return [String]
|
|
388
400
|
attr_reader :success_url
|
|
@@ -391,11 +403,12 @@ module Perata
|
|
|
391
403
|
# @return [String]
|
|
392
404
|
attr_reader :url
|
|
393
405
|
|
|
394
|
-
def initialize(amount_cents:, cancel_url:, client_reference_id:, created_at:, expires_at:, id:, items:, label:, metadata:, price_id:, product_id:, quantity:, status:, success_url:, url:)
|
|
406
|
+
def initialize(amount_cents:, cancel_url:, client_reference_id:, created_at:, discount_id:, expires_at:, id:, items:, label:, metadata:, price_id:, product_id:, quantity:, showcase_id:, status:, subscription_start_at:, success_url:, url:)
|
|
395
407
|
@amount_cents = amount_cents
|
|
396
408
|
@cancel_url = cancel_url
|
|
397
409
|
@client_reference_id = client_reference_id
|
|
398
410
|
@created_at = created_at
|
|
411
|
+
@discount_id = discount_id
|
|
399
412
|
@expires_at = expires_at
|
|
400
413
|
@id = id
|
|
401
414
|
@items = items
|
|
@@ -404,7 +417,9 @@ module Perata
|
|
|
404
417
|
@price_id = price_id
|
|
405
418
|
@product_id = product_id
|
|
406
419
|
@quantity = quantity
|
|
420
|
+
@showcase_id = showcase_id
|
|
407
421
|
@status = status
|
|
422
|
+
@subscription_start_at = subscription_start_at
|
|
408
423
|
@success_url = success_url
|
|
409
424
|
@url = url
|
|
410
425
|
freeze
|
|
@@ -417,6 +432,7 @@ module Perata
|
|
|
417
432
|
cancel_url: data.fetch("cancel_url"),
|
|
418
433
|
client_reference_id: data.fetch("client_reference_id"),
|
|
419
434
|
created_at: data.fetch("created_at"),
|
|
435
|
+
discount_id: data.fetch("discount_id"),
|
|
420
436
|
expires_at: data["expires_at"],
|
|
421
437
|
id: data.fetch("id"),
|
|
422
438
|
items: data.fetch("items").map { |item| CheckoutLine.from_hash(item) },
|
|
@@ -425,7 +441,9 @@ module Perata
|
|
|
425
441
|
price_id: data.fetch("price_id"),
|
|
426
442
|
product_id: data.fetch("product_id"),
|
|
427
443
|
quantity: data.fetch("quantity"),
|
|
444
|
+
showcase_id: data.fetch("showcase_id"),
|
|
428
445
|
status: data.fetch("status"),
|
|
446
|
+
subscription_start_at: data["subscription_start_at"],
|
|
429
447
|
success_url: data.fetch("success_url"),
|
|
430
448
|
url: data.fetch("url")
|
|
431
449
|
)
|
|
@@ -434,7 +452,7 @@ module Perata
|
|
|
434
452
|
|
|
435
453
|
# CheckoutClient is a resource of Peráta's API.
|
|
436
454
|
class CheckoutClient < Model
|
|
437
|
-
MEMBERS = %i[amount_cents amount_locked cancel_url card_kinds client_reference_id currency customer discount discount_cents editable environment expires_at id installments items missing next_action payment payment_methods requires_billing_address requires_tax_id status status_key success_url total_cents].freeze
|
|
455
|
+
MEMBERS = %i[amount_cents amount_locked cancel_url card_kinds client_reference_id currency customer discount discount_cents editable environment expires_at first_charge_at id installments items missing next_action payment payment_methods requires_billing_address requires_tax_id status status_key success_url total_cents].freeze
|
|
438
456
|
|
|
439
457
|
# Antes do desconto.
|
|
440
458
|
# @return [Integer]
|
|
@@ -479,6 +497,10 @@ module Perata
|
|
|
479
497
|
# @return [String]
|
|
480
498
|
attr_reader :expires_at
|
|
481
499
|
|
|
500
|
+
# O dia da primeira cobrança de uma assinatura que não cobra hoje, a meia-noite desse dia em São Paulo: o fim do teste grátis ou a data que o servidor do lojista pediu (subscription_start_at). Nulo quando o pagamento é cobrado na hora.
|
|
501
|
+
# @return [String, nil]
|
|
502
|
+
attr_reader :first_charge_at
|
|
503
|
+
|
|
482
504
|
# O ID da sessão de checkout.
|
|
483
505
|
# @return [String]
|
|
484
506
|
attr_reader :id
|
|
@@ -528,7 +550,7 @@ module Perata
|
|
|
528
550
|
# @return [Integer]
|
|
529
551
|
attr_reader :total_cents
|
|
530
552
|
|
|
531
|
-
def initialize(amount_cents:, amount_locked:, cancel_url:, card_kinds:, client_reference_id:, currency:, customer:, discount:, discount_cents:, editable:, environment:, expires_at:, id:, installments:, items:, missing:, next_action:, payment:, payment_methods:, requires_billing_address:, requires_tax_id:, status:, status_key:, success_url:, total_cents:)
|
|
553
|
+
def initialize(amount_cents:, amount_locked:, cancel_url:, card_kinds:, client_reference_id:, currency:, customer:, discount:, discount_cents:, editable:, environment:, expires_at:, first_charge_at:, id:, installments:, items:, missing:, next_action:, payment:, payment_methods:, requires_billing_address:, requires_tax_id:, status:, status_key:, success_url:, total_cents:)
|
|
532
554
|
@amount_cents = amount_cents
|
|
533
555
|
@amount_locked = amount_locked
|
|
534
556
|
@cancel_url = cancel_url
|
|
@@ -541,6 +563,7 @@ module Perata
|
|
|
541
563
|
@editable = editable
|
|
542
564
|
@environment = environment
|
|
543
565
|
@expires_at = expires_at
|
|
566
|
+
@first_charge_at = first_charge_at
|
|
544
567
|
@id = id
|
|
545
568
|
@installments = installments
|
|
546
569
|
@items = items
|
|
@@ -572,6 +595,7 @@ module Perata
|
|
|
572
595
|
editable: data.fetch("editable"),
|
|
573
596
|
environment: data.fetch("environment"),
|
|
574
597
|
expires_at: data.fetch("expires_at"),
|
|
598
|
+
first_charge_at: data["first_charge_at"],
|
|
575
599
|
id: data.fetch("id"),
|
|
576
600
|
installments: data.fetch("installments").map { |item| CheckoutInstallment.from_hash(item) },
|
|
577
601
|
items: data.fetch("items").map { |item| CheckoutClientItem.from_hash(item) },
|
|
@@ -856,7 +880,7 @@ module Perata
|
|
|
856
880
|
|
|
857
881
|
# CheckoutCreated is a resource of Peráta's API.
|
|
858
882
|
class CheckoutCreated < Model
|
|
859
|
-
MEMBERS = %i[amount_cents cancel_url client_reference_id client_secret client_secret_expires_at created_at expires_at id items label metadata price_id product_id quantity session_id status status_key success_url url].freeze
|
|
883
|
+
MEMBERS = %i[amount_cents cancel_url client_reference_id client_secret client_secret_expires_at created_at discount_id expires_at id items label metadata price_id product_id quantity session_id showcase_id status status_key subscription_start_at success_url url].freeze
|
|
860
884
|
|
|
861
885
|
# O valor, em centavos, que o seu servidor fixou; o comprador o vê e não pode mudá-lo. Nulo quando é o comprador quem digita o valor.
|
|
862
886
|
# @return [Integer, nil]
|
|
@@ -881,6 +905,10 @@ module Perata
|
|
|
881
905
|
# @return [String]
|
|
882
906
|
attr_reader :created_at
|
|
883
907
|
|
|
908
|
+
# O desconto que o checkout aplica sozinho, como o seu servidor o enviou na criação; vazio sem ele. O comprador o vê no resumo e ele conta desde a primeira cobrança.
|
|
909
|
+
# @return [String]
|
|
910
|
+
attr_reader :discount_id
|
|
911
|
+
|
|
884
912
|
# Quando o link deixa de abrir sessões; nulo sem prazo.
|
|
885
913
|
# @return [String, nil]
|
|
886
914
|
attr_reader :expires_at
|
|
@@ -914,6 +942,10 @@ module Perata
|
|
|
914
942
|
# @return [String]
|
|
915
943
|
attr_reader :session_id
|
|
916
944
|
|
|
945
|
+
# O showcase a que pertence: o da chave de API que fez a chamada. Uma chave só alcança o seu showcase.
|
|
946
|
+
# @return [String]
|
|
947
|
+
attr_reader :showcase_id
|
|
948
|
+
|
|
917
949
|
# active abre sessões de compra; archived saiu de circulação.
|
|
918
950
|
# @return [String ("active", "archived")]
|
|
919
951
|
attr_reader :status
|
|
@@ -922,6 +954,10 @@ module Perata
|
|
|
922
954
|
# @return [String]
|
|
923
955
|
attr_reader :status_key
|
|
924
956
|
|
|
957
|
+
# O dia da primeira cobrança de uma assinatura que começa numa data (a meia-noite desse dia em São Paulo, com o fuso); nulo quando o checkout cobra na hora ou começa por um teste em dias. O cartão é guardado sem cobrança e a cobrança acontece nesse dia.
|
|
958
|
+
# @return [String, nil]
|
|
959
|
+
attr_reader :subscription_start_at
|
|
960
|
+
|
|
925
961
|
# Endereço https para onde o comprador volta depois de pagar; vazio sem ele.
|
|
926
962
|
# @return [String]
|
|
927
963
|
attr_reader :success_url
|
|
@@ -930,13 +966,14 @@ module Perata
|
|
|
930
966
|
# @return [String]
|
|
931
967
|
attr_reader :url
|
|
932
968
|
|
|
933
|
-
def initialize(amount_cents:, cancel_url:, client_reference_id:, client_secret:, client_secret_expires_at:, created_at:, expires_at:, id:, items:, label:, metadata:, price_id:, product_id:, quantity:, session_id:, status:, status_key:, success_url:, url:)
|
|
969
|
+
def initialize(amount_cents:, cancel_url:, client_reference_id:, client_secret:, client_secret_expires_at:, created_at:, discount_id:, expires_at:, id:, items:, label:, metadata:, price_id:, product_id:, quantity:, session_id:, showcase_id:, status:, status_key:, subscription_start_at:, success_url:, url:)
|
|
934
970
|
@amount_cents = amount_cents
|
|
935
971
|
@cancel_url = cancel_url
|
|
936
972
|
@client_reference_id = client_reference_id
|
|
937
973
|
@client_secret = client_secret
|
|
938
974
|
@client_secret_expires_at = client_secret_expires_at
|
|
939
975
|
@created_at = created_at
|
|
976
|
+
@discount_id = discount_id
|
|
940
977
|
@expires_at = expires_at
|
|
941
978
|
@id = id
|
|
942
979
|
@items = items
|
|
@@ -946,8 +983,10 @@ module Perata
|
|
|
946
983
|
@product_id = product_id
|
|
947
984
|
@quantity = quantity
|
|
948
985
|
@session_id = session_id
|
|
986
|
+
@showcase_id = showcase_id
|
|
949
987
|
@status = status
|
|
950
988
|
@status_key = status_key
|
|
989
|
+
@subscription_start_at = subscription_start_at
|
|
951
990
|
@success_url = success_url
|
|
952
991
|
@url = url
|
|
953
992
|
freeze
|
|
@@ -962,6 +1001,7 @@ module Perata
|
|
|
962
1001
|
client_secret: data.fetch("client_secret"),
|
|
963
1002
|
client_secret_expires_at: data.fetch("client_secret_expires_at"),
|
|
964
1003
|
created_at: data.fetch("created_at"),
|
|
1004
|
+
discount_id: data.fetch("discount_id"),
|
|
965
1005
|
expires_at: data["expires_at"],
|
|
966
1006
|
id: data.fetch("id"),
|
|
967
1007
|
items: data.fetch("items").map { |item| CheckoutLine.from_hash(item) },
|
|
@@ -971,8 +1011,10 @@ module Perata
|
|
|
971
1011
|
product_id: data.fetch("product_id"),
|
|
972
1012
|
quantity: data.fetch("quantity"),
|
|
973
1013
|
session_id: data.fetch("session_id"),
|
|
1014
|
+
showcase_id: data.fetch("showcase_id"),
|
|
974
1015
|
status: data.fetch("status"),
|
|
975
1016
|
status_key: data.fetch("status_key"),
|
|
1017
|
+
subscription_start_at: data["subscription_start_at"],
|
|
976
1018
|
success_url: data.fetch("success_url"),
|
|
977
1019
|
url: data.fetch("url")
|
|
978
1020
|
)
|
|
@@ -1498,7 +1540,7 @@ module Perata
|
|
|
1498
1540
|
|
|
1499
1541
|
# Customer is a resource of Peráta's API.
|
|
1500
1542
|
class Customer < Model
|
|
1501
|
-
MEMBERS = %i[billing_address billing_name created_at email external_id id name phone status tax_id tax_id_kind].freeze
|
|
1543
|
+
MEMBERS = %i[billing_address billing_name created_at email external_id id name phone showcase_id status tax_id tax_id_kind].freeze
|
|
1502
1544
|
|
|
1503
1545
|
# Endereço de cobrança; fica de fora quando o cliente não tem.
|
|
1504
1546
|
# @return [BillingAddress, nil]
|
|
@@ -1527,6 +1569,10 @@ module Perata
|
|
|
1527
1569
|
# @return [String, nil]
|
|
1528
1570
|
attr_reader :phone
|
|
1529
1571
|
|
|
1572
|
+
# O showcase a que pertence: o da chave de API que fez a chamada. Uma chave só alcança o seu showcase.
|
|
1573
|
+
# @return [String]
|
|
1574
|
+
attr_reader :showcase_id
|
|
1575
|
+
|
|
1530
1576
|
# @return [String ("active", "archived")]
|
|
1531
1577
|
attr_reader :status
|
|
1532
1578
|
|
|
@@ -1538,7 +1584,7 @@ module Perata
|
|
|
1538
1584
|
# @return [String ("cpf", "cnpj"), nil]
|
|
1539
1585
|
attr_reader :tax_id_kind
|
|
1540
1586
|
|
|
1541
|
-
def initialize(billing_address: nil, billing_name: nil, created_at:, email:, external_id:, id:, name:, phone: nil, status:, tax_id: nil, tax_id_kind: nil)
|
|
1587
|
+
def initialize(billing_address: nil, billing_name: nil, created_at:, email:, external_id:, id:, name:, phone: nil, showcase_id:, status:, tax_id: nil, tax_id_kind: nil)
|
|
1542
1588
|
@billing_address = billing_address
|
|
1543
1589
|
@billing_name = billing_name
|
|
1544
1590
|
@created_at = created_at
|
|
@@ -1547,6 +1593,7 @@ module Perata
|
|
|
1547
1593
|
@id = id
|
|
1548
1594
|
@name = name
|
|
1549
1595
|
@phone = phone
|
|
1596
|
+
@showcase_id = showcase_id
|
|
1550
1597
|
@status = status
|
|
1551
1598
|
@tax_id = tax_id
|
|
1552
1599
|
@tax_id_kind = tax_id_kind
|
|
@@ -1564,6 +1611,7 @@ module Perata
|
|
|
1564
1611
|
id: data.fetch("id"),
|
|
1565
1612
|
name: data.fetch("name"),
|
|
1566
1613
|
phone: data["phone"],
|
|
1614
|
+
showcase_id: data.fetch("showcase_id"),
|
|
1567
1615
|
status: data.fetch("status"),
|
|
1568
1616
|
tax_id: data["tax_id"],
|
|
1569
1617
|
tax_id_kind: data["tax_id_kind"]
|
|
@@ -1605,7 +1653,7 @@ module Perata
|
|
|
1605
1653
|
|
|
1606
1654
|
# CustomerState is a resource of Peráta's API.
|
|
1607
1655
|
class CustomerState < Model
|
|
1608
|
-
MEMBERS = %i[active_subscriptions created_at email external_id granted_benefits id name status].freeze
|
|
1656
|
+
MEMBERS = %i[active_subscriptions created_at email external_id granted_benefits id name showcase_id status].freeze
|
|
1609
1657
|
|
|
1610
1658
|
# As assinaturas ativas ou em teste do cliente.
|
|
1611
1659
|
# @return [Array<Subscription>]
|
|
@@ -1630,10 +1678,14 @@ module Perata
|
|
|
1630
1678
|
# @return [String]
|
|
1631
1679
|
attr_reader :name
|
|
1632
1680
|
|
|
1681
|
+
# O showcase a que pertence: o da chave de API que fez a chamada. Uma chave só alcança o seu showcase.
|
|
1682
|
+
# @return [String]
|
|
1683
|
+
attr_reader :showcase_id
|
|
1684
|
+
|
|
1633
1685
|
# @return [String ("active", "archived")]
|
|
1634
1686
|
attr_reader :status
|
|
1635
1687
|
|
|
1636
|
-
def initialize(active_subscriptions:, created_at:, email:, external_id:, granted_benefits:, id:, name:, status:)
|
|
1688
|
+
def initialize(active_subscriptions:, created_at:, email:, external_id:, granted_benefits:, id:, name:, showcase_id:, status:)
|
|
1637
1689
|
@active_subscriptions = active_subscriptions
|
|
1638
1690
|
@created_at = created_at
|
|
1639
1691
|
@email = email
|
|
@@ -1641,6 +1693,7 @@ module Perata
|
|
|
1641
1693
|
@granted_benefits = granted_benefits
|
|
1642
1694
|
@id = id
|
|
1643
1695
|
@name = name
|
|
1696
|
+
@showcase_id = showcase_id
|
|
1644
1697
|
@status = status
|
|
1645
1698
|
freeze
|
|
1646
1699
|
end
|
|
@@ -1655,6 +1708,7 @@ module Perata
|
|
|
1655
1708
|
granted_benefits: data.fetch("granted_benefits").map { |item| CustomerStateBenefitGrant.from_hash(item) },
|
|
1656
1709
|
id: data.fetch("id"),
|
|
1657
1710
|
name: data.fetch("name"),
|
|
1711
|
+
showcase_id: data.fetch("showcase_id"),
|
|
1658
1712
|
status: data.fetch("status")
|
|
1659
1713
|
)
|
|
1660
1714
|
end
|
|
@@ -2174,7 +2228,7 @@ module Perata
|
|
|
2174
2228
|
|
|
2175
2229
|
# Order is a resource of Peráta's API.
|
|
2176
2230
|
class Order < Model
|
|
2177
|
-
MEMBERS = %i[amount_cents client_reference_id currency customer_id id installment_interest_cents installments items metadata order_status paid_at price_id product_id refunded_amount_cents status].freeze
|
|
2231
|
+
MEMBERS = %i[amount_cents client_reference_id currency customer_id cycle_sequence id installment_interest_cents installments items metadata order_status paid_at period_end period_start price_id product_id refunded_amount_cents showcase_id status subscription_id].freeze
|
|
2178
2232
|
|
|
2179
2233
|
# @return [Integer]
|
|
2180
2234
|
attr_reader :amount_cents
|
|
@@ -2189,6 +2243,10 @@ module Perata
|
|
|
2189
2243
|
# @return [String]
|
|
2190
2244
|
attr_reader :customer_id
|
|
2191
2245
|
|
|
2246
|
+
# Qual ciclo da assinatura o pedido pagou: 1 é o primeiro; nulo fora de uma assinatura.
|
|
2247
|
+
# @return [Integer, nil]
|
|
2248
|
+
attr_reader :cycle_sequence
|
|
2249
|
+
|
|
2192
2250
|
# @return [String]
|
|
2193
2251
|
attr_reader :id
|
|
2194
2252
|
|
|
@@ -2215,6 +2273,14 @@ module Perata
|
|
|
2215
2273
|
# @return [String, nil]
|
|
2216
2274
|
attr_reader :paid_at
|
|
2217
2275
|
|
|
2276
|
+
# O fim do período que o ciclo paga; nulo fora de uma assinatura.
|
|
2277
|
+
# @return [String, nil]
|
|
2278
|
+
attr_reader :period_end
|
|
2279
|
+
|
|
2280
|
+
# O começo do período que o ciclo paga; nulo fora de uma assinatura.
|
|
2281
|
+
# @return [String, nil]
|
|
2282
|
+
attr_reader :period_start
|
|
2283
|
+
|
|
2218
2284
|
# @return [String]
|
|
2219
2285
|
attr_reader :price_id
|
|
2220
2286
|
|
|
@@ -2225,14 +2291,23 @@ module Perata
|
|
|
2225
2291
|
# @return [Integer]
|
|
2226
2292
|
attr_reader :refunded_amount_cents
|
|
2227
2293
|
|
|
2294
|
+
# O showcase a que pertence: o da chave de API que fez a chamada. Uma chave só alcança o seu showcase.
|
|
2295
|
+
# @return [String]
|
|
2296
|
+
attr_reader :showcase_id
|
|
2297
|
+
|
|
2228
2298
|
# @return [String ("open", "confirmed", "succeeded", "failed", "expired")]
|
|
2229
2299
|
attr_reader :status
|
|
2230
2300
|
|
|
2231
|
-
|
|
2301
|
+
# A assinatura de que este pedido é a cobrança (a primeira ou uma renovação); nulo quando o pedido não é de uma assinatura.
|
|
2302
|
+
# @return [String, nil]
|
|
2303
|
+
attr_reader :subscription_id
|
|
2304
|
+
|
|
2305
|
+
def initialize(amount_cents:, client_reference_id:, currency:, customer_id:, cycle_sequence:, id:, installment_interest_cents:, installments:, items:, metadata:, order_status:, paid_at:, period_end:, period_start:, price_id:, product_id:, refunded_amount_cents:, showcase_id:, status:, subscription_id:)
|
|
2232
2306
|
@amount_cents = amount_cents
|
|
2233
2307
|
@client_reference_id = client_reference_id
|
|
2234
2308
|
@currency = currency
|
|
2235
2309
|
@customer_id = customer_id
|
|
2310
|
+
@cycle_sequence = cycle_sequence
|
|
2236
2311
|
@id = id
|
|
2237
2312
|
@installment_interest_cents = installment_interest_cents
|
|
2238
2313
|
@installments = installments
|
|
@@ -2240,10 +2315,14 @@ module Perata
|
|
|
2240
2315
|
@metadata = metadata
|
|
2241
2316
|
@order_status = order_status
|
|
2242
2317
|
@paid_at = paid_at
|
|
2318
|
+
@period_end = period_end
|
|
2319
|
+
@period_start = period_start
|
|
2243
2320
|
@price_id = price_id
|
|
2244
2321
|
@product_id = product_id
|
|
2245
2322
|
@refunded_amount_cents = refunded_amount_cents
|
|
2323
|
+
@showcase_id = showcase_id
|
|
2246
2324
|
@status = status
|
|
2325
|
+
@subscription_id = subscription_id
|
|
2247
2326
|
freeze
|
|
2248
2327
|
end
|
|
2249
2328
|
|
|
@@ -2254,6 +2333,7 @@ module Perata
|
|
|
2254
2333
|
client_reference_id: data.fetch("client_reference_id"),
|
|
2255
2334
|
currency: data.fetch("currency"),
|
|
2256
2335
|
customer_id: data.fetch("customer_id"),
|
|
2336
|
+
cycle_sequence: data["cycle_sequence"],
|
|
2257
2337
|
id: data.fetch("id"),
|
|
2258
2338
|
installment_interest_cents: data.fetch("installment_interest_cents"),
|
|
2259
2339
|
installments: data.fetch("installments"),
|
|
@@ -2261,10 +2341,14 @@ module Perata
|
|
|
2261
2341
|
metadata: data.fetch("metadata"),
|
|
2262
2342
|
order_status: data["order_status"],
|
|
2263
2343
|
paid_at: data["paid_at"],
|
|
2344
|
+
period_end: data["period_end"],
|
|
2345
|
+
period_start: data["period_start"],
|
|
2264
2346
|
price_id: data.fetch("price_id"),
|
|
2265
2347
|
product_id: data.fetch("product_id"),
|
|
2266
2348
|
refunded_amount_cents: data.fetch("refunded_amount_cents"),
|
|
2267
|
-
|
|
2349
|
+
showcase_id: data.fetch("showcase_id"),
|
|
2350
|
+
status: data.fetch("status"),
|
|
2351
|
+
subscription_id: data["subscription_id"]
|
|
2268
2352
|
)
|
|
2269
2353
|
end
|
|
2270
2354
|
end
|
|
@@ -2474,7 +2558,7 @@ module Perata
|
|
|
2474
2558
|
|
|
2475
2559
|
# Payment is a resource of Peráta's API.
|
|
2476
2560
|
class Payment < Model
|
|
2477
|
-
MEMBERS = %i[amount_cents captured_cents checkout_id client_reference_id created_at currency customer_id id installment_amount_cents installment_interest_cents installments metadata method refunded_cents state].freeze
|
|
2561
|
+
MEMBERS = %i[amount_cents captured_cents checkout_id client_reference_id created_at currency customer_id cycle_sequence id installment_amount_cents installment_interest_cents installments metadata method period_end period_start refunded_cents showcase_id state subscription_id].freeze
|
|
2478
2562
|
|
|
2479
2563
|
# @return [Integer]
|
|
2480
2564
|
attr_reader :amount_cents
|
|
@@ -2498,6 +2582,10 @@ module Perata
|
|
|
2498
2582
|
# @return [String]
|
|
2499
2583
|
attr_reader :customer_id
|
|
2500
2584
|
|
|
2585
|
+
# Qual ciclo da assinatura o pagamento pagou: 1 é o primeiro; nulo fora de uma assinatura.
|
|
2586
|
+
# @return [Integer, nil]
|
|
2587
|
+
attr_reader :cycle_sequence
|
|
2588
|
+
|
|
2501
2589
|
# @return [String]
|
|
2502
2590
|
attr_reader :id
|
|
2503
2591
|
|
|
@@ -2520,13 +2608,29 @@ module Perata
|
|
|
2520
2608
|
# @return [String ("card", "pix", "boleto")]
|
|
2521
2609
|
attr_reader :method
|
|
2522
2610
|
|
|
2611
|
+
# O fim do período que o ciclo paga; nulo fora de uma assinatura.
|
|
2612
|
+
# @return [String, nil]
|
|
2613
|
+
attr_reader :period_end
|
|
2614
|
+
|
|
2615
|
+
# O começo do período que o ciclo paga; nulo fora de uma assinatura.
|
|
2616
|
+
# @return [String, nil]
|
|
2617
|
+
attr_reader :period_start
|
|
2618
|
+
|
|
2523
2619
|
# @return [Integer]
|
|
2524
2620
|
attr_reader :refunded_cents
|
|
2525
2621
|
|
|
2622
|
+
# O showcase a que pertence: o da chave de API que fez a chamada. Uma chave só alcança o seu showcase.
|
|
2623
|
+
# @return [String]
|
|
2624
|
+
attr_reader :showcase_id
|
|
2625
|
+
|
|
2526
2626
|
# @return [String ("unknown", "pending", "authorized", "captured", "refused", "canceled", "refunded", "partially_refunded")]
|
|
2527
2627
|
attr_reader :state
|
|
2528
2628
|
|
|
2529
|
-
|
|
2629
|
+
# A assinatura que este pagamento cobrou (a primeira ou uma renovação); nulo quando o pagamento não é de uma assinatura.
|
|
2630
|
+
# @return [String, nil]
|
|
2631
|
+
attr_reader :subscription_id
|
|
2632
|
+
|
|
2633
|
+
def initialize(amount_cents:, captured_cents:, checkout_id:, client_reference_id:, created_at:, currency:, customer_id:, cycle_sequence:, id:, installment_amount_cents:, installment_interest_cents:, installments:, metadata:, method:, period_end:, period_start:, refunded_cents:, showcase_id:, state:, subscription_id:)
|
|
2530
2634
|
@amount_cents = amount_cents
|
|
2531
2635
|
@captured_cents = captured_cents
|
|
2532
2636
|
@checkout_id = checkout_id
|
|
@@ -2534,14 +2638,19 @@ module Perata
|
|
|
2534
2638
|
@created_at = created_at
|
|
2535
2639
|
@currency = currency
|
|
2536
2640
|
@customer_id = customer_id
|
|
2641
|
+
@cycle_sequence = cycle_sequence
|
|
2537
2642
|
@id = id
|
|
2538
2643
|
@installment_amount_cents = installment_amount_cents
|
|
2539
2644
|
@installment_interest_cents = installment_interest_cents
|
|
2540
2645
|
@installments = installments
|
|
2541
2646
|
@metadata = metadata
|
|
2542
2647
|
@method = method
|
|
2648
|
+
@period_end = period_end
|
|
2649
|
+
@period_start = period_start
|
|
2543
2650
|
@refunded_cents = refunded_cents
|
|
2651
|
+
@showcase_id = showcase_id
|
|
2544
2652
|
@state = state
|
|
2653
|
+
@subscription_id = subscription_id
|
|
2545
2654
|
freeze
|
|
2546
2655
|
end
|
|
2547
2656
|
|
|
@@ -2555,14 +2664,19 @@ module Perata
|
|
|
2555
2664
|
created_at: data.fetch("created_at"),
|
|
2556
2665
|
currency: data.fetch("currency"),
|
|
2557
2666
|
customer_id: data.fetch("customer_id"),
|
|
2667
|
+
cycle_sequence: data["cycle_sequence"],
|
|
2558
2668
|
id: data.fetch("id"),
|
|
2559
2669
|
installment_amount_cents: data.fetch("installment_amount_cents"),
|
|
2560
2670
|
installment_interest_cents: data.fetch("installment_interest_cents"),
|
|
2561
2671
|
installments: data.fetch("installments"),
|
|
2562
2672
|
metadata: data.fetch("metadata"),
|
|
2563
2673
|
method: data.fetch("method"),
|
|
2674
|
+
period_end: data["period_end"],
|
|
2675
|
+
period_start: data["period_start"],
|
|
2564
2676
|
refunded_cents: data.fetch("refunded_cents"),
|
|
2565
|
-
|
|
2677
|
+
showcase_id: data.fetch("showcase_id"),
|
|
2678
|
+
state: data.fetch("state"),
|
|
2679
|
+
subscription_id: data["subscription_id"]
|
|
2566
2680
|
)
|
|
2567
2681
|
end
|
|
2568
2682
|
end
|
|
@@ -2691,7 +2805,7 @@ module Perata
|
|
|
2691
2805
|
|
|
2692
2806
|
# Product is a resource of Peráta's API.
|
|
2693
2807
|
class Product < Model
|
|
2694
|
-
MEMBERS = %i[created_at description id name status].freeze
|
|
2808
|
+
MEMBERS = %i[created_at description id name showcase_id status].freeze
|
|
2695
2809
|
|
|
2696
2810
|
# @return [String]
|
|
2697
2811
|
attr_reader :created_at
|
|
@@ -2705,14 +2819,19 @@ module Perata
|
|
|
2705
2819
|
# @return [String]
|
|
2706
2820
|
attr_reader :name
|
|
2707
2821
|
|
|
2822
|
+
# O showcase a que pertence: o da chave de API que fez a chamada. Uma chave só alcança o seu showcase.
|
|
2823
|
+
# @return [String]
|
|
2824
|
+
attr_reader :showcase_id
|
|
2825
|
+
|
|
2708
2826
|
# @return [String ("active", "archived")]
|
|
2709
2827
|
attr_reader :status
|
|
2710
2828
|
|
|
2711
|
-
def initialize(created_at:, description:, id:, name:, status:)
|
|
2829
|
+
def initialize(created_at:, description:, id:, name:, showcase_id:, status:)
|
|
2712
2830
|
@created_at = created_at
|
|
2713
2831
|
@description = description
|
|
2714
2832
|
@id = id
|
|
2715
2833
|
@name = name
|
|
2834
|
+
@showcase_id = showcase_id
|
|
2716
2835
|
@status = status
|
|
2717
2836
|
freeze
|
|
2718
2837
|
end
|
|
@@ -2724,6 +2843,7 @@ module Perata
|
|
|
2724
2843
|
description: data.fetch("description"),
|
|
2725
2844
|
id: data.fetch("id"),
|
|
2726
2845
|
name: data.fetch("name"),
|
|
2846
|
+
showcase_id: data.fetch("showcase_id"),
|
|
2727
2847
|
status: data.fetch("status")
|
|
2728
2848
|
)
|
|
2729
2849
|
end
|
|
@@ -2731,24 +2851,61 @@ module Perata
|
|
|
2731
2851
|
|
|
2732
2852
|
# Refund is a resource of Peráta's API.
|
|
2733
2853
|
class Refund < Model
|
|
2734
|
-
MEMBERS = %i[amount_cents id payment_id status].freeze
|
|
2854
|
+
MEMBERS = %i[amount_cents client_reference_id created_at id metadata order_id payment_id reason refund_metadata showcase_id status].freeze
|
|
2735
2855
|
|
|
2856
|
+
# O valor deste reembolso, em centavos.
|
|
2736
2857
|
# @return [Integer]
|
|
2737
2858
|
attr_reader :amount_cents
|
|
2738
2859
|
|
|
2860
|
+
# O id do pedido no seu sistema, enviado ao criar o checkout; vazio sem ele. É o do pedido, não do reembolso.
|
|
2861
|
+
# @return [String]
|
|
2862
|
+
attr_reader :client_reference_id
|
|
2863
|
+
|
|
2864
|
+
# @return [String]
|
|
2865
|
+
attr_reader :created_at
|
|
2866
|
+
|
|
2739
2867
|
# @return [String]
|
|
2740
2868
|
attr_reader :id
|
|
2741
2869
|
|
|
2870
|
+
# Os pares que o seu servidor enviou ao criar o checkout do pedido; vazio sem eles. É o mesmo metadata dos eventos de venda e de reembolso.
|
|
2871
|
+
# @return [Hash{String => Object}]
|
|
2872
|
+
attr_reader :metadata
|
|
2873
|
+
|
|
2874
|
+
# O pedido a que o pagamento pertence: o id que GET /orders/{id} recebe. Vazio quando o reembolso não é de um pagamento de checkout.
|
|
2875
|
+
# @return [String]
|
|
2876
|
+
attr_reader :order_id
|
|
2877
|
+
|
|
2878
|
+
# O pagamento de que o dinheiro volta.
|
|
2742
2879
|
# @return [String]
|
|
2743
2880
|
attr_reader :payment_id
|
|
2744
2881
|
|
|
2882
|
+
# Por que o dinheiro voltou, como o seu servidor informou.
|
|
2883
|
+
# @return [String]
|
|
2884
|
+
attr_reader :reason
|
|
2885
|
+
|
|
2886
|
+
# Os pares que o seu servidor enviou no campo metadata ao pedir este reembolso; vazio sem eles.
|
|
2887
|
+
# @return [Hash{String => Object}]
|
|
2888
|
+
attr_reader :refund_metadata
|
|
2889
|
+
|
|
2890
|
+
# O showcase a que pertence: o da chave de API que fez a chamada. Uma chave só alcança o seu showcase.
|
|
2891
|
+
# @return [String]
|
|
2892
|
+
attr_reader :showcase_id
|
|
2893
|
+
|
|
2894
|
+
# requested e pending esperam a Cielo; unknown é uma resposta que não chegou, e o valor continua reservado até a Cielo responder; succeeded devolveu o dinheiro; failed e canceled não devolveram.
|
|
2745
2895
|
# @return [String ("requested", "pending", "unknown", "succeeded", "failed", "canceled")]
|
|
2746
2896
|
attr_reader :status
|
|
2747
2897
|
|
|
2748
|
-
def initialize(amount_cents:, id:, payment_id:, status:)
|
|
2898
|
+
def initialize(amount_cents:, client_reference_id:, created_at:, id:, metadata:, order_id:, payment_id:, reason:, refund_metadata:, showcase_id:, status:)
|
|
2749
2899
|
@amount_cents = amount_cents
|
|
2900
|
+
@client_reference_id = client_reference_id
|
|
2901
|
+
@created_at = created_at
|
|
2750
2902
|
@id = id
|
|
2903
|
+
@metadata = metadata
|
|
2904
|
+
@order_id = order_id
|
|
2751
2905
|
@payment_id = payment_id
|
|
2906
|
+
@reason = reason
|
|
2907
|
+
@refund_metadata = refund_metadata
|
|
2908
|
+
@showcase_id = showcase_id
|
|
2752
2909
|
@status = status
|
|
2753
2910
|
freeze
|
|
2754
2911
|
end
|
|
@@ -2757,16 +2914,73 @@ module Perata
|
|
|
2757
2914
|
def self.from_hash(data)
|
|
2758
2915
|
new(
|
|
2759
2916
|
amount_cents: data.fetch("amount_cents"),
|
|
2917
|
+
client_reference_id: data.fetch("client_reference_id"),
|
|
2918
|
+
created_at: data.fetch("created_at"),
|
|
2760
2919
|
id: data.fetch("id"),
|
|
2920
|
+
metadata: data.fetch("metadata"),
|
|
2921
|
+
order_id: data.fetch("order_id"),
|
|
2761
2922
|
payment_id: data.fetch("payment_id"),
|
|
2923
|
+
reason: data.fetch("reason"),
|
|
2924
|
+
refund_metadata: data.fetch("refund_metadata"),
|
|
2925
|
+
showcase_id: data.fetch("showcase_id"),
|
|
2762
2926
|
status: data.fetch("status")
|
|
2763
2927
|
)
|
|
2764
2928
|
end
|
|
2765
2929
|
end
|
|
2766
2930
|
|
|
2931
|
+
# Showcase is a resource of Peráta's API.
|
|
2932
|
+
class Showcase < Model
|
|
2933
|
+
MEMBERS = %i[created_at environment has_logo id is_principal name].freeze
|
|
2934
|
+
|
|
2935
|
+
# @return [String]
|
|
2936
|
+
attr_reader :created_at
|
|
2937
|
+
|
|
2938
|
+
# O ambiente da chave.
|
|
2939
|
+
# @return [String ("test", "live")]
|
|
2940
|
+
attr_reader :environment
|
|
2941
|
+
|
|
2942
|
+
# true quando o showcase tem logo. A logo é privada e não sai pela API: quem a mostra é o painel.
|
|
2943
|
+
# @return [Boolean]
|
|
2944
|
+
attr_reader :has_logo
|
|
2945
|
+
|
|
2946
|
+
# O ID do showcase: o showcase_id que os objetos e os eventos de webhook trazem.
|
|
2947
|
+
# @return [String]
|
|
2948
|
+
attr_reader :id
|
|
2949
|
+
|
|
2950
|
+
# true no showcase com que a organização começou; os outros foram abertos depois, no painel.
|
|
2951
|
+
# @return [Boolean]
|
|
2952
|
+
attr_reader :is_principal
|
|
2953
|
+
|
|
2954
|
+
# O nome do showcase, como o lojista o vê no painel.
|
|
2955
|
+
# @return [String]
|
|
2956
|
+
attr_reader :name
|
|
2957
|
+
|
|
2958
|
+
def initialize(created_at:, environment:, has_logo:, id:, is_principal:, name:)
|
|
2959
|
+
@created_at = created_at
|
|
2960
|
+
@environment = environment
|
|
2961
|
+
@has_logo = has_logo
|
|
2962
|
+
@id = id
|
|
2963
|
+
@is_principal = is_principal
|
|
2964
|
+
@name = name
|
|
2965
|
+
freeze
|
|
2966
|
+
end
|
|
2967
|
+
|
|
2968
|
+
# Builds a Showcase from the API's JSON.
|
|
2969
|
+
def self.from_hash(data)
|
|
2970
|
+
new(
|
|
2971
|
+
created_at: data.fetch("created_at"),
|
|
2972
|
+
environment: data.fetch("environment"),
|
|
2973
|
+
has_logo: data.fetch("has_logo"),
|
|
2974
|
+
id: data.fetch("id"),
|
|
2975
|
+
is_principal: data.fetch("is_principal"),
|
|
2976
|
+
name: data.fetch("name")
|
|
2977
|
+
)
|
|
2978
|
+
end
|
|
2979
|
+
end
|
|
2980
|
+
|
|
2767
2981
|
# Subscription is a resource of Peráta's API.
|
|
2768
2982
|
class Subscription < Model
|
|
2769
|
-
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 suspended_at suspension_reason trial_end trial_start].freeze
|
|
2983
|
+
MEMBERS = %i[amount_cents cancel_at_period_end currency current_period_end current_period_start customer_id id interval metadata price_id product_id showcase_id status suspended_at suspension_reason trial_end trial_start].freeze
|
|
2770
2984
|
|
|
2771
2985
|
# @return [Integer]
|
|
2772
2986
|
attr_reader :amount_cents
|
|
@@ -2802,6 +3016,10 @@ module Perata
|
|
|
2802
3016
|
# @return [String]
|
|
2803
3017
|
attr_reader :product_id
|
|
2804
3018
|
|
|
3019
|
+
# O showcase a que pertence: o da chave de API que fez a chamada. Uma chave só alcança o seu showcase.
|
|
3020
|
+
# @return [String]
|
|
3021
|
+
attr_reader :showcase_id
|
|
3022
|
+
|
|
2805
3023
|
# @return [String ("trialing", "active", "past_due", "suspended", "paused", "canceled")]
|
|
2806
3024
|
attr_reader :status
|
|
2807
3025
|
|
|
@@ -2819,7 +3037,7 @@ module Perata
|
|
|
2819
3037
|
# @return [String, nil]
|
|
2820
3038
|
attr_reader :trial_start
|
|
2821
3039
|
|
|
2822
|
-
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:, suspended_at:, suspension_reason:, trial_end:, trial_start:)
|
|
3040
|
+
def initialize(amount_cents:, cancel_at_period_end:, currency:, current_period_end:, current_period_start:, customer_id:, id:, interval:, metadata:, price_id:, product_id:, showcase_id:, status:, suspended_at:, suspension_reason:, trial_end:, trial_start:)
|
|
2823
3041
|
@amount_cents = amount_cents
|
|
2824
3042
|
@cancel_at_period_end = cancel_at_period_end
|
|
2825
3043
|
@currency = currency
|
|
@@ -2831,6 +3049,7 @@ module Perata
|
|
|
2831
3049
|
@metadata = metadata
|
|
2832
3050
|
@price_id = price_id
|
|
2833
3051
|
@product_id = product_id
|
|
3052
|
+
@showcase_id = showcase_id
|
|
2834
3053
|
@status = status
|
|
2835
3054
|
@suspended_at = suspended_at
|
|
2836
3055
|
@suspension_reason = suspension_reason
|
|
@@ -2853,6 +3072,7 @@ module Perata
|
|
|
2853
3072
|
metadata: data.fetch("metadata"),
|
|
2854
3073
|
price_id: data.fetch("price_id"),
|
|
2855
3074
|
product_id: data.fetch("product_id"),
|
|
3075
|
+
showcase_id: data.fetch("showcase_id"),
|
|
2856
3076
|
status: data.fetch("status"),
|
|
2857
3077
|
suspended_at: data["suspended_at"],
|
|
2858
3078
|
suspension_reason: data["suspension_reason"],
|
|
@@ -2958,7 +3178,7 @@ module Perata
|
|
|
2958
3178
|
|
|
2959
3179
|
# WebhookCheckout is a resource of Peráta's API.
|
|
2960
3180
|
class WebhookCheckout < Model
|
|
2961
|
-
MEMBERS = %i[amount_cents checkout_link_id client_reference_id created_at currency customer_id cycle_sequence discount_cents expires_at id items metadata period_end period_start price_id product_id status subscription_id total_cents].freeze
|
|
3181
|
+
MEMBERS = %i[amount_cents checkout_link_id client_reference_id created_at currency customer_id cycle_sequence discount_cents expires_at id items metadata period_end period_start price_id product_id showcase_id status subscription_id total_cents].freeze
|
|
2962
3182
|
|
|
2963
3183
|
# @return [Integer]
|
|
2964
3184
|
attr_reader :amount_cents
|
|
@@ -3015,6 +3235,10 @@ module Perata
|
|
|
3015
3235
|
# @return [String]
|
|
3016
3236
|
attr_reader :product_id
|
|
3017
3237
|
|
|
3238
|
+
# O showcase da venda.
|
|
3239
|
+
# @return [String]
|
|
3240
|
+
attr_reader :showcase_id
|
|
3241
|
+
|
|
3018
3242
|
# @return [String ("open", "confirmed", "succeeded", "failed", "expired")]
|
|
3019
3243
|
attr_reader :status
|
|
3020
3244
|
|
|
@@ -3025,7 +3249,7 @@ module Perata
|
|
|
3025
3249
|
# @return [Integer]
|
|
3026
3250
|
attr_reader :total_cents
|
|
3027
3251
|
|
|
3028
|
-
def initialize(amount_cents:, checkout_link_id:, client_reference_id: nil, created_at:, currency:, customer_id:, cycle_sequence: nil, discount_cents:, expires_at:, id:, items: nil, metadata: nil, period_end: nil, period_start: nil, price_id:, product_id:, status:, subscription_id: nil, total_cents:)
|
|
3252
|
+
def initialize(amount_cents:, checkout_link_id:, client_reference_id: nil, created_at:, currency:, customer_id:, cycle_sequence: nil, discount_cents:, expires_at:, id:, items: nil, metadata: nil, period_end: nil, period_start: nil, price_id:, product_id:, showcase_id:, status:, subscription_id: nil, total_cents:)
|
|
3029
3253
|
@amount_cents = amount_cents
|
|
3030
3254
|
@checkout_link_id = checkout_link_id
|
|
3031
3255
|
@client_reference_id = client_reference_id
|
|
@@ -3042,6 +3266,7 @@ module Perata
|
|
|
3042
3266
|
@period_start = period_start
|
|
3043
3267
|
@price_id = price_id
|
|
3044
3268
|
@product_id = product_id
|
|
3269
|
+
@showcase_id = showcase_id
|
|
3045
3270
|
@status = status
|
|
3046
3271
|
@subscription_id = subscription_id
|
|
3047
3272
|
@total_cents = total_cents
|
|
@@ -3067,6 +3292,7 @@ module Perata
|
|
|
3067
3292
|
period_start: data["period_start"],
|
|
3068
3293
|
price_id: data.fetch("price_id"),
|
|
3069
3294
|
product_id: data.fetch("product_id"),
|
|
3295
|
+
showcase_id: data.fetch("showcase_id"),
|
|
3070
3296
|
status: data.fetch("status"),
|
|
3071
3297
|
subscription_id: data["subscription_id"],
|
|
3072
3298
|
total_cents: data.fetch("total_cents")
|
|
@@ -3503,7 +3729,7 @@ module Perata
|
|
|
3503
3729
|
|
|
3504
3730
|
# O pedido como a API o devolve (Order) e, nos eventos que um reembolso causou (order.refunded e o order.updated que o acompanha), o reembolso que o causou. status continua sendo o do checkout (succeeded) depois de um reembolso: order_status e refunded_amount_cents dizem onde o dinheiro está.
|
|
3505
3731
|
class WebhookOrder < Model
|
|
3506
|
-
MEMBERS = %i[amount_cents client_reference_id currency customer_id cycle_sequence id installment_interest_cents installments items metadata order_status paid_at period_end period_start price_id product_id refund_amount_cents refund_id refunded_amount_cents status subscription_id].freeze
|
|
3732
|
+
MEMBERS = %i[amount_cents client_reference_id currency customer_id cycle_sequence id installment_interest_cents installments items metadata order_status paid_at period_end period_start price_id product_id refund_amount_cents refund_id refunded_amount_cents showcase_id status subscription_id].freeze
|
|
3507
3733
|
|
|
3508
3734
|
# @return [Integer]
|
|
3509
3735
|
attr_reader :amount_cents
|
|
@@ -3574,6 +3800,10 @@ module Perata
|
|
|
3574
3800
|
# @return [Integer]
|
|
3575
3801
|
attr_reader :refunded_amount_cents
|
|
3576
3802
|
|
|
3803
|
+
# O showcase da venda.
|
|
3804
|
+
# @return [String]
|
|
3805
|
+
attr_reader :showcase_id
|
|
3806
|
+
|
|
3577
3807
|
# @return [String ("open", "confirmed", "succeeded", "failed", "expired")]
|
|
3578
3808
|
attr_reader :status
|
|
3579
3809
|
|
|
@@ -3581,7 +3811,7 @@ module Perata
|
|
|
3581
3811
|
# @return [String, nil]
|
|
3582
3812
|
attr_reader :subscription_id
|
|
3583
3813
|
|
|
3584
|
-
def initialize(amount_cents:, client_reference_id:, currency:, customer_id:, cycle_sequence: nil, id:, installment_interest_cents:, installments:, items:, metadata:, order_status:, paid_at:, period_end: nil, period_start: nil, price_id:, product_id:, refund_amount_cents:, refund_id:, refunded_amount_cents:, status:, subscription_id: nil)
|
|
3814
|
+
def initialize(amount_cents:, client_reference_id:, currency:, customer_id:, cycle_sequence: nil, id:, installment_interest_cents:, installments:, items:, metadata:, order_status:, paid_at:, period_end: nil, period_start: nil, price_id:, product_id:, refund_amount_cents:, refund_id:, refunded_amount_cents:, showcase_id:, status:, subscription_id: nil)
|
|
3585
3815
|
@amount_cents = amount_cents
|
|
3586
3816
|
@client_reference_id = client_reference_id
|
|
3587
3817
|
@currency = currency
|
|
@@ -3601,6 +3831,7 @@ module Perata
|
|
|
3601
3831
|
@refund_amount_cents = refund_amount_cents
|
|
3602
3832
|
@refund_id = refund_id
|
|
3603
3833
|
@refunded_amount_cents = refunded_amount_cents
|
|
3834
|
+
@showcase_id = showcase_id
|
|
3604
3835
|
@status = status
|
|
3605
3836
|
@subscription_id = subscription_id
|
|
3606
3837
|
freeze
|
|
@@ -3628,6 +3859,7 @@ module Perata
|
|
|
3628
3859
|
refund_amount_cents: data["refund_amount_cents"],
|
|
3629
3860
|
refund_id: data["refund_id"],
|
|
3630
3861
|
refunded_amount_cents: data.fetch("refunded_amount_cents"),
|
|
3862
|
+
showcase_id: data.fetch("showcase_id"),
|
|
3631
3863
|
status: data.fetch("status"),
|
|
3632
3864
|
subscription_id: data["subscription_id"]
|
|
3633
3865
|
)
|
|
@@ -3636,7 +3868,7 @@ module Perata
|
|
|
3636
3868
|
|
|
3637
3869
|
# WebhookRefund is a resource of Peráta's API.
|
|
3638
3870
|
class WebhookRefund < Model
|
|
3639
|
-
MEMBERS = %i[amount_cents checkout_id client_reference_id id metadata payment_id status].freeze
|
|
3871
|
+
MEMBERS = %i[amount_cents checkout_id client_reference_id id metadata order_id payment_id reason refund_metadata showcase_id status].freeze
|
|
3640
3872
|
|
|
3641
3873
|
# @return [Integer]
|
|
3642
3874
|
attr_reader :amount_cents
|
|
@@ -3646,7 +3878,7 @@ module Perata
|
|
|
3646
3878
|
attr_reader :checkout_id
|
|
3647
3879
|
|
|
3648
3880
|
# O id do pedido no sistema do lojista; vazio sem ele.
|
|
3649
|
-
# @return [String
|
|
3881
|
+
# @return [String]
|
|
3650
3882
|
attr_reader :client_reference_id
|
|
3651
3883
|
|
|
3652
3884
|
# @return [String]
|
|
@@ -3656,19 +3888,39 @@ module Perata
|
|
|
3656
3888
|
# @return [Hash{String => Object}]
|
|
3657
3889
|
attr_reader :metadata
|
|
3658
3890
|
|
|
3891
|
+
# O mesmo pedido, com o nome que a API de reembolsos dá a ele; igual a checkout_id.
|
|
3892
|
+
# @return [String, nil]
|
|
3893
|
+
attr_reader :order_id
|
|
3894
|
+
|
|
3659
3895
|
# @return [String]
|
|
3660
3896
|
attr_reader :payment_id
|
|
3661
3897
|
|
|
3898
|
+
# Por que o dinheiro voltou.
|
|
3899
|
+
# @return [String, nil]
|
|
3900
|
+
attr_reader :reason
|
|
3901
|
+
|
|
3902
|
+
# Os pares que o servidor do lojista enviou no campo metadata ao pedir este reembolso; vazio sem eles.
|
|
3903
|
+
# @return [Hash{String => Object}]
|
|
3904
|
+
attr_reader :refund_metadata
|
|
3905
|
+
|
|
3906
|
+
# O showcase da venda.
|
|
3907
|
+
# @return [String]
|
|
3908
|
+
attr_reader :showcase_id
|
|
3909
|
+
|
|
3662
3910
|
# @return [String ("requested", "pending", "unknown", "succeeded", "failed", "canceled")]
|
|
3663
3911
|
attr_reader :status
|
|
3664
3912
|
|
|
3665
|
-
def initialize(amount_cents:, checkout_id: nil, client_reference_id: nil,
|
|
3913
|
+
def initialize(amount_cents:, checkout_id: nil, client_reference_id:, id:, metadata:, order_id: nil, payment_id:, reason: nil, refund_metadata:, showcase_id:, status:)
|
|
3666
3914
|
@amount_cents = amount_cents
|
|
3667
3915
|
@checkout_id = checkout_id
|
|
3668
3916
|
@client_reference_id = client_reference_id
|
|
3669
3917
|
@id = id
|
|
3670
3918
|
@metadata = metadata
|
|
3919
|
+
@order_id = order_id
|
|
3671
3920
|
@payment_id = payment_id
|
|
3921
|
+
@reason = reason
|
|
3922
|
+
@refund_metadata = refund_metadata
|
|
3923
|
+
@showcase_id = showcase_id
|
|
3672
3924
|
@status = status
|
|
3673
3925
|
freeze
|
|
3674
3926
|
end
|
|
@@ -3678,10 +3930,14 @@ module Perata
|
|
|
3678
3930
|
new(
|
|
3679
3931
|
amount_cents: data.fetch("amount_cents"),
|
|
3680
3932
|
checkout_id: data["checkout_id"],
|
|
3681
|
-
client_reference_id: data
|
|
3933
|
+
client_reference_id: data.fetch("client_reference_id"),
|
|
3682
3934
|
id: data.fetch("id"),
|
|
3683
3935
|
metadata: data.fetch("metadata"),
|
|
3936
|
+
order_id: data["order_id"],
|
|
3684
3937
|
payment_id: data.fetch("payment_id"),
|
|
3938
|
+
reason: data["reason"],
|
|
3939
|
+
refund_metadata: data.fetch("refund_metadata"),
|
|
3940
|
+
showcase_id: data.fetch("showcase_id"),
|
|
3685
3941
|
status: data.fetch("status")
|
|
3686
3942
|
)
|
|
3687
3943
|
end
|
|
@@ -3689,7 +3945,7 @@ module Perata
|
|
|
3689
3945
|
|
|
3690
3946
|
# Os eventos da venda (checkout_payment.* e refund.*): os identificadores de sempre e, além deles, o checkout, o valor e o que o servidor do lojista enviou ao criar o checkout.
|
|
3691
3947
|
class WebhookSale < Model
|
|
3692
|
-
MEMBERS = %i[aggregate aggregate_id amount_cents checkout_id client_reference_id currency cycle_sequence environment event_id merchant_id metadata method payment_id period_end period_start refund_amount_cents refund_id refunded_amount_cents subscription_id].freeze
|
|
3948
|
+
MEMBERS = %i[aggregate aggregate_id amount_cents checkout_id client_reference_id currency cycle_sequence environment event_id failure_code failure_reason merchant_id metadata method payment_id period_end period_start refund_amount_cents refund_id refunded_amount_cents subscription_id].freeze
|
|
3693
3949
|
|
|
3694
3950
|
# @return [String]
|
|
3695
3951
|
attr_reader :aggregate
|
|
@@ -3722,6 +3978,14 @@ module Perata
|
|
|
3722
3978
|
# @return [String]
|
|
3723
3979
|
attr_reader :event_id
|
|
3724
3980
|
|
|
3981
|
+
# O código que a Cielo deu para a recusa, nos eventos refund.* de um reembolso que falhou; serve ao suporte.
|
|
3982
|
+
# @return [String, nil]
|
|
3983
|
+
attr_reader :failure_code
|
|
3984
|
+
|
|
3985
|
+
# Por que o dinheiro não voltou, em português, nos eventos refund.* de um reembolso que falhou (refund.failed).
|
|
3986
|
+
# @return [String, nil]
|
|
3987
|
+
attr_reader :failure_reason
|
|
3988
|
+
|
|
3725
3989
|
# @return [String]
|
|
3726
3990
|
attr_reader :merchant_id
|
|
3727
3991
|
|
|
@@ -3761,7 +4025,7 @@ module Perata
|
|
|
3761
4025
|
# @return [String, nil]
|
|
3762
4026
|
attr_reader :subscription_id
|
|
3763
4027
|
|
|
3764
|
-
def initialize(aggregate:, aggregate_id:, amount_cents: nil, checkout_id: nil, client_reference_id: nil, currency: nil, cycle_sequence: nil, environment:, event_id:, merchant_id:, metadata: nil, method: nil, payment_id: nil, period_end: nil, period_start: nil, refund_amount_cents: nil, refund_id: nil, refunded_amount_cents: nil, subscription_id: nil)
|
|
4028
|
+
def initialize(aggregate:, aggregate_id:, amount_cents: nil, checkout_id: nil, client_reference_id: nil, currency: nil, cycle_sequence: nil, environment:, event_id:, failure_code: nil, failure_reason: nil, merchant_id:, metadata: nil, method: nil, payment_id: nil, period_end: nil, period_start: nil, refund_amount_cents: nil, refund_id: nil, refunded_amount_cents: nil, subscription_id: nil)
|
|
3765
4029
|
@aggregate = aggregate
|
|
3766
4030
|
@aggregate_id = aggregate_id
|
|
3767
4031
|
@amount_cents = amount_cents
|
|
@@ -3771,6 +4035,8 @@ module Perata
|
|
|
3771
4035
|
@cycle_sequence = cycle_sequence
|
|
3772
4036
|
@environment = environment
|
|
3773
4037
|
@event_id = event_id
|
|
4038
|
+
@failure_code = failure_code
|
|
4039
|
+
@failure_reason = failure_reason
|
|
3774
4040
|
@merchant_id = merchant_id
|
|
3775
4041
|
@metadata = metadata
|
|
3776
4042
|
@method = method
|
|
@@ -3796,6 +4062,8 @@ module Perata
|
|
|
3796
4062
|
cycle_sequence: data["cycle_sequence"],
|
|
3797
4063
|
environment: data.fetch("environment"),
|
|
3798
4064
|
event_id: data.fetch("event_id"),
|
|
4065
|
+
failure_code: data["failure_code"],
|
|
4066
|
+
failure_reason: data["failure_reason"],
|
|
3799
4067
|
merchant_id: data.fetch("merchant_id"),
|
|
3800
4068
|
metadata: data["metadata"],
|
|
3801
4069
|
method: data["method"],
|
|
@@ -3812,7 +4080,7 @@ module Perata
|
|
|
3812
4080
|
|
|
3813
4081
|
# A assinatura como a API a devolve (Subscription) e, nos eventos que uma cobrança recusada causou (subscription.past_due, subscription.suspended e o subscription.updated que os acompanha), a cobrança recusada em payment_failure.
|
|
3814
4082
|
class WebhookSubscription < Model
|
|
3815
|
-
MEMBERS = %i[amount_cents cancel_at_period_end currency current_period_end current_period_start customer_id id interval metadata payment_failure price_id product_id status suspended_at suspension_reason trial_end trial_start].freeze
|
|
4083
|
+
MEMBERS = %i[amount_cents cancel_at_period_end currency current_period_end current_period_start customer_id id interval metadata payment_failure price_id product_id showcase_id status suspended_at suspension_reason trial_end trial_start].freeze
|
|
3816
4084
|
|
|
3817
4085
|
# @return [Integer]
|
|
3818
4086
|
attr_reader :amount_cents
|
|
@@ -3852,6 +4120,10 @@ module Perata
|
|
|
3852
4120
|
# @return [String]
|
|
3853
4121
|
attr_reader :product_id
|
|
3854
4122
|
|
|
4123
|
+
# O showcase da venda.
|
|
4124
|
+
# @return [String]
|
|
4125
|
+
attr_reader :showcase_id
|
|
4126
|
+
|
|
3855
4127
|
# @return [String ("trialing", "active", "past_due", "suspended", "paused", "canceled")]
|
|
3856
4128
|
attr_reader :status
|
|
3857
4129
|
|
|
@@ -3869,7 +4141,7 @@ module Perata
|
|
|
3869
4141
|
# @return [String, nil]
|
|
3870
4142
|
attr_reader :trial_start
|
|
3871
4143
|
|
|
3872
|
-
def initialize(amount_cents:, cancel_at_period_end:, currency:, current_period_end:, current_period_start:, customer_id:, id:, interval:, metadata:, payment_failure: nil, price_id:, product_id:, status:, suspended_at:, suspension_reason:, trial_end:, trial_start:)
|
|
4144
|
+
def initialize(amount_cents:, cancel_at_period_end:, currency:, current_period_end:, current_period_start:, customer_id:, id:, interval:, metadata:, payment_failure: nil, price_id:, product_id:, showcase_id:, status:, suspended_at:, suspension_reason:, trial_end:, trial_start:)
|
|
3873
4145
|
@amount_cents = amount_cents
|
|
3874
4146
|
@cancel_at_period_end = cancel_at_period_end
|
|
3875
4147
|
@currency = currency
|
|
@@ -3882,6 +4154,7 @@ module Perata
|
|
|
3882
4154
|
@payment_failure = payment_failure
|
|
3883
4155
|
@price_id = price_id
|
|
3884
4156
|
@product_id = product_id
|
|
4157
|
+
@showcase_id = showcase_id
|
|
3885
4158
|
@status = status
|
|
3886
4159
|
@suspended_at = suspended_at
|
|
3887
4160
|
@suspension_reason = suspension_reason
|
|
@@ -3905,6 +4178,7 @@ module Perata
|
|
|
3905
4178
|
payment_failure: data["payment_failure"]&.then { |value| WebhookSubscriptionPaymentFailure.from_hash(value) },
|
|
3906
4179
|
price_id: data.fetch("price_id"),
|
|
3907
4180
|
product_id: data.fetch("product_id"),
|
|
4181
|
+
showcase_id: data.fetch("showcase_id"),
|
|
3908
4182
|
status: data.fetch("status"),
|
|
3909
4183
|
suspended_at: data["suspended_at"],
|
|
3910
4184
|
suspension_reason: data["suspension_reason"],
|