xero-ruby 9.3.0 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xero-ruby/api/accounting_api.rb +178 -319
  3. data/lib/xero-ruby/api/files_api.rb +9 -2
  4. data/lib/xero-ruby/api/finance_api.rb +0 -299
  5. data/lib/xero-ruby/api/payroll_au_v2_api.rb +751 -0
  6. data/lib/xero-ruby/api/payroll_nz_api.rb +0 -86
  7. data/lib/xero-ruby/api/payroll_uk_api.rb +0 -86
  8. data/lib/xero-ruby/models/accounting/bank_transfer.rb +71 -1
  9. data/lib/xero-ruby/models/accounting/bank_transfer_delete.rb +244 -0
  10. data/lib/xero-ruby/models/accounting/bank_transfer_delete_by_url_param.rb +229 -0
  11. data/lib/xero-ruby/models/accounting/bank_transfers_delete.rb +224 -0
  12. data/lib/xero-ruby/models/accounting/contact.rb +27 -1
  13. data/lib/xero-ruby/models/accounting/credit_note.rb +11 -1
  14. data/lib/xero-ruby/models/accounting/invoice.rb +12 -2
  15. data/lib/xero-ruby/models/accounting/organisation.rb +25 -6
  16. data/lib/xero-ruby/models/accounting/overpayment.rb +21 -1
  17. data/lib/xero-ruby/models/accounting/payment.rb +11 -1
  18. data/lib/xero-ruby/models/accounting/prepayment.rb +31 -1
  19. data/lib/xero-ruby/models/accounting/tracking_reference.rb +277 -0
  20. data/lib/xero-ruby/models/accounting/user.rb +3 -2
  21. data/lib/xero-ruby/models/app_store/product.rb +4 -3
  22. data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +54 -4
  23. data/lib/xero-ruby/models/files/association.rb +21 -1
  24. data/lib/xero-ruby/models/finance/current_statement_response.rb +1 -1
  25. data/lib/xero-ruby/models/finance/data_source_response.rb +1 -31
  26. data/lib/xero-ruby/models/payroll_au/earnings_rate.rb +16 -1
  27. data/lib/xero-ruby/models/payroll_au/employee.rb +1 -13
  28. data/lib/xero-ruby/models/payroll_au/leave_line.rb +16 -1
  29. data/lib/xero-ruby/models/payroll_au/leave_type.rb +19 -4
  30. data/lib/xero-ruby/models/payroll_au/opening_balance_leave_line.rb +232 -0
  31. data/lib/xero-ruby/models/payroll_au/opening_balances.rb +1 -1
  32. data/lib/xero-ruby/models/payroll_au/tax_declaration.rb +14 -4
  33. data/lib/xero-ruby/models/payroll_au_v2/invalid_field.rb +232 -0
  34. data/lib/xero-ruby/models/payroll_au_v2/pagination.rb +252 -0
  35. data/lib/xero-ruby/models/payroll_au_v2/problem.rb +275 -0
  36. data/lib/xero-ruby/models/payroll_au_v2/timesheet.rb +361 -0
  37. data/lib/xero-ruby/models/payroll_au_v2/timesheet_line.rb +277 -0
  38. data/lib/xero-ruby/models/payroll_au_v2/timesheet_line_object.rb +242 -0
  39. data/lib/xero-ruby/models/payroll_au_v2/timesheet_object.rb +242 -0
  40. data/lib/xero-ruby/models/payroll_au_v2/timesheets.rb +244 -0
  41. data/lib/xero-ruby/models/payroll_nz/employee.rb +20 -0
  42. data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +29 -19
  43. data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +31 -11
  44. data/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb +5 -0
  45. data/lib/xero-ruby/models/payroll_nz/employment.rb +15 -0
  46. data/lib/xero-ruby/models/payroll_nz/leave_period.rb +35 -4
  47. data/lib/xero-ruby/models/payroll_nz/leave_type.rb +24 -4
  48. data/lib/xero-ruby/models/payroll_uk/contract_type.rb +38 -0
  49. data/lib/xero-ruby/models/payroll_uk/contracts.rb +297 -0
  50. data/lib/xero-ruby/models/payroll_uk/developmental_role_details.rb +267 -0
  51. data/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +5 -2
  52. data/lib/xero-ruby/models/payroll_uk/employee.rb +68 -4
  53. data/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb +5 -0
  54. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb +4 -2
  55. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb +5 -2
  56. data/lib/xero-ruby/models/payroll_uk/employment.rb +49 -52
  57. data/lib/xero-ruby/models/payroll_uk/employment_status.rb +37 -0
  58. data/lib/xero-ruby/models/payroll_uk/ni_category.rb +318 -0
  59. data/lib/xero-ruby/models/payroll_uk/ni_category_letter.rb +51 -0
  60. data/lib/xero-ruby/models/payroll_uk/ni_category_one_of.rb +264 -0
  61. data/lib/xero-ruby/models/payroll_uk/ni_category_one_of1.rb +257 -0
  62. data/lib/xero-ruby/version.rb +2 -2
  63. data/lib/xero-ruby.rb +22 -10
  64. data/spec/finance/api/finance_api_spec.rb +0 -53
  65. metadata +393 -391
  66. data/spec/finance/models/account_usage_response_spec.rb +0 -58
  67. data/spec/finance/models/account_usage_spec.rb +0 -112
  68. data/spec/finance/models/history_record_response_spec.rb +0 -64
  69. data/spec/finance/models/lock_history_model_spec.rb +0 -52
  70. data/spec/finance/models/lock_history_response_spec.rb +0 -52
  71. data/spec/finance/models/practice_response_spec.rb +0 -64
  72. data/spec/finance/models/report_history_model_spec.rb +0 -52
  73. data/spec/finance/models/report_history_response_spec.rb +0 -52
  74. data/spec/finance/models/user_activities_response_spec.rb +0 -52
  75. data/spec/finance/models/user_response_spec.rb +0 -106
@@ -34,6 +34,12 @@ module XeroRuby::PayrollNz
34
34
  # Shows whether the leave type is active or not
35
35
  attr_accessor :is_active
36
36
 
37
+ # The type of units to be paid for the leave type
38
+ attr_accessor :type_of_units
39
+
40
+ # The type of units to be accrued for the leave type
41
+ attr_accessor :type_of_units_to_accrue
42
+
37
43
  # Attribute mapping from ruby-style variable name to JSON key.
38
44
  def self.attribute_map
39
45
  {
@@ -42,7 +48,9 @@ module XeroRuby::PayrollNz
42
48
  :'is_paid_leave' => :'isPaidLeave',
43
49
  :'show_on_payslip' => :'showOnPayslip',
44
50
  :'updated_date_utc' => :'updatedDateUTC',
45
- :'is_active' => :'isActive'
51
+ :'is_active' => :'isActive',
52
+ :'type_of_units' => :'typeOfUnits',
53
+ :'type_of_units_to_accrue' => :'typeOfUnitsToAccrue'
46
54
  }
47
55
  end
48
56
 
@@ -54,7 +62,9 @@ module XeroRuby::PayrollNz
54
62
  :'is_paid_leave' => :'Boolean',
55
63
  :'show_on_payslip' => :'Boolean',
56
64
  :'updated_date_utc' => :'DateTime',
57
- :'is_active' => :'Boolean'
65
+ :'is_active' => :'Boolean',
66
+ :'type_of_units' => :'String',
67
+ :'type_of_units_to_accrue' => :'String'
58
68
  }
59
69
  end
60
70
 
@@ -96,6 +106,14 @@ module XeroRuby::PayrollNz
96
106
  if attributes.key?(:'is_active')
97
107
  self.is_active = attributes[:'is_active']
98
108
  end
109
+
110
+ if attributes.key?(:'type_of_units')
111
+ self.type_of_units = attributes[:'type_of_units']
112
+ end
113
+
114
+ if attributes.key?(:'type_of_units_to_accrue')
115
+ self.type_of_units_to_accrue = attributes[:'type_of_units_to_accrue']
116
+ end
99
117
  end
100
118
 
101
119
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -136,7 +154,9 @@ module XeroRuby::PayrollNz
136
154
  is_paid_leave == o.is_paid_leave &&
137
155
  show_on_payslip == o.show_on_payslip &&
138
156
  updated_date_utc == o.updated_date_utc &&
139
- is_active == o.is_active
157
+ is_active == o.is_active &&
158
+ type_of_units == o.type_of_units &&
159
+ type_of_units_to_accrue == o.type_of_units_to_accrue
140
160
  end
141
161
 
142
162
  # @see the `==` method
@@ -148,7 +168,7 @@ module XeroRuby::PayrollNz
148
168
  # Calculates hash code according to all attributes.
149
169
  # @return [Integer] Hash code
150
170
  def hash
151
- [leave_type_id, name, is_paid_leave, show_on_payslip, updated_date_utc, is_active].hash
171
+ [leave_type_id, name, is_paid_leave, show_on_payslip, updated_date_utc, is_active, type_of_units, type_of_units_to_accrue].hash
152
172
  end
153
173
 
154
174
  # Builds the object from hash
@@ -0,0 +1,38 @@
1
+ =begin
2
+ #Xero Payroll UK
3
+
4
+ #This is the Xero Payroll API for orgs in the UK region.
5
+
6
+ Contact: api@xero.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 4.3.1
9
+
10
+ =end
11
+
12
+ require 'time'
13
+ require 'date'
14
+
15
+ module XeroRuby::PayrollUk
16
+ class ContractType
17
+ FULL_TIME ||= "FullTime".freeze
18
+ PART_TIME ||= "PartTime".freeze
19
+ ZERO_HOUR ||= "ZeroHour".freeze
20
+ UNSPECIFIED ||= "Unspecified".freeze
21
+
22
+ # Builds the enum from string
23
+ # @param [String] The enum value in the form of the string
24
+ # @return [String] The enum value
25
+ def self.build_from_hash(value)
26
+ new.build_from_hash(value)
27
+ end
28
+
29
+ # Builds the enum from string
30
+ # @param [String] The enum value in the form of the string
31
+ # @return [String] The enum value
32
+ def build_from_hash(value)
33
+ constantValues = ContractType.constants.select { |c| ContractType::const_get(c) == value }
34
+ raise "Invalid ENUM value #{value} for class #ContractType" if constantValues.empty?
35
+ value
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,297 @@
1
+ =begin
2
+ #Xero Payroll UK
3
+
4
+ #This is the Xero Payroll API for orgs in the UK region.
5
+
6
+ Contact: api@xero.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 4.3.1
9
+
10
+ =end
11
+
12
+ require 'time'
13
+ require 'date'
14
+
15
+ module XeroRuby::PayrollUk
16
+ require 'bigdecimal'
17
+
18
+ class Contracts
19
+ # The contract start date of the employee. This will be locked once an employee has been paid and cannot be changed (YYYY-MM-DD)
20
+ attr_accessor :start_date
21
+
22
+
23
+ attr_accessor :employment_status
24
+
25
+
26
+ attr_accessor :contract_type
27
+
28
+ # The public key of the contract. Public key is required if the intention is to edit an existing contract. If no key is supplied a new contract will be created
29
+ attr_accessor :public_key
30
+
31
+ # describes whether the contract is fixed term (required if trying to create Fixed term contract)
32
+ attr_accessor :is_fixed_term
33
+
34
+ # The fixed term end date of the employee. Not required if isFixedTerm is false or not provided (required if trying to create Fixed term contract)
35
+ attr_accessor :fixed_term_end_date
36
+
37
+
38
+ attr_accessor :developmental_role_details
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'start_date' => :'startDate',
44
+ :'employment_status' => :'employmentStatus',
45
+ :'contract_type' => :'contractType',
46
+ :'public_key' => :'publicKey',
47
+ :'is_fixed_term' => :'isFixedTerm',
48
+ :'fixed_term_end_date' => :'fixedTermEndDate',
49
+ :'developmental_role_details' => :'developmentalRoleDetails'
50
+ }
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'start_date' => :'Date',
57
+ :'employment_status' => :'EmploymentStatus',
58
+ :'contract_type' => :'ContractType',
59
+ :'public_key' => :'String',
60
+ :'is_fixed_term' => :'Boolean',
61
+ :'fixed_term_end_date' => :'Date',
62
+ :'developmental_role_details' => :'DevelopmentalRoleDetails'
63
+ }
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollUk::Contracts` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ attributes = attributes.each_with_object({}) { |(k, v), h|
75
+ if (!self.class.attribute_map.key?(k.to_sym))
76
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollUk::Contracts`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
+ end
78
+ h[k.to_sym] = v
79
+ }
80
+
81
+ if attributes.key?(:'start_date')
82
+ self.start_date = attributes[:'start_date']
83
+ end
84
+
85
+ if attributes.key?(:'employment_status')
86
+ self.employment_status = attributes[:'employment_status']
87
+ end
88
+
89
+ if attributes.key?(:'contract_type')
90
+ self.contract_type = attributes[:'contract_type']
91
+ end
92
+
93
+ if attributes.key?(:'public_key')
94
+ self.public_key = attributes[:'public_key']
95
+ end
96
+
97
+ if attributes.key?(:'is_fixed_term')
98
+ self.is_fixed_term = attributes[:'is_fixed_term']
99
+ end
100
+
101
+ if attributes.key?(:'fixed_term_end_date')
102
+ self.fixed_term_end_date = attributes[:'fixed_term_end_date']
103
+ end
104
+
105
+ if attributes.key?(:'developmental_role_details')
106
+ self.developmental_role_details = attributes[:'developmental_role_details']
107
+ end
108
+ end
109
+
110
+ # Show invalid properties with the reasons. Usually used together with valid?
111
+ # @return Array for valid properties with the reasons
112
+ def list_invalid_properties
113
+ invalid_properties = Array.new
114
+ if @start_date.nil?
115
+ invalid_properties.push('invalid value for "start_date", start_date cannot be nil.')
116
+ end
117
+
118
+ if @employment_status.nil?
119
+ invalid_properties.push('invalid value for "employment_status", employment_status cannot be nil.')
120
+ end
121
+
122
+ if @contract_type.nil?
123
+ invalid_properties.push('invalid value for "contract_type", contract_type cannot be nil.')
124
+ end
125
+
126
+ invalid_properties
127
+ end
128
+
129
+ # Check to see if the all the properties in the model are valid
130
+ # @return true if the model is valid
131
+ def valid?
132
+ return false if @start_date.nil?
133
+ return false if @employment_status.nil?
134
+ return false if @contract_type.nil?
135
+ true
136
+ end
137
+
138
+ # Checks equality by comparing each attribute.
139
+ # @param [Object] Object to be compared
140
+ def ==(o)
141
+ return true if self.equal?(o)
142
+ self.class == o.class &&
143
+ start_date == o.start_date &&
144
+ employment_status == o.employment_status &&
145
+ contract_type == o.contract_type &&
146
+ public_key == o.public_key &&
147
+ is_fixed_term == o.is_fixed_term &&
148
+ fixed_term_end_date == o.fixed_term_end_date &&
149
+ developmental_role_details == o.developmental_role_details
150
+ end
151
+
152
+ # @see the `==` method
153
+ # @param [Object] Object to be compared
154
+ def eql?(o)
155
+ self == o
156
+ end
157
+
158
+ # Calculates hash code according to all attributes.
159
+ # @return [Integer] Hash code
160
+ def hash
161
+ [start_date, employment_status, contract_type, public_key, is_fixed_term, fixed_term_end_date, developmental_role_details].hash
162
+ end
163
+
164
+ # Builds the object from hash
165
+ # @param [Hash] attributes Model attributes in the form of hash
166
+ # @return [Object] Returns the model itself
167
+ def self.build_from_hash(attributes)
168
+ new.build_from_hash(attributes)
169
+ end
170
+
171
+ # Builds the object from hash
172
+ # @param [Hash] attributes Model attributes in the form of hash
173
+ # @return [Object] Returns the model itself
174
+ def build_from_hash(attributes)
175
+ return nil unless attributes.is_a?(Hash)
176
+ self.class.openapi_types.each_pair do |key, type|
177
+ if type =~ /\AArray<(.*)>/i
178
+ # check to ensure the input is an array given that the attribute
179
+ # is documented as an array but the input is not
180
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
181
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
182
+ end
183
+ elsif !attributes[self.class.attribute_map[key]].nil?
184
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
185
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
186
+ end
187
+
188
+ self
189
+ end
190
+
191
+ # Deserializes the data based on type
192
+ # @param string type Data type
193
+ # @param string value Value to be deserialized
194
+ # @return [Object] Deserialized data
195
+ def _deserialize(type, value)
196
+ case type.to_sym
197
+ when :DateTime
198
+ DateTime.parse(parse_date(value))
199
+ when :Date
200
+ Date.parse(parse_date(value))
201
+ when :String
202
+ value.to_s
203
+ when :Integer
204
+ value.to_i
205
+ when :Float
206
+ value.to_f
207
+ when :BigDecimal
208
+ BigDecimal(value.to_s)
209
+ when :Boolean
210
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
211
+ true
212
+ else
213
+ false
214
+ end
215
+ when :Object
216
+ # generic object (usually a Hash), return directly
217
+ value
218
+ when /\AArray<(?<inner_type>.+)>\z/
219
+ inner_type = Regexp.last_match[:inner_type]
220
+ value.map { |v| _deserialize(inner_type, v) }
221
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
222
+ k_type = Regexp.last_match[:k_type]
223
+ v_type = Regexp.last_match[:v_type]
224
+ {}.tap do |hash|
225
+ value.each do |k, v|
226
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
227
+ end
228
+ end
229
+ else # model
230
+ XeroRuby::PayrollUk.const_get(type).build_from_hash(value)
231
+ end
232
+ end
233
+
234
+ # Returns the string representation of the object
235
+ # @return [String] String presentation of the object
236
+ def to_s
237
+ to_hash.to_s
238
+ end
239
+
240
+ # to_body is an alias to to_hash (backward compatibility)
241
+ # @return [Hash] Returns the object in the form of hash
242
+ def to_body
243
+ to_hash
244
+ end
245
+
246
+ # Returns the object in the form of hash
247
+ # @return [Hash] Returns the object in the form of hash
248
+ def to_hash(downcase: false)
249
+ hash = {}
250
+ self.class.attribute_map.each_pair do |attr, param|
251
+ value = self.send(attr)
252
+ next if value.nil?
253
+ key = downcase ? attr : param
254
+ hash[key] = _to_hash(value, downcase: downcase)
255
+ end
256
+ hash
257
+ end
258
+
259
+ # Returns the object in the form of hash with snake_case
260
+ def to_attributes
261
+ to_hash(downcase: true)
262
+ end
263
+
264
+ # Outputs non-array value in the form of hash
265
+ # For object, use to_hash. Otherwise, just return the value
266
+ # @param [Object] value Any valid value
267
+ # @return [Hash] Returns the value in the form of hash
268
+ def _to_hash(value, downcase: false)
269
+ if value.is_a?(Array)
270
+ value.map do |v|
271
+ v.to_hash(downcase: downcase)
272
+ end
273
+ elsif value.is_a?(Hash)
274
+ {}.tap do |hash|
275
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
276
+ end
277
+ elsif value.respond_to? :to_hash
278
+ value.to_hash(downcase: downcase)
279
+ else
280
+ value
281
+ end
282
+ end
283
+
284
+ def parse_date(datestring)
285
+ if datestring.include?('Date')
286
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
287
+ original, date, timezone = *date_pattern.match(datestring)
288
+ date = (date.to_i / 1000)
289
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
290
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
291
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
292
+ else # handle date 'types' for small subset of payroll API's
293
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
294
+ end
295
+ end
296
+ end
297
+ end
@@ -0,0 +1,267 @@
1
+ =begin
2
+ #Xero Payroll UK
3
+
4
+ #This is the Xero Payroll API for orgs in the UK region.
5
+
6
+ Contact: api@xero.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 4.3.1
9
+
10
+ =end
11
+
12
+ require 'time'
13
+ require 'date'
14
+
15
+ module XeroRuby::PayrollUk
16
+ require 'bigdecimal'
17
+
18
+ class DevelopmentalRoleDetails
19
+ # The start date of the developmental role
20
+ attr_accessor :start_date
21
+
22
+ # The end date of the developmental role
23
+ attr_accessor :end_date
24
+
25
+ # The developmental role type - \"Apprentice\" is the only supported role currently
26
+ attr_accessor :developmental_role
27
+
28
+ # The public key of the developmental role. Public key is required if the intention is to edit an existing developmental role. If no key is supplied a new developmental role will be created
29
+ attr_accessor :public_key
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'start_date' => :'startDate',
35
+ :'end_date' => :'endDate',
36
+ :'developmental_role' => :'developmentalRole',
37
+ :'public_key' => :'publicKey'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'start_date' => :'Date',
45
+ :'end_date' => :'Date',
46
+ :'developmental_role' => :'String',
47
+ :'public_key' => :'String'
48
+ }
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollUk::DevelopmentalRoleDetails` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollUk::DevelopmentalRoleDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'start_date')
67
+ self.start_date = attributes[:'start_date']
68
+ end
69
+
70
+ if attributes.key?(:'end_date')
71
+ self.end_date = attributes[:'end_date']
72
+ end
73
+
74
+ if attributes.key?(:'developmental_role')
75
+ self.developmental_role = attributes[:'developmental_role']
76
+ end
77
+
78
+ if attributes.key?(:'public_key')
79
+ self.public_key = attributes[:'public_key']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ if @start_date.nil?
88
+ invalid_properties.push('invalid value for "start_date", start_date cannot be nil.')
89
+ end
90
+
91
+ if @end_date.nil?
92
+ invalid_properties.push('invalid value for "end_date", end_date cannot be nil.')
93
+ end
94
+
95
+ if @developmental_role.nil?
96
+ invalid_properties.push('invalid value for "developmental_role", developmental_role cannot be nil.')
97
+ end
98
+
99
+ invalid_properties
100
+ end
101
+
102
+ # Check to see if the all the properties in the model are valid
103
+ # @return true if the model is valid
104
+ def valid?
105
+ return false if @start_date.nil?
106
+ return false if @end_date.nil?
107
+ return false if @developmental_role.nil?
108
+ true
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ start_date == o.start_date &&
117
+ end_date == o.end_date &&
118
+ developmental_role == o.developmental_role &&
119
+ public_key == o.public_key
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(o)
125
+ self == o
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Integer] Hash code
130
+ def hash
131
+ [start_date, end_date, developmental_role, public_key].hash
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def self.build_from_hash(attributes)
138
+ new.build_from_hash(attributes)
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ self.class.openapi_types.each_pair do |key, type|
147
+ if type =~ /\AArray<(.*)>/i
148
+ # check to ensure the input is an array given that the attribute
149
+ # is documented as an array but the input is not
150
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
151
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
152
+ end
153
+ elsif !attributes[self.class.attribute_map[key]].nil?
154
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
155
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
156
+ end
157
+
158
+ self
159
+ end
160
+
161
+ # Deserializes the data based on type
162
+ # @param string type Data type
163
+ # @param string value Value to be deserialized
164
+ # @return [Object] Deserialized data
165
+ def _deserialize(type, value)
166
+ case type.to_sym
167
+ when :DateTime
168
+ DateTime.parse(parse_date(value))
169
+ when :Date
170
+ Date.parse(parse_date(value))
171
+ when :String
172
+ value.to_s
173
+ when :Integer
174
+ value.to_i
175
+ when :Float
176
+ value.to_f
177
+ when :BigDecimal
178
+ BigDecimal(value.to_s)
179
+ when :Boolean
180
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
181
+ true
182
+ else
183
+ false
184
+ end
185
+ when :Object
186
+ # generic object (usually a Hash), return directly
187
+ value
188
+ when /\AArray<(?<inner_type>.+)>\z/
189
+ inner_type = Regexp.last_match[:inner_type]
190
+ value.map { |v| _deserialize(inner_type, v) }
191
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
192
+ k_type = Regexp.last_match[:k_type]
193
+ v_type = Regexp.last_match[:v_type]
194
+ {}.tap do |hash|
195
+ value.each do |k, v|
196
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
197
+ end
198
+ end
199
+ else # model
200
+ XeroRuby::PayrollUk.const_get(type).build_from_hash(value)
201
+ end
202
+ end
203
+
204
+ # Returns the string representation of the object
205
+ # @return [String] String presentation of the object
206
+ def to_s
207
+ to_hash.to_s
208
+ end
209
+
210
+ # to_body is an alias to to_hash (backward compatibility)
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_body
213
+ to_hash
214
+ end
215
+
216
+ # Returns the object in the form of hash
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_hash(downcase: false)
219
+ hash = {}
220
+ self.class.attribute_map.each_pair do |attr, param|
221
+ value = self.send(attr)
222
+ next if value.nil?
223
+ key = downcase ? attr : param
224
+ hash[key] = _to_hash(value, downcase: downcase)
225
+ end
226
+ hash
227
+ end
228
+
229
+ # Returns the object in the form of hash with snake_case
230
+ def to_attributes
231
+ to_hash(downcase: true)
232
+ end
233
+
234
+ # Outputs non-array value in the form of hash
235
+ # For object, use to_hash. Otherwise, just return the value
236
+ # @param [Object] value Any valid value
237
+ # @return [Hash] Returns the value in the form of hash
238
+ def _to_hash(value, downcase: false)
239
+ if value.is_a?(Array)
240
+ value.map do |v|
241
+ v.to_hash(downcase: downcase)
242
+ end
243
+ elsif value.is_a?(Hash)
244
+ {}.tap do |hash|
245
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
246
+ end
247
+ elsif value.respond_to? :to_hash
248
+ value.to_hash(downcase: downcase)
249
+ else
250
+ value
251
+ end
252
+ end
253
+
254
+ def parse_date(datestring)
255
+ if datestring.include?('Date')
256
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
257
+ original, date, timezone = *date_pattern.match(datestring)
258
+ date = (date.to_i / 1000)
259
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
260
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
261
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
262
+ else # handle date 'types' for small subset of payroll API's
263
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
264
+ end
265
+ end
266
+ end
267
+ end