xero-ruby 9.0.0 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xero-ruby/api/payroll_nz_api.rb +330 -7
  3. data/lib/xero-ruby/models/accounting/bank_transactions.rb +13 -1
  4. data/lib/xero-ruby/models/accounting/contacts.rb +13 -1
  5. data/lib/xero-ruby/models/accounting/credit_notes.rb +13 -1
  6. data/lib/xero-ruby/models/accounting/invoices.rb +13 -1
  7. data/lib/xero-ruby/models/accounting/journals.rb +13 -1
  8. data/lib/xero-ruby/models/accounting/manual_journals.rb +13 -1
  9. data/lib/xero-ruby/models/accounting/overpayments.rb +13 -1
  10. data/lib/xero-ruby/models/accounting/payments.rb +13 -1
  11. data/lib/xero-ruby/models/accounting/prepayments.rb +13 -1
  12. data/lib/xero-ruby/models/accounting/purchase_orders.rb +13 -1
  13. data/lib/xero-ruby/models/payroll_nz/employee.rb +24 -4
  14. data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +24 -4
  15. data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +14 -4
  16. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern.rb +242 -0
  17. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks.rb +254 -0
  18. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks_object.rb +242 -0
  19. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks_request.rb +244 -0
  20. data/lib/xero-ruby/models/payroll_nz/employee_working_patterns_object.rb +244 -0
  21. data/lib/xero-ruby/models/payroll_nz/employment.rb +24 -4
  22. data/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb +28 -4
  23. data/lib/xero-ruby/models/payroll_nz/working_week.rb +317 -0
  24. data/lib/xero-ruby/version.rb +2 -2
  25. data/lib/xero-ruby.rb +6 -0
  26. metadata +8 -2
@@ -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 EmployeeWorkingPatternWithWorkingWeeksObject
19
+
20
+ attr_accessor :pagination
21
+
22
+
23
+ attr_accessor :problem
24
+
25
+
26
+ attr_accessor :payee_working_pattern
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'pagination' => :'pagination',
32
+ :'problem' => :'problem',
33
+ :'payee_working_pattern' => :'payeeWorkingPattern'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'pagination' => :'Pagination',
41
+ :'problem' => :'Problem',
42
+ :'payee_working_pattern' => :'EmployeeWorkingPatternWithWorkingWeeks'
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::EmployeeWorkingPatternWithWorkingWeeksObject` 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::EmployeeWorkingPatternWithWorkingWeeksObject`. 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?(:'pagination')
62
+ self.pagination = attributes[:'pagination']
63
+ end
64
+
65
+ if attributes.key?(:'problem')
66
+ self.problem = attributes[:'problem']
67
+ end
68
+
69
+ if attributes.key?(:'payee_working_pattern')
70
+ self.payee_working_pattern = attributes[:'payee_working_pattern']
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ invalid_properties = Array.new
78
+ invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ pagination == o.pagination &&
93
+ problem == o.problem &&
94
+ payee_working_pattern == o.payee_working_pattern
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
+ [pagination, problem, payee_working_pattern].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,244 @@
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 EmployeeWorkingPatternWithWorkingWeeksRequest
19
+ # The effective date of the corresponding salary and wages
20
+ attr_accessor :effective_from
21
+
22
+
23
+ attr_accessor :working_weeks
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'effective_from' => :'effectiveFrom',
29
+ :'working_weeks' => :'workingWeeks'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'effective_from' => :'Date',
37
+ :'working_weeks' => :'Array<WorkingWeek>'
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::EmployeeWorkingPatternWithWorkingWeeksRequest` 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::EmployeeWorkingPatternWithWorkingWeeksRequest`. 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?(:'effective_from')
57
+ self.effective_from = attributes[:'effective_from']
58
+ end
59
+
60
+ if attributes.key?(:'working_weeks')
61
+ if (value = attributes[:'working_weeks']).is_a?(Array)
62
+ self.working_weeks = value
63
+ end
64
+ end
65
+ end
66
+
67
+ # Show invalid properties with the reasons. Usually used together with valid?
68
+ # @return Array for valid properties with the reasons
69
+ def list_invalid_properties
70
+ invalid_properties = Array.new
71
+ if @effective_from.nil?
72
+ invalid_properties.push('invalid value for "effective_from", effective_from cannot be nil.')
73
+ end
74
+
75
+ if @working_weeks.nil?
76
+ invalid_properties.push('invalid value for "working_weeks", working_weeks cannot be nil.')
77
+ end
78
+
79
+ invalid_properties
80
+ end
81
+
82
+ # Check to see if the all the properties in the model are valid
83
+ # @return true if the model is valid
84
+ def valid?
85
+ return false if @effective_from.nil?
86
+ return false if @working_weeks.nil?
87
+ true
88
+ end
89
+
90
+ # Checks equality by comparing each attribute.
91
+ # @param [Object] Object to be compared
92
+ def ==(o)
93
+ return true if self.equal?(o)
94
+ self.class == o.class &&
95
+ effective_from == o.effective_from &&
96
+ working_weeks == o.working_weeks
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [effective_from, working_weeks].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ new.build_from_hash(attributes)
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ self.class.openapi_types.each_pair do |key, type|
124
+ if type =~ /\AArray<(.*)>/i
125
+ # check to ensure the input is an array given that the attribute
126
+ # is documented as an array but the input is not
127
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
128
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
129
+ end
130
+ elsif !attributes[self.class.attribute_map[key]].nil?
131
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
132
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
133
+ end
134
+
135
+ self
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def _deserialize(type, value)
143
+ case type.to_sym
144
+ when :DateTime
145
+ DateTime.parse(parse_date(value))
146
+ when :Date
147
+ Date.parse(parse_date(value))
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :BigDecimal
155
+ BigDecimal(value.to_s)
156
+ when :Boolean
157
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
165
+ when /\AArray<(?<inner_type>.+)>\z/
166
+ inner_type = Regexp.last_match[:inner_type]
167
+ value.map { |v| _deserialize(inner_type, v) }
168
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
169
+ k_type = Regexp.last_match[:k_type]
170
+ v_type = Regexp.last_match[:v_type]
171
+ {}.tap do |hash|
172
+ value.each do |k, v|
173
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
174
+ end
175
+ end
176
+ else # model
177
+ XeroRuby::PayrollNz.const_get(type).build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash(downcase: false)
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ next if value.nil?
200
+ key = downcase ? attr : param
201
+ hash[key] = _to_hash(value, downcase: downcase)
202
+ end
203
+ hash
204
+ end
205
+
206
+ # Returns the object in the form of hash with snake_case
207
+ def to_attributes
208
+ to_hash(downcase: true)
209
+ end
210
+
211
+ # Outputs non-array value in the form of hash
212
+ # For object, use to_hash. Otherwise, just return the value
213
+ # @param [Object] value Any valid value
214
+ # @return [Hash] Returns the value in the form of hash
215
+ def _to_hash(value, downcase: false)
216
+ if value.is_a?(Array)
217
+ value.map do |v|
218
+ v.to_hash(downcase: downcase)
219
+ end
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash(downcase: downcase)
226
+ else
227
+ value
228
+ end
229
+ end
230
+
231
+ def parse_date(datestring)
232
+ if datestring.include?('Date')
233
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
234
+ original, date, timezone = *date_pattern.match(datestring)
235
+ date = (date.to_i / 1000)
236
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
237
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
238
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
239
+ else # handle date 'types' for small subset of payroll API's
240
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
241
+ end
242
+ end
243
+ end
244
+ end