Class: XeroRuby::PayrollAu::Employee

Inherits:
Object
  • Object
show all
Defined in:
lib/xero-ruby/models/payroll_au/employee.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Constant Summary collapse

N =
"N".freeze
M =
"M".freeze
F =
"F".freeze
I =
"I".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Employee

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
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
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 214

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollAu::Employee` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollAu::Employee`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#bank_accountsObject

Returns the value of attribute bank_accounts.



87
88
89
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 87

def bank_accounts
  @bank_accounts
end

#classificationObject

Employees classification



69
70
71
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 69

def classification
  @classification
end

#date_of_birthObject

Date of birth of the employee (YYYY-MM-DD)



26
27
28
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 26

def date_of_birth
  @date_of_birth
end

#emailObject

The email address for the employee



41
42
43
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 41

def email
  @email
end

#employee_group_nameObject

The Employee Group allows you to report on payroll expenses and liabilities for each group of employees



78
79
80
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 78

def employee_group_name
  @employee_group_name
end

#employee_idObject

Xero unique identifier for an Employee



81
82
83
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 81

def employee_id
  @employee_id
end

#first_nameObject

First name of employee



20
21
22
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 20

def first_name
  @first_name
end

#genderObject

The employee’s gender. See Employee Gender



44
45
46
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 44

def gender
  @gender
end

#home_addressObject

Returns the value of attribute home_address.



29
30
31
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 29

def home_address
  @home_address
end

#is_authorised_to_approve_leaveObject

Authorised to approve other employees’ leave requests



60
61
62
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 60

def is_authorised_to_approve_leave
  @is_authorised_to_approve_leave
end

#is_authorised_to_approve_timesheetsObject

Authorised to approve timesheets



63
64
65
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 63

def is_authorised_to_approve_timesheets
  @is_authorised_to_approve_timesheets
end

#job_titleObject

JobTitle of the employee



66
67
68
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 66

def job_title
  @job_title
end

#last_nameObject

Last name of employee



23
24
25
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 23

def last_name
  @last_name
end

#leave_balancesObject

Returns the value of attribute leave_balances.



99
100
101
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 99

def leave_balances
  @leave_balances
end

#leave_linesObject

Returns the value of attribute leave_lines.



102
103
104
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 102

def leave_lines
  @leave_lines
end

#middle_namesObject

Middle name(s) of the employee



38
39
40
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 38

def middle_names
  @middle_names
end

#mobileObject

Employee mobile number



54
55
56
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 54

def mobile
  @mobile
end

#opening_balancesObject

Returns the value of attribute opening_balances.



93
94
95
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 93

def opening_balances
  @opening_balances
end

#ordinary_earnings_rate_idObject

Xero unique identifier for earnings rate



72
73
74
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 72

def ordinary_earnings_rate_id
  @ordinary_earnings_rate_id
end

#pay_templateObject

Returns the value of attribute pay_template.



90
91
92
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 90

def pay_template
  @pay_template
end

#payroll_calendar_idObject

Xero unique identifier for payroll calendar for the employee



75
76
77
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 75

def payroll_calendar_id
  @payroll_calendar_id
end

#phoneObject

Employee phone number



51
52
53
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 51

def phone
  @phone
end

#start_dateObject

Start date for an employee (YYYY-MM-DD)



32
33
34
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 32

def start_date
  @start_date
end

#statusObject

Returns the value of attribute status.



108
109
110
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 108

def status
  @status
end

#super_membershipsObject

Returns the value of attribute super_memberships.



105
106
107
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 105

def super_memberships
  @super_memberships
end

#tax_declarationObject

Returns the value of attribute tax_declaration.



96
97
98
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 96

def tax_declaration
  @tax_declaration
end

#termination_dateObject

Employee Termination Date (YYYY-MM-DD)



84
85
86
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 84

def termination_date
  @termination_date
end

#titleObject

Title of the employee



35
36
37
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 35

def title
  @title
end

#twitter_user_nameObject

Employee’s twitter name



57
58
59
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 57

def twitter_user_name
  @twitter_user_name
end

#updated_date_utcObject

Last modified timestamp



111
112
113
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 111

def updated_date_utc
  @updated_date_utc
end

#validation_errorsObject

Displays array of validation error messages from the API



114
115
116
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 114

def validation_errors
  @validation_errors
end

Class Method Details

.attribute_mapObject

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



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
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 139

def self.attribute_map
  {
    :'first_name' => :'FirstName',
    :'last_name' => :'LastName',
    :'date_of_birth' => :'DateOfBirth',
    :'home_address' => :'HomeAddress',
    :'start_date' => :'StartDate',
    :'title' => :'Title',
    :'middle_names' => :'MiddleNames',
    :'email' => :'Email',
    :'gender' => :'Gender',
    :'phone' => :'Phone',
    :'mobile' => :'Mobile',
    :'twitter_user_name' => :'TwitterUserName',
    :'is_authorised_to_approve_leave' => :'IsAuthorisedToApproveLeave',
    :'is_authorised_to_approve_timesheets' => :'IsAuthorisedToApproveTimesheets',
    :'job_title' => :'JobTitle',
    :'classification' => :'Classification',
    :'ordinary_earnings_rate_id' => :'OrdinaryEarningsRateID',
    :'payroll_calendar_id' => :'PayrollCalendarID',
    :'employee_group_name' => :'EmployeeGroupName',
    :'employee_id' => :'EmployeeID',
    :'termination_date' => :'TerminationDate',
    :'bank_accounts' => :'BankAccounts',
    :'pay_template' => :'PayTemplate',
    :'opening_balances' => :'OpeningBalances',
    :'tax_declaration' => :'TaxDeclaration',
    :'leave_balances' => :'LeaveBalances',
    :'leave_lines' => :'LeaveLines',
    :'super_memberships' => :'SuperMemberships',
    :'status' => :'Status',
    :'updated_date_utc' => :'UpdatedDateUTC',
    :'validation_errors' => :'ValidationErrors'
  }
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



455
456
457
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 455

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_typesObject

Attribute type mapping.



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
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 176

def self.openapi_types
  {
    :'first_name' => :'String',
    :'last_name' => :'String',
    :'date_of_birth' => :'Date',
    :'home_address' => :'HomeAddress',
    :'start_date' => :'Date',
    :'title' => :'String',
    :'middle_names' => :'String',
    :'email' => :'String',
    :'gender' => :'String',
    :'phone' => :'String',
    :'mobile' => :'String',
    :'twitter_user_name' => :'String',
    :'is_authorised_to_approve_leave' => :'Boolean',
    :'is_authorised_to_approve_timesheets' => :'Boolean',
    :'job_title' => :'String',
    :'classification' => :'String',
    :'ordinary_earnings_rate_id' => :'String',
    :'payroll_calendar_id' => :'String',
    :'employee_group_name' => :'String',
    :'employee_id' => :'String',
    :'termination_date' => :'Date',
    :'bank_accounts' => :'Array<BankAccount>',
    :'pay_template' => :'PayTemplate',
    :'opening_balances' => :'OpeningBalances',
    :'tax_declaration' => :'TaxDeclaration',
    :'leave_balances' => :'Array<LeaveBalance>',
    :'leave_lines' => :'Array<LeaveLine>',
    :'super_memberships' => :'Array<SuperMembership>',
    :'status' => :'EmployeeStatus',
    :'updated_date_utc' => :'DateTime',
    :'validation_errors' => :'Array<ValidationError>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 404

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      first_name == o.first_name &&
      last_name == o.last_name &&
      date_of_birth == o.date_of_birth &&
      home_address == o.home_address &&
      start_date == o.start_date &&
      title == o.title &&
      middle_names == o.middle_names &&
      email == o.email &&
      gender == o.gender &&
      phone == o.phone &&
      mobile == o.mobile &&
      twitter_user_name == o.twitter_user_name &&
      is_authorised_to_approve_leave == o.is_authorised_to_approve_leave &&
      is_authorised_to_approve_timesheets == o.is_authorised_to_approve_timesheets &&
      job_title == o.job_title &&
      classification == o.classification &&
      ordinary_earnings_rate_id == o.ordinary_earnings_rate_id &&
      payroll_calendar_id == o.payroll_calendar_id &&
      employee_group_name == o.employee_group_name &&
      employee_id == o.employee_id &&
      termination_date == o.termination_date &&
      bank_accounts == o.bank_accounts &&
      pay_template == o.pay_template &&
      opening_balances == o.opening_balances &&
      tax_declaration == o.tax_declaration &&
      leave_balances == o.leave_balances &&
      leave_lines == o.leave_lines &&
      super_memberships == o.super_memberships &&
      status == o.status &&
      updated_date_utc == o.updated_date_utc &&
      validation_errors == o.validation_errors
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



483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 483

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(parse_date(value))
  when :Date
    Date.parse(parse_date(value))
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BigDecimal
    BigDecimal(value.to_s)
  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
    XeroRuby::PayrollAu.const_get(type).build_from_hash(value)
  end
end

#_to_hash(value, downcase: false) ⇒ 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



556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 556

def _to_hash(value, downcase: false)
  if value.is_a?(Array)
    value.map do |v|
      v.to_hash(downcase: downcase)
    end
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash(downcase: downcase)
  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



462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 462

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if 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[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


442
443
444
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 442

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



448
449
450
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 448

def hash
  [first_name, last_name, date_of_birth, home_address, start_date, title, middle_names, email, gender, phone, mobile, twitter_user_name, is_authorised_to_approve_leave, is_authorised_to_approve_timesheets, job_title, classification, ordinary_earnings_rate_id, payroll_calendar_id, employee_group_name, employee_id, termination_date, bank_accounts, pay_template, opening_balances, tax_declaration, leave_balances, leave_lines, super_memberships, status, updated_date_utc, validation_errors].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 364

def list_invalid_properties
  invalid_properties = Array.new
  if @first_name.nil?
    invalid_properties.push('invalid value for "first_name", first_name cannot be nil.')
  end

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

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

  invalid_properties
end

#parse_date(datestring) ⇒ Object



572
573
574
575
576
577
578
579
580
581
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 572

def parse_date(datestring)
  if datestring.include?('Date')
    date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
    original, date, timezone = *date_pattern.match(datestring)
    date = (date.to_i / 1000)
    Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
  else # handle date 'types' for small subset of payroll API's
    Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
  end
end

#to_attributesObject

Returns the object in the form of hash with snake_case



548
549
550
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 548

def to_attributes
  to_hash(downcase: true)
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



530
531
532
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 530

def to_body
  to_hash
end

#to_hash(downcase: false) ⇒ Hash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



536
537
538
539
540
541
542
543
544
545
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 536

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

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



524
525
526
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 524

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



383
384
385
386
387
388
389
390
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 383

def valid?
  return false if @first_name.nil?
  return false if @last_name.nil?
  return false if @date_of_birth.nil?
  gender_validator = EnumAttributeValidator.new('String', ["N", "M", "F", "I"])
  return false unless gender_validator.valid?(@gender)
  true
end