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.
- checksums.yaml +4 -4
- data/lib/xero-ruby/api/accounting_api.rb +178 -319
- data/lib/xero-ruby/api/files_api.rb +9 -2
- data/lib/xero-ruby/api/finance_api.rb +0 -299
- data/lib/xero-ruby/api/payroll_au_v2_api.rb +751 -0
- data/lib/xero-ruby/api/payroll_nz_api.rb +0 -86
- data/lib/xero-ruby/api/payroll_uk_api.rb +0 -86
- data/lib/xero-ruby/models/accounting/bank_transfer.rb +71 -1
- data/lib/xero-ruby/models/accounting/bank_transfer_delete.rb +244 -0
- data/lib/xero-ruby/models/accounting/bank_transfer_delete_by_url_param.rb +229 -0
- data/lib/xero-ruby/models/accounting/bank_transfers_delete.rb +224 -0
- data/lib/xero-ruby/models/accounting/contact.rb +27 -1
- data/lib/xero-ruby/models/accounting/credit_note.rb +11 -1
- data/lib/xero-ruby/models/accounting/invoice.rb +12 -2
- data/lib/xero-ruby/models/accounting/organisation.rb +25 -6
- data/lib/xero-ruby/models/accounting/overpayment.rb +21 -1
- data/lib/xero-ruby/models/accounting/payment.rb +11 -1
- data/lib/xero-ruby/models/accounting/prepayment.rb +31 -1
- data/lib/xero-ruby/models/accounting/tracking_reference.rb +277 -0
- data/lib/xero-ruby/models/accounting/user.rb +3 -2
- data/lib/xero-ruby/models/app_store/product.rb +4 -3
- data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +54 -4
- data/lib/xero-ruby/models/files/association.rb +21 -1
- data/lib/xero-ruby/models/finance/current_statement_response.rb +1 -1
- data/lib/xero-ruby/models/finance/data_source_response.rb +1 -31
- data/lib/xero-ruby/models/payroll_au/earnings_rate.rb +16 -1
- data/lib/xero-ruby/models/payroll_au/employee.rb +1 -13
- data/lib/xero-ruby/models/payroll_au/leave_line.rb +16 -1
- data/lib/xero-ruby/models/payroll_au/leave_type.rb +19 -4
- data/lib/xero-ruby/models/payroll_au/opening_balance_leave_line.rb +232 -0
- data/lib/xero-ruby/models/payroll_au/opening_balances.rb +1 -1
- data/lib/xero-ruby/models/payroll_au/tax_declaration.rb +14 -4
- data/lib/xero-ruby/models/payroll_au_v2/invalid_field.rb +232 -0
- data/lib/xero-ruby/models/payroll_au_v2/pagination.rb +252 -0
- data/lib/xero-ruby/models/payroll_au_v2/problem.rb +275 -0
- data/lib/xero-ruby/models/payroll_au_v2/timesheet.rb +361 -0
- data/lib/xero-ruby/models/payroll_au_v2/timesheet_line.rb +277 -0
- data/lib/xero-ruby/models/payroll_au_v2/timesheet_line_object.rb +242 -0
- data/lib/xero-ruby/models/payroll_au_v2/timesheet_object.rb +242 -0
- data/lib/xero-ruby/models/payroll_au_v2/timesheets.rb +244 -0
- data/lib/xero-ruby/models/payroll_nz/employee.rb +20 -0
- data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +29 -19
- data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +31 -11
- data/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb +5 -0
- data/lib/xero-ruby/models/payroll_nz/employment.rb +15 -0
- data/lib/xero-ruby/models/payroll_nz/leave_period.rb +35 -4
- data/lib/xero-ruby/models/payroll_nz/leave_type.rb +24 -4
- data/lib/xero-ruby/models/payroll_uk/contract_type.rb +38 -0
- data/lib/xero-ruby/models/payroll_uk/contracts.rb +297 -0
- data/lib/xero-ruby/models/payroll_uk/developmental_role_details.rb +267 -0
- data/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +5 -2
- data/lib/xero-ruby/models/payroll_uk/employee.rb +68 -4
- data/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb +5 -0
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb +4 -2
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb +5 -2
- data/lib/xero-ruby/models/payroll_uk/employment.rb +49 -52
- data/lib/xero-ruby/models/payroll_uk/employment_status.rb +37 -0
- data/lib/xero-ruby/models/payroll_uk/ni_category.rb +318 -0
- data/lib/xero-ruby/models/payroll_uk/ni_category_letter.rb +51 -0
- data/lib/xero-ruby/models/payroll_uk/ni_category_one_of.rb +264 -0
- data/lib/xero-ruby/models/payroll_uk/ni_category_one_of1.rb +257 -0
- data/lib/xero-ruby/version.rb +2 -2
- data/lib/xero-ruby.rb +22 -10
- data/spec/finance/api/finance_api_spec.rb +0 -53
- metadata +393 -391
- data/spec/finance/models/account_usage_response_spec.rb +0 -58
- data/spec/finance/models/account_usage_spec.rb +0 -112
- data/spec/finance/models/history_record_response_spec.rb +0 -64
- data/spec/finance/models/lock_history_model_spec.rb +0 -52
- data/spec/finance/models/lock_history_response_spec.rb +0 -52
- data/spec/finance/models/practice_response_spec.rb +0 -64
- data/spec/finance/models/report_history_model_spec.rb +0 -52
- data/spec/finance/models/report_history_response_spec.rb +0 -52
- data/spec/finance/models/user_activities_response_spec.rb +0 -52
- data/spec/finance/models/user_response_spec.rb +0 -106
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Xero Payroll AU API
|
|
3
|
+
|
|
4
|
+
#This is the Xero Payroll API for orgs in Australia 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::PayrollAu
|
|
16
|
+
require 'bigdecimal'
|
|
17
|
+
|
|
18
|
+
class OpeningBalanceLeaveLine
|
|
19
|
+
# Xero leave type identifier
|
|
20
|
+
attr_accessor :leave_type_id
|
|
21
|
+
|
|
22
|
+
# Number of units for leave line.
|
|
23
|
+
attr_accessor :number_of_units
|
|
24
|
+
|
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
26
|
+
def self.attribute_map
|
|
27
|
+
{
|
|
28
|
+
:'leave_type_id' => :'LeaveTypeID',
|
|
29
|
+
:'number_of_units' => :'NumberOfUnits'
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Attribute type mapping.
|
|
34
|
+
def self.openapi_types
|
|
35
|
+
{
|
|
36
|
+
:'leave_type_id' => :'String',
|
|
37
|
+
:'number_of_units' => :'BigDecimal'
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Initializes the object
|
|
42
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
43
|
+
def initialize(attributes = {})
|
|
44
|
+
if (!attributes.is_a?(Hash))
|
|
45
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollAu::OpeningBalanceLeaveLine` initialize method"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
49
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
50
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
51
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollAu::OpeningBalanceLeaveLine`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
52
|
+
end
|
|
53
|
+
h[k.to_sym] = v
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if attributes.key?(:'leave_type_id')
|
|
57
|
+
self.leave_type_id = attributes[:'leave_type_id']
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if attributes.key?(:'number_of_units')
|
|
61
|
+
self.number_of_units = attributes[:'number_of_units']
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
66
|
+
# @return Array for valid properties with the reasons
|
|
67
|
+
def list_invalid_properties
|
|
68
|
+
invalid_properties = Array.new
|
|
69
|
+
invalid_properties
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Check to see if the all the properties in the model are valid
|
|
73
|
+
# @return true if the model is valid
|
|
74
|
+
def valid?
|
|
75
|
+
true
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Checks equality by comparing each attribute.
|
|
79
|
+
# @param [Object] Object to be compared
|
|
80
|
+
def ==(o)
|
|
81
|
+
return true if self.equal?(o)
|
|
82
|
+
self.class == o.class &&
|
|
83
|
+
leave_type_id == o.leave_type_id &&
|
|
84
|
+
number_of_units == o.number_of_units
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# @see the `==` method
|
|
88
|
+
# @param [Object] Object to be compared
|
|
89
|
+
def eql?(o)
|
|
90
|
+
self == o
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Calculates hash code according to all attributes.
|
|
94
|
+
# @return [Integer] Hash code
|
|
95
|
+
def hash
|
|
96
|
+
[leave_type_id, number_of_units].hash
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Builds the object from hash
|
|
100
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
101
|
+
# @return [Object] Returns the model itself
|
|
102
|
+
def self.build_from_hash(attributes)
|
|
103
|
+
new.build_from_hash(attributes)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Builds the object from hash
|
|
107
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
108
|
+
# @return [Object] Returns the model itself
|
|
109
|
+
def build_from_hash(attributes)
|
|
110
|
+
return nil unless attributes.is_a?(Hash)
|
|
111
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
112
|
+
if type =~ /\AArray<(.*)>/i
|
|
113
|
+
# check to ensure the input is an array given that the attribute
|
|
114
|
+
# is documented as an array but the input is not
|
|
115
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
116
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
117
|
+
end
|
|
118
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
119
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
120
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
self
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Deserializes the data based on type
|
|
127
|
+
# @param string type Data type
|
|
128
|
+
# @param string value Value to be deserialized
|
|
129
|
+
# @return [Object] Deserialized data
|
|
130
|
+
def _deserialize(type, value)
|
|
131
|
+
case type.to_sym
|
|
132
|
+
when :DateTime
|
|
133
|
+
DateTime.parse(parse_date(value))
|
|
134
|
+
when :Date
|
|
135
|
+
Date.parse(parse_date(value))
|
|
136
|
+
when :String
|
|
137
|
+
value.to_s
|
|
138
|
+
when :Integer
|
|
139
|
+
value.to_i
|
|
140
|
+
when :Float
|
|
141
|
+
value.to_f
|
|
142
|
+
when :BigDecimal
|
|
143
|
+
BigDecimal(value.to_s)
|
|
144
|
+
when :Boolean
|
|
145
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
146
|
+
true
|
|
147
|
+
else
|
|
148
|
+
false
|
|
149
|
+
end
|
|
150
|
+
when :Object
|
|
151
|
+
# generic object (usually a Hash), return directly
|
|
152
|
+
value
|
|
153
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
154
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
155
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
156
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
157
|
+
k_type = Regexp.last_match[:k_type]
|
|
158
|
+
v_type = Regexp.last_match[:v_type]
|
|
159
|
+
{}.tap do |hash|
|
|
160
|
+
value.each do |k, v|
|
|
161
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
else # model
|
|
165
|
+
XeroRuby::PayrollAu.const_get(type).build_from_hash(value)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Returns the string representation of the object
|
|
170
|
+
# @return [String] String presentation of the object
|
|
171
|
+
def to_s
|
|
172
|
+
to_hash.to_s
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
176
|
+
# @return [Hash] Returns the object in the form of hash
|
|
177
|
+
def to_body
|
|
178
|
+
to_hash
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Returns the object in the form of hash
|
|
182
|
+
# @return [Hash] Returns the object in the form of hash
|
|
183
|
+
def to_hash(downcase: false)
|
|
184
|
+
hash = {}
|
|
185
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
186
|
+
value = self.send(attr)
|
|
187
|
+
next if value.nil?
|
|
188
|
+
key = downcase ? attr : param
|
|
189
|
+
hash[key] = _to_hash(value, downcase: downcase)
|
|
190
|
+
end
|
|
191
|
+
hash
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Returns the object in the form of hash with snake_case
|
|
195
|
+
def to_attributes
|
|
196
|
+
to_hash(downcase: true)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Outputs non-array value in the form of hash
|
|
200
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
201
|
+
# @param [Object] value Any valid value
|
|
202
|
+
# @return [Hash] Returns the value in the form of hash
|
|
203
|
+
def _to_hash(value, downcase: false)
|
|
204
|
+
if value.is_a?(Array)
|
|
205
|
+
value.map do |v|
|
|
206
|
+
v.to_hash(downcase: downcase)
|
|
207
|
+
end
|
|
208
|
+
elsif value.is_a?(Hash)
|
|
209
|
+
{}.tap do |hash|
|
|
210
|
+
value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
|
|
211
|
+
end
|
|
212
|
+
elsif value.respond_to? :to_hash
|
|
213
|
+
value.to_hash(downcase: downcase)
|
|
214
|
+
else
|
|
215
|
+
value
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def parse_date(datestring)
|
|
220
|
+
if datestring.include?('Date')
|
|
221
|
+
date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
|
|
222
|
+
original, date, timezone = *date_pattern.match(datestring)
|
|
223
|
+
date = (date.to_i / 1000)
|
|
224
|
+
Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
|
|
225
|
+
elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
|
|
226
|
+
Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
|
|
227
|
+
else # handle date 'types' for small subset of payroll API's
|
|
228
|
+
Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|
|
@@ -63,7 +63,7 @@ module XeroRuby::PayrollAu
|
|
|
63
63
|
:'deduction_lines' => :'Array<DeductionLine>',
|
|
64
64
|
:'super_lines' => :'Array<SuperLine>',
|
|
65
65
|
:'reimbursement_lines' => :'Array<ReimbursementLine>',
|
|
66
|
-
:'leave_lines' => :'Array<
|
|
66
|
+
:'leave_lines' => :'Array<OpeningBalanceLeaveLine>',
|
|
67
67
|
:'paid_leave_earnings_lines' => :'Array<PaidLeaveEarningsLine>'
|
|
68
68
|
}
|
|
69
69
|
end
|
|
@@ -79,6 +79,9 @@ module XeroRuby::PayrollAu
|
|
|
79
79
|
# Last modified timestamp
|
|
80
80
|
attr_accessor :updated_date_utc
|
|
81
81
|
|
|
82
|
+
# Boolean to determine if leave loading is considered as qualifying earnings for superannuation guarantee calculations. Required when IncludeLeaveLoadingInSGC is specified in the payload
|
|
83
|
+
attr_accessor :include_leave_loading_in_qualifying_earnings
|
|
84
|
+
|
|
82
85
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
83
86
|
def self.attribute_map
|
|
84
87
|
{
|
|
@@ -102,7 +105,8 @@ module XeroRuby::PayrollAu
|
|
|
102
105
|
:'approved_withholding_variation_percentage' => :'ApprovedWithholdingVariationPercentage',
|
|
103
106
|
:'has_student_startup_loan' => :'HasStudentStartupLoan',
|
|
104
107
|
:'has_loan_or_student_debt' => :'HasLoanOrStudentDebt',
|
|
105
|
-
:'updated_date_utc' => :'UpdatedDateUTC'
|
|
108
|
+
:'updated_date_utc' => :'UpdatedDateUTC',
|
|
109
|
+
:'include_leave_loading_in_qualifying_earnings' => :'IncludeLeaveLoadingInQualifyingEarnings'
|
|
106
110
|
}
|
|
107
111
|
end
|
|
108
112
|
|
|
@@ -129,7 +133,8 @@ module XeroRuby::PayrollAu
|
|
|
129
133
|
:'approved_withholding_variation_percentage' => :'Float',
|
|
130
134
|
:'has_student_startup_loan' => :'Boolean',
|
|
131
135
|
:'has_loan_or_student_debt' => :'Boolean',
|
|
132
|
-
:'updated_date_utc' => :'DateTime'
|
|
136
|
+
:'updated_date_utc' => :'DateTime',
|
|
137
|
+
:'include_leave_loading_in_qualifying_earnings' => :'Boolean'
|
|
133
138
|
}
|
|
134
139
|
end
|
|
135
140
|
|
|
@@ -231,6 +236,10 @@ module XeroRuby::PayrollAu
|
|
|
231
236
|
if attributes.key?(:'updated_date_utc')
|
|
232
237
|
self.updated_date_utc = attributes[:'updated_date_utc']
|
|
233
238
|
end
|
|
239
|
+
|
|
240
|
+
if attributes.key?(:'include_leave_loading_in_qualifying_earnings')
|
|
241
|
+
self.include_leave_loading_in_qualifying_earnings = attributes[:'include_leave_loading_in_qualifying_earnings']
|
|
242
|
+
end
|
|
234
243
|
end
|
|
235
244
|
|
|
236
245
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -271,7 +280,8 @@ module XeroRuby::PayrollAu
|
|
|
271
280
|
approved_withholding_variation_percentage == o.approved_withholding_variation_percentage &&
|
|
272
281
|
has_student_startup_loan == o.has_student_startup_loan &&
|
|
273
282
|
has_loan_or_student_debt == o.has_loan_or_student_debt &&
|
|
274
|
-
updated_date_utc == o.updated_date_utc
|
|
283
|
+
updated_date_utc == o.updated_date_utc &&
|
|
284
|
+
include_leave_loading_in_qualifying_earnings == o.include_leave_loading_in_qualifying_earnings
|
|
275
285
|
end
|
|
276
286
|
|
|
277
287
|
# @see the `==` method
|
|
@@ -283,7 +293,7 @@ module XeroRuby::PayrollAu
|
|
|
283
293
|
# Calculates hash code according to all attributes.
|
|
284
294
|
# @return [Integer] Hash code
|
|
285
295
|
def hash
|
|
286
|
-
[employee_id, employment_basis, tfn_exemption_type, tax_file_number, abn, australian_resident_for_tax_purposes, residency_status, tax_scale_type, work_condition, senior_marital_status, tax_free_threshold_claimed, tax_offset_estimated_amount, has_help_debt, has_sfss_debt, has_trade_support_loan_debt, upward_variation_tax_withholding_amount, eligible_to_receive_leave_loading, approved_withholding_variation_percentage, has_student_startup_loan, has_loan_or_student_debt, updated_date_utc].hash
|
|
296
|
+
[employee_id, employment_basis, tfn_exemption_type, tax_file_number, abn, australian_resident_for_tax_purposes, residency_status, tax_scale_type, work_condition, senior_marital_status, tax_free_threshold_claimed, tax_offset_estimated_amount, has_help_debt, has_sfss_debt, has_trade_support_loan_debt, upward_variation_tax_withholding_amount, eligible_to_receive_leave_loading, approved_withholding_variation_percentage, has_student_startup_loan, has_loan_or_student_debt, updated_date_utc, include_leave_loading_in_qualifying_earnings].hash
|
|
287
297
|
end
|
|
288
298
|
|
|
289
299
|
# Builds the object from hash
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Xero Payroll AU API 2.0
|
|
3
|
+
|
|
4
|
+
#This is the Xero Payroll API 2.0 for orgs in Australia 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::PayrollAuV2
|
|
16
|
+
require 'bigdecimal'
|
|
17
|
+
|
|
18
|
+
class InvalidField
|
|
19
|
+
# The name of the field that caused the error
|
|
20
|
+
attr_accessor :name
|
|
21
|
+
|
|
22
|
+
# The reason the error occurred
|
|
23
|
+
attr_accessor :reason
|
|
24
|
+
|
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
26
|
+
def self.attribute_map
|
|
27
|
+
{
|
|
28
|
+
:'name' => :'name',
|
|
29
|
+
:'reason' => :'reason'
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Attribute type mapping.
|
|
34
|
+
def self.openapi_types
|
|
35
|
+
{
|
|
36
|
+
:'name' => :'String',
|
|
37
|
+
:'reason' => :'String'
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Initializes the object
|
|
42
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
43
|
+
def initialize(attributes = {})
|
|
44
|
+
if (!attributes.is_a?(Hash))
|
|
45
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollAuV2::InvalidField` initialize method"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
49
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
50
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
51
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollAuV2::InvalidField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
52
|
+
end
|
|
53
|
+
h[k.to_sym] = v
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if attributes.key?(:'name')
|
|
57
|
+
self.name = attributes[:'name']
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if attributes.key?(:'reason')
|
|
61
|
+
self.reason = attributes[:'reason']
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
66
|
+
# @return Array for valid properties with the reasons
|
|
67
|
+
def list_invalid_properties
|
|
68
|
+
invalid_properties = Array.new
|
|
69
|
+
invalid_properties
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Check to see if the all the properties in the model are valid
|
|
73
|
+
# @return true if the model is valid
|
|
74
|
+
def valid?
|
|
75
|
+
true
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Checks equality by comparing each attribute.
|
|
79
|
+
# @param [Object] Object to be compared
|
|
80
|
+
def ==(o)
|
|
81
|
+
return true if self.equal?(o)
|
|
82
|
+
self.class == o.class &&
|
|
83
|
+
name == o.name &&
|
|
84
|
+
reason == o.reason
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# @see the `==` method
|
|
88
|
+
# @param [Object] Object to be compared
|
|
89
|
+
def eql?(o)
|
|
90
|
+
self == o
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Calculates hash code according to all attributes.
|
|
94
|
+
# @return [Integer] Hash code
|
|
95
|
+
def hash
|
|
96
|
+
[name, reason].hash
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Builds the object from hash
|
|
100
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
101
|
+
# @return [Object] Returns the model itself
|
|
102
|
+
def self.build_from_hash(attributes)
|
|
103
|
+
new.build_from_hash(attributes)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Builds the object from hash
|
|
107
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
108
|
+
# @return [Object] Returns the model itself
|
|
109
|
+
def build_from_hash(attributes)
|
|
110
|
+
return nil unless attributes.is_a?(Hash)
|
|
111
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
112
|
+
if type =~ /\AArray<(.*)>/i
|
|
113
|
+
# check to ensure the input is an array given that the attribute
|
|
114
|
+
# is documented as an array but the input is not
|
|
115
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
116
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
117
|
+
end
|
|
118
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
119
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
120
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
self
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Deserializes the data based on type
|
|
127
|
+
# @param string type Data type
|
|
128
|
+
# @param string value Value to be deserialized
|
|
129
|
+
# @return [Object] Deserialized data
|
|
130
|
+
def _deserialize(type, value)
|
|
131
|
+
case type.to_sym
|
|
132
|
+
when :DateTime
|
|
133
|
+
DateTime.parse(parse_date(value))
|
|
134
|
+
when :Date
|
|
135
|
+
Date.parse(parse_date(value))
|
|
136
|
+
when :String
|
|
137
|
+
value.to_s
|
|
138
|
+
when :Integer
|
|
139
|
+
value.to_i
|
|
140
|
+
when :Float
|
|
141
|
+
value.to_f
|
|
142
|
+
when :BigDecimal
|
|
143
|
+
BigDecimal(value.to_s)
|
|
144
|
+
when :Boolean
|
|
145
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
146
|
+
true
|
|
147
|
+
else
|
|
148
|
+
false
|
|
149
|
+
end
|
|
150
|
+
when :Object
|
|
151
|
+
# generic object (usually a Hash), return directly
|
|
152
|
+
value
|
|
153
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
154
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
155
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
156
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
157
|
+
k_type = Regexp.last_match[:k_type]
|
|
158
|
+
v_type = Regexp.last_match[:v_type]
|
|
159
|
+
{}.tap do |hash|
|
|
160
|
+
value.each do |k, v|
|
|
161
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
else # model
|
|
165
|
+
XeroRuby::PayrollAuV2.const_get(type).build_from_hash(value)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Returns the string representation of the object
|
|
170
|
+
# @return [String] String presentation of the object
|
|
171
|
+
def to_s
|
|
172
|
+
to_hash.to_s
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
176
|
+
# @return [Hash] Returns the object in the form of hash
|
|
177
|
+
def to_body
|
|
178
|
+
to_hash
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Returns the object in the form of hash
|
|
182
|
+
# @return [Hash] Returns the object in the form of hash
|
|
183
|
+
def to_hash(downcase: false)
|
|
184
|
+
hash = {}
|
|
185
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
186
|
+
value = self.send(attr)
|
|
187
|
+
next if value.nil?
|
|
188
|
+
key = downcase ? attr : param
|
|
189
|
+
hash[key] = _to_hash(value, downcase: downcase)
|
|
190
|
+
end
|
|
191
|
+
hash
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Returns the object in the form of hash with snake_case
|
|
195
|
+
def to_attributes
|
|
196
|
+
to_hash(downcase: true)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Outputs non-array value in the form of hash
|
|
200
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
201
|
+
# @param [Object] value Any valid value
|
|
202
|
+
# @return [Hash] Returns the value in the form of hash
|
|
203
|
+
def _to_hash(value, downcase: false)
|
|
204
|
+
if value.is_a?(Array)
|
|
205
|
+
value.map do |v|
|
|
206
|
+
v.to_hash(downcase: downcase)
|
|
207
|
+
end
|
|
208
|
+
elsif value.is_a?(Hash)
|
|
209
|
+
{}.tap do |hash|
|
|
210
|
+
value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
|
|
211
|
+
end
|
|
212
|
+
elsif value.respond_to? :to_hash
|
|
213
|
+
value.to_hash(downcase: downcase)
|
|
214
|
+
else
|
|
215
|
+
value
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def parse_date(datestring)
|
|
220
|
+
if datestring.include?('Date')
|
|
221
|
+
date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
|
|
222
|
+
original, date, timezone = *date_pattern.match(datestring)
|
|
223
|
+
date = (date.to_i / 1000)
|
|
224
|
+
Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
|
|
225
|
+
elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
|
|
226
|
+
Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
|
|
227
|
+
else # handle date 'types' for small subset of payroll API's
|
|
228
|
+
Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|