Class: Interapp::SendMessageService
- Inherits:
-
Object
- Object
- Interapp::SendMessageService
- Defined in:
- app/services/interapp/send_message_service.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#peer ⇒ Object
readonly
Returns the value of attribute peer.
Instance Method Summary collapse
-
#initialize(data:, peer_identifier:) ⇒ SendMessageService
constructor
A new instance of SendMessageService.
- #perform ⇒ Object
Constructor Details
#initialize(data:, peer_identifier:) ⇒ SendMessageService
Returns a new instance of SendMessageService.
5 6 7 8 9 10 |
# File 'app/services/interapp/send_message_service.rb', line 5 def initialize(data:, peer_identifier:) find_peer(peer_identifier) @payload = JSON.dump(data) @message = Message.new(payload: @payload, peer: peer) @message.sign end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'app/services/interapp/send_message_service.rb', line 3 def @message end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
3 4 5 |
# File 'app/services/interapp/send_message_service.rb', line 3 def payload @payload end |
#peer ⇒ Object (readonly)
Returns the value of attribute peer.
3 4 5 |
# File 'app/services/interapp/send_message_service.rb', line 3 def peer @peer end |
Instance Method Details
#perform ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/services/interapp/send_message_service.rb', line 12 def perform response = RestClient.post(peer.endpoint, .payload, { content_type: 'application/json', "X-Interapp-Identifier" => Interapp.configuration.identifier, "X-Interapp-Signature" => .signature }) JSON.parse(response) if response end |