Class: ConstantContact::WebhooksUtil
- Inherits:
-
Object
- Object
- ConstantContact::WebhooksUtil
- Defined in:
- lib/constantcontact/webhooks/webhooks_util.rb
Instance Attribute Summary collapse
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
Instance Method Summary collapse
-
#get_billing_change_notification(hmac, data) ⇒ BillingChangeNotification
Get the BillingChangeNotification model object (has url and event_type as properties) Validates and parses the received data into a BillingChangeNotification model.
-
#initialize(api_secret = nil) ⇒ Object
constructor
Class constructor.
-
#is_valid_webhook(hmac, data) ⇒ Object
Validates a Webhook encrypted message.
Constructor Details
#initialize(api_secret = nil) ⇒ Object
Class constructor
14 15 16 17 18 19 |
# File 'lib/constantcontact/webhooks/webhooks_util.rb', line 14 def initialize(api_secret = nil) @client_secret = api_secret || Util::Config.get('auth.api_secret') if @client_secret.nil? || @client_secret == '' raise ArgumentError.new(Util::Config.get('errors.api_secret_missing')) end end |
Instance Attribute Details
#client_secret ⇒ Object
Returns the value of attribute client_secret
9 10 11 |
# File 'lib/constantcontact/webhooks/webhooks_util.rb', line 9 def client_secret @client_secret end |
Instance Method Details
#get_billing_change_notification(hmac, data) ⇒ BillingChangeNotification
Get the BillingChangeNotification model object (has url and event_type as properties) Validates and parses the received data into a BillingChangeNotification model
27 28 29 30 31 32 33 |
# File 'lib/constantcontact/webhooks/webhooks_util.rb', line 27 def get_billing_change_notification(hmac, data) if is_valid_webhook(hmac, data) Webhooks::Models::BillingChangeNotification.create(JSON.parse(data)) else raise Exceptions::WebhooksException, Util::Config.get('errors.invalid_webhook') end end |