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.
8 9 10 11 12 13 |
# File 'app/services/interapp/send_message_service.rb', line 8 def initialize(data:, peer_identifier:) find_peer(peer_identifier) @payload = JSON.dump(data) = Message.new(payload: @payload, peer: peer) .sign end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'app/services/interapp/send_message_service.rb', line 6 def end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
6 7 8 |
# File 'app/services/interapp/send_message_service.rb', line 6 def payload @payload end |
#peer ⇒ Object (readonly)
Returns the value of attribute peer.
6 7 8 |
# File 'app/services/interapp/send_message_service.rb', line 6 def peer @peer end |
Instance Method Details
#perform ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/interapp/send_message_service.rb', line 15 def perform response = Net::HTTP.post( URI(peer.endpoint), .payload, { "X-Interapp-Identifier" => Interapp.configuration.identifier, "X-Interapp-Signature" => .signature, "Content-Type" => "application/json", "Accept" => "application/json" } ) JSON.parse(response.body) if response end |