Class: BotMob::InboundMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/bot_mob/inbound_message.rb

Overview

# BotMob::InboundMessage

Structured data provided to a bot

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ InboundMessage

Returns a new instance of InboundMessage.



8
9
10
11
# File 'lib/bot_mob/inbound_message.rb', line 8

def initialize(**options)
  @network = options[:network]
  @body = options[:body]
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/bot_mob/inbound_message.rb', line 6

def body
  @body
end

#networkObject (readonly)

Returns the value of attribute network.



6
7
8
# File 'lib/bot_mob/inbound_message.rb', line 6

def network
  @network
end

Class Method Details

.prepare(message, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/bot_mob/inbound_message.rb', line 13

def self.prepare(message, options = {})
  return message if message.is_a?(BotMob::InboundMessage)

  BotMob::InboundMessage.new(
    network: options[:network] || :roaming,
    body: message
  )
end

Instance Method Details

#paramsObject



22
23
24
# File 'lib/bot_mob/inbound_message.rb', line 22

def params
  @params || { body: body }
end