Class: Repull::Conversation

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

Overview

Channel-agnostic message thread between the host workspace and a guest. Returned by ‘GET /v1/conversations`. The `id` is the internal Repull thread id (integer) — pass it back as the `#id` path param on detail / messages calls.

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 = {}) ⇒ Conversation

Initializes the object

Parameters:

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

    Model attributes in the form of hash



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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
# File 'lib/repull/models/conversation.rb', line 107

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

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#guest_idObject

Returns the value of attribute guest_id.



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

def guest_id
  @guest_id
end

#idObject

Returns the value of attribute id.



19
20
21
# File 'lib/repull/models/conversation.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.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.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.rb', line 25

def listing_id
  @listing_id
end

#platformObject

Returns the value of attribute platform.



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

def platform
  @platform
end

#reservation_idObject

Returns the value of attribute reservation_id.



27
28
29
# File 'lib/repull/models/conversation.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.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.rb', line 30

def subject
  @subject
end

#unread_countObject

Returns the value of attribute unread_count.



37
38
39
# File 'lib/repull/models/conversation.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.rb', line 44

def updated_at
  @updated_at
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



65
66
67
# File 'lib/repull/models/conversation.rb', line 65

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



70
71
72
# File 'lib/repull/models/conversation.rb', line 70

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/repull/models/conversation.rb', line 47

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'
  }
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



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/repull/models/conversation.rb', line 219

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_nullableObject

List of attributes with nullable: true



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/repull/models/conversation.rb', line 93

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

.openapi_typesObject

Attribute type mapping.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/repull/models/conversation.rb', line 75

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'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/repull/models/conversation.rb', line 187

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
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


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

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



212
213
214
# File 'lib/repull/models/conversation.rb', line 212

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

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



172
173
174
175
176
# File 'lib/repull/models/conversation.rb', line 172

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



241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/repull/models/conversation.rb', line 241

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



180
181
182
183
# File 'lib/repull/models/conversation.rb', line 180

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