Class: SelfSDK::Messages::Chat

Inherits:
Base
  • Object
show all
Defined in:
lib/messages/chat.rb

Instance Attribute Summary

Attributes inherited from Base

#description, #exp_timeout, #expires, #fields, #from, #from_device, #id, #input, #intermediary, #payload, #status, #sub, #to, #to_device, #typ

Instance Method Summary collapse

Methods inherited from Base

#accepted?, #encrypt_message, #errored?, #initialize, #rejected?, #request, #send_message, #unauthorized?, #validate!

Constructor Details

This class inherits a constructor from SelfSDK::Messages::Base

Instance Method Details

#parse(input, envelope = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/messages/chat.rb', line 12

def parse(input, envelope=nil)
  @input = input
  @payload = get_payload input
  @id = @payload[:jti]
  @from = @payload[:iss]
  @to = @payload[:sub]
  @audience = payload[:aud]
  @expires = @payload[:exp]

  if envelope
    issuer = envelope.sender.split(":")
    @from_device = issuer.last
  end
end