Class: Rapidomize::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/rapidomize/message.rb

Overview

Message objects are at the core of SDK. Each message is an independent entity with following information

uri

A message must have a URI, which is the destination of the message.

payload

_(optional)_ A message may contain a Payload to transmit data

token

_(optional)_ token for authorization purposes

app_id

_(optional)_ app_id of the receiving ICAPP

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, payload = nil, token = nil, app_id = nil) ⇒ Message

Initialize a message object

Parameters:

  • uri (URI, String)

    Destination of the message.

  • payload (Hash, String, Rapidomize::Payload) (defaults to: nil)

    Payload to transmit.

  • token (String) (defaults to: nil)

    Authorization token

  • app_id (String) (defaults to: nil)

    Receiving app id

Raises:

  • (ArgumentError)


19
20
21
22
23
24
25
26
# File 'lib/rapidomize/message.rb', line 19

def initialize(uri, payload = nil, token = nil, app_id = nil)
  raise ArgumentError, 'uri is nil' if uri.nil?

  @payload = Payload.create(payload)
  @uri = sanitize_uri(uri)
  @app_id = app_id
  @token = token
end

Instance Attribute Details

#app_idObject (readonly)

Returns the value of attribute app_id.



12
13
14
# File 'lib/rapidomize/message.rb', line 12

def app_id
  @app_id
end

#payloadObject (readonly)

Returns the value of attribute payload.



12
13
14
# File 'lib/rapidomize/message.rb', line 12

def payload
  @payload
end

#tokenObject (readonly)

Returns the value of attribute token.



12
13
14
# File 'lib/rapidomize/message.rb', line 12

def token
  @token
end

#uriObject (readonly)

Returns the value of attribute uri.



12
13
14
# File 'lib/rapidomize/message.rb', line 12

def uri
  @uri
end