xero-ruby 10.1.0 → 11.0.0.pre.alpha1
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/models/payroll_uk/employee.rb +23 -1
- data/lib/xero-ruby/models/payroll_uk/employment.rb +17 -52
- 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 +4 -0
- metadata +372 -368
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0fd6d939d302c67385e11d0ddcdf4bf5cd4fb29a9a8a5a6db5b98f2129203e9
|
4
|
+
data.tar.gz: 57e9feb49f1df14abf7841f9652beef0f2fc0d60d3423cc36954d680ffe16f73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43b97869e6985d4aa6b11040158384b13bd2276c87424fb876f1f544b0d55b795726fc828babad0e360c39723cae9c497dbbd3ef4ef7ccd01c1e328e513891aa
|
7
|
+
data.tar.gz: 4550d090ce8d1fc3e2ca79998f38254ce395762ba61e402e725c16fca034adbef1f80b6f1f4369150e9cca4f362234b87fe9b1edfcb7da58a2849ec41270734c
|
@@ -60,6 +60,12 @@ module XeroRuby::PayrollUk
|
|
60
60
|
# UTC timestamp when the employee was created in Xero
|
61
61
|
attr_accessor :created_date_utc
|
62
62
|
|
63
|
+
|
64
|
+
attr_accessor :ni_category
|
65
|
+
|
66
|
+
# The employee's NI categories
|
67
|
+
attr_accessor :ni_categories
|
68
|
+
|
63
69
|
# National insurance number of the employee
|
64
70
|
attr_accessor :national_insurance_number
|
65
71
|
|
@@ -105,6 +111,8 @@ module XeroRuby::PayrollUk
|
|
105
111
|
:'payroll_calendar_id' => :'payrollCalendarID',
|
106
112
|
:'updated_date_utc' => :'updatedDateUTC',
|
107
113
|
:'created_date_utc' => :'createdDateUTC',
|
114
|
+
:'ni_category' => :'niCategory',
|
115
|
+
:'ni_categories' => :'niCategories',
|
108
116
|
:'national_insurance_number' => :'nationalInsuranceNumber',
|
109
117
|
:'is_off_payroll_worker' => :'isOffPayrollWorker'
|
110
118
|
}
|
@@ -127,6 +135,8 @@ module XeroRuby::PayrollUk
|
|
127
135
|
:'payroll_calendar_id' => :'String',
|
128
136
|
:'updated_date_utc' => :'DateTime',
|
129
137
|
:'created_date_utc' => :'DateTime',
|
138
|
+
:'ni_category' => :'NICategoryLetter',
|
139
|
+
:'ni_categories' => :'Array<NICategory>',
|
130
140
|
:'national_insurance_number' => :'String',
|
131
141
|
:'is_off_payroll_worker' => :'Boolean'
|
132
142
|
}
|
@@ -203,6 +213,16 @@ module XeroRuby::PayrollUk
|
|
203
213
|
self.created_date_utc = attributes[:'created_date_utc']
|
204
214
|
end
|
205
215
|
|
216
|
+
if attributes.key?(:'ni_category')
|
217
|
+
self.ni_category = attributes[:'ni_category']
|
218
|
+
end
|
219
|
+
|
220
|
+
if attributes.key?(:'ni_categories')
|
221
|
+
if (value = attributes[:'ni_categories']).is_a?(Array)
|
222
|
+
self.ni_categories = value
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
206
226
|
if attributes.key?(:'national_insurance_number')
|
207
227
|
self.national_insurance_number = attributes[:'national_insurance_number']
|
208
228
|
end
|
@@ -256,6 +276,8 @@ module XeroRuby::PayrollUk
|
|
256
276
|
payroll_calendar_id == o.payroll_calendar_id &&
|
257
277
|
updated_date_utc == o.updated_date_utc &&
|
258
278
|
created_date_utc == o.created_date_utc &&
|
279
|
+
ni_category == o.ni_category &&
|
280
|
+
ni_categories == o.ni_categories &&
|
259
281
|
national_insurance_number == o.national_insurance_number &&
|
260
282
|
is_off_payroll_worker == o.is_off_payroll_worker
|
261
283
|
end
|
@@ -269,7 +291,7 @@ module XeroRuby::PayrollUk
|
|
269
291
|
# Calculates hash code according to all attributes.
|
270
292
|
# @return [Integer] Hash code
|
271
293
|
def hash
|
272
|
-
[employee_id, title, first_name, last_name, date_of_birth, address, email, gender, phone_number, start_date, end_date, payroll_calendar_id, updated_date_utc, created_date_utc, national_insurance_number, is_off_payroll_worker].hash
|
294
|
+
[employee_id, title, first_name, last_name, date_of_birth, address, email, gender, phone_number, start_date, end_date, payroll_calendar_id, updated_date_utc, created_date_utc, ni_category, ni_categories, national_insurance_number, is_off_payroll_worker].hash
|
273
295
|
end
|
274
296
|
|
275
297
|
# Builds the object from hash
|
@@ -25,51 +25,20 @@ module XeroRuby::PayrollUk
|
|
25
25
|
# The employment number of the employee
|
26
26
|
attr_accessor :employee_number
|
27
27
|
|
28
|
-
|
28
|
+
|
29
29
|
attr_accessor :ni_category
|
30
|
-
A ||= "A".freeze
|
31
|
-
B ||= "B".freeze
|
32
|
-
C ||= "C".freeze
|
33
|
-
F ||= "F".freeze
|
34
|
-
H ||= "H".freeze
|
35
|
-
I ||= "I".freeze
|
36
|
-
J ||= "J".freeze
|
37
|
-
L ||= "L".freeze
|
38
|
-
M ||= "M".freeze
|
39
|
-
S ||= "S".freeze
|
40
|
-
V ||= "V".freeze
|
41
|
-
X ||= "X".freeze
|
42
|
-
Z ||= "Z".freeze
|
43
30
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
def initialize(datatype, allowable_values)
|
49
|
-
@allowable_values = allowable_values.map do |value|
|
50
|
-
case datatype.to_s
|
51
|
-
when /Integer/i
|
52
|
-
value.to_i
|
53
|
-
when /Float/i
|
54
|
-
value.to_f
|
55
|
-
else
|
56
|
-
value
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def valid?(value)
|
62
|
-
!value || allowable_values.include?(value)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
31
|
+
# The employee's NI categories
|
32
|
+
attr_accessor :ni_categories
|
33
|
+
|
66
34
|
# Attribute mapping from ruby-style variable name to JSON key.
|
67
35
|
def self.attribute_map
|
68
36
|
{
|
69
37
|
:'payroll_calendar_id' => :'payrollCalendarID',
|
70
38
|
:'start_date' => :'startDate',
|
71
39
|
:'employee_number' => :'employeeNumber',
|
72
|
-
:'ni_category' => :'niCategory'
|
40
|
+
:'ni_category' => :'niCategory',
|
41
|
+
:'ni_categories' => :'niCategories'
|
73
42
|
}
|
74
43
|
end
|
75
44
|
|
@@ -79,7 +48,8 @@ module XeroRuby::PayrollUk
|
|
79
48
|
:'payroll_calendar_id' => :'String',
|
80
49
|
:'start_date' => :'Date',
|
81
50
|
:'employee_number' => :'String',
|
82
|
-
:'ni_category' => :'
|
51
|
+
:'ni_category' => :'NICategoryLetter',
|
52
|
+
:'ni_categories' => :'Array<NICategory>'
|
83
53
|
}
|
84
54
|
end
|
85
55
|
|
@@ -113,6 +83,12 @@ module XeroRuby::PayrollUk
|
|
113
83
|
if attributes.key?(:'ni_category')
|
114
84
|
self.ni_category = attributes[:'ni_category']
|
115
85
|
end
|
86
|
+
|
87
|
+
if attributes.key?(:'ni_categories')
|
88
|
+
if (value = attributes[:'ni_categories']).is_a?(Array)
|
89
|
+
self.ni_categories = value
|
90
|
+
end
|
91
|
+
end
|
116
92
|
end
|
117
93
|
|
118
94
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -125,21 +101,9 @@ module XeroRuby::PayrollUk
|
|
125
101
|
# Check to see if the all the properties in the model are valid
|
126
102
|
# @return true if the model is valid
|
127
103
|
def valid?
|
128
|
-
ni_category_validator = EnumAttributeValidator.new('String', ["A", "B", "C", "F", "H", "I", "J", "L", "M", "S", "V", "X", "Z"])
|
129
|
-
return false unless ni_category_validator.valid?(@ni_category)
|
130
104
|
true
|
131
105
|
end
|
132
106
|
|
133
|
-
# Custom attribute writer method checking allowed values (enum).
|
134
|
-
# @param [Object] ni_category Object to be assigned
|
135
|
-
def ni_category=(ni_category)
|
136
|
-
validator = EnumAttributeValidator.new('String', ["A", "B", "C", "F", "H", "I", "J", "L", "M", "S", "V", "X", "Z"])
|
137
|
-
unless validator.valid?(ni_category)
|
138
|
-
fail ArgumentError, "invalid value for \"ni_category\", must be one of #{validator.allowable_values}."
|
139
|
-
end
|
140
|
-
@ni_category = ni_category
|
141
|
-
end
|
142
|
-
|
143
107
|
# Checks equality by comparing each attribute.
|
144
108
|
# @param [Object] Object to be compared
|
145
109
|
def ==(o)
|
@@ -148,7 +112,8 @@ module XeroRuby::PayrollUk
|
|
148
112
|
payroll_calendar_id == o.payroll_calendar_id &&
|
149
113
|
start_date == o.start_date &&
|
150
114
|
employee_number == o.employee_number &&
|
151
|
-
ni_category == o.ni_category
|
115
|
+
ni_category == o.ni_category &&
|
116
|
+
ni_categories == o.ni_categories
|
152
117
|
end
|
153
118
|
|
154
119
|
# @see the `==` method
|
@@ -160,7 +125,7 @@ module XeroRuby::PayrollUk
|
|
160
125
|
# Calculates hash code according to all attributes.
|
161
126
|
# @return [Integer] Hash code
|
162
127
|
def hash
|
163
|
-
[payroll_calendar_id, start_date, employee_number, ni_category].hash
|
128
|
+
[payroll_calendar_id, start_date, employee_number, ni_category, ni_categories].hash
|
164
129
|
end
|
165
130
|
|
166
131
|
# Builds the object from hash
|
@@ -0,0 +1,318 @@
|
|
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 NICategory
|
19
|
+
# The start date of the NI category (YYYY-MM-DD)
|
20
|
+
attr_accessor :start_date
|
21
|
+
|
22
|
+
|
23
|
+
attr_accessor :ni_category
|
24
|
+
|
25
|
+
# Xero unique identifier for the NI category
|
26
|
+
attr_accessor :ni_category_id
|
27
|
+
|
28
|
+
# The date in which the employee was first employed as a civilian (YYYY-MM-DD)
|
29
|
+
attr_accessor :date_first_employed_as_civilian
|
30
|
+
|
31
|
+
# The workplace postcode
|
32
|
+
attr_accessor :workplace_postcode
|
33
|
+
|
34
|
+
class EnumAttributeValidator
|
35
|
+
attr_reader :datatype
|
36
|
+
attr_reader :allowable_values
|
37
|
+
|
38
|
+
def initialize(datatype, allowable_values)
|
39
|
+
@allowable_values = allowable_values.map do |value|
|
40
|
+
case datatype.to_s
|
41
|
+
when /Integer/i
|
42
|
+
value.to_i
|
43
|
+
when /Float/i
|
44
|
+
value.to_f
|
45
|
+
else
|
46
|
+
value
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def valid?(value)
|
52
|
+
!value || allowable_values.include?(value)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
57
|
+
def self.attribute_map
|
58
|
+
{
|
59
|
+
:'start_date' => :'startDate',
|
60
|
+
:'ni_category' => :'niCategory',
|
61
|
+
:'ni_category_id' => :'niCategoryID',
|
62
|
+
:'date_first_employed_as_civilian' => :'dateFirstEmployedAsCivilian',
|
63
|
+
:'workplace_postcode' => :'workplacePostcode'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# Attribute type mapping.
|
68
|
+
def self.openapi_types
|
69
|
+
{
|
70
|
+
:'start_date' => :'Date',
|
71
|
+
:'ni_category' => :'NICategoryLetter',
|
72
|
+
:'ni_category_id' => :'Float',
|
73
|
+
:'date_first_employed_as_civilian' => :'Date',
|
74
|
+
:'workplace_postcode' => :'String'
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
# List of class defined in oneOf (OpenAPI v3)
|
79
|
+
def self.openapi_one_of
|
80
|
+
[
|
81
|
+
:'NICategoryOneOf',
|
82
|
+
:'NICategoryOneOf1'
|
83
|
+
]
|
84
|
+
end
|
85
|
+
|
86
|
+
# Initializes the object
|
87
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
88
|
+
def initialize(attributes = {})
|
89
|
+
if (!attributes.is_a?(Hash))
|
90
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollUk::NICategory` initialize method"
|
91
|
+
end
|
92
|
+
|
93
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
94
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
95
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
96
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollUk::NICategory`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
97
|
+
end
|
98
|
+
h[k.to_sym] = v
|
99
|
+
}
|
100
|
+
|
101
|
+
if attributes.key?(:'start_date')
|
102
|
+
self.start_date = attributes[:'start_date']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:'ni_category')
|
106
|
+
self.ni_category = attributes[:'ni_category']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:'ni_category_id')
|
110
|
+
self.ni_category_id = attributes[:'ni_category_id']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.key?(:'date_first_employed_as_civilian')
|
114
|
+
self.date_first_employed_as_civilian = attributes[:'date_first_employed_as_civilian']
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.key?(:'workplace_postcode')
|
118
|
+
self.workplace_postcode = attributes[:'workplace_postcode']
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
123
|
+
# @return Array for valid properties with the reasons
|
124
|
+
def list_invalid_properties
|
125
|
+
invalid_properties = Array.new
|
126
|
+
if @ni_category.nil?
|
127
|
+
invalid_properties.push('invalid value for "ni_category", ni_category cannot be nil.')
|
128
|
+
end
|
129
|
+
|
130
|
+
if @workplace_postcode.nil?
|
131
|
+
invalid_properties.push('invalid value for "workplace_postcode", workplace_postcode cannot be nil.')
|
132
|
+
end
|
133
|
+
|
134
|
+
invalid_properties
|
135
|
+
end
|
136
|
+
|
137
|
+
# Check to see if the all the properties in the model are valid
|
138
|
+
# @return true if the model is valid
|
139
|
+
def valid?
|
140
|
+
return false if @ni_category.nil?
|
141
|
+
return false if @workplace_postcode.nil?
|
142
|
+
_one_of_found = false
|
143
|
+
self.class.openapi_one_of.each do |_class|
|
144
|
+
_one_of = XeroRuby::PayrollUk.const_get(_class).build_from_hash(self.to_hash)
|
145
|
+
if _one_of.valid?
|
146
|
+
if _one_of_found
|
147
|
+
return false
|
148
|
+
else
|
149
|
+
_one_of_found = true
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
if !_one_of_found
|
155
|
+
return false
|
156
|
+
end
|
157
|
+
|
158
|
+
true
|
159
|
+
end
|
160
|
+
|
161
|
+
# Checks equality by comparing each attribute.
|
162
|
+
# @param [Object] Object to be compared
|
163
|
+
def ==(o)
|
164
|
+
return true if self.equal?(o)
|
165
|
+
self.class == o.class &&
|
166
|
+
start_date == o.start_date &&
|
167
|
+
ni_category == o.ni_category &&
|
168
|
+
ni_category_id == o.ni_category_id &&
|
169
|
+
date_first_employed_as_civilian == o.date_first_employed_as_civilian &&
|
170
|
+
workplace_postcode == o.workplace_postcode
|
171
|
+
end
|
172
|
+
|
173
|
+
# @see the `==` method
|
174
|
+
# @param [Object] Object to be compared
|
175
|
+
def eql?(o)
|
176
|
+
self == o
|
177
|
+
end
|
178
|
+
|
179
|
+
# Calculates hash code according to all attributes.
|
180
|
+
# @return [Integer] Hash code
|
181
|
+
def hash
|
182
|
+
[start_date, ni_category, ni_category_id, date_first_employed_as_civilian, workplace_postcode].hash
|
183
|
+
end
|
184
|
+
|
185
|
+
# Builds the object from hash
|
186
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
187
|
+
# @return [Object] Returns the model itself
|
188
|
+
def self.build_from_hash(attributes)
|
189
|
+
new.build_from_hash(attributes)
|
190
|
+
end
|
191
|
+
|
192
|
+
# Builds the object from hash
|
193
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
194
|
+
# @return [Object] Returns the model itself
|
195
|
+
def build_from_hash(attributes)
|
196
|
+
return nil unless attributes.is_a?(Hash)
|
197
|
+
self.class.openapi_types.each_pair do |key, type|
|
198
|
+
if type =~ /\AArray<(.*)>/i
|
199
|
+
# check to ensure the input is an array given that the attribute
|
200
|
+
# is documented as an array but the input is not
|
201
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
202
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
203
|
+
end
|
204
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
205
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
206
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
207
|
+
end
|
208
|
+
|
209
|
+
self
|
210
|
+
end
|
211
|
+
|
212
|
+
# Deserializes the data based on type
|
213
|
+
# @param string type Data type
|
214
|
+
# @param string value Value to be deserialized
|
215
|
+
# @return [Object] Deserialized data
|
216
|
+
def _deserialize(type, value)
|
217
|
+
case type.to_sym
|
218
|
+
when :DateTime
|
219
|
+
DateTime.parse(parse_date(value))
|
220
|
+
when :Date
|
221
|
+
Date.parse(parse_date(value))
|
222
|
+
when :String
|
223
|
+
value.to_s
|
224
|
+
when :Integer
|
225
|
+
value.to_i
|
226
|
+
when :Float
|
227
|
+
value.to_f
|
228
|
+
when :BigDecimal
|
229
|
+
BigDecimal(value.to_s)
|
230
|
+
when :Boolean
|
231
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
232
|
+
true
|
233
|
+
else
|
234
|
+
false
|
235
|
+
end
|
236
|
+
when :Object
|
237
|
+
# generic object (usually a Hash), return directly
|
238
|
+
value
|
239
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
240
|
+
inner_type = Regexp.last_match[:inner_type]
|
241
|
+
value.map { |v| _deserialize(inner_type, v) }
|
242
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
243
|
+
k_type = Regexp.last_match[:k_type]
|
244
|
+
v_type = Regexp.last_match[:v_type]
|
245
|
+
{}.tap do |hash|
|
246
|
+
value.each do |k, v|
|
247
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
else # model
|
251
|
+
XeroRuby::PayrollUk.const_get(type).build_from_hash(value)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
# Returns the string representation of the object
|
256
|
+
# @return [String] String presentation of the object
|
257
|
+
def to_s
|
258
|
+
to_hash.to_s
|
259
|
+
end
|
260
|
+
|
261
|
+
# to_body is an alias to to_hash (backward compatibility)
|
262
|
+
# @return [Hash] Returns the object in the form of hash
|
263
|
+
def to_body
|
264
|
+
to_hash
|
265
|
+
end
|
266
|
+
|
267
|
+
# Returns the object in the form of hash
|
268
|
+
# @return [Hash] Returns the object in the form of hash
|
269
|
+
def to_hash(downcase: false)
|
270
|
+
hash = {}
|
271
|
+
self.class.attribute_map.each_pair do |attr, param|
|
272
|
+
value = self.send(attr)
|
273
|
+
next if value.nil?
|
274
|
+
key = downcase ? attr : param
|
275
|
+
hash[key] = _to_hash(value, downcase: downcase)
|
276
|
+
end
|
277
|
+
hash
|
278
|
+
end
|
279
|
+
|
280
|
+
# Returns the object in the form of hash with snake_case
|
281
|
+
def to_attributes
|
282
|
+
to_hash(downcase: true)
|
283
|
+
end
|
284
|
+
|
285
|
+
# Outputs non-array value in the form of hash
|
286
|
+
# For object, use to_hash. Otherwise, just return the value
|
287
|
+
# @param [Object] value Any valid value
|
288
|
+
# @return [Hash] Returns the value in the form of hash
|
289
|
+
def _to_hash(value, downcase: false)
|
290
|
+
if value.is_a?(Array)
|
291
|
+
value.map do |v|
|
292
|
+
v.to_hash(downcase: downcase)
|
293
|
+
end
|
294
|
+
elsif value.is_a?(Hash)
|
295
|
+
{}.tap do |hash|
|
296
|
+
value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
|
297
|
+
end
|
298
|
+
elsif value.respond_to? :to_hash
|
299
|
+
value.to_hash(downcase: downcase)
|
300
|
+
else
|
301
|
+
value
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
def parse_date(datestring)
|
306
|
+
if datestring.include?('Date')
|
307
|
+
date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
|
308
|
+
original, date, timezone = *date_pattern.match(datestring)
|
309
|
+
date = (date.to_i / 1000)
|
310
|
+
Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
|
311
|
+
elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
|
312
|
+
Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
|
313
|
+
else # handle date 'types' for small subset of payroll API's
|
314
|
+
Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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 NICategoryLetter
|
17
|
+
A ||= "A".freeze
|
18
|
+
B ||= "B".freeze
|
19
|
+
C ||= "C".freeze
|
20
|
+
F ||= "F".freeze
|
21
|
+
H ||= "H".freeze
|
22
|
+
I ||= "I".freeze
|
23
|
+
J ||= "J".freeze
|
24
|
+
L ||= "L".freeze
|
25
|
+
M ||= "M".freeze
|
26
|
+
S ||= "S".freeze
|
27
|
+
V ||= "V".freeze
|
28
|
+
X ||= "X".freeze
|
29
|
+
Z ||= "Z".freeze
|
30
|
+
D ||= "D".freeze
|
31
|
+
E ||= "E".freeze
|
32
|
+
K ||= "K".freeze
|
33
|
+
N ||= "N".freeze
|
34
|
+
|
35
|
+
# Builds the enum from string
|
36
|
+
# @param [String] The enum value in the form of the string
|
37
|
+
# @return [String] The enum value
|
38
|
+
def self.build_from_hash(value)
|
39
|
+
new.build_from_hash(value)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Builds the enum from string
|
43
|
+
# @param [String] The enum value in the form of the string
|
44
|
+
# @return [String] The enum value
|
45
|
+
def build_from_hash(value)
|
46
|
+
constantValues = NICategoryLetter.constants.select { |c| NICategoryLetter::const_get(c) == value }
|
47
|
+
raise "Invalid ENUM value #{value} for class #NICategoryLetter" if constantValues.empty?
|
48
|
+
value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|