Class: Reach::REST::Api::Messaging::MessagingItemInstance
- Inherits:
-
InstanceResource
- Object
- InstanceResource
- Reach::REST::Api::Messaging::MessagingItemInstance
- Defined in:
- lib/reach-ruby/rest/api/messaging/messaging_item.rb
Instance Method Summary collapse
-
#apiVersion ⇒ String
The API version used to process the message.
-
#appletId ⇒ String
The identifier of the applet sending the message.
-
#body ⇒ String
The message text.
-
#bulkId ⇒ String
The bulk identifier allowing to group messages together and have corresponding statistics.
-
#context ⇒ MessagingItemContext
Generate an instance context for the instance, the context is capable of performing various actions.
-
#dateCreated ⇒ Time
The date and time in GMT that the message was created.
-
#dateSent ⇒ Time
The date and time in GMT that the message was sent.
-
#dateUpdated ⇒ Time
The date and time in GMT that the message status was last updated.
-
#delete ⇒ Boolean
Delete the MessagingItemInstance.
-
#dest ⇒ String
The phone number in E.164 format that received the message.
-
#errorCode ⇒ String
The error code returned if the message status is ‘failed` or `undelivered`.
-
#errorMessage ⇒ String
The error message returned if the message status is ‘failed` or `undelivered`.
-
#fetch ⇒ MessagingItemInstance
Fetch the MessagingItemInstance.
-
#initialize(version, payload, message_id: nil) ⇒ MessagingItemInstance
constructor
Initialize the MessagingItemInstance.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#messageId ⇒ String
The identifier of the message.
-
#messageType ⇒ String
The type of the message.
-
#numMedia ⇒ String
The number of media files included in the message.
-
#numSegments ⇒ String
The number of segments associated to the message.
-
#price ⇒ Float
The cost billed for the message, in the currency specified by ‘priceUnit`.
-
#priceUnit ⇒ String
The currency, in ISO 4127 format, in which price is measured.
-
#src ⇒ String
The phone number (in E.164 format), or the alphanumeric sender ID that initiated the message.
-
#status ⇒ String
The status of the message.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#unschedule ⇒ MessagingItemInstance
Unschedule the MessagingItemInstance.
-
#update(body: nil) ⇒ MessagingItemInstance
Update the MessagingItemInstance.
Constructor Details
#initialize(version, payload, message_id: nil) ⇒ MessagingItemInstance
Initialize the MessagingItemInstance
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' => || @properties['messageId'] , } end |
Instance Method Details
#apiVersion ⇒ String
Returns 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 |
#appletId ⇒ String
Returns 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 |
#body ⇒ String
Returns The message text.
427 428 429 |
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 427 def body @properties['body'] end |
#bulkId ⇒ String
Returns 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 |
#context ⇒ MessagingItemContext
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context
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 |
#dateCreated ⇒ Time
Returns 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 |
#dateSent ⇒ Time
Returns 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 |
#dateUpdated ⇒ Time
Returns 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 |
#delete ⇒ Boolean
Delete the MessagingItemInstance
524 525 526 527 528 529 |
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 524 def delete( ) context.delete( ) end |
#dest ⇒ String
Returns 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 |
#errorCode ⇒ String
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.
493 494 495 |
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 493 def errorCode @properties['errorCode'] end |
#errorMessage ⇒ String
Returns 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 |
#fetch ⇒ MessagingItemInstance
Fetch the MessagingItemInstance
534 535 536 537 538 539 |
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 534 def fetch( ) context.fetch( ) end |
#inspect ⇒ Object
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 |
#messageId ⇒ String
Returns The identifier of the message.
475 476 477 |
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 475 def @properties['messageId'] end |
#messageType ⇒ String
Returns 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 @properties['messageType'] end |
#numMedia ⇒ String
Returns 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 |
#numSegments ⇒ String
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.
451 452 453 |
# File 'lib/reach-ruby/rest/api/messaging/messaging_item.rb', line 451 def numSegments @properties['numSegments'] end |
#price ⇒ Float
Returns 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 |
#priceUnit ⇒ String
Returns 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 |
#src ⇒ String
Returns 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 |
#status ⇒ String
Returns 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_s ⇒ Object
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 |
#unschedule ⇒ MessagingItemInstance
Unschedule the MessagingItemInstance
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
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 |