perata-sdk 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
 
5
5
  module Perata
6
6
  # This SDK's version.
7
- VERSION = "0.2.0"
7
+ VERSION = "0.3.0"
8
8
 
9
9
  # The contract this SDK was generated from.
10
10
  API_VERSION = "0.1.0"
@@ -41,6 +41,11 @@ module Perata
41
41
  end
42
42
  end
43
43
 
44
+ # The events that carry a WebhookBenefit; +data+ is WebhookBenefit.
45
+ class BenefitWebhookEvent < WebhookEvent
46
+ TYPES = %w[benefit.created benefit.updated].freeze
47
+ end
48
+
44
49
  # The events that carry a BenefitGrant; +data+ is BenefitGrant.
45
50
  class BenefitGrantWebhookEvent < WebhookEvent
46
51
  TYPES = %w[benefit_grant.created benefit_grant.revoked benefit_grant.updated].freeze
@@ -56,6 +61,11 @@ module Perata
56
61
  TYPES = %w[customer.created customer.deleted customer.updated].freeze
57
62
  end
58
63
 
64
+ # The events that carry a WebhookDiscount; +data+ is WebhookDiscount.
65
+ class DiscountWebhookEvent < WebhookEvent
66
+ TYPES = %w[discount.created discount.deleted discount.updated].freeze
67
+ end
68
+
59
69
  # The events that carry a WebhookDispute; +data+ is WebhookDispute.
60
70
  class DisputeWebhookEvent < WebhookEvent
61
71
  TYPES = %w[dispute.lost dispute.opened dispute.won].freeze
@@ -63,7 +73,7 @@ module Perata
63
73
 
64
74
  # The events that carry the event's identifiers; +data+ is Hash{String => String}.
65
75
  class IdentifiersWebhookEvent < WebhookEvent
66
- TYPES = %w[benefit.archived benefit.created benefit.updated benefit.version_created benefit_product_link.linked benefit_product_link.unlinked checkout_link.archived checkout_link.created checkout_payment.authorized checkout_payment.canceled checkout_payment.captured checkout_payment.partially_refunded checkout_payment.refunded checkout_payment.refused checkout_session.confirmed checkout_session.expired checkout_session.failed checkout_session.opened checkout_session.succeeded customer.archived discount.created discount.deleted discount.exhausted discount.expired discount.reactivated discount.redeemed discount.updated discount_redemption.released invoice.drafted invoice.issued invoice.settled invoice.uncollectible invoice.voided price.archived price.created product.archived product.created product.updated refund.canceled refund.failed refund.requested refund.succeeded seat_allocation.opened seat_allocation.resized seat_assignment.claimed seat_assignment.invited seat_assignment.revoked usage_event.recorded usage_period.closed usage_period.opened usage_period_adjustment.created].freeze
76
+ TYPES = %w[benefit.archived benefit.version_created benefit_product_link.linked benefit_product_link.unlinked checkout_link.archived checkout_link.created checkout_payment.authorized checkout_payment.canceled checkout_payment.captured checkout_payment.partially_refunded checkout_payment.refunded checkout_payment.refused checkout_session.confirmed checkout_session.expired checkout_session.failed checkout_session.opened checkout_session.succeeded customer.archived discount.exhausted discount.expired discount.reactivated discount.redeemed discount_redemption.released invoice.drafted invoice.issued invoice.settled invoice.uncollectible invoice.voided price.archived price.created product.archived refund.canceled refund.failed refund.requested refund.succeeded seat_allocation.opened seat_allocation.resized seat_assignment.claimed seat_assignment.invited seat_assignment.revoked usage_event.recorded usage_period.closed usage_period.opened usage_period_adjustment.created].freeze
67
77
  end
68
78
 
69
79
  # The events that carry an Order; +data+ is Order.
@@ -71,6 +81,11 @@ module Perata
71
81
  TYPES = %w[order.created order.paid order.refunded order.updated].freeze
72
82
  end
73
83
 
84
+ # The events that carry a Product; +data+ is Product.
85
+ class ProductWebhookEvent < WebhookEvent
86
+ TYPES = %w[product.created product.updated].freeze
87
+ end
88
+
74
89
  # The events that carry a Refund; +data+ is Refund.
75
90
  class RefundWebhookEvent < WebhookEvent
76
91
  TYPES = %w[refund.created refund.updated].freeze
@@ -140,12 +155,15 @@ module Perata
140
155
  data = event["data"] || {}
141
156
  message = { id: event.fetch("id"), type: event.fetch("type"), timestamp: event.fetch("timestamp") }
142
157
  case message[:type]
158
+ when *BenefitWebhookEvent::TYPES then BenefitWebhookEvent.new(**message, data: WebhookBenefit.from_hash(data))
143
159
  when *BenefitGrantWebhookEvent::TYPES then BenefitGrantWebhookEvent.new(**message, data: BenefitGrant.from_hash(data))
144
160
  when *CheckoutWebhookEvent::TYPES then CheckoutWebhookEvent.new(**message, data: WebhookCheckout.from_hash(data))
145
161
  when *CustomerWebhookEvent::TYPES then CustomerWebhookEvent.new(**message, data: Customer.from_hash(data))
162
+ when *DiscountWebhookEvent::TYPES then DiscountWebhookEvent.new(**message, data: WebhookDiscount.from_hash(data))
146
163
  when *DisputeWebhookEvent::TYPES then DisputeWebhookEvent.new(**message, data: WebhookDispute.from_hash(data))
147
164
  when *IdentifiersWebhookEvent::TYPES then IdentifiersWebhookEvent.new(**message, data: data)
148
165
  when *OrderWebhookEvent::TYPES then OrderWebhookEvent.new(**message, data: Order.from_hash(data))
166
+ when *ProductWebhookEvent::TYPES then ProductWebhookEvent.new(**message, data: Product.from_hash(data))
149
167
  when *RefundWebhookEvent::TYPES then RefundWebhookEvent.new(**message, data: Refund.from_hash(data))
150
168
  when *SubscriptionWebhookEvent::TYPES then SubscriptionWebhookEvent.new(**message, data: Subscription.from_hash(data))
151
169
  else UnknownWebhookEvent.new(**message, data: data)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perata-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peráta