Class: Repull::Guest

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

Overview

Guest list-row shape returned by ‘GET /v1/guests`. Pre-resolved primary phone/email + display name + cumulative stay aggregates so list UIs can render without a per-row 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 = {}) ⇒ Guest

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/repull/models/guest.rb', line 116

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#avatar_urlObject

Returns the value of attribute avatar_url.



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

def avatar_url
  @avatar_url
end

#countryObject

Guest country (from profile metadata or address).



33
34
35
# File 'lib/repull/models/guest.rb', line 33

def country
  @country
end

#created_atObject

Returns the value of attribute created_at.



51
52
53
# File 'lib/repull/models/guest.rb', line 51

def created_at
  @created_at
end

#display_nameObject

Short display name (first name).



22
23
24
# File 'lib/repull/models/guest.rb', line 22

def display_name
  @display_name
end

#display_name_longObject

Long display name (first + last). Falls back to displayName when last name is missing.



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

def display_name_long
  @display_name_long
end

#emailObject

Primary email contact.



39
40
41
# File 'lib/repull/models/guest.rb', line 39

def email
  @email
end

#first_stayed_atObject

Returns the value of attribute first_stayed_at.



49
50
51
# File 'lib/repull/models/guest.rb', line 49

def first_stayed_at
  @first_stayed_at
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#languageObject

Guest’s preferred language (ISO 639-1).



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

def language
  @language
end

#last_stayed_atObject

Returns the value of attribute last_stayed_at.



47
48
49
# File 'lib/repull/models/guest.rb', line 47

def last_stayed_at
  @last_stayed_at
end

#phoneObject

Primary phone contact (or first non-primary if no primary set).



36
37
38
# File 'lib/repull/models/guest.rb', line 36

def phone
  @phone
end

#total_reservationsObject

Lifetime reservation count.



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

def total_reservations
  @total_reservations
end

#total_revenueObject

Decimal-as-string to preserve precision across mixed-currency totals.



45
46
47
# File 'lib/repull/models/guest.rb', line 45

def total_revenue
  @total_revenue
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



73
74
75
# File 'lib/repull/models/guest.rb', line 73

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



78
79
80
# File 'lib/repull/models/guest.rb', line 78

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/repull/models/guest.rb', line 54

def self.attribute_map
  {
    :'id' => :'id',
    :'display_name' => :'displayName',
    :'display_name_long' => :'displayNameLong',
    :'avatar_url' => :'avatarUrl',
    :'language' => :'language',
    :'country' => :'country',
    :'phone' => :'phone',
    :'email' => :'email',
    :'total_reservations' => :'totalReservations',
    :'total_revenue' => :'totalRevenue',
    :'last_stayed_at' => :'lastStayedAt',
    :'first_stayed_at' => :'firstStayedAt',
    :'created_at' => :'createdAt'
  }
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



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/repull/models/guest.rb', line 233

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



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

def self.openapi_nullable
  Set.new([
    :'avatar_url',
    :'language',
    :'country',
    :'phone',
    :'email',
    :'last_stayed_at',
    :'first_stayed_at',
  ])
end

.openapi_typesObject

Attribute type mapping.



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

def self.openapi_types
  {
    :'id' => :'String',
    :'display_name' => :'String',
    :'display_name_long' => :'String',
    :'avatar_url' => :'String',
    :'language' => :'String',
    :'country' => :'String',
    :'phone' => :'String',
    :'email' => :'String',
    :'total_reservations' => :'Integer',
    :'total_revenue' => :'String',
    :'last_stayed_at' => :'Time',
    :'first_stayed_at' => :'Time',
    :'created_at' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/repull/models/guest.rb', line 200

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      display_name == o.display_name &&
      display_name_long == o.display_name_long &&
      avatar_url == o.avatar_url &&
      language == o.language &&
      country == o.country &&
      phone == o.phone &&
      email == o.email &&
      total_reservations == o.total_reservations &&
      total_revenue == o.total_revenue &&
      last_stayed_at == o.last_stayed_at &&
      first_stayed_at == o.first_stayed_at &&
      created_at == o.created_at
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


220
221
222
# File 'lib/repull/models/guest.rb', line 220

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



226
227
228
# File 'lib/repull/models/guest.rb', line 226

def hash
  [id, display_name, display_name_long, avatar_url, language, country, phone, email, total_reservations, total_revenue, last_stayed_at, first_stayed_at, created_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



185
186
187
188
189
# File 'lib/repull/models/guest.rb', line 185

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



255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/repull/models/guest.rb', line 255

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



193
194
195
196
# File 'lib/repull/models/guest.rb', line 193

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