Class: Sendly::RcsMessage
- Inherits:
-
Object
- Object
- Sendly::RcsMessage
- Defined in:
- lib/sendly/rcs_resource.rb
Overview
A message sent through the RCS channel. channel is "rcs" when it was
delivered as RCS, or "sms" when the recipient couldn't receive RCS and
the message fell back to plain SMS — check with #fell_back?. On a
fallback fell_back_to is "sms" and +segments+/+credits_used+ are
billed as SMS; rcs carries the channel-specific details either way.
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#credits_used ⇒ Object
readonly
Returns the value of attribute credits_used.
-
#fell_back_to ⇒ Object
readonly
Returns the value of attribute fell_back_to.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#message_format ⇒ Object
readonly
Returns the value of attribute message_format.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#rcs ⇒ Object
readonly
Returns the value of attribute rcs.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #delivered? ⇒ Boolean
- #failed? ⇒ Boolean
- #fell_back? ⇒ Boolean
-
#initialize(data) ⇒ RcsMessage
constructor
A new instance of RcsMessage.
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ RcsMessage
Returns a new instance of RcsMessage.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/sendly/rcs_resource.rb', line 100 def initialize(data) @id = data["id"] @channel = data["channel"] || "rcs" @fell_back_to = data["fellBackTo"] || data["fell_back_to"] @message_format = data["message_format"] || data["messageFormat"] || @channel @to = data["to"] @from = data["from"] @text = data["text"] @status = data["status"] @segments = data["segments"] || 1 @credits_used = data["creditsUsed"] || data["credits_used"] || 0 @rcs = data["rcs"] ? RcsMessageDetails.new(data["rcs"]) : nil @created_at = data["createdAt"] || data["created_at"] @metadata = data["metadata"] end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def channel @channel end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def created_at @created_at end |
#credits_used ⇒ Object (readonly)
Returns the value of attribute credits_used.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def credits_used @credits_used end |
#fell_back_to ⇒ Object (readonly)
Returns the value of attribute fell_back_to.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def fell_back_to @fell_back_to end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def from @from end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def id @id end |
#message_format ⇒ Object (readonly)
Returns the value of attribute message_format.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def @message_format end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def @metadata end |
#rcs ⇒ Object (readonly)
Returns the value of attribute rcs.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def rcs @rcs end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def segments @segments end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def status @status end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def text @text end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
96 97 98 |
# File 'lib/sendly/rcs_resource.rb', line 96 def to @to end |
Instance Method Details
#delivered? ⇒ Boolean
120 121 122 |
# File 'lib/sendly/rcs_resource.rb', line 120 def delivered? status == "delivered" end |
#failed? ⇒ Boolean
124 125 126 |
# File 'lib/sendly/rcs_resource.rb', line 124 def failed? status == "failed" end |
#fell_back? ⇒ Boolean
116 117 118 |
# File 'lib/sendly/rcs_resource.rb', line 116 def fell_back? fell_back_to == "sms" end |
#to_h ⇒ Object
128 129 130 131 132 133 134 135 |
# File 'lib/sendly/rcs_resource.rb', line 128 def to_h { id: id, channel: channel, fell_back_to: fell_back_to, message_format: , to: to, from: from, text: text, status: status, segments: segments, credits_used: credits_used, rcs: rcs&.to_h, created_at: created_at, metadata: }.compact end |