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