Class: QwilAPI::UserSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/qwil_api/models/user_serializer.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UserSerializer

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
284
285
286
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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/qwil_api/models/user_serializer.rb', line 222

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}

  if attributes.has_key?(:'url')
    self.url = attributes[:'url']
  end

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

  if attributes.has_key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.has_key?(:'first_name')
    self.first_name = attributes[:'first_name']
  end

  if attributes.has_key?(:'last_name')
    self.last_name = attributes[:'last_name']
  end

  if attributes.has_key?(:'business_name')
    self.business_name = attributes[:'business_name']
  end

  if attributes.has_key?(:'contractor_type')
    self.contractor_type = attributes[:'contractor_type']
  end

  if attributes.has_key?(:'default_account')
    self. = attributes[:'default_account']
  end

  if attributes.has_key?(:'kyc_status')
    self.kyc_status = attributes[:'kyc_status']
  end

  if attributes.has_key?(:'tax_savings_account')
    self. = attributes[:'tax_savings_account']
  end

  if attributes.has_key?(:'tax_savings_percent')
    self.tax_savings_percent = attributes[:'tax_savings_percent']
  end

  if attributes.has_key?(:'use_plaid')
    self.use_plaid = attributes[:'use_plaid']
  end

  if attributes.has_key?(:'use_income_requests')
    self.use_income_requests = attributes[:'use_income_requests']
  end

  if attributes.has_key?(:'use_tax_savings')
    self.use_tax_savings = attributes[:'use_tax_savings']
  end

  if attributes.has_key?(:'is_auto_cashout_enabled')
    self.is_auto_cashout_enabled = attributes[:'is_auto_cashout_enabled']
  end

  if attributes.has_key?(:'income')
    self.income = attributes[:'income']
  end

  if attributes.has_key?(:'cashouts')
    self.cashouts = attributes[:'cashouts']
  end

  if attributes.has_key?(:'receivables')
    self.receivables = attributes[:'receivables']
  end

  if attributes.has_key?(:'accounts')
    self.accounts = attributes[:'accounts']
  end

  if attributes.has_key?(:'administered_platforms')
    self.administered_platforms = attributes[:'administered_platforms']
  end

  if attributes.has_key?(:'cashout_available')
    self.cashout_available = attributes[:'cashout_available']
  end

  if attributes.has_key?(:'unpaid_income')
    self.unpaid_income = attributes[:'unpaid_income']
  end

  if attributes.has_key?(:'tax_savings')
    self.tax_savings = attributes[:'tax_savings']
  end

  if attributes.has_key?(:'platform')
    self.platform = attributes[:'platform']
  end

  if attributes.has_key?(:'platform_summary')
    self.platform_summary = attributes[:'platform_summary']
  end

  if attributes.has_key?(:'platform_membership_requests')
    self.platform_membership_requests = attributes[:'platform_membership_requests']
  end

  if attributes.has_key?(:'income_requests')
    self.income_requests = attributes[:'income_requests']
  end

  if attributes.has_key?(:'is_platform_admin')
    self.is_platform_admin = attributes[:'is_platform_admin']
  end

  if attributes.has_key?(:'has_password')
    self.has_password = attributes[:'has_password']
  end

  if attributes.has_key?(:'cashout_fee_percent')
    self.cashout_fee_percent = attributes[:'cashout_fee_percent']
  end

  if attributes.has_key?(:'personal_information')
    self.personal_information = attributes[:'personal_information']
  end

  if attributes.has_key?(:'calculate_cashout_available')
    self.calculate_cashout_available = attributes[:'calculate_cashout_available']
  end

  if attributes.has_key?(:'managers')
    if (value = attributes[:'managers']).is_a?(Array)
      self.managers = value
    end
  end

end

Instance Attribute Details

#accountsObject

URL of the endpoint describing the User’s Accounts.



79
80
81
# File 'lib/qwil_api/models/user_serializer.rb', line 79

def accounts
  @accounts
end

#administered_platformsObject

The platforms that this User is an Admin for.



82
83
84
# File 'lib/qwil_api/models/user_serializer.rb', line 82

def administered_platforms
  @administered_platforms
end

#business_nameObject

Business name. Only use this field if this user is a business entity.



41
42
43
# File 'lib/qwil_api/models/user_serializer.rb', line 41

def business_name
  @business_name
end

#calculate_cashout_availableObject

Calculate what fees would be charged for a specific Cashout amount.



116
117
118
# File 'lib/qwil_api/models/user_serializer.rb', line 116

def calculate_cashout_available
  @calculate_cashout_available
end

#cashout_availableObject

The dollar amount available for Cashout.



85
86
87
# File 'lib/qwil_api/models/user_serializer.rb', line 85

def cashout_available
  @cashout_available
end

#cashout_fee_percentObject

Percentage amount charged for each Cashout.



111
112
113
# File 'lib/qwil_api/models/user_serializer.rb', line 111

def cashout_fee_percent
  @cashout_fee_percent
end

#cashoutsObject

URL of the endpoint describing the User’s Cashouts.



73
74
75
# File 'lib/qwil_api/models/user_serializer.rb', line 73

def cashouts
  @cashouts
end

#contractor_typeObject

Returns the value of attribute contractor_type.



43
44
45
# File 'lib/qwil_api/models/user_serializer.rb', line 43

def contractor_type
  @contractor_type
end

#default_accountObject

Default account to use for payment of unpaid income.



46
47
48
# File 'lib/qwil_api/models/user_serializer.rb', line 46

def 
  @default_account
end

#emailObject

Returns the value of attribute email.



29
30
31
# File 'lib/qwil_api/models/user_serializer.rb', line 29

def email
  @email
end

#first_nameObject

First name, if the user is an individual. Leave blank if this user is a company.



35
36
37
# File 'lib/qwil_api/models/user_serializer.rb', line 35

def first_name
  @first_name
end

#has_passwordObject

Flag specifying if the User has set their password.



108
109
110
# File 'lib/qwil_api/models/user_serializer.rb', line 108

def has_password
  @has_password
end

#incomeObject

URL of the endpoint describing the User’s Income.



70
71
72
# File 'lib/qwil_api/models/user_serializer.rb', line 70

def income
  @income
end

#income_requestsObject

URL of the list of income requests.



102
103
104
# File 'lib/qwil_api/models/user_serializer.rb', line 102

def income_requests
  @income_requests
end

#is_auto_cashout_enabledObject

Whether or not all income should be immediately cashed out for this user.



67
68
69
# File 'lib/qwil_api/models/user_serializer.rb', line 67

def is_auto_cashout_enabled
  @is_auto_cashout_enabled
end

#is_platform_adminObject

Flag specifying if the User has access to the Platform Admin UI.



105
106
107
# File 'lib/qwil_api/models/user_serializer.rb', line 105

def is_platform_admin
  @is_platform_admin
end

#kyc_statusObject

Status of the User’s KYC check.



49
50
51
# File 'lib/qwil_api/models/user_serializer.rb', line 49

def kyc_status
  @kyc_status
end

#last_nameObject

Last name, if the user is an individual. Leave blank if this user is a company.



38
39
40
# File 'lib/qwil_api/models/user_serializer.rb', line 38

def last_name
  @last_name
end

#managersObject

Returns the value of attribute managers.



118
119
120
# File 'lib/qwil_api/models/user_serializer.rb', line 118

def managers
  @managers
end

#nameObject

DEPRECATED: The full name of the contractor. Use first_name/last_name instead.



32
33
34
# File 'lib/qwil_api/models/user_serializer.rb', line 32

def name
  @name
end

#personal_informationObject

Returns the value of attribute personal_information.



113
114
115
# File 'lib/qwil_api/models/user_serializer.rb', line 113

def personal_information
  @personal_information
end

#platformObject

URL of the platform that the User is contracting for.



94
95
96
# File 'lib/qwil_api/models/user_serializer.rb', line 94

def platform
  @platform
end

#platform_membership_requestsObject

URL of the list of platform membership requests.



99
100
101
# File 'lib/qwil_api/models/user_serializer.rb', line 99

def platform_membership_requests
  @platform_membership_requests
end

#platform_summaryObject

Returns the value of attribute platform_summary.



96
97
98
# File 'lib/qwil_api/models/user_serializer.rb', line 96

def platform_summary
  @platform_summary
end

#receivablesObject

URL of the endpoint describing the User’s Cashouts.



76
77
78
# File 'lib/qwil_api/models/user_serializer.rb', line 76

def receivables
  @receivables
end

#tax_savingsObject

URL for tax savings information for the given User.



91
92
93
# File 'lib/qwil_api/models/user_serializer.rb', line 91

def tax_savings
  @tax_savings
end

#tax_savings_accountObject

Account to use for tax savings.



52
53
54
# File 'lib/qwil_api/models/user_serializer.rb', line 52

def 
  @tax_savings_account
end

#tax_savings_percentObject

The percent of income to be withheld for tax savings purposes.



55
56
57
# File 'lib/qwil_api/models/user_serializer.rb', line 55

def tax_savings_percent
  @tax_savings_percent
end

#unpaid_incomeObject

The dollar amount of Income not yet paid (Cashout/Rebate).



88
89
90
# File 'lib/qwil_api/models/user_serializer.rb', line 88

def unpaid_income
  @unpaid_income
end

#urlObject

Returns the value of attribute url.



27
28
29
# File 'lib/qwil_api/models/user_serializer.rb', line 27

def url
  @url
end

#use_income_requestsObject

Feature flag specifying if IncomeRequests should be enabled for this user.



61
62
63
# File 'lib/qwil_api/models/user_serializer.rb', line 61

def use_income_requests
  @use_income_requests
end

#use_plaidObject

Feature flag specifying if Plaid integration should be used.



58
59
60
# File 'lib/qwil_api/models/user_serializer.rb', line 58

def use_plaid
  @use_plaid
end

#use_tax_savingsObject

Feature flag specifying if tax savings should be enabled.



64
65
66
# File 'lib/qwil_api/models/user_serializer.rb', line 64

def use_tax_savings
  @use_tax_savings
end

Class Method Details

.attribute_mapObject

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



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
# File 'lib/qwil_api/models/user_serializer.rb', line 143

def self.attribute_map
  {
    :'url' => :'url',
    :'email' => :'email',
    :'name' => :'name',
    :'first_name' => :'first_name',
    :'last_name' => :'last_name',
    :'business_name' => :'business_name',
    :'contractor_type' => :'contractor_type',
    :'default_account' => :'default_account',
    :'kyc_status' => :'kyc_status',
    :'tax_savings_account' => :'tax_savings_account',
    :'tax_savings_percent' => :'tax_savings_percent',
    :'use_plaid' => :'use_plaid',
    :'use_income_requests' => :'use_income_requests',
    :'use_tax_savings' => :'use_tax_savings',
    :'is_auto_cashout_enabled' => :'is_auto_cashout_enabled',
    :'income' => :'income',
    :'cashouts' => :'cashouts',
    :'receivables' => :'receivables',
    :'accounts' => :'accounts',
    :'administered_platforms' => :'administered_platforms',
    :'cashout_available' => :'cashout_available',
    :'unpaid_income' => :'unpaid_income',
    :'tax_savings' => :'tax_savings',
    :'platform' => :'platform',
    :'platform_summary' => :'platform_summary',
    :'platform_membership_requests' => :'platform_membership_requests',
    :'income_requests' => :'income_requests',
    :'is_platform_admin' => :'is_platform_admin',
    :'has_password' => :'has_password',
    :'cashout_fee_percent' => :'cashout_fee_percent',
    :'personal_information' => :'personal_information',
    :'calculate_cashout_available' => :'calculate_cashout_available',
    :'managers' => :'managers'
  }
end

.swagger_typesObject

Attribute type mapping.



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
# File 'lib/qwil_api/models/user_serializer.rb', line 182

def self.swagger_types
  {
    :'url' => :'String',
    :'email' => :'String',
    :'name' => :'String',
    :'first_name' => :'String',
    :'last_name' => :'String',
    :'business_name' => :'String',
    :'contractor_type' => :'String',
    :'default_account' => :'String',
    :'kyc_status' => :'String',
    :'tax_savings_account' => :'String',
    :'tax_savings_percent' => :'String',
    :'use_plaid' => :'BOOLEAN',
    :'use_income_requests' => :'BOOLEAN',
    :'use_tax_savings' => :'BOOLEAN',
    :'is_auto_cashout_enabled' => :'BOOLEAN',
    :'income' => :'String',
    :'cashouts' => :'String',
    :'receivables' => :'String',
    :'accounts' => :'String',
    :'administered_platforms' => :'String',
    :'cashout_available' => :'String',
    :'unpaid_income' => :'String',
    :'tax_savings' => :'String',
    :'platform' => :'String',
    :'platform_summary' => :'PlatformSummarySerializer',
    :'platform_membership_requests' => :'String',
    :'income_requests' => :'String',
    :'is_platform_admin' => :'String',
    :'has_password' => :'String',
    :'cashout_fee_percent' => :'String',
    :'personal_information' => :'PersonalInformationSerializer',
    :'calculate_cashout_available' => :'String',
    :'managers' => :'Array<String>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
# File 'lib/qwil_api/models/user_serializer.rb', line 436

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      url == o.url &&
      email == o.email &&
      name == o.name &&
      first_name == o.first_name &&
      last_name == o.last_name &&
      business_name == o.business_name &&
      contractor_type == o.contractor_type &&
       == o. &&
      kyc_status == o.kyc_status &&
       == o. &&
      tax_savings_percent == o.tax_savings_percent &&
      use_plaid == o.use_plaid &&
      use_income_requests == o.use_income_requests &&
      use_tax_savings == o.use_tax_savings &&
      is_auto_cashout_enabled == o.is_auto_cashout_enabled &&
      income == o.income &&
      cashouts == o.cashouts &&
      receivables == o.receivables &&
      accounts == o.accounts &&
      administered_platforms == o.administered_platforms &&
      cashout_available == o.cashout_available &&
      unpaid_income == o.unpaid_income &&
      tax_savings == o.tax_savings &&
      platform == o.platform &&
      platform_summary == o.platform_summary &&
      platform_membership_requests == o.platform_membership_requests &&
      income_requests == o.income_requests &&
      is_platform_admin == o.is_platform_admin &&
      has_password == o.has_password &&
      cashout_fee_percent == o.cashout_fee_percent &&
      personal_information == o.personal_information &&
      calculate_cashout_available == o.calculate_cashout_available &&
      managers == o.managers
end

#_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



510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
# File 'lib/qwil_api/models/user_serializer.rb', line 510

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.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 =~ /^(true|t|yes|y|1)$/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
    temp_model = QwilAPI.const_get(type).new
    temp_model.build_from_hash(value)
  end
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



576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/qwil_api/models/user_serializer.rb', line 576

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

#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



489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/qwil_api/models/user_serializer.rb', line 489

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


476
477
478
# File 'lib/qwil_api/models/user_serializer.rb', line 476

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



482
483
484
# File 'lib/qwil_api/models/user_serializer.rb', line 482

def hash
  [url, email, name, first_name, last_name, business_name, contractor_type, , kyc_status, , tax_savings_percent, use_plaid, use_income_requests, use_tax_savings, is_auto_cashout_enabled, income, cashouts, receivables, accounts, administered_platforms, cashout_available, unpaid_income, tax_savings, platform, platform_summary, platform_membership_requests, income_requests, is_platform_admin, has_password, cashout_fee_percent, personal_information, calculate_cashout_available, managers].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properies with the reasons



366
367
368
369
# File 'lib/qwil_api/models/user_serializer.rb', line 366

def list_invalid_properties
  invalid_properties = Array.new
  return 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



556
557
558
# File 'lib/qwil_api/models/user_serializer.rb', line 556

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



562
563
564
565
566
567
568
569
570
# File 'lib/qwil_api/models/user_serializer.rb', line 562

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



550
551
552
# File 'lib/qwil_api/models/user_serializer.rb', line 550

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



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/qwil_api/models/user_serializer.rb', line 373

def valid?
  return false if @url.nil?
  return false if @email.nil?
  return false if @name.nil?
  return false if @first_name.nil?
  return false if @last_name.nil?
  return false if @business_name.nil?
  return false if @contractor_type.nil?
  contractor_type_validator = EnumAttributeValidator.new('String', ["INDIVIDUAL", "BUSINESS"])
  return false unless contractor_type_validator.valid?(@contractor_type)
  return false if @default_account.nil?
  return false if @kyc_status.nil?
  kyc_status_validator = EnumAttributeValidator.new('String', ["NOT_CHECKED", "PENDING", "APPROVED", "DENIED"])
  return false unless kyc_status_validator.valid?(@kyc_status)
  return false if @tax_savings_account.nil?
  return false if @tax_savings_percent.nil?
  return false if @use_plaid.nil?
  return false if @use_income_requests.nil?
  return false if @use_tax_savings.nil?
  return false if @is_auto_cashout_enabled.nil?
  return false if @income.nil?
  return false if @cashouts.nil?
  return false if @receivables.nil?
  return false if @accounts.nil?
  return false if @administered_platforms.nil?
  return false if @cashout_available.nil?
  return false if @unpaid_income.nil?
  return false if @tax_savings.nil?
  return false if @platform.nil?
  return false if @platform_summary.nil?
  return false if @platform_membership_requests.nil?
  return false if @income_requests.nil?
  return false if @is_platform_admin.nil?
  return false if @has_password.nil?
  return false if @cashout_fee_percent.nil?
  return false if @personal_information.nil?
  return false if @calculate_cashout_available.nil?
  return false if @managers.nil?
  return true
end