Class: Messenger::Parameters::Messaging
- Inherits:
-
Object
- Object
- Messenger::Parameters::Messaging
- Defined in:
- lib/messenger/parameters/messaging.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#recipient_id ⇒ Object
Returns the value of attribute recipient_id.
-
#sender_id ⇒ Object
Returns the value of attribute sender_id.
Instance Method Summary collapse
-
#initialize(sender:, recipient:, timestamp: nil, message: nil, delivery: nil, postback: nil, optin: nil, read: nil, account_linking: nil) ⇒ Messaging
constructor
A new instance of Messaging.
- #set_callback(callbacks) ⇒ Object
Constructor Details
#initialize(sender:, recipient:, timestamp: nil, message: nil, delivery: nil, postback: nil, optin: nil, read: nil, account_linking: nil) ⇒ Messaging
Returns a new instance of Messaging.
6 7 8 9 10 |
# File 'lib/messenger/parameters/messaging.rb', line 6 def initialize(sender:, recipient:, timestamp: nil, message: nil, delivery: nil, postback: nil, optin: nil, read: nil, account_linking: nil) @sender_id = sender['id'] @recipient_id = recipient['id'] @callback = set_callback(message: , delivery: delivery, postback: postback, optin: optin, read: read, account_linking: account_linking) end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
4 5 6 |
# File 'lib/messenger/parameters/messaging.rb', line 4 def callback @callback end |
#recipient_id ⇒ Object
Returns the value of attribute recipient_id.
4 5 6 |
# File 'lib/messenger/parameters/messaging.rb', line 4 def recipient_id @recipient_id end |
#sender_id ⇒ Object
Returns the value of attribute sender_id.
4 5 6 |
# File 'lib/messenger/parameters/messaging.rb', line 4 def sender_id @sender_id end |
Instance Method Details
#set_callback(callbacks) ⇒ Object
12 13 14 15 |
# File 'lib/messenger/parameters/messaging.rb', line 12 def set_callback(callbacks) type = callbacks.select { |_, v| v.present? }.keys.first @callback = constant(type).new(callbacks[type].transform_keys(&:to_sym)) end |