Class: Pay::Abacatepay::Webhooks::Event
- Inherits:
-
Object
- Object
- Pay::Abacatepay::Webhooks::Event
- Defined in:
- lib/pay/abacatepay/webhooks/event.rb
Constant Summary collapse
- FREQUENCY_TO_INTERVAL =
{ "WEEKLY" => 1.week, "MONTHLY" => 1.month, "SEMIANNUALLY" => 6.months, "ANNUALLY" => 1.year }.freeze
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #api_version ⇒ Object
- #canceled_at ⇒ Object
- #charge_amount_cents ⇒ Object
- #charge_id ⇒ Object
- #charge_status ⇒ Object
- #checkout_amount_cents ⇒ Object
- #checkout_frequency ⇒ Object
- #checkout_id ⇒ Object
- #checkout_methods ⇒ Object
- #checkout_paid_amount_cents ⇒ Object
- #checkout_platform_fee_cents ⇒ Object
- #checkout_status ⇒ Object
- #checkout_url ⇒ Object
- #customer_email ⇒ Object
- #customer_id ⇒ Object
- #customer_name ⇒ Object
- #customer_tax_id ⇒ Object
- #data ⇒ Object
- #dev_mode? ⇒ Boolean
- #frequency ⇒ Object
- #id ⇒ Object
-
#initialize(raw) ⇒ Event
constructor
A new instance of Event.
- #interval ⇒ Object
- #paid_amount_cents ⇒ Object
- #paid_at ⇒ Object
- #platform_fee_cents ⇒ Object
- #product_id ⇒ Object
- #subscription_amount_cents ⇒ Object
- #subscription_created_at ⇒ Object
- #subscription_currency ⇒ Object
- #subscription_id ⇒ Object
- #subscription_status ⇒ Object
- #subscription_updated_at ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(raw) ⇒ Event
Returns a new instance of Event.
12 13 14 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 12 def initialize(raw) @raw = raw.is_a?(Hash) ? raw : {} end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
16 17 18 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 16 def raw @raw end |
Instance Method Details
#api_version ⇒ Object
24 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 24 def api_version = @raw["apiVersion"] |
#canceled_at ⇒ Object
42 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 42 def canceled_at = parse_time(data.dig("subscription", "canceledAt")) |
#charge_amount_cents ⇒ Object
54 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 54 def charge_amount_cents = data.dig("payment", "amount") |
#charge_id ⇒ Object
52 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 52 def charge_id = data.dig("payment", "id") |
#charge_status ⇒ Object
60 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 60 def charge_status = data.dig("payment", "status") |
#checkout_amount_cents ⇒ Object
72 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 72 def checkout_amount_cents = data.dig("checkout", "amount") |
#checkout_frequency ⇒ Object
66 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 66 def checkout_frequency = data.dig("checkout", "frequency") |
#checkout_id ⇒ Object
64 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 64 def checkout_id = data.dig("checkout", "id") |
#checkout_methods ⇒ Object
78 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 78 def checkout_methods = data.dig("checkout", "methods") |
#checkout_paid_amount_cents ⇒ Object
74 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 74 def checkout_paid_amount_cents = data.dig("checkout", "paidAmount") |
#checkout_platform_fee_cents ⇒ Object
76 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 76 def checkout_platform_fee_cents = data.dig("checkout", "platformFee") |
#checkout_status ⇒ Object
68 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 68 def checkout_status = data.dig("checkout", "status") |
#checkout_url ⇒ Object
70 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 70 def checkout_url = data.dig("checkout", "url") |
#customer_email ⇒ Object
46 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 46 def customer_email = data.dig("customer", "email") |
#customer_id ⇒ Object
44 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 44 def customer_id = data.dig("customer", "id") |
#customer_name ⇒ Object
48 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 48 def customer_name = data.dig("customer", "name") |
#customer_tax_id ⇒ Object
50 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 50 def customer_tax_id = data.dig("customer", "taxId") |
#data ⇒ Object
22 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 22 def data = @raw["data"] || {} |
#dev_mode? ⇒ Boolean
26 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 26 def dev_mode? = @raw["devMode"] == true |
#frequency ⇒ Object
36 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 36 def frequency = data.dig("subscription", "frequency") |
#id ⇒ Object
18 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 18 def id = @raw["id"] |
#interval ⇒ Object
82 83 84 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 82 def interval FREQUENCY_TO_INTERVAL[frequency] end |
#paid_amount_cents ⇒ Object
56 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 56 def paid_amount_cents = data.dig("payment", "paidAmount") |
#paid_at ⇒ Object
62 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 62 def paid_at = parse_time(data.dig("payment", "updatedAt")) |
#platform_fee_cents ⇒ Object
58 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 58 def platform_fee_cents = data.dig("payment", "platformFee") |
#product_id ⇒ Object
80 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 80 def product_id = data.dig("checkout", "items", 0, "id") |
#subscription_amount_cents ⇒ Object
32 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 32 def subscription_amount_cents = data.dig("subscription", "amount") |
#subscription_created_at ⇒ Object
38 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 38 def subscription_created_at = parse_time(data.dig("subscription", "createdAt")) |
#subscription_currency ⇒ Object
34 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 34 def subscription_currency = data.dig("subscription", "currency") || "BRL" |
#subscription_id ⇒ Object
28 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 28 def subscription_id = data.dig("subscription", "id") |
#subscription_status ⇒ Object
30 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 30 def subscription_status = data.dig("subscription", "status") |
#subscription_updated_at ⇒ Object
40 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 40 def subscription_updated_at = parse_time(data.dig("subscription", "updatedAt")) |
#type ⇒ Object
20 |
# File 'lib/pay/abacatepay/webhooks/event.rb', line 20 def type = @raw["event"] || @raw["type"] |