xero-ruby 3.16.0 → 10.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 +645 -3
- data/lib/xero-ruby/api/app_store_api.rb +6 -0
- data/lib/xero-ruby/api/asset_api.rb +16 -6
- data/lib/xero-ruby/api/files_api.rb +156 -20
- data/lib/xero-ruby/api/payroll_au_api.rb +326 -30
- data/lib/xero-ruby/api/payroll_nz_api.rb +417 -7
- data/lib/xero-ruby/api/payroll_uk_api.rb +81 -0
- data/lib/xero-ruby/api/project_api.rb +21 -0
- data/lib/xero-ruby/api_client.rb +7 -7
- data/lib/xero-ruby/models/accounting/account_type.rb +0 -4
- data/lib/xero-ruby/models/accounting/allocation.rb +21 -1
- data/lib/xero-ruby/models/accounting/bank_transactions.rb +23 -1
- data/lib/xero-ruby/models/accounting/contact.rb +1 -11
- data/lib/xero-ruby/models/accounting/contacts.rb +23 -1
- data/lib/xero-ruby/models/accounting/credit_note.rb +17 -5
- data/lib/xero-ruby/models/accounting/credit_notes.rb +23 -1
- data/lib/xero-ruby/models/accounting/currency_code.rb +10 -8
- data/lib/xero-ruby/models/accounting/invoice.rb +16 -4
- data/lib/xero-ruby/models/accounting/invoice_address.rb +338 -0
- data/lib/xero-ruby/models/accounting/invoices.rb +23 -1
- data/lib/xero-ruby/models/accounting/journals.rb +13 -1
- data/lib/xero-ruby/models/accounting/line_item.rb +75 -4
- data/lib/xero-ruby/models/accounting/manual_journals.rb +23 -1
- data/lib/xero-ruby/models/accounting/organisation.rb +9 -2
- data/lib/xero-ruby/models/accounting/overpayments.rb +23 -1
- data/lib/xero-ruby/models/accounting/pagination.rb +252 -0
- data/lib/xero-ruby/models/accounting/payment.rb +16 -4
- data/lib/xero-ruby/models/accounting/payments.rb +23 -1
- data/lib/xero-ruby/models/accounting/prepayments.rb +23 -1
- data/lib/xero-ruby/models/accounting/purchase_orders.rb +23 -1
- data/lib/xero-ruby/models/accounting/tax_breakdown_component.rb +351 -0
- data/lib/xero-ruby/models/accounting/tax_rate.rb +13 -6
- data/lib/xero-ruby/models/accounting/tax_type.rb +45 -4
- data/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb +75 -4
- data/lib/xero-ruby/models/files/association.rb +31 -1
- data/lib/xero-ruby/models/finance/current_statement_response.rb +1 -1
- data/lib/xero-ruby/models/finance/data_source_response.rb +13 -43
- data/lib/xero-ruby/models/finance/problem_type.rb +1 -0
- data/lib/xero-ruby/models/finance/statement_line_response.rb +11 -1
- data/lib/xero-ruby/models/finance/statement_response.rb +24 -4
- data/lib/xero-ruby/models/payroll_au/allowance_type.rb +0 -1
- data/lib/xero-ruby/models/payroll_au/country_of_residence.rb +0 -1
- data/lib/xero-ruby/models/payroll_au/earnings_rate.rb +21 -1
- data/lib/xero-ruby/models/payroll_au/leave_application.rb +11 -1
- data/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb +14 -4
- data/lib/xero-ruby/models/payroll_au/leave_line_calculation_type.rb +0 -1
- data/lib/xero-ruby/models/payroll_au/leave_period_status.rb +2 -0
- data/lib/xero-ruby/models/payroll_au/opening_balances.rb +16 -4
- data/lib/xero-ruby/models/payroll_au/paid_leave_earnings_line.rb +272 -0
- data/lib/xero-ruby/models/payroll_au/pay_out_type.rb +36 -0
- data/lib/xero-ruby/models/payroll_nz/employee.rb +34 -4
- data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +56 -6
- data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +47 -7
- data/lib/xero-ruby/models/payroll_nz/employee_working_pattern.rb +242 -0
- data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks.rb +254 -0
- data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks_object.rb +242 -0
- data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks_request.rb +244 -0
- data/lib/xero-ruby/models/payroll_nz/employee_working_patterns_object.rb +244 -0
- data/lib/xero-ruby/models/payroll_nz/employment.rb +24 -4
- 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_nz/salary_and_wage.rb +28 -4
- data/lib/xero-ruby/models/payroll_nz/working_week.rb +317 -0
- data/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +3 -3
- data/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb +14 -4
- data/lib/xero-ruby/models/projects/currency_code.rb +0 -1
- data/lib/xero-ruby/version.rb +2 -2
- data/lib/xero-ruby/where.rb +37 -37
- data/lib/xero-ruby.rb +11 -0
- data/spec/api_client_spec.rb +56 -56
- data/spec/api_error_spec.rb +1 -1
- data/spec/configuration_spec.rb +2 -2
- data/spec/helper_methods_spec.rb +3 -3
- data/spec/where_spec.rb +2 -2
- metadata +38 -27
@@ -26,15 +26,24 @@ module XeroRuby::PayrollNz
|
|
26
26
|
PERCENTAGE_OF_GROSS_EARNINGS ||= "PercentageOfGrossEarnings".freeze
|
27
27
|
NO_ACCRUALS ||= "NoAccruals".freeze
|
28
28
|
|
29
|
-
#
|
29
|
+
# Deprecated use UnitsAccruedAnnually
|
30
30
|
attr_accessor :hours_accrued_annually
|
31
31
|
|
32
|
-
# The
|
32
|
+
# The number of units accrued for the leave annually. This is 0 when the ScheduleOfAccrual chosen is \"NoAccruals\"
|
33
|
+
attr_accessor :units_accrued_annually
|
34
|
+
|
35
|
+
# The type of units accrued for the leave annually
|
36
|
+
attr_accessor :type_of_units_to_accrue
|
37
|
+
|
38
|
+
# The maximum number of units that can be accrued for the leave
|
33
39
|
attr_accessor :maximum_to_accrue
|
34
40
|
|
35
|
-
# The initial number of
|
41
|
+
# The initial number of units assigned when the leave was added to the employee
|
36
42
|
attr_accessor :opening_balance
|
37
43
|
|
44
|
+
# The type of units for the opening balance
|
45
|
+
attr_accessor :opening_balance_type_of_units
|
46
|
+
|
38
47
|
# The number of hours added to the leave balance for every hour worked by the employee. This is normally 0, unless the scheduleOfAccrual chosen is \"OnHourWorked\"
|
39
48
|
attr_accessor :rate_accrued_hourly
|
40
49
|
|
@@ -50,6 +59,9 @@ module XeroRuby::PayrollNz
|
|
50
59
|
# Specific to Annual Leave. Annual leave balance in dollars
|
51
60
|
attr_accessor :annual_leave_total_amount_paid
|
52
61
|
|
62
|
+
# The date when an employee becomes entitled to their accrual.
|
63
|
+
attr_accessor :schedule_of_accrual_date
|
64
|
+
|
53
65
|
class EnumAttributeValidator
|
54
66
|
attr_reader :datatype
|
55
67
|
attr_reader :allowable_values
|
@@ -78,13 +90,17 @@ module XeroRuby::PayrollNz
|
|
78
90
|
:'leave_type_id' => :'leaveTypeID',
|
79
91
|
:'schedule_of_accrual' => :'scheduleOfAccrual',
|
80
92
|
:'hours_accrued_annually' => :'hoursAccruedAnnually',
|
93
|
+
:'units_accrued_annually' => :'UnitsAccruedAnnually',
|
94
|
+
:'type_of_units_to_accrue' => :'typeOfUnitsToAccrue',
|
81
95
|
:'maximum_to_accrue' => :'maximumToAccrue',
|
82
96
|
:'opening_balance' => :'openingBalance',
|
97
|
+
:'opening_balance_type_of_units' => :'openingBalanceTypeOfUnits',
|
83
98
|
:'rate_accrued_hourly' => :'rateAccruedHourly',
|
84
99
|
:'percentage_of_gross_earnings' => :'percentageOfGrossEarnings',
|
85
100
|
:'include_holiday_pay_every_pay' => :'includeHolidayPayEveryPay',
|
86
101
|
:'show_annual_leave_in_advance' => :'showAnnualLeaveInAdvance',
|
87
|
-
:'annual_leave_total_amount_paid' => :'annualLeaveTotalAmountPaid'
|
102
|
+
:'annual_leave_total_amount_paid' => :'annualLeaveTotalAmountPaid',
|
103
|
+
:'schedule_of_accrual_date' => :'scheduleOfAccrualDate'
|
88
104
|
}
|
89
105
|
end
|
90
106
|
|
@@ -94,13 +110,17 @@ module XeroRuby::PayrollNz
|
|
94
110
|
:'leave_type_id' => :'String',
|
95
111
|
:'schedule_of_accrual' => :'String',
|
96
112
|
:'hours_accrued_annually' => :'BigDecimal',
|
113
|
+
:'units_accrued_annually' => :'BigDecimal',
|
114
|
+
:'type_of_units_to_accrue' => :'String',
|
97
115
|
:'maximum_to_accrue' => :'BigDecimal',
|
98
116
|
:'opening_balance' => :'BigDecimal',
|
117
|
+
:'opening_balance_type_of_units' => :'String',
|
99
118
|
:'rate_accrued_hourly' => :'BigDecimal',
|
100
119
|
:'percentage_of_gross_earnings' => :'BigDecimal',
|
101
120
|
:'include_holiday_pay_every_pay' => :'Boolean',
|
102
121
|
:'show_annual_leave_in_advance' => :'Boolean',
|
103
|
-
:'annual_leave_total_amount_paid' => :'BigDecimal'
|
122
|
+
:'annual_leave_total_amount_paid' => :'BigDecimal',
|
123
|
+
:'schedule_of_accrual_date' => :'Date'
|
104
124
|
}
|
105
125
|
end
|
106
126
|
|
@@ -131,6 +151,14 @@ module XeroRuby::PayrollNz
|
|
131
151
|
self.hours_accrued_annually = attributes[:'hours_accrued_annually']
|
132
152
|
end
|
133
153
|
|
154
|
+
if attributes.key?(:'units_accrued_annually')
|
155
|
+
self.units_accrued_annually = attributes[:'units_accrued_annually']
|
156
|
+
end
|
157
|
+
|
158
|
+
if attributes.key?(:'type_of_units_to_accrue')
|
159
|
+
self.type_of_units_to_accrue = attributes[:'type_of_units_to_accrue']
|
160
|
+
end
|
161
|
+
|
134
162
|
if attributes.key?(:'maximum_to_accrue')
|
135
163
|
self.maximum_to_accrue = attributes[:'maximum_to_accrue']
|
136
164
|
end
|
@@ -139,6 +167,10 @@ module XeroRuby::PayrollNz
|
|
139
167
|
self.opening_balance = attributes[:'opening_balance']
|
140
168
|
end
|
141
169
|
|
170
|
+
if attributes.key?(:'opening_balance_type_of_units')
|
171
|
+
self.opening_balance_type_of_units = attributes[:'opening_balance_type_of_units']
|
172
|
+
end
|
173
|
+
|
142
174
|
if attributes.key?(:'rate_accrued_hourly')
|
143
175
|
self.rate_accrued_hourly = attributes[:'rate_accrued_hourly']
|
144
176
|
end
|
@@ -158,6 +190,10 @@ module XeroRuby::PayrollNz
|
|
158
190
|
if attributes.key?(:'annual_leave_total_amount_paid')
|
159
191
|
self.annual_leave_total_amount_paid = attributes[:'annual_leave_total_amount_paid']
|
160
192
|
end
|
193
|
+
|
194
|
+
if attributes.key?(:'schedule_of_accrual_date')
|
195
|
+
self.schedule_of_accrual_date = attributes[:'schedule_of_accrual_date']
|
196
|
+
end
|
161
197
|
end
|
162
198
|
|
163
199
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -193,13 +229,17 @@ module XeroRuby::PayrollNz
|
|
193
229
|
leave_type_id == o.leave_type_id &&
|
194
230
|
schedule_of_accrual == o.schedule_of_accrual &&
|
195
231
|
hours_accrued_annually == o.hours_accrued_annually &&
|
232
|
+
units_accrued_annually == o.units_accrued_annually &&
|
233
|
+
type_of_units_to_accrue == o.type_of_units_to_accrue &&
|
196
234
|
maximum_to_accrue == o.maximum_to_accrue &&
|
197
235
|
opening_balance == o.opening_balance &&
|
236
|
+
opening_balance_type_of_units == o.opening_balance_type_of_units &&
|
198
237
|
rate_accrued_hourly == o.rate_accrued_hourly &&
|
199
238
|
percentage_of_gross_earnings == o.percentage_of_gross_earnings &&
|
200
239
|
include_holiday_pay_every_pay == o.include_holiday_pay_every_pay &&
|
201
240
|
show_annual_leave_in_advance == o.show_annual_leave_in_advance &&
|
202
|
-
annual_leave_total_amount_paid == o.annual_leave_total_amount_paid
|
241
|
+
annual_leave_total_amount_paid == o.annual_leave_total_amount_paid &&
|
242
|
+
schedule_of_accrual_date == o.schedule_of_accrual_date
|
203
243
|
end
|
204
244
|
|
205
245
|
# @see the `==` method
|
@@ -211,7 +251,7 @@ module XeroRuby::PayrollNz
|
|
211
251
|
# Calculates hash code according to all attributes.
|
212
252
|
# @return [Integer] Hash code
|
213
253
|
def hash
|
214
|
-
[leave_type_id, schedule_of_accrual, hours_accrued_annually, maximum_to_accrue, opening_balance, rate_accrued_hourly, percentage_of_gross_earnings, include_holiday_pay_every_pay, show_annual_leave_in_advance, annual_leave_total_amount_paid].hash
|
254
|
+
[leave_type_id, schedule_of_accrual, hours_accrued_annually, units_accrued_annually, type_of_units_to_accrue, maximum_to_accrue, opening_balance, opening_balance_type_of_units, rate_accrued_hourly, percentage_of_gross_earnings, include_holiday_pay_every_pay, show_annual_leave_in_advance, annual_leave_total_amount_paid, schedule_of_accrual_date].hash
|
215
255
|
end
|
216
256
|
|
217
257
|
# Builds the object from hash
|
@@ -0,0 +1,242 @@
|
|
1
|
+
=begin
|
2
|
+
#Xero Payroll NZ
|
3
|
+
|
4
|
+
#This is the Xero Payroll API for orgs in the NZ 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::PayrollNz
|
16
|
+
require 'bigdecimal'
|
17
|
+
|
18
|
+
class EmployeeWorkingPattern
|
19
|
+
# The Xero identifier for for Employee working pattern
|
20
|
+
attr_accessor :payee_working_pattern_id
|
21
|
+
|
22
|
+
# The effective date of the corresponding salary and wages
|
23
|
+
attr_accessor :effective_from
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'payee_working_pattern_id' => :'payeeWorkingPatternID',
|
29
|
+
:'effective_from' => :'effectiveFrom'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Attribute type mapping.
|
34
|
+
def self.openapi_types
|
35
|
+
{
|
36
|
+
:'payee_working_pattern_id' => :'String',
|
37
|
+
:'effective_from' => :'Date'
|
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::PayrollNz::EmployeeWorkingPattern` 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::PayrollNz::EmployeeWorkingPattern`. 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?(:'payee_working_pattern_id')
|
57
|
+
self.payee_working_pattern_id = attributes[:'payee_working_pattern_id']
|
58
|
+
end
|
59
|
+
|
60
|
+
if attributes.key?(:'effective_from')
|
61
|
+
self.effective_from = attributes[:'effective_from']
|
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
|
+
if @payee_working_pattern_id.nil?
|
70
|
+
invalid_properties.push('invalid value for "payee_working_pattern_id", payee_working_pattern_id cannot be nil.')
|
71
|
+
end
|
72
|
+
|
73
|
+
if @effective_from.nil?
|
74
|
+
invalid_properties.push('invalid value for "effective_from", effective_from cannot be nil.')
|
75
|
+
end
|
76
|
+
|
77
|
+
invalid_properties
|
78
|
+
end
|
79
|
+
|
80
|
+
# Check to see if the all the properties in the model are valid
|
81
|
+
# @return true if the model is valid
|
82
|
+
def valid?
|
83
|
+
return false if @payee_working_pattern_id.nil?
|
84
|
+
return false if @effective_from.nil?
|
85
|
+
true
|
86
|
+
end
|
87
|
+
|
88
|
+
# Checks equality by comparing each attribute.
|
89
|
+
# @param [Object] Object to be compared
|
90
|
+
def ==(o)
|
91
|
+
return true if self.equal?(o)
|
92
|
+
self.class == o.class &&
|
93
|
+
payee_working_pattern_id == o.payee_working_pattern_id &&
|
94
|
+
effective_from == o.effective_from
|
95
|
+
end
|
96
|
+
|
97
|
+
# @see the `==` method
|
98
|
+
# @param [Object] Object to be compared
|
99
|
+
def eql?(o)
|
100
|
+
self == o
|
101
|
+
end
|
102
|
+
|
103
|
+
# Calculates hash code according to all attributes.
|
104
|
+
# @return [Integer] Hash code
|
105
|
+
def hash
|
106
|
+
[payee_working_pattern_id, effective_from].hash
|
107
|
+
end
|
108
|
+
|
109
|
+
# Builds the object from hash
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
111
|
+
# @return [Object] Returns the model itself
|
112
|
+
def self.build_from_hash(attributes)
|
113
|
+
new.build_from_hash(attributes)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Builds the object from hash
|
117
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
118
|
+
# @return [Object] Returns the model itself
|
119
|
+
def build_from_hash(attributes)
|
120
|
+
return nil unless attributes.is_a?(Hash)
|
121
|
+
self.class.openapi_types.each_pair do |key, type|
|
122
|
+
if type =~ /\AArray<(.*)>/i
|
123
|
+
# check to ensure the input is an array given that the attribute
|
124
|
+
# is documented as an array but the input is not
|
125
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
126
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
127
|
+
end
|
128
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
129
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
130
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
131
|
+
end
|
132
|
+
|
133
|
+
self
|
134
|
+
end
|
135
|
+
|
136
|
+
# Deserializes the data based on type
|
137
|
+
# @param string type Data type
|
138
|
+
# @param string value Value to be deserialized
|
139
|
+
# @return [Object] Deserialized data
|
140
|
+
def _deserialize(type, value)
|
141
|
+
case type.to_sym
|
142
|
+
when :DateTime
|
143
|
+
DateTime.parse(parse_date(value))
|
144
|
+
when :Date
|
145
|
+
Date.parse(parse_date(value))
|
146
|
+
when :String
|
147
|
+
value.to_s
|
148
|
+
when :Integer
|
149
|
+
value.to_i
|
150
|
+
when :Float
|
151
|
+
value.to_f
|
152
|
+
when :BigDecimal
|
153
|
+
BigDecimal(value.to_s)
|
154
|
+
when :Boolean
|
155
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
156
|
+
true
|
157
|
+
else
|
158
|
+
false
|
159
|
+
end
|
160
|
+
when :Object
|
161
|
+
# generic object (usually a Hash), return directly
|
162
|
+
value
|
163
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
164
|
+
inner_type = Regexp.last_match[:inner_type]
|
165
|
+
value.map { |v| _deserialize(inner_type, v) }
|
166
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
167
|
+
k_type = Regexp.last_match[:k_type]
|
168
|
+
v_type = Regexp.last_match[:v_type]
|
169
|
+
{}.tap do |hash|
|
170
|
+
value.each do |k, v|
|
171
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
else # model
|
175
|
+
XeroRuby::PayrollNz.const_get(type).build_from_hash(value)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
# Returns the string representation of the object
|
180
|
+
# @return [String] String presentation of the object
|
181
|
+
def to_s
|
182
|
+
to_hash.to_s
|
183
|
+
end
|
184
|
+
|
185
|
+
# to_body is an alias to to_hash (backward compatibility)
|
186
|
+
# @return [Hash] Returns the object in the form of hash
|
187
|
+
def to_body
|
188
|
+
to_hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the object in the form of hash
|
192
|
+
# @return [Hash] Returns the object in the form of hash
|
193
|
+
def to_hash(downcase: false)
|
194
|
+
hash = {}
|
195
|
+
self.class.attribute_map.each_pair do |attr, param|
|
196
|
+
value = self.send(attr)
|
197
|
+
next if value.nil?
|
198
|
+
key = downcase ? attr : param
|
199
|
+
hash[key] = _to_hash(value, downcase: downcase)
|
200
|
+
end
|
201
|
+
hash
|
202
|
+
end
|
203
|
+
|
204
|
+
# Returns the object in the form of hash with snake_case
|
205
|
+
def to_attributes
|
206
|
+
to_hash(downcase: true)
|
207
|
+
end
|
208
|
+
|
209
|
+
# Outputs non-array value in the form of hash
|
210
|
+
# For object, use to_hash. Otherwise, just return the value
|
211
|
+
# @param [Object] value Any valid value
|
212
|
+
# @return [Hash] Returns the value in the form of hash
|
213
|
+
def _to_hash(value, downcase: false)
|
214
|
+
if value.is_a?(Array)
|
215
|
+
value.map do |v|
|
216
|
+
v.to_hash(downcase: downcase)
|
217
|
+
end
|
218
|
+
elsif value.is_a?(Hash)
|
219
|
+
{}.tap do |hash|
|
220
|
+
value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
|
221
|
+
end
|
222
|
+
elsif value.respond_to? :to_hash
|
223
|
+
value.to_hash(downcase: downcase)
|
224
|
+
else
|
225
|
+
value
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def parse_date(datestring)
|
230
|
+
if datestring.include?('Date')
|
231
|
+
date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
|
232
|
+
original, date, timezone = *date_pattern.match(datestring)
|
233
|
+
date = (date.to_i / 1000)
|
234
|
+
Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
|
235
|
+
elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
|
236
|
+
Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
|
237
|
+
else # handle date 'types' for small subset of payroll API's
|
238
|
+
Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
@@ -0,0 +1,254 @@
|
|
1
|
+
=begin
|
2
|
+
#Xero Payroll NZ
|
3
|
+
|
4
|
+
#This is the Xero Payroll API for orgs in the NZ 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::PayrollNz
|
16
|
+
require 'bigdecimal'
|
17
|
+
|
18
|
+
class EmployeeWorkingPatternWithWorkingWeeks
|
19
|
+
# The Xero identifier for for Employee working pattern
|
20
|
+
attr_accessor :payee_working_pattern_id
|
21
|
+
|
22
|
+
# The effective date of the corresponding salary and wages
|
23
|
+
attr_accessor :effective_from
|
24
|
+
|
25
|
+
|
26
|
+
attr_accessor :working_weeks
|
27
|
+
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
+
def self.attribute_map
|
30
|
+
{
|
31
|
+
:'payee_working_pattern_id' => :'payeeWorkingPatternID',
|
32
|
+
:'effective_from' => :'effectiveFrom',
|
33
|
+
:'working_weeks' => :'workingWeeks'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# Attribute type mapping.
|
38
|
+
def self.openapi_types
|
39
|
+
{
|
40
|
+
:'payee_working_pattern_id' => :'String',
|
41
|
+
:'effective_from' => :'Date',
|
42
|
+
:'working_weeks' => :'Array<WorkingWeek>'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# Initializes the object
|
47
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
48
|
+
def initialize(attributes = {})
|
49
|
+
if (!attributes.is_a?(Hash))
|
50
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollNz::EmployeeWorkingPatternWithWorkingWeeks` initialize method"
|
51
|
+
end
|
52
|
+
|
53
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
54
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
55
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
56
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollNz::EmployeeWorkingPatternWithWorkingWeeks`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
57
|
+
end
|
58
|
+
h[k.to_sym] = v
|
59
|
+
}
|
60
|
+
|
61
|
+
if attributes.key?(:'payee_working_pattern_id')
|
62
|
+
self.payee_working_pattern_id = attributes[:'payee_working_pattern_id']
|
63
|
+
end
|
64
|
+
|
65
|
+
if attributes.key?(:'effective_from')
|
66
|
+
self.effective_from = attributes[:'effective_from']
|
67
|
+
end
|
68
|
+
|
69
|
+
if attributes.key?(:'working_weeks')
|
70
|
+
if (value = attributes[:'working_weeks']).is_a?(Array)
|
71
|
+
self.working_weeks = value
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
77
|
+
# @return Array for valid properties with the reasons
|
78
|
+
def list_invalid_properties
|
79
|
+
invalid_properties = Array.new
|
80
|
+
if @payee_working_pattern_id.nil?
|
81
|
+
invalid_properties.push('invalid value for "payee_working_pattern_id", payee_working_pattern_id cannot be nil.')
|
82
|
+
end
|
83
|
+
|
84
|
+
if @effective_from.nil?
|
85
|
+
invalid_properties.push('invalid value for "effective_from", effective_from cannot be nil.')
|
86
|
+
end
|
87
|
+
|
88
|
+
invalid_properties
|
89
|
+
end
|
90
|
+
|
91
|
+
# Check to see if the all the properties in the model are valid
|
92
|
+
# @return true if the model is valid
|
93
|
+
def valid?
|
94
|
+
return false if @payee_working_pattern_id.nil?
|
95
|
+
return false if @effective_from.nil?
|
96
|
+
true
|
97
|
+
end
|
98
|
+
|
99
|
+
# Checks equality by comparing each attribute.
|
100
|
+
# @param [Object] Object to be compared
|
101
|
+
def ==(o)
|
102
|
+
return true if self.equal?(o)
|
103
|
+
self.class == o.class &&
|
104
|
+
payee_working_pattern_id == o.payee_working_pattern_id &&
|
105
|
+
effective_from == o.effective_from &&
|
106
|
+
working_weeks == o.working_weeks
|
107
|
+
end
|
108
|
+
|
109
|
+
# @see the `==` method
|
110
|
+
# @param [Object] Object to be compared
|
111
|
+
def eql?(o)
|
112
|
+
self == o
|
113
|
+
end
|
114
|
+
|
115
|
+
# Calculates hash code according to all attributes.
|
116
|
+
# @return [Integer] Hash code
|
117
|
+
def hash
|
118
|
+
[payee_working_pattern_id, effective_from, working_weeks].hash
|
119
|
+
end
|
120
|
+
|
121
|
+
# Builds the object from hash
|
122
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
123
|
+
# @return [Object] Returns the model itself
|
124
|
+
def self.build_from_hash(attributes)
|
125
|
+
new.build_from_hash(attributes)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Builds the object from hash
|
129
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
130
|
+
# @return [Object] Returns the model itself
|
131
|
+
def build_from_hash(attributes)
|
132
|
+
return nil unless attributes.is_a?(Hash)
|
133
|
+
self.class.openapi_types.each_pair do |key, type|
|
134
|
+
if type =~ /\AArray<(.*)>/i
|
135
|
+
# check to ensure the input is an array given that the attribute
|
136
|
+
# is documented as an array but the input is not
|
137
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
138
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
139
|
+
end
|
140
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
141
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
142
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
143
|
+
end
|
144
|
+
|
145
|
+
self
|
146
|
+
end
|
147
|
+
|
148
|
+
# Deserializes the data based on type
|
149
|
+
# @param string type Data type
|
150
|
+
# @param string value Value to be deserialized
|
151
|
+
# @return [Object] Deserialized data
|
152
|
+
def _deserialize(type, value)
|
153
|
+
case type.to_sym
|
154
|
+
when :DateTime
|
155
|
+
DateTime.parse(parse_date(value))
|
156
|
+
when :Date
|
157
|
+
Date.parse(parse_date(value))
|
158
|
+
when :String
|
159
|
+
value.to_s
|
160
|
+
when :Integer
|
161
|
+
value.to_i
|
162
|
+
when :Float
|
163
|
+
value.to_f
|
164
|
+
when :BigDecimal
|
165
|
+
BigDecimal(value.to_s)
|
166
|
+
when :Boolean
|
167
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
168
|
+
true
|
169
|
+
else
|
170
|
+
false
|
171
|
+
end
|
172
|
+
when :Object
|
173
|
+
# generic object (usually a Hash), return directly
|
174
|
+
value
|
175
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
176
|
+
inner_type = Regexp.last_match[:inner_type]
|
177
|
+
value.map { |v| _deserialize(inner_type, v) }
|
178
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
179
|
+
k_type = Regexp.last_match[:k_type]
|
180
|
+
v_type = Regexp.last_match[:v_type]
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each do |k, v|
|
183
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
else # model
|
187
|
+
XeroRuby::PayrollNz.const_get(type).build_from_hash(value)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the string representation of the object
|
192
|
+
# @return [String] String presentation of the object
|
193
|
+
def to_s
|
194
|
+
to_hash.to_s
|
195
|
+
end
|
196
|
+
|
197
|
+
# to_body is an alias to to_hash (backward compatibility)
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
199
|
+
def to_body
|
200
|
+
to_hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Returns the object in the form of hash
|
204
|
+
# @return [Hash] Returns the object in the form of hash
|
205
|
+
def to_hash(downcase: false)
|
206
|
+
hash = {}
|
207
|
+
self.class.attribute_map.each_pair do |attr, param|
|
208
|
+
value = self.send(attr)
|
209
|
+
next if value.nil?
|
210
|
+
key = downcase ? attr : param
|
211
|
+
hash[key] = _to_hash(value, downcase: downcase)
|
212
|
+
end
|
213
|
+
hash
|
214
|
+
end
|
215
|
+
|
216
|
+
# Returns the object in the form of hash with snake_case
|
217
|
+
def to_attributes
|
218
|
+
to_hash(downcase: true)
|
219
|
+
end
|
220
|
+
|
221
|
+
# Outputs non-array value in the form of hash
|
222
|
+
# For object, use to_hash. Otherwise, just return the value
|
223
|
+
# @param [Object] value Any valid value
|
224
|
+
# @return [Hash] Returns the value in the form of hash
|
225
|
+
def _to_hash(value, downcase: false)
|
226
|
+
if value.is_a?(Array)
|
227
|
+
value.map do |v|
|
228
|
+
v.to_hash(downcase: downcase)
|
229
|
+
end
|
230
|
+
elsif value.is_a?(Hash)
|
231
|
+
{}.tap do |hash|
|
232
|
+
value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
|
233
|
+
end
|
234
|
+
elsif value.respond_to? :to_hash
|
235
|
+
value.to_hash(downcase: downcase)
|
236
|
+
else
|
237
|
+
value
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def parse_date(datestring)
|
242
|
+
if datestring.include?('Date')
|
243
|
+
date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
|
244
|
+
original, date, timezone = *date_pattern.match(datestring)
|
245
|
+
date = (date.to_i / 1000)
|
246
|
+
Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
|
247
|
+
elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
|
248
|
+
Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
|
249
|
+
else # handle date 'types' for small subset of payroll API's
|
250
|
+
Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|