xero-ruby 12.0.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xero-ruby/api/accounting_api.rb +11 -0
  3. data/lib/xero-ruby/api/finance_api.rb +0 -299
  4. data/lib/xero-ruby/api/payroll_au_v2_api.rb +751 -0
  5. data/lib/xero-ruby/api/payroll_nz_api.rb +0 -86
  6. data/lib/xero-ruby/api/payroll_uk_api.rb +0 -86
  7. data/lib/xero-ruby/models/accounting/contact.rb +27 -1
  8. data/lib/xero-ruby/models/accounting/overpayment.rb +11 -1
  9. data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +54 -4
  10. data/lib/xero-ruby/models/payroll_au/earnings_rate.rb +11 -1
  11. data/lib/xero-ruby/models/payroll_au/employee.rb +1 -13
  12. data/lib/xero-ruby/models/payroll_au/leave_line.rb +11 -1
  13. data/lib/xero-ruby/models/payroll_au/leave_type.rb +14 -4
  14. data/lib/xero-ruby/models/payroll_au/opening_balance_leave_line.rb +232 -0
  15. data/lib/xero-ruby/models/payroll_au/opening_balances.rb +1 -1
  16. data/lib/xero-ruby/models/payroll_au/tax_declaration.rb +14 -4
  17. data/lib/xero-ruby/models/payroll_au_v2/invalid_field.rb +232 -0
  18. data/lib/xero-ruby/models/payroll_au_v2/pagination.rb +252 -0
  19. data/lib/xero-ruby/models/payroll_au_v2/problem.rb +275 -0
  20. data/lib/xero-ruby/models/payroll_au_v2/timesheet.rb +361 -0
  21. data/lib/xero-ruby/models/payroll_au_v2/timesheet_line.rb +277 -0
  22. data/lib/xero-ruby/models/payroll_au_v2/timesheet_line_object.rb +242 -0
  23. data/lib/xero-ruby/models/payroll_au_v2/timesheet_object.rb +242 -0
  24. data/lib/xero-ruby/models/payroll_au_v2/timesheets.rb +244 -0
  25. data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +1 -21
  26. data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +3 -13
  27. data/lib/xero-ruby/models/payroll_uk/contract_type.rb +38 -0
  28. data/lib/xero-ruby/models/payroll_uk/contracts.rb +297 -0
  29. data/lib/xero-ruby/models/payroll_uk/developmental_role_details.rb +267 -0
  30. data/lib/xero-ruby/models/payroll_uk/employee.rb +16 -4
  31. data/lib/xero-ruby/models/payroll_uk/employment.rb +16 -4
  32. data/lib/xero-ruby/models/payroll_uk/employment_status.rb +37 -0
  33. data/lib/xero-ruby/version.rb +2 -2
  34. data/lib/xero-ruby.rb +14 -10
  35. data/spec/finance/api/finance_api_spec.rb +0 -53
  36. metadata +379 -385
  37. data/spec/finance/models/account_usage_response_spec.rb +0 -58
  38. data/spec/finance/models/account_usage_spec.rb +0 -112
  39. data/spec/finance/models/history_record_response_spec.rb +0 -64
  40. data/spec/finance/models/lock_history_model_spec.rb +0 -52
  41. data/spec/finance/models/lock_history_response_spec.rb +0 -52
  42. data/spec/finance/models/practice_response_spec.rb +0 -64
  43. data/spec/finance/models/report_history_model_spec.rb +0 -52
  44. data/spec/finance/models/report_history_response_spec.rb +0 -52
  45. data/spec/finance/models/user_activities_response_spec.rb +0 -52
  46. data/spec/finance/models/user_response_spec.rb +0 -106
@@ -0,0 +1,252 @@
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 Pagination
19
+
20
+ attr_accessor :page
21
+
22
+
23
+ attr_accessor :page_size
24
+
25
+
26
+ attr_accessor :page_count
27
+
28
+
29
+ attr_accessor :item_count
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'page' => :'page',
35
+ :'page_size' => :'pageSize',
36
+ :'page_count' => :'pageCount',
37
+ :'item_count' => :'itemCount'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'page' => :'Integer',
45
+ :'page_size' => :'Integer',
46
+ :'page_count' => :'Integer',
47
+ :'item_count' => :'Integer'
48
+ }
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollAuV2::Pagination` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollAuV2::Pagination`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'page')
67
+ self.page = attributes[:'page']
68
+ end
69
+
70
+ if attributes.key?(:'page_size')
71
+ self.page_size = attributes[:'page_size']
72
+ end
73
+
74
+ if attributes.key?(:'page_count')
75
+ self.page_count = attributes[:'page_count']
76
+ end
77
+
78
+ if attributes.key?(:'item_count')
79
+ self.item_count = attributes[:'item_count']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ invalid_properties
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ true
94
+ end
95
+
96
+ # Checks equality by comparing each attribute.
97
+ # @param [Object] Object to be compared
98
+ def ==(o)
99
+ return true if self.equal?(o)
100
+ self.class == o.class &&
101
+ page == o.page &&
102
+ page_size == o.page_size &&
103
+ page_count == o.page_count &&
104
+ item_count == o.item_count
105
+ end
106
+
107
+ # @see the `==` method
108
+ # @param [Object] Object to be compared
109
+ def eql?(o)
110
+ self == o
111
+ end
112
+
113
+ # Calculates hash code according to all attributes.
114
+ # @return [Integer] Hash code
115
+ def hash
116
+ [page, page_size, page_count, item_count].hash
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def self.build_from_hash(attributes)
123
+ new.build_from_hash(attributes)
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def build_from_hash(attributes)
130
+ return nil unless attributes.is_a?(Hash)
131
+ self.class.openapi_types.each_pair do |key, type|
132
+ if type =~ /\AArray<(.*)>/i
133
+ # check to ensure the input is an array given that the attribute
134
+ # is documented as an array but the input is not
135
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
136
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
137
+ end
138
+ elsif !attributes[self.class.attribute_map[key]].nil?
139
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
140
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
141
+ end
142
+
143
+ self
144
+ end
145
+
146
+ # Deserializes the data based on type
147
+ # @param string type Data type
148
+ # @param string value Value to be deserialized
149
+ # @return [Object] Deserialized data
150
+ def _deserialize(type, value)
151
+ case type.to_sym
152
+ when :DateTime
153
+ DateTime.parse(parse_date(value))
154
+ when :Date
155
+ Date.parse(parse_date(value))
156
+ when :String
157
+ value.to_s
158
+ when :Integer
159
+ value.to_i
160
+ when :Float
161
+ value.to_f
162
+ when :BigDecimal
163
+ BigDecimal(value.to_s)
164
+ when :Boolean
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ XeroRuby::PayrollAuV2.const_get(type).build_from_hash(value)
186
+ end
187
+ end
188
+
189
+ # Returns the string representation of the object
190
+ # @return [String] String presentation of the object
191
+ def to_s
192
+ to_hash.to_s
193
+ end
194
+
195
+ # to_body is an alias to to_hash (backward compatibility)
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_body
198
+ to_hash
199
+ end
200
+
201
+ # Returns the object in the form of hash
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_hash(downcase: false)
204
+ hash = {}
205
+ self.class.attribute_map.each_pair do |attr, param|
206
+ value = self.send(attr)
207
+ next if value.nil?
208
+ key = downcase ? attr : param
209
+ hash[key] = _to_hash(value, downcase: downcase)
210
+ end
211
+ hash
212
+ end
213
+
214
+ # Returns the object in the form of hash with snake_case
215
+ def to_attributes
216
+ to_hash(downcase: true)
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value, downcase: false)
224
+ if value.is_a?(Array)
225
+ value.map do |v|
226
+ v.to_hash(downcase: downcase)
227
+ end
228
+ elsif value.is_a?(Hash)
229
+ {}.tap do |hash|
230
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
231
+ end
232
+ elsif value.respond_to? :to_hash
233
+ value.to_hash(downcase: downcase)
234
+ else
235
+ value
236
+ end
237
+ end
238
+
239
+ def parse_date(datestring)
240
+ if datestring.include?('Date')
241
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
242
+ original, date, timezone = *date_pattern.match(datestring)
243
+ date = (date.to_i / 1000)
244
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
245
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
246
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
247
+ else # handle date 'types' for small subset of payroll API's
248
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
249
+ end
250
+ end
251
+ end
252
+ end
@@ -0,0 +1,275 @@
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
+ # The object returned for a bad request
17
+ require 'bigdecimal'
18
+
19
+ class Problem
20
+ # The type of error format
21
+ attr_accessor :type
22
+
23
+ # The type of the error
24
+ attr_accessor :title
25
+
26
+ # The error status code
27
+ attr_accessor :status
28
+
29
+ # A description of the error
30
+ attr_accessor :detail
31
+
32
+
33
+ attr_accessor :instance
34
+
35
+
36
+ attr_accessor :invalid_fields
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'type' => :'type',
42
+ :'title' => :'title',
43
+ :'status' => :'status',
44
+ :'detail' => :'detail',
45
+ :'instance' => :'instance',
46
+ :'invalid_fields' => :'invalidFields'
47
+ }
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'type' => :'String',
54
+ :'title' => :'String',
55
+ :'status' => :'String',
56
+ :'detail' => :'String',
57
+ :'instance' => :'String',
58
+ :'invalid_fields' => :'Array<InvalidField>'
59
+ }
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollAuV2::Problem` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollAuV2::Problem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'type')
78
+ self.type = attributes[:'type']
79
+ end
80
+
81
+ if attributes.key?(:'title')
82
+ self.title = attributes[:'title']
83
+ end
84
+
85
+ if attributes.key?(:'status')
86
+ self.status = attributes[:'status']
87
+ end
88
+
89
+ if attributes.key?(:'detail')
90
+ self.detail = attributes[:'detail']
91
+ end
92
+
93
+ if attributes.key?(:'instance')
94
+ self.instance = attributes[:'instance']
95
+ end
96
+
97
+ if attributes.key?(:'invalid_fields')
98
+ if (value = attributes[:'invalid_fields']).is_a?(Array)
99
+ self.invalid_fields = value
100
+ end
101
+ end
102
+ end
103
+
104
+ # Show invalid properties with the reasons. Usually used together with valid?
105
+ # @return Array for valid properties with the reasons
106
+ def list_invalid_properties
107
+ invalid_properties = Array.new
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ true
115
+ end
116
+
117
+ # Checks equality by comparing each attribute.
118
+ # @param [Object] Object to be compared
119
+ def ==(o)
120
+ return true if self.equal?(o)
121
+ self.class == o.class &&
122
+ type == o.type &&
123
+ title == o.title &&
124
+ status == o.status &&
125
+ detail == o.detail &&
126
+ instance == o.instance &&
127
+ invalid_fields == o.invalid_fields
128
+ end
129
+
130
+ # @see the `==` method
131
+ # @param [Object] Object to be compared
132
+ def eql?(o)
133
+ self == o
134
+ end
135
+
136
+ # Calculates hash code according to all attributes.
137
+ # @return [Integer] Hash code
138
+ def hash
139
+ [type, title, status, detail, instance, invalid_fields].hash
140
+ end
141
+
142
+ # Builds the object from hash
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ # @return [Object] Returns the model itself
145
+ def self.build_from_hash(attributes)
146
+ new.build_from_hash(attributes)
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def build_from_hash(attributes)
153
+ return nil unless attributes.is_a?(Hash)
154
+ self.class.openapi_types.each_pair do |key, type|
155
+ if type =~ /\AArray<(.*)>/i
156
+ # check to ensure the input is an array given that the attribute
157
+ # is documented as an array but the input is not
158
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
159
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
160
+ end
161
+ elsif !attributes[self.class.attribute_map[key]].nil?
162
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
163
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
164
+ end
165
+
166
+ self
167
+ end
168
+
169
+ # Deserializes the data based on type
170
+ # @param string type Data type
171
+ # @param string value Value to be deserialized
172
+ # @return [Object] Deserialized data
173
+ def _deserialize(type, value)
174
+ case type.to_sym
175
+ when :DateTime
176
+ DateTime.parse(parse_date(value))
177
+ when :Date
178
+ Date.parse(parse_date(value))
179
+ when :String
180
+ value.to_s
181
+ when :Integer
182
+ value.to_i
183
+ when :Float
184
+ value.to_f
185
+ when :BigDecimal
186
+ BigDecimal(value.to_s)
187
+ when :Boolean
188
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
189
+ true
190
+ else
191
+ false
192
+ end
193
+ when :Object
194
+ # generic object (usually a Hash), return directly
195
+ value
196
+ when /\AArray<(?<inner_type>.+)>\z/
197
+ inner_type = Regexp.last_match[:inner_type]
198
+ value.map { |v| _deserialize(inner_type, v) }
199
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
200
+ k_type = Regexp.last_match[:k_type]
201
+ v_type = Regexp.last_match[:v_type]
202
+ {}.tap do |hash|
203
+ value.each do |k, v|
204
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
205
+ end
206
+ end
207
+ else # model
208
+ XeroRuby::PayrollAuV2.const_get(type).build_from_hash(value)
209
+ end
210
+ end
211
+
212
+ # Returns the string representation of the object
213
+ # @return [String] String presentation of the object
214
+ def to_s
215
+ to_hash.to_s
216
+ end
217
+
218
+ # to_body is an alias to to_hash (backward compatibility)
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_body
221
+ to_hash
222
+ end
223
+
224
+ # Returns the object in the form of hash
225
+ # @return [Hash] Returns the object in the form of hash
226
+ def to_hash(downcase: false)
227
+ hash = {}
228
+ self.class.attribute_map.each_pair do |attr, param|
229
+ value = self.send(attr)
230
+ next if value.nil?
231
+ key = downcase ? attr : param
232
+ hash[key] = _to_hash(value, downcase: downcase)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Returns the object in the form of hash with snake_case
238
+ def to_attributes
239
+ to_hash(downcase: true)
240
+ end
241
+
242
+ # Outputs non-array value in the form of hash
243
+ # For object, use to_hash. Otherwise, just return the value
244
+ # @param [Object] value Any valid value
245
+ # @return [Hash] Returns the value in the form of hash
246
+ def _to_hash(value, downcase: false)
247
+ if value.is_a?(Array)
248
+ value.map do |v|
249
+ v.to_hash(downcase: downcase)
250
+ end
251
+ elsif value.is_a?(Hash)
252
+ {}.tap do |hash|
253
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
254
+ end
255
+ elsif value.respond_to? :to_hash
256
+ value.to_hash(downcase: downcase)
257
+ else
258
+ value
259
+ end
260
+ end
261
+
262
+ def parse_date(datestring)
263
+ if datestring.include?('Date')
264
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
265
+ original, date, timezone = *date_pattern.match(datestring)
266
+ date = (date.to_i / 1000)
267
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
268
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
269
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
270
+ else # handle date 'types' for small subset of payroll API's
271
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
272
+ end
273
+ end
274
+ end
275
+ end