Class: Messenger::Parameters::Messaging

Inherits:
Object
  • Object
show all
Defined in:
lib/messenger/parameters/messaging.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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: message, delivery: delivery, postback: postback, optin: optin, read: read, account_linking: )
end

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



4
5
6
# File 'lib/messenger/parameters/messaging.rb', line 4

def callback
  @callback
end

#recipient_idObject

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_idObject

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