Class: Messenger::Request
- Inherits:
-
Object
- Object
- Messenger::Request
- Defined in:
- lib/messenger/request.rb
Instance Method Summary collapse
- #add_element(element) ⇒ Object
- #add_sender_action(action) ⇒ Object
- #body ⇒ Object
- #build ⇒ Object
- #create_request(component) ⇒ Object
-
#initialize(component, recipient_id) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(component, recipient_id) ⇒ Request
Returns a new instance of Request.
3 4 5 6 7 |
# File 'lib/messenger/request.rb', line 3 def initialize(component, recipient_id) @recipient_id = recipient_id @body = body create_request(component) end |
Instance Method Details
#add_element(element) ⇒ Object
13 14 15 |
# File 'lib/messenger/request.rb', line 13 def add_element(element) @body.merge!({ message: element.build }) end |
#add_sender_action(action) ⇒ Object
17 18 19 |
# File 'lib/messenger/request.rb', line 17 def add_sender_action(action) @body.merge!(action.build) end |
#body ⇒ Object
21 22 23 24 25 |
# File 'lib/messenger/request.rb', line 21 def body { recipient: { id: @recipient_id } } end |
#build ⇒ Object
9 10 11 |
# File 'lib/messenger/request.rb', line 9 def build return @body end |
#create_request(component) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/messenger/request.rb', line 27 def create_request(component) if component.is_a? Elements::SenderAction add_sender_action(component) else add_element(component) end end |