Class: K2Notification
- Inherits:
-
Object
- Object
- K2Notification
- Includes:
- K2Utilities, K2Validation
- Defined in:
- lib/k2-connect-ruby/k2_entity/k2_notification.rb
Constant Summary
Constants included from K2Validation
K2Validation::ALL_EVENT_TYPES, K2Validation::TILL_SCOPE_EVENT_TYPES
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#k2_response_body ⇒ Object
readonly
Returns the value of attribute k2_response_body.
-
#location_url ⇒ Object
readonly
Returns the value of attribute location_url.
Instance Method Summary collapse
-
#initialize(access_token) ⇒ K2Notification
constructor
Initialize with access_token.
-
#query_resource(location_url = @location_url) ⇒ Object
Query Recent Webhook.
-
#query_resource_url(url) ⇒ Object
Query Specific Webhook URL.
-
#send_sms_transaction_notification(params) ⇒ Object
Sends transaction notifications via SMS.
Methods included from K2Validation
#determine_scope_details, #incorrect_keys, #nil_values, #to_indifferent_access, #validate_email, #validate_hash, #validate_input, #validate_network, #validate_phone, #validate_settlement_method, #validate_till_number_prefix, #validate_url, #validate_webhook, #validate_webhook_input
Methods included from K2Utilities
Constructor Details
#initialize(access_token) ⇒ K2Notification
Initialize with access_token
7 8 9 10 11 |
# File 'lib/k2-connect-ruby/k2_entity/k2_notification.rb', line 7 def initialize(access_token) raise ArgumentError, 'Nil or Empty Access Token Given!' if access_token.blank? @threads = [] @access_token = access_token end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
4 5 6 |
# File 'lib/k2-connect-ruby/k2_entity/k2_notification.rb', line 4 def access_token @access_token end |
#k2_response_body ⇒ Object (readonly)
Returns the value of attribute k2_response_body.
3 4 5 |
# File 'lib/k2-connect-ruby/k2_entity/k2_notification.rb', line 3 def k2_response_body @k2_response_body end |
#location_url ⇒ Object (readonly)
Returns the value of attribute location_url.
3 4 5 |
# File 'lib/k2-connect-ruby/k2_entity/k2_notification.rb', line 3 def location_url @location_url end |
Instance Method Details
#query_resource(location_url = @location_url) ⇒ Object
Query Recent Webhook
28 29 30 31 32 33 34 35 |
# File 'lib/k2-connect-ruby/k2_entity/k2_notification.rb', line 28 def query_resource(location_url = @location_url) query_hash = make_hash(location_url, 'get', @access_token, 'Notification', nil) @threads << Thread.new do sleep 0.25 @k2_response_body = K2Connect.make_request(query_hash) end @threads.each(&:join) end |
#query_resource_url(url) ⇒ Object
Query Specific Webhook URL
38 39 40 |
# File 'lib/k2-connect-ruby/k2_entity/k2_notification.rb', line 38 def query_resource_url(url) query_resource(url) end |
#send_sms_transaction_notification(params) ⇒ Object
Sends transaction notifications via SMS
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/k2-connect-ruby/k2_entity/k2_notification.rb', line 14 def send_sms_transaction_notification(params) k2_request_links = { callback_url: params[:callback_url] } k2_request_body = { webhook_event_reference: params[:webhook_event_reference], message: params[:message], _links: k2_request_links, } subscribe_hash = make_hash(K2Config.path_url('transaction_sms_notifications'), 'post', @access_token,'Notification', k2_request_body) @location_url = K2Connect.make_request(subscribe_hash) end |