Class: Twilio::REST::Conversations::V1::ConversationContext::MessageContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/conversation/message.rb,
lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb

Defined Under Namespace

Classes: DeliveryReceiptContext, DeliveryReceiptInstance, DeliveryReceiptList, DeliveryReceiptPage

Instance Method Summary collapse

Constructor Details

#initialize(version, conversation_sid, sid) ⇒ MessageContext

Initialize the MessageContext



188
189
190
191
192
193
194
195
196
197
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 188

def initialize(version, conversation_sid, sid)
  super(version)

  # Path Solution
  @solution = {conversation_sid: conversation_sid, sid: sid, }
  @uri = "/Conversations/#{@solution[:conversation_sid]}/Messages/#{@solution[:sid]}"

  # Dependents
  @delivery_receipts = nil
end

Instance Method Details

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the MessageInstance



239
240
241
242
243
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 239

def delete(x_twilio_webhook_enabled: :unset)
  headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

   @version.delete('DELETE', @uri, headers: headers)
end

#delivery_receipts(sid = :unset) ⇒ DeliveryReceiptList, DeliveryReceiptContext

Access the delivery_receipts

Raises:

  • (ArgumentError)


263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 263

def delivery_receipts(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return DeliveryReceiptContext.new(@version, @solution[:conversation_sid], @solution[:sid], sid, )
  end

  unless @delivery_receipts
    @delivery_receipts = DeliveryReceiptList.new(
        @version,
        conversation_sid: @solution[:conversation_sid],
        message_sid: @solution[:sid],
    )
  end

  @delivery_receipts
end

#fetchMessageInstance

Fetch the MessageInstance



248
249
250
251
252
253
254
255
256
257
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 248

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

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

#inspectObject

Provide a detailed, user friendly representation



290
291
292
293
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 290

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

#to_sObject

Provide a user friendly representation



283
284
285
286
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 283

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

#update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, x_twilio_webhook_enabled: :unset) ⇒ MessageInstance

Update the MessageInstance



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 214

def update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, x_twilio_webhook_enabled: :unset)
  data = Twilio::Values.of({
      'Author' => author,
      'Body' => body,
      'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
      'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
      'Attributes' => attributes,
  })
  headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

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

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