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



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

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.



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

def bank_accounts
  @bank_accounts
end

#classificationObject

Employees classification



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

def classification
  @classification
end

#date_of_birthObject

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



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

def date_of_birth
  @date_of_birth
end

#emailObject

The email address for the employee



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

def email
  @email
end

#employee_group_nameObject

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



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

def employee_group_name
  @employee_group_name
end

#employee_idObject

Xero unique identifier for an Employee



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

def employee_id
  @employee_id
end

#first_nameObject

First name of employee



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

def first_name
  @first_name
end

#genderObject

The employee’s gender. See Employee Gender



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

def gender
  @gender
end

#home_addressObject

Returns the value of attribute home_address.



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

def home_address
  @home_address
end

#is_authorised_to_approve_leaveObject

Authorised to approve other employees' leave requests



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

def is_authorised_to_approve_leave
  @is_authorised_to_approve_leave
end

#is_authorised_to_approve_timesheetsObject

Authorised to approve timesheets



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

def is_authorised_to_approve_timesheets
  @is_authorised_to_approve_timesheets
end

#job_titleObject

JobTitle of the employee



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

def job_title
  @job_title
end

#last_nameObject

Last name of employee



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

def last_name
  @last_name
end

#leave_balancesObject

Returns the value of attribute leave_balances.



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

def leave_balances
  @leave_balances
end

#leave_linesObject

Returns the value of attribute leave_lines.



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

def leave_lines
  @leave_lines
end

#middle_namesObject

Middle name(s) of the employee



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

def middle_names
  @middle_names
end

#mobileObject

Employee mobile number



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

def mobile
  @mobile
end

#opening_balancesObject

Returns the value of attribute opening_balances.



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

def opening_balances
  @opening_balances
end

#ordinary_earnings_rate_idObject

Xero unique identifier for earnings rate



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

def ordinary_earnings_rate_id
  @ordinary_earnings_rate_id
end

#pay_templateObject

Returns the value of attribute pay_template.



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

def pay_template
  @pay_template
end

#payroll_calendar_idObject

Xero unique identifier for payroll calendar for the employee



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

def payroll_calendar_id
  @payroll_calendar_id
end

#phoneObject

Employee phone number



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

def phone
  @phone
end

#start_dateObject

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



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

def start_date
  @start_date
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#super_membershipsObject

Returns the value of attribute super_memberships.



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

def super_memberships
  @super_memberships
end

#tax_declarationObject

Returns the value of attribute tax_declaration.



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

def tax_declaration
  @tax_declaration
end

#termination_dateObject

Employee Termination Date (YYYY-MM-DD)



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

def termination_date
  @termination_date
end

#titleObject

Title of the employee



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

def title
  @title
end

#twitter_user_nameObject

Employee’s twitter name



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

def twitter_user_name
  @twitter_user_name
end

#updated_date_utcObject

Last modified timestamp



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

def updated_date_utc
  @updated_date_utc
end

#validation_errorsObject

Displays array of validation error messages from the API



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

def validation_errors
  @validation_errors
end

Class Method Details

.attribute_mapObject

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



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

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



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

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

.openapi_typesObject

Attribute type mapping.



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

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



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

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



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

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) ⇒ 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



551
552
553
554
555
556
557
558
559
560
561
562
563
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 551

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



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

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


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

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



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

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



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

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

customized data_parser



566
567
568
569
# File 'lib/xero-ruby/models/payroll_au/employee.rb', line 566

def parse_date(datestring)
  seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
  return Time.at(seconds_since_epoch).strftime('%Y-%m-%dT%l:%M:%S%z').to_s
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



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

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



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

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



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

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



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

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