Class: Twilio::REST::Chat::V1::ServiceContext::ChannelContext::MessageContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/chat/v1/service/channel/message.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, channel_sid, sid) ⇒ MessageContext

Initialize the MessageContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The service_sid

  • channel_sid (String)

    The channel_sid

  • sid (String)

    The sid



191
192
193
194
195
196
197
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 191

def initialize(version, service_sid, channel_sid, sid)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, channel_sid: channel_sid, sid: sid, }
  @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Messages/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Deletes the MessageInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



223
224
225
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 223

def delete
  @version.delete('delete', @uri)
end

#fetchMessageInstance

Fetch a MessageInstance

Returns:



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 202

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  MessageInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      channel_sid: @solution[:channel_sid],
      sid: @solution[:sid],
  )
end

#to_sObject

Provide a user friendly representation



255
256
257
258
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 255

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Chat.V1.MessageContext #{context}>"
end

#update(body: :unset, attributes: :unset) ⇒ MessageInstance

Update the MessageInstance

Parameters:

  • body (String) (defaults to: :unset)

    The new message body string. You can also send structured data by serializing it into a string.

  • attributes (String) (defaults to: :unset)

    The new attributes metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified.

Returns:



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 235

def update(body: :unset, attributes: :unset)
  data = Twilio::Values.of({'Body' => body, 'Attributes' => attributes, })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  MessageInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      channel_sid: @solution[:channel_sid],
      sid: @solution[:sid],
  )
end