Module: UniOne::Client::Helpers
- Included in:
- UniOne::Client
- Defined in:
- lib/unione/helpers.rb
Instance Method Summary collapse
- #callback_helper(params) {|params.dig('events_by_user', 0, 'events')| ... } ⇒ Object
-
#verify_callback_auth!(params) ⇒ Object
Helper function for webhooks callback.
Instance Method Details
#callback_helper(params) {|params.dig('events_by_user', 0, 'events')| ... } ⇒ Object
16 17 18 19 |
# File 'lib/unione/helpers.rb', line 16 def callback_helper(params) verify_callback_auth!(params) yield params.dig('events_by_user', 0, 'events') end |
#verify_callback_auth!(params) ⇒ Object
Helper function for webhooks callback. It is checking auth field and if it is invalid, raises Unione::Client::InvalidCallbackAuth exception
8 9 10 11 12 13 14 |
# File 'lib/unione/helpers.rb', line 8 def verify_callback_auth!(params) params = params.transform_keys(&:to_sym) auth = params[:auth] unless auth == Digest::MD5.hexdigest(params.merge(auth: @api_key).to_json) raise InvalidCallbackAuth end end |