Class: Reach::REST::Api::Messaging::MessagingItemInstance

Inherits:
InstanceResource show all
Defined in:
lib/reach-ruby/rest/api/messaging/messaging_item.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, message_id: nil) ⇒ MessagingItemInstance

Initialize the MessagingItemInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Reach(TalkyLabs)

  • account_sid (String)

    The SID of the Account that created this MessagingItem resource.

  • sid (String)

    The SID of the Call resource to fetch.



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 372

def initialize(version, payload , message_id: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'appletId' => payload['appletId'],
        'apiVersion' => payload['apiVersion'],
        'body' => payload['body'],
        'dest' => payload['dest'],
        'src' => payload['src'],
        'bulkId' => payload['bulkId'],
        'numSegments' => payload['numSegments'] == nil ? payload['numSegments'] : payload['numSegments'].to_i,
        'numMedia' => payload['numMedia'] == nil ? payload['numMedia'] : payload['numMedia'].to_i,
        'price' => payload['price'],
        'priceUnit' => payload['priceUnit'],
        'messageId' => payload['messageId'],
        'status' => payload['status'],
        'messageType' => payload['messageType'],
        'errorCode' => payload['errorCode'] == nil ? payload['errorCode'] : payload['errorCode'].to_i,
        'errorMessage' => payload['errorMessage'],
        'dateCreated' => Reach.deserialize_iso8601_datetime(payload['dateCreated']),
        'dateSent' => Reach.deserialize_iso8601_datetime(payload['dateSent']),
        'dateUpdated' => Reach.deserialize_iso8601_datetime(payload['dateUpdated']),
    }

    # Context
    @instance_context = nil
    @params = { 'message_id' => message_id  || @properties['messageId']  , }
end

Instance Method Details

#apiVersionString

Returns The API version used to process the message.

Returns:

  • (String)

    The API version used to process the message.



421
422
423
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 421

def apiVersion
    @properties['apiVersion']
end

#appletIdString

Returns The identifier of the applet sending the message.

Returns:

  • (String)

    The identifier of the applet sending the message.



415
416
417
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 415

def appletId
    @properties['appletId']
end

#bodyString

Returns The message text.

Returns:

  • (String)

    The message text.



427
428
429
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 427

def body
    @properties['body']
end

#bulkIdString

Returns The bulk identifier allowing to group messages together and have corresponding statistics.

Returns:

  • (String)

    The bulk identifier allowing to group messages together and have corresponding statistics.



445
446
447
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 445

def bulkId
    @properties['bulkId']
end

#contextMessagingItemContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



406
407
408
409
410
411
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 406

def context
    unless @instance_context
        @instance_context = MessagingItemContext.new(@version , @params['message_id'])
    end
    @instance_context
end

#dateCreatedTime

Returns The date and time in GMT that the message was created.

Returns:

  • (Time)

    The date and time in GMT that the message was created.



505
506
507
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 505

def dateCreated
    @properties['dateCreated']
end

#dateSentTime

Returns The date and time in GMT that the message was sent.

Returns:

  • (Time)

    The date and time in GMT that the message was sent.



511
512
513
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 511

def dateSent
    @properties['dateSent']
end

#dateUpdatedTime

Returns The date and time in GMT that the message status was last updated.

Returns:

  • (Time)

    The date and time in GMT that the message status was last updated.



517
518
519
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 517

def dateUpdated
    @properties['dateUpdated']
end

#deleteBoolean

Delete the MessagingItemInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



524
525
526
527
528
529
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 524

def delete(
)

    context.delete(
    )
end

#destString

Returns The phone number in E.164 format that received the message.

Returns:

  • (String)

    The phone number in E.164 format that received the message.



433
434
435
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 433

def dest
    @properties['dest']
end

#errorCodeString

Returns The error code returned if the message status is ‘failed` or `undelivered`. The errorMessage provides more information about the failure. The value is null if the message is successful.

Returns:

  • (String)

    The error code returned if the message status is ‘failed` or `undelivered`. The errorMessage provides more information about the failure. The value is null if the message is successful.



493
494
495
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 493

def errorCode
    @properties['errorCode']
end

#errorMessageString

Returns The error message returned if the message status is ‘failed` or `undelivered`. The value is null if the message is successful.

Returns:

  • (String)

    The error message returned if the message status is ‘failed` or `undelivered`. The value is null if the message is successful.



499
500
501
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 499

def errorMessage
    @properties['errorMessage']
end

#fetchMessagingItemInstance

Fetch the MessagingItemInstance

Returns:



534
535
536
537
538
539
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 534

def fetch(
)

    context.fetch(
    )
end

#inspectObject

Provide a detailed, user friendly representation



573
574
575
576
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 573

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Reach.Api.Messaging.MessagingItemInstance #{values}>"
end

#messageIdString

Returns The identifier of the message.

Returns:

  • (String)

    The identifier of the message



475
476
477
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 475

def messageId
    @properties['messageId']
end

#messageTypeString

Returns The type of the message. Can be: ‘inbound` for incoming messages, `outbound` for messages initiated by a REST API.

Returns:

  • (String)

    The type of the message. Can be: ‘inbound` for incoming messages, `outbound` for messages initiated by a REST API.



487
488
489
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 487

def messageType
    @properties['messageType']
end

#numMediaString

Returns The number of media files included in the message.

Returns:

  • (String)

    The number of media files included in the message



457
458
459
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 457

def numMedia
    @properties['numMedia']
end

#numSegmentsString

Returns The number of segments associated to the message. A message body that is too large to be sent in a single SMS is segmented and charged as multiple messages. The segments are reassembled once received by the destination phone. A message can have a maximum of 10 segments.

Returns:

  • (String)

    The number of segments associated to the message. A message body that is too large to be sent in a single SMS is segmented and charged as multiple messages. The segments are reassembled once received by the destination phone. A message can have a maximum of 10 segments.



451
452
453
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 451

def numSegments
    @properties['numSegments']
end

#priceFloat

Returns The cost billed for the message, in the currency specified by ‘priceUnit`.

Returns:

  • (Float)

    The cost billed for the message, in the currency specified by ‘priceUnit`.



463
464
465
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 463

def price
    @properties['price']
end

#priceUnitString

Returns The currency, in ISO 4127 format, in which price is measured. for example, usd, xaf, eur, cad.

Returns:

  • (String)

    The currency, in ISO 4127 format, in which price is measured. for example, usd, xaf, eur, cad.



469
470
471
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 469

def priceUnit
    @properties['priceUnit']
end

#srcString

Returns The phone number (in E.164 format), or the alphanumeric sender ID that initiated the message.

Returns:

  • (String)

    The phone number (in E.164 format), or the alphanumeric sender ID that initiated the message.



439
440
441
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 439

def src
    @properties['src']
end

#statusString

Returns The status of the message. Can be: ‘sent`, `scheduled`, `failed`, `delivered`, `undelivered`, `canceled`, `accepted`, `queued`, `sending`, `received`, `receiving`.

Returns:

  • (String)

    The status of the message. Can be: ‘sent`, `scheduled`, `failed`, `delivered`, `undelivered`, `canceled`, `accepted`, `queued`, `sending`, `received`, `receiving`.



481
482
483
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 481

def status
    @properties['status']
end

#to_sObject

Provide a user friendly representation



566
567
568
569
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 566

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Reach.Api.Messaging.MessagingItemInstance #{values}>"
end

#unscheduleMessagingItemInstance

Unschedule the MessagingItemInstance

Returns:



544
545
546
547
548
549
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 544

def unschedule(
)

    context.unschedule(
    )
end

#update(body: nil) ⇒ MessagingItemInstance

Update the MessagingItemInstance

Parameters:

  • body (String) (defaults to: nil)

    The text to be newly associated with the message.

Returns:



555
556
557
558
559
560
561
562
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 555

def update(
    body: nil
)

    context.update(
        body: body, 
    )
end