Class: WhatpulseSdk::UserResource

Inherits:
Object
  • Object
show all
Defined in:
lib/whatpulse-sdk/models/user_resource.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UserResource

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 162

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

  if attributes.key?(:'username')
    self.username = attributes[:'username']
  else
    self.username = nil
  end

  if attributes.key?(:'date_joined')
    self.date_joined = attributes[:'date_joined']
  else
    self.date_joined = nil
  end

  if attributes.key?(:'first_pulse_date')
    self.first_pulse_date = attributes[:'first_pulse_date']
  else
    self.first_pulse_date = nil
  end

  if attributes.key?(:'last_pulse_date')
    self.last_pulse_date = attributes[:'last_pulse_date']
  else
    self.last_pulse_date = nil
  end

  if attributes.key?(:'pulses')
    self.pulses = attributes[:'pulses']
  else
    self.pulses = nil
  end

  if attributes.key?(:'team_id')
    self.team_id = attributes[:'team_id']
  else
    self.team_id = nil
  end

  if attributes.key?(:'team_is_manager')
    self.team_is_manager = attributes[:'team_is_manager']
  else
    self.team_is_manager = nil
  end

  if attributes.key?(:'country_id')
    self.country_id = attributes[:'country_id']
  else
    self.country_id = nil
  end

  if attributes.key?(:'is_premium')
    self.is_premium = attributes[:'is_premium']
  else
    self.is_premium = nil
  end

  if attributes.key?(:'referrals')
    self.referrals = attributes[:'referrals']
  else
    self.referrals = nil
  end

  if attributes.key?(:'last_referral_date')
    self.last_referral_date = attributes[:'last_referral_date']
  else
    self.last_referral_date = nil
  end

  if attributes.key?(:'avatar')
    self.avatar = attributes[:'avatar']
  else
    self.avatar = nil
  end

  if attributes.key?(:'totals')
    self.totals = attributes[:'totals']
  else
    self.totals = nil
  end

  if attributes.key?(:'ranks')
    self.ranks = attributes[:'ranks']
  else
    self.ranks = nil
  end

  if attributes.key?(:'include_in_rankings')
    self.include_in_rankings = attributes[:'include_in_rankings']
  else
    self.include_in_rankings = nil
  end

  if attributes.key?(:'distance_system')
    self.distance_system = attributes[:'distance_system']
  else
    self.distance_system = nil
  end

  if attributes.key?(:'last_pulse')
    self.last_pulse = attributes[:'last_pulse']
  else
    self.last_pulse = nil
  end
end

Instance Attribute Details

#avatarObject

The user’s avatar URL.



55
56
57
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 55

def avatar
  @avatar
end

#country_idObject

The country ID of the user, used for geographical information.



43
44
45
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 43

def country_id
  @country_id
end

#date_joinedObject

The date the user joined WhatPulse, in ISO 8601 format.



25
26
27
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 25

def date_joined
  @date_joined
end

#distance_systemObject

The system used for measuring distance (miles or kilometers).



65
66
67
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 65

def distance_system
  @distance_system
end

#first_pulse_dateObject

The date of the first pulse, in ISO 8601 format.



28
29
30
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 28

def first_pulse_date
  @first_pulse_date
end

#idObject

The unique identifier for the user.



19
20
21
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 19

def id
  @id
end

#include_in_rankingsObject

Whether the user is included in rankings.



62
63
64
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 62

def include_in_rankings
  @include_in_rankings
end

#is_premiumObject

Whether the user is an active premium member.



46
47
48
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 46

def is_premium
  @is_premium
end

#last_pulseObject

Returns the value of attribute last_pulse.



67
68
69
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 67

def last_pulse
  @last_pulse
end

#last_pulse_dateObject

The date of the last pulse, in ISO 8601 format.



31
32
33
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 31

def last_pulse_date
  @last_pulse_date
end

#last_referral_dateObject

The date of the last referral, in ISO 8601 format.



52
53
54
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 52

def last_referral_date
  @last_referral_date
end

#pulsesObject

The total number of pulses sent by the user.



34
35
36
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 34

def pulses
  @pulses
end

#ranksObject

Returns the value of attribute ranks.



59
60
61
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 59

def ranks
  @ranks
end

#referralsObject

The number of referrals the user has made.



49
50
51
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 49

def referrals
  @referrals
end

#team_idObject

The ID of the team the user is part of, if any.



37
38
39
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 37

def team_id
  @team_id
end

#team_is_managerObject

Whether the user is a manager of their team.



40
41
42
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 40

def team_is_manager
  @team_is_manager
end

#totalsObject

Returns the value of attribute totals.



57
58
59
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 57

def totals
  @totals
end

#usernameObject

The username of the user.



22
23
24
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 22

def username
  @username
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 561

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = WhatpulseSdk.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



116
117
118
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 116

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



121
122
123
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 121

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 92

def self.attribute_map
  {
    :'id' => :'id',
    :'username' => :'username',
    :'date_joined' => :'date_joined',
    :'first_pulse_date' => :'first_pulse_date',
    :'last_pulse_date' => :'last_pulse_date',
    :'pulses' => :'pulses',
    :'team_id' => :'team_id',
    :'team_is_manager' => :'team_is_manager',
    :'country_id' => :'country_id',
    :'is_premium' => :'is_premium',
    :'referrals' => :'referrals',
    :'last_referral_date' => :'last_referral_date',
    :'avatar' => :'avatar',
    :'totals' => :'totals',
    :'ranks' => :'ranks',
    :'include_in_rankings' => :'include_in_rankings',
    :'distance_system' => :'distance_system',
    :'last_pulse' => :'last_pulse'
  }
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



537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 537

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



150
151
152
153
154
155
156
157
158
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 150

def self.openapi_nullable
  Set.new([
    :'first_pulse_date',
    :'last_pulse_date',
    :'team_id',
    :'last_referral_date',
    :'avatar',
  ])
end

.openapi_typesObject

Attribute type mapping.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 126

def self.openapi_types
  {
    :'id' => :'Integer',
    :'username' => :'String',
    :'date_joined' => :'String',
    :'first_pulse_date' => :'String',
    :'last_pulse_date' => :'String',
    :'pulses' => :'Integer',
    :'team_id' => :'Integer',
    :'team_is_manager' => :'Boolean',
    :'country_id' => :'Integer',
    :'is_premium' => :'Boolean',
    :'referrals' => :'Integer',
    :'last_referral_date' => :'String',
    :'avatar' => :'String',
    :'totals' => :'UserResourceTotals',
    :'ranks' => :'UserResourceRanks',
    :'include_in_rankings' => :'Boolean',
    :'distance_system' => :'String',
    :'last_pulse' => :'UserResourceLastPulse'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 499

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      username == o.username &&
      date_joined == o.date_joined &&
      first_pulse_date == o.first_pulse_date &&
      last_pulse_date == o.last_pulse_date &&
      pulses == o.pulses &&
      team_id == o.team_id &&
      team_is_manager == o.team_is_manager &&
      country_id == o.country_id &&
      is_premium == o.is_premium &&
      referrals == o.referrals &&
      last_referral_date == o.last_referral_date &&
      avatar == o.avatar &&
      totals == o.totals &&
      ranks == o.ranks &&
      include_in_rankings == o.include_in_rankings &&
      distance_system == o.distance_system &&
      last_pulse == o.last_pulse
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



632
633
634
635
636
637
638
639
640
641
642
643
644
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 632

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


524
525
526
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 524

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



530
531
532
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 530

def hash
  [id, username, date_joined, first_pulse_date, last_pulse_date, pulses, team_id, team_is_manager, country_id, is_premium, referrals, last_referral_date, avatar, totals, ranks, include_in_rankings, distance_system, last_pulse].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 287

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  if @username.nil?
    invalid_properties.push('invalid value for "username", username cannot be nil.')
  end

  if @date_joined.nil?
    invalid_properties.push('invalid value for "date_joined", date_joined cannot be nil.')
  end

  if @pulses.nil?
    invalid_properties.push('invalid value for "pulses", pulses cannot be nil.')
  end

  if @team_is_manager.nil?
    invalid_properties.push('invalid value for "team_is_manager", team_is_manager cannot be nil.')
  end

  if @country_id.nil?
    invalid_properties.push('invalid value for "country_id", country_id cannot be nil.')
  end

  if @is_premium.nil?
    invalid_properties.push('invalid value for "is_premium", is_premium cannot be nil.')
  end

  if @referrals.nil?
    invalid_properties.push('invalid value for "referrals", referrals cannot be nil.')
  end

  if @totals.nil?
    invalid_properties.push('invalid value for "totals", totals cannot be nil.')
  end

  if @ranks.nil?
    invalid_properties.push('invalid value for "ranks", ranks cannot be nil.')
  end

  if @include_in_rankings.nil?
    invalid_properties.push('invalid value for "include_in_rankings", include_in_rankings cannot be nil.')
  end

  if @distance_system.nil?
    invalid_properties.push('invalid value for "distance_system", distance_system cannot be nil.')
  end

  if @last_pulse.nil?
    invalid_properties.push('invalid value for "last_pulse", last_pulse cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



608
609
610
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 608

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



614
615
616
617
618
619
620
621
622
623
624
625
626
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 614

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

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



602
603
604
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 602

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/whatpulse-sdk/models/user_resource.rb', line 347

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @username.nil?
  return false if @date_joined.nil?
  return false if @pulses.nil?
  return false if @team_is_manager.nil?
  return false if @country_id.nil?
  return false if @is_premium.nil?
  return false if @referrals.nil?
  return false if @totals.nil?
  return false if @ranks.nil?
  return false if @include_in_rankings.nil?
  return false if @distance_system.nil?
  distance_system_validator = EnumAttributeValidator.new('String', ["metric", "imperial", "auto"])
  return false unless distance_system_validator.valid?(@distance_system)
  return false if @last_pulse.nil?
  true
end