Class: Repull::ConversationDetail

Inherits:
ApiModelBase show all
Defined in:
lib/repull/models/conversation_detail.rb

Overview

Returned by ‘GET /v1/conversations/#id`. Extends the list-row `Conversation` shape with expanded `host` + `guest` blocks so SDK consumers can render thread headers without an extra round-trip.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ ConversationDetail

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
# File 'lib/repull/models/conversation_detail.rb', line 124

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::ConversationDetail` 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::ConversationDetail`. 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?(:'platform')
    self.platform = attributes[:'platform']
  end

  if attributes.key?(:'guest_id')
    self.guest_id = attributes[:'guest_id']
  end

  if attributes.key?(:'listing_id')
    self.listing_id = attributes[:'listing_id']
  end

  if attributes.key?(:'reservation_id')
    self.reservation_id = attributes[:'reservation_id']
  end

  if attributes.key?(:'subject')
    self.subject = attributes[:'subject']
  end

  if attributes.key?(:'last_message_at')
    self.last_message_at = attributes[:'last_message_at']
  end

  if attributes.key?(:'last_message_preview')
    self.last_message_preview = attributes[:'last_message_preview']
  end

  if attributes.key?(:'unread_count')
    self.unread_count = attributes[:'unread_count']
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end

  if attributes.key?(:'updated_at')
    self.updated_at = attributes[:'updated_at']
  end

  if attributes.key?(:'host')
    self.host = attributes[:'host']
  end

  if attributes.key?(:'guest')
    self.guest = attributes[:'guest']
  end
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



42
43
44
# File 'lib/repull/models/conversation_detail.rb', line 42

def created_at
  @created_at
end

#guestObject

Returns the value of attribute guest.



48
49
50
# File 'lib/repull/models/conversation_detail.rb', line 48

def guest
  @guest
end

#guest_idObject

Returns the value of attribute guest_id.



23
24
25
# File 'lib/repull/models/conversation_detail.rb', line 23

def guest_id
  @guest_id
end

#hostObject

Returns the value of attribute host.



46
47
48
# File 'lib/repull/models/conversation_detail.rb', line 46

def host
  @host
end

#idObject

Returns the value of attribute id.



19
20
21
# File 'lib/repull/models/conversation_detail.rb', line 19

def id
  @id
end

#last_message_atObject

Returns the value of attribute last_message_at.



32
33
34
# File 'lib/repull/models/conversation_detail.rb', line 32

def last_message_at
  @last_message_at
end

#last_message_previewObject

Short preview of the most recent message body for list-UI rendering.



35
36
37
# File 'lib/repull/models/conversation_detail.rb', line 35

def last_message_preview
  @last_message_preview
end

#listing_idObject

Returns the value of attribute listing_id.



25
26
27
# File 'lib/repull/models/conversation_detail.rb', line 25

def listing_id
  @listing_id
end

#platformObject

Returns the value of attribute platform.



21
22
23
# File 'lib/repull/models/conversation_detail.rb', line 21

def platform
  @platform
end

#reservation_idObject

Returns the value of attribute reservation_id.



27
28
29
# File 'lib/repull/models/conversation_detail.rb', line 27

def reservation_id
  @reservation_id
end

#statusObject

‘archived` is reserved for a future bit on `message_threads` — currently always `open`.



40
41
42
# File 'lib/repull/models/conversation_detail.rb', line 40

def status
  @status
end

#subjectObject

Thread subject (email/website channels) or null when not applicable.



30
31
32
# File 'lib/repull/models/conversation_detail.rb', line 30

def subject
  @subject
end

#unread_countObject

Returns the value of attribute unread_count.



37
38
39
# File 'lib/repull/models/conversation_detail.rb', line 37

def unread_count
  @unread_count
end

#updated_atObject

Returns the value of attribute updated_at.



44
45
46
# File 'lib/repull/models/conversation_detail.rb', line 44

def updated_at
  @updated_at
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



71
72
73
# File 'lib/repull/models/conversation_detail.rb', line 71

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



76
77
78
# File 'lib/repull/models/conversation_detail.rb', line 76

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/repull/models/conversation_detail.rb', line 51

def self.attribute_map
  {
    :'id' => :'id',
    :'platform' => :'platform',
    :'guest_id' => :'guestId',
    :'listing_id' => :'listingId',
    :'reservation_id' => :'reservationId',
    :'subject' => :'subject',
    :'last_message_at' => :'lastMessageAt',
    :'last_message_preview' => :'lastMessagePreview',
    :'unread_count' => :'unreadCount',
    :'status' => :'status',
    :'created_at' => :'createdAt',
    :'updated_at' => :'updatedAt',
    :'host' => :'host',
    :'guest' => :'guest'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/repull/models/conversation_detail.rb', line 246

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_all_ofObject

List of class defined in allOf (OpenAPI v3)



116
117
118
119
120
# File 'lib/repull/models/conversation_detail.rb', line 116

def self.openapi_all_of
  [
  :'Conversation'
  ]
end

.openapi_nullableObject

List of attributes with nullable: true



101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/repull/models/conversation_detail.rb', line 101

def self.openapi_nullable
  Set.new([
    :'platform',
    :'guest_id',
    :'listing_id',
    :'reservation_id',
    :'subject',
    :'last_message_at',
    :'last_message_preview',
    :'host',
    :'guest'
  ])
end

.openapi_typesObject

Attribute type mapping.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/repull/models/conversation_detail.rb', line 81

def self.openapi_types
  {
    :'id' => :'String',
    :'platform' => :'String',
    :'guest_id' => :'String',
    :'listing_id' => :'String',
    :'reservation_id' => :'String',
    :'subject' => :'String',
    :'last_message_at' => :'Time',
    :'last_message_preview' => :'String',
    :'unread_count' => :'Integer',
    :'status' => :'String',
    :'created_at' => :'Time',
    :'updated_at' => :'Time',
    :'host' => :'ConversationHost',
    :'guest' => :'ConversationGuest'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/repull/models/conversation_detail.rb', line 212

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      platform == o.platform &&
      guest_id == o.guest_id &&
      listing_id == o.listing_id &&
      reservation_id == o.reservation_id &&
      subject == o.subject &&
      last_message_at == o.last_message_at &&
      last_message_preview == o.last_message_preview &&
      unread_count == o.unread_count &&
      status == o.status &&
      created_at == o.created_at &&
      updated_at == o.updated_at &&
      host == o.host &&
      guest == o.guest
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


233
234
235
# File 'lib/repull/models/conversation_detail.rb', line 233

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



239
240
241
# File 'lib/repull/models/conversation_detail.rb', line 239

def hash
  [id, platform, guest_id, listing_id, reservation_id, subject, last_message_at, last_message_preview, unread_count, status, created_at, updated_at, host, guest].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



197
198
199
200
201
# File 'lib/repull/models/conversation_detail.rb', line 197

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/repull/models/conversation_detail.rb', line 268

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

Returns:

  • (Boolean)

    true if the model is valid



205
206
207
208
# File 'lib/repull/models/conversation_detail.rb', line 205

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  true
end