Class: Repull::Message
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- Repull::Message
- Defined in:
- lib/repull/models/message.rb
Overview
A single message inside a conversation thread. Returned by ‘GET /v1/conversations/#id/messages`. `direction` is normalized to `inbound` (from the guest) / `outbound` (from the host or an automation).
Instance Attribute Summary collapse
-
#ai_generated ⇒ Object
‘true` when the body was authored by Vanio AI (autopilot, draft).
-
#attachments ⇒ Object
Returns the value of attribute attachments.
-
#body ⇒ Object
Message body in the original language.
-
#channel ⇒ Object
Delivery channel — ‘airbnb`, `booking`, `sms`, `email`, etc.
-
#delivered_at ⇒ Object
Returns the value of attribute delivered_at.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#external_message_id ⇒ Object
ID assigned by the source channel (Airbnb message id, Booking message id, etc.).
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_automated ⇒ Object
‘true` when the message was sent by a Vanio automation (template, schedule, etc.).
-
#read_at ⇒ Object
Returns the value of attribute read_at.
-
#sender_avatar ⇒ Object
Returns the value of attribute sender_avatar.
-
#sender_name ⇒ Object
Returns the value of attribute sender_name.
-
#sender_type ⇒ Object
Free-form sender role from the channel (e.g. ‘guest`, `host`, `system`, `airbnb`).
-
#sent_at ⇒ Object
Returns the value of attribute sent_at.
-
#translated_body ⇒ Object
English translation when the original language is non-English and a translation has been computed.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Message
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ Message
Initializes the object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/repull/models/message.rb', line 122 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::Message` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Repull::Message`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'id') self.id = attributes[:'id'] end if attributes.key?(:'external_message_id') self. = attributes[:'external_message_id'] end if attributes.key?(:'direction') self.direction = attributes[:'direction'] end if attributes.key?(:'sender_type') self.sender_type = attributes[:'sender_type'] end if attributes.key?(:'sender_name') self.sender_name = attributes[:'sender_name'] end if attributes.key?(:'sender_avatar') self.sender_avatar = attributes[:'sender_avatar'] end if attributes.key?(:'channel') self.channel = attributes[:'channel'] end if attributes.key?(:'body') self.body = attributes[:'body'] end if attributes.key?(:'translated_body') self.translated_body = attributes[:'translated_body'] end if attributes.key?(:'attachments') if (value = attributes[:'attachments']).is_a?(Array) self. = value end end if attributes.key?(:'is_automated') self.is_automated = attributes[:'is_automated'] end if attributes.key?(:'ai_generated') self.ai_generated = attributes[:'ai_generated'] end if attributes.key?(:'sent_at') self.sent_at = attributes[:'sent_at'] end if attributes.key?(:'delivered_at') self.delivered_at = attributes[:'delivered_at'] end if attributes.key?(:'read_at') self.read_at = attributes[:'read_at'] end end |
Instance Attribute Details
#ai_generated ⇒ Object
‘true` when the body was authored by Vanio AI (autopilot, draft).
48 49 50 |
# File 'lib/repull/models/message.rb', line 48 def ai_generated @ai_generated end |
#attachments ⇒ Object
Returns the value of attribute attachments.
42 43 44 |
# File 'lib/repull/models/message.rb', line 42 def @attachments end |
#body ⇒ Object
Message body in the original language.
37 38 39 |
# File 'lib/repull/models/message.rb', line 37 def body @body end |
#channel ⇒ Object
Delivery channel — ‘airbnb`, `booking`, `sms`, `email`, etc.
34 35 36 |
# File 'lib/repull/models/message.rb', line 34 def channel @channel end |
#delivered_at ⇒ Object
Returns the value of attribute delivered_at.
52 53 54 |
# File 'lib/repull/models/message.rb', line 52 def delivered_at @delivered_at end |
#direction ⇒ Object
Returns the value of attribute direction.
24 25 26 |
# File 'lib/repull/models/message.rb', line 24 def direction @direction end |
#external_message_id ⇒ Object
ID assigned by the source channel (Airbnb message id, Booking message id, etc.). Stable across syncs.
22 23 24 |
# File 'lib/repull/models/message.rb', line 22 def @external_message_id end |
#id ⇒ Object
Returns the value of attribute id.
19 20 21 |
# File 'lib/repull/models/message.rb', line 19 def id @id end |
#is_automated ⇒ Object
‘true` when the message was sent by a Vanio automation (template, schedule, etc.).
45 46 47 |
# File 'lib/repull/models/message.rb', line 45 def is_automated @is_automated end |
#read_at ⇒ Object
Returns the value of attribute read_at.
54 55 56 |
# File 'lib/repull/models/message.rb', line 54 def read_at @read_at end |
#sender_avatar ⇒ Object
Returns the value of attribute sender_avatar.
31 32 33 |
# File 'lib/repull/models/message.rb', line 31 def sender_avatar @sender_avatar end |
#sender_name ⇒ Object
Returns the value of attribute sender_name.
29 30 31 |
# File 'lib/repull/models/message.rb', line 29 def sender_name @sender_name end |
#sender_type ⇒ Object
Free-form sender role from the channel (e.g. ‘guest`, `host`, `system`, `airbnb`). Use `direction` for binary inbound/outbound logic.
27 28 29 |
# File 'lib/repull/models/message.rb', line 27 def sender_type @sender_type end |
#sent_at ⇒ Object
Returns the value of attribute sent_at.
50 51 52 |
# File 'lib/repull/models/message.rb', line 50 def sent_at @sent_at end |
#translated_body ⇒ Object
English translation when the original language is non-English and a translation has been computed.
40 41 42 |
# File 'lib/repull/models/message.rb', line 40 def translated_body @translated_body end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
78 79 80 |
# File 'lib/repull/models/message.rb', line 78 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
83 84 85 |
# File 'lib/repull/models/message.rb', line 83 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/repull/models/message.rb', line 57 def self.attribute_map { :'id' => :'id', :'external_message_id' => :'externalMessageId', :'direction' => :'direction', :'sender_type' => :'senderType', :'sender_name' => :'senderName', :'sender_avatar' => :'senderAvatar', :'channel' => :'channel', :'body' => :'body', :'translated_body' => :'translatedBody', :'attachments' => :'attachments', :'is_automated' => :'isAutomated', :'ai_generated' => :'aiGenerated', :'sent_at' => :'sentAt', :'delivered_at' => :'deliveredAt', :'read_at' => :'readAt' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/repull/models/message.rb', line 251 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/repull/models/message.rb', line 109 def self.openapi_nullable Set.new([ :'external_message_id', :'sender_type', :'sender_avatar', :'channel', :'translated_body', :'read_at' ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/repull/models/message.rb', line 88 def self.openapi_types { :'id' => :'String', :'external_message_id' => :'String', :'direction' => :'String', :'sender_type' => :'String', :'sender_name' => :'String', :'sender_avatar' => :'String', :'channel' => :'String', :'body' => :'String', :'translated_body' => :'String', :'attachments' => :'Array<ConversationMessageAttachment>', :'is_automated' => :'Boolean', :'ai_generated' => :'Boolean', :'sent_at' => :'Time', :'delivered_at' => :'Time', :'read_at' => :'Time' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/repull/models/message.rb', line 216 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && == o. && direction == o.direction && sender_type == o.sender_type && sender_name == o.sender_name && sender_avatar == o.sender_avatar && channel == o.channel && body == o.body && translated_body == o.translated_body && == o. && is_automated == o.is_automated && ai_generated == o.ai_generated && sent_at == o.sent_at && delivered_at == o.delivered_at && read_at == o.read_at end |
#eql?(o) ⇒ Boolean
238 239 240 |
# File 'lib/repull/models/message.rb', line 238 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
244 245 246 |
# File 'lib/repull/models/message.rb', line 244 def hash [id, , direction, sender_type, sender_name, sender_avatar, channel, body, translated_body, , is_automated, ai_generated, sent_at, delivered_at, read_at].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
201 202 203 204 205 |
# File 'lib/repull/models/message.rb', line 201 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/repull/models/message.rb', line 273 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
209 210 211 212 |
# File 'lib/repull/models/message.rb', line 209 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' true end |