Class: Smartpay::Requests::WebhookEndpoint

Inherits:
Object
  • Object
show all
Includes:
Validator
Defined in:
lib/smartpay/requests/webhook_endpoint.rb

Overview

WebhookEndpoint

Direct Known Subclasses

WebhookEndpointUpdate

Constant Summary collapse

REQUIREMENT_KEY_NAME =
i[url].freeze
ALLOWED_EVENT_SUBSCRIPTIONS_VALUES =
[
  "order.authorized",
  "order.rejected",
  "order.canceled",
  "payment.created",
  "refund.created",
  "payout.generated",
  "payout.paid",
  "coupon.created",
  "coupon.updated",
  "promotion_code.created",
  "promotion_code.updated",
  "merchant_user.created",
  "merchant_user.password_reset",
  "token.approved",
  "token.rejected",
  "token.deleted",
  "token.disabled",
  "token.enabled",
  "token.created",
  "token.used"
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_payload) ⇒ WebhookEndpoint

Returns a new instance of WebhookEndpoint.



35
36
37
# File 'lib/smartpay/requests/webhook_endpoint.rb', line 35

def initialize(raw_payload)
  @payload = raw_payload.transform_keys(&:to_sym)
end

Instance Attribute Details

#payloadObject

Returns the value of attribute payload.



9
10
11
# File 'lib/smartpay/requests/webhook_endpoint.rb', line 9

def payload
  @payload
end

Instance Method Details

#as_hashObject



39
40
41
42
43
# File 'lib/smartpay/requests/webhook_endpoint.rb', line 39

def as_hash
  check_requirement!(REQUIREMENT_KEY_NAME)
  validate_event_subscription
  normalize_payload
end