Class: K2ConnectRuby::K2Entity::K2FinancialEntities::Webhook::WebhookSubscriptionRequest
- Inherits:
-
Object
- Object
- K2ConnectRuby::K2Entity::K2FinancialEntities::Webhook::WebhookSubscriptionRequest
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb
Instance Attribute Summary collapse
-
#enable_daraja_payload ⇒ Object
Returns the value of attribute enable_daraja_payload.
-
#event_type ⇒ Object
Returns the value of attribute event_type.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#scope_reference ⇒ Object
Returns the value of attribute scope_reference.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #endpoint ⇒ Object
-
#initialize(kwargs) ⇒ WebhookSubscriptionRequest
constructor
A new instance of WebhookSubscriptionRequest.
- #request_body ⇒ Object
- #till_scope? ⇒ Boolean
- #validate_daraja_payload_flag ⇒ Object
Constructor Details
#initialize(kwargs) ⇒ WebhookSubscriptionRequest
Returns a new instance of WebhookSubscriptionRequest.
33 34 35 36 37 |
# File 'lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb', line 33 def initialize(kwargs) kwargs.each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#enable_daraja_payload ⇒ Object
Returns the value of attribute enable_daraja_payload.
10 11 12 |
# File 'lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb', line 10 def enable_daraja_payload @enable_daraja_payload end |
#event_type ⇒ Object
Returns the value of attribute event_type.
10 11 12 |
# File 'lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb', line 10 def event_type @event_type end |
#scope ⇒ Object
Returns the value of attribute scope.
10 11 12 |
# File 'lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb', line 10 def scope @scope end |
#scope_reference ⇒ Object
Returns the value of attribute scope_reference.
10 11 12 |
# File 'lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb', line 10 def scope_reference @scope_reference end |
#url ⇒ Object
Returns the value of attribute url.
10 11 12 |
# File 'lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb', line 10 def url @url end |
Instance Method Details
#endpoint ⇒ Object
39 40 41 |
# File 'lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb', line 39 def endpoint K2ConnectRuby::K2Utilities::Config::K2Config.endpoint("webhook_subscriptions") end |
#request_body ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb', line 43 def request_body { event_type: event_type, url: url, scope: scope, scope_reference: scope_reference, enable_daraja_payload: enable_daraja_payload || false, } end |
#till_scope? ⇒ Boolean
53 54 55 |
# File 'lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb', line 53 def till_scope? scope == "till" end |
#validate_daraja_payload_flag ⇒ Object
57 58 59 60 61 |
# File 'lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb', line 57 def validate_daraja_payload_flag unless event_type.in?(["buygoods_transaction_received", "b2b_transaction_received"]) errors.add(:base, "Can only enable daraja_payloads for 'buygoods_transaction_received' and 'b2b_transaction_received' webhooks.") end end |