xero-ruby 9.3.0 → 18.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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xero-ruby/api/accounting_api.rb +178 -319
  3. data/lib/xero-ruby/api/files_api.rb +9 -2
  4. data/lib/xero-ruby/api/finance_api.rb +0 -299
  5. data/lib/xero-ruby/api/payroll_au_v2_api.rb +751 -0
  6. data/lib/xero-ruby/api/payroll_nz_api.rb +0 -86
  7. data/lib/xero-ruby/api/payroll_uk_api.rb +0 -86
  8. data/lib/xero-ruby/models/accounting/bank_transfer.rb +71 -1
  9. data/lib/xero-ruby/models/accounting/bank_transfer_delete.rb +244 -0
  10. data/lib/xero-ruby/models/accounting/bank_transfer_delete_by_url_param.rb +229 -0
  11. data/lib/xero-ruby/models/accounting/bank_transfers_delete.rb +224 -0
  12. data/lib/xero-ruby/models/accounting/contact.rb +27 -1
  13. data/lib/xero-ruby/models/accounting/credit_note.rb +11 -1
  14. data/lib/xero-ruby/models/accounting/invoice.rb +12 -2
  15. data/lib/xero-ruby/models/accounting/organisation.rb +25 -6
  16. data/lib/xero-ruby/models/accounting/overpayment.rb +21 -1
  17. data/lib/xero-ruby/models/accounting/payment.rb +11 -1
  18. data/lib/xero-ruby/models/accounting/prepayment.rb +31 -1
  19. data/lib/xero-ruby/models/accounting/tracking_reference.rb +277 -0
  20. data/lib/xero-ruby/models/accounting/user.rb +3 -2
  21. data/lib/xero-ruby/models/app_store/product.rb +4 -3
  22. data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +54 -4
  23. data/lib/xero-ruby/models/files/association.rb +21 -1
  24. data/lib/xero-ruby/models/finance/current_statement_response.rb +1 -1
  25. data/lib/xero-ruby/models/finance/data_source_response.rb +1 -31
  26. data/lib/xero-ruby/models/payroll_au/earnings_rate.rb +16 -1
  27. data/lib/xero-ruby/models/payroll_au/employee.rb +1 -13
  28. data/lib/xero-ruby/models/payroll_au/leave_line.rb +16 -1
  29. data/lib/xero-ruby/models/payroll_au/leave_type.rb +19 -4
  30. data/lib/xero-ruby/models/payroll_au/opening_balance_leave_line.rb +232 -0
  31. data/lib/xero-ruby/models/payroll_au/opening_balances.rb +1 -1
  32. data/lib/xero-ruby/models/payroll_au/tax_declaration.rb +14 -4
  33. data/lib/xero-ruby/models/payroll_au_v2/invalid_field.rb +232 -0
  34. data/lib/xero-ruby/models/payroll_au_v2/pagination.rb +252 -0
  35. data/lib/xero-ruby/models/payroll_au_v2/problem.rb +275 -0
  36. data/lib/xero-ruby/models/payroll_au_v2/timesheet.rb +361 -0
  37. data/lib/xero-ruby/models/payroll_au_v2/timesheet_line.rb +277 -0
  38. data/lib/xero-ruby/models/payroll_au_v2/timesheet_line_object.rb +242 -0
  39. data/lib/xero-ruby/models/payroll_au_v2/timesheet_object.rb +242 -0
  40. data/lib/xero-ruby/models/payroll_au_v2/timesheets.rb +244 -0
  41. data/lib/xero-ruby/models/payroll_nz/employee.rb +20 -0
  42. data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +29 -19
  43. data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +31 -11
  44. data/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb +5 -0
  45. data/lib/xero-ruby/models/payroll_nz/employment.rb +15 -0
  46. data/lib/xero-ruby/models/payroll_nz/leave_period.rb +35 -4
  47. data/lib/xero-ruby/models/payroll_nz/leave_type.rb +24 -4
  48. data/lib/xero-ruby/models/payroll_uk/contract_type.rb +38 -0
  49. data/lib/xero-ruby/models/payroll_uk/contracts.rb +297 -0
  50. data/lib/xero-ruby/models/payroll_uk/developmental_role_details.rb +267 -0
  51. data/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +5 -2
  52. data/lib/xero-ruby/models/payroll_uk/employee.rb +68 -4
  53. data/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb +5 -0
  54. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb +4 -2
  55. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb +5 -2
  56. data/lib/xero-ruby/models/payroll_uk/employment.rb +49 -52
  57. data/lib/xero-ruby/models/payroll_uk/employment_status.rb +37 -0
  58. data/lib/xero-ruby/models/payroll_uk/ni_category.rb +318 -0
  59. data/lib/xero-ruby/models/payroll_uk/ni_category_letter.rb +51 -0
  60. data/lib/xero-ruby/models/payroll_uk/ni_category_one_of.rb +264 -0
  61. data/lib/xero-ruby/models/payroll_uk/ni_category_one_of1.rb +257 -0
  62. data/lib/xero-ruby/version.rb +2 -2
  63. data/lib/xero-ruby.rb +22 -10
  64. data/spec/finance/api/finance_api_spec.rb +0 -53
  65. metadata +393 -391
  66. data/spec/finance/models/account_usage_response_spec.rb +0 -58
  67. data/spec/finance/models/account_usage_spec.rb +0 -112
  68. data/spec/finance/models/history_record_response_spec.rb +0 -64
  69. data/spec/finance/models/lock_history_model_spec.rb +0 -52
  70. data/spec/finance/models/lock_history_response_spec.rb +0 -52
  71. data/spec/finance/models/practice_response_spec.rb +0 -64
  72. data/spec/finance/models/report_history_model_spec.rb +0 -52
  73. data/spec/finance/models/report_history_response_spec.rb +0 -52
  74. data/spec/finance/models/user_activities_response_spec.rb +0 -52
  75. data/spec/finance/models/user_response_spec.rb +0 -106
@@ -5477,92 +5477,6 @@ module XeroRuby
5477
5477
  return data, status_code, headers
5478
5478
  end
5479
5479
 
5480
- # Updates a pay run
5481
- # @param xero_tenant_id [String] Xero identifier for Tenant
5482
- # @param pay_run_id [String] Identifier for the pay run
5483
- # @param pay_run [PayRun]
5484
- # @param [Hash] opts the optional parameters
5485
- # @option opts [String] :idempotency_key This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
5486
- # @return [PayRunObject]
5487
- def update_pay_run(xero_tenant_id, pay_run_id, pay_run, opts = {})
5488
- data, _status_code, _headers = update_pay_run_with_http_info(xero_tenant_id, pay_run_id, pay_run, opts)
5489
- data
5490
- end
5491
-
5492
- # Updates a pay run
5493
- # @param xero_tenant_id [String] Xero identifier for Tenant
5494
- # @param pay_run_id [String] Identifier for the pay run
5495
- # @param pay_run [PayRun]
5496
- # @param [Hash] opts the optional parameters
5497
- # @option opts [String] :idempotency_key This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
5498
- # @return [Array<(PayRunObject, Integer, Hash)>] PayRunObject data, response status code and response headers
5499
- def update_pay_run_with_http_info(xero_tenant_id, pay_run_id, pay_run, options = {})
5500
- opts = options.dup
5501
- if @api_client.config.debugging
5502
- @api_client.config.logger.debug 'Calling API: PayrollNzApi.update_pay_run ...'
5503
- end
5504
- # verify the required parameter 'xero_tenant_id' is set
5505
- if @api_client.config.client_side_validation && xero_tenant_id.nil?
5506
- fail ArgumentError, "Missing the required parameter 'xero_tenant_id' when calling PayrollNzApi.update_pay_run"
5507
- end
5508
- # verify the required parameter 'pay_run_id' is set
5509
- if @api_client.config.client_side_validation && pay_run_id.nil?
5510
- fail ArgumentError, "Missing the required parameter 'pay_run_id' when calling PayrollNzApi.update_pay_run"
5511
- end
5512
- # verify the required parameter 'pay_run' is set
5513
- if @api_client.config.client_side_validation && pay_run.nil?
5514
- fail ArgumentError, "Missing the required parameter 'pay_run' when calling PayrollNzApi.update_pay_run"
5515
- end
5516
- # resource path
5517
- local_var_path = '/PayRuns/{PayRunID}'.sub('{' + 'PayRunID' + '}', pay_run_id.to_s)
5518
-
5519
- # camelize keys of incoming `where` opts
5520
- opts[:'where'] = @api_client.parameterize_where(opts[:'where']) if !opts[:'where'].nil?
5521
-
5522
- # query parameters
5523
- query_params = opts[:query_params] || {}
5524
-
5525
- # XeroAPI's `IDs` convention openapi-generator does not snake_case properly.. manual over-riding `i_ds` malformations:
5526
- query_params[:'IDs'] = @api_client.build_collection_param(opts[:'ids'], :csv) if !opts[:'ids'].nil?
5527
- query_params[:'ContactIDs'] = @api_client.build_collection_param(opts[:'contact_ids'], :csv) if !opts[:'contact_ids'].nil?
5528
-
5529
- # header parameters
5530
- header_params = opts[:header_params] || {}
5531
- # HTTP header 'Accept' (if needed)
5532
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
5533
- # HTTP header 'Content-Type'
5534
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
5535
- header_params[:'Xero-Tenant-Id'] = xero_tenant_id
5536
- header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?
5537
-
5538
- # form parameters
5539
- form_params = opts[:form_params] || {}
5540
-
5541
- # http body (model)
5542
- post_body = opts[:body] || @api_client.object_to_http_body(pay_run)
5543
-
5544
- # return_type
5545
- return_type = opts[:return_type] || 'PayRunObject'
5546
-
5547
- # auth_names
5548
- auth_names = opts[:auth_names] || ['OAuth2']
5549
-
5550
- new_options = opts.merge(
5551
- :header_params => header_params,
5552
- :query_params => query_params,
5553
- :form_params => form_params,
5554
- :body => post_body,
5555
- :auth_names => auth_names,
5556
- :return_type => return_type
5557
- )
5558
-
5559
- data, status_code, headers = @api_client.call_api(:PUT, local_var_path, "PayrollNzApi", new_options)
5560
- if @api_client.config.debugging
5561
- @api_client.config.logger.debug "API called: PayrollNzApi#update_pay_run\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
5562
- end
5563
- return data, status_code, headers
5564
- end
5565
-
5566
5480
  # Creates an employee pay slip
5567
5481
  # @param xero_tenant_id [String] Xero identifier for Tenant
5568
5482
  # @param pay_slip_id [String] Identifier for the payslip
@@ -5379,92 +5379,6 @@ module XeroRuby
5379
5379
  return data, status_code, headers
5380
5380
  end
5381
5381
 
5382
- # Updates a specific pay run
5383
- # @param xero_tenant_id [String] Xero identifier for Tenant
5384
- # @param pay_run_id [String] Identifier for the pay run
5385
- # @param pay_run [PayRun]
5386
- # @param [Hash] opts the optional parameters
5387
- # @option opts [String] :idempotency_key This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
5388
- # @return [PayRunObject]
5389
- def update_pay_run(xero_tenant_id, pay_run_id, pay_run, opts = {})
5390
- data, _status_code, _headers = update_pay_run_with_http_info(xero_tenant_id, pay_run_id, pay_run, opts)
5391
- data
5392
- end
5393
-
5394
- # Updates a specific pay run
5395
- # @param xero_tenant_id [String] Xero identifier for Tenant
5396
- # @param pay_run_id [String] Identifier for the pay run
5397
- # @param pay_run [PayRun]
5398
- # @param [Hash] opts the optional parameters
5399
- # @option opts [String] :idempotency_key This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
5400
- # @return [Array<(PayRunObject, Integer, Hash)>] PayRunObject data, response status code and response headers
5401
- def update_pay_run_with_http_info(xero_tenant_id, pay_run_id, pay_run, options = {})
5402
- opts = options.dup
5403
- if @api_client.config.debugging
5404
- @api_client.config.logger.debug 'Calling API: PayrollUkApi.update_pay_run ...'
5405
- end
5406
- # verify the required parameter 'xero_tenant_id' is set
5407
- if @api_client.config.client_side_validation && xero_tenant_id.nil?
5408
- fail ArgumentError, "Missing the required parameter 'xero_tenant_id' when calling PayrollUkApi.update_pay_run"
5409
- end
5410
- # verify the required parameter 'pay_run_id' is set
5411
- if @api_client.config.client_side_validation && pay_run_id.nil?
5412
- fail ArgumentError, "Missing the required parameter 'pay_run_id' when calling PayrollUkApi.update_pay_run"
5413
- end
5414
- # verify the required parameter 'pay_run' is set
5415
- if @api_client.config.client_side_validation && pay_run.nil?
5416
- fail ArgumentError, "Missing the required parameter 'pay_run' when calling PayrollUkApi.update_pay_run"
5417
- end
5418
- # resource path
5419
- local_var_path = '/PayRuns/{PayRunID}'.sub('{' + 'PayRunID' + '}', pay_run_id.to_s)
5420
-
5421
- # camelize keys of incoming `where` opts
5422
- opts[:'where'] = @api_client.parameterize_where(opts[:'where']) if !opts[:'where'].nil?
5423
-
5424
- # query parameters
5425
- query_params = opts[:query_params] || {}
5426
-
5427
- # XeroAPI's `IDs` convention openapi-generator does not snake_case properly.. manual over-riding `i_ds` malformations:
5428
- query_params[:'IDs'] = @api_client.build_collection_param(opts[:'ids'], :csv) if !opts[:'ids'].nil?
5429
- query_params[:'ContactIDs'] = @api_client.build_collection_param(opts[:'contact_ids'], :csv) if !opts[:'contact_ids'].nil?
5430
-
5431
- # header parameters
5432
- header_params = opts[:header_params] || {}
5433
- # HTTP header 'Accept' (if needed)
5434
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
5435
- # HTTP header 'Content-Type'
5436
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
5437
- header_params[:'Xero-Tenant-Id'] = xero_tenant_id
5438
- header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?
5439
-
5440
- # form parameters
5441
- form_params = opts[:form_params] || {}
5442
-
5443
- # http body (model)
5444
- post_body = opts[:body] || @api_client.object_to_http_body(pay_run)
5445
-
5446
- # return_type
5447
- return_type = opts[:return_type] || 'PayRunObject'
5448
-
5449
- # auth_names
5450
- auth_names = opts[:auth_names] || ['OAuth2']
5451
-
5452
- new_options = opts.merge(
5453
- :header_params => header_params,
5454
- :query_params => query_params,
5455
- :form_params => form_params,
5456
- :body => post_body,
5457
- :auth_names => auth_names,
5458
- :return_type => return_type
5459
- )
5460
-
5461
- data, status_code, headers = @api_client.call_api(:PUT, local_var_path, "PayrollUkApi", new_options)
5462
- if @api_client.config.debugging
5463
- @api_client.config.logger.debug "API called: PayrollUkApi#update_pay_run\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
5464
- end
5465
- return data, status_code, headers
5466
- end
5467
-
5468
5382
  # Updates a specific timesheet line for a specific timesheet
5469
5383
  # @param xero_tenant_id [String] Xero identifier for Tenant
5470
5384
  # @param timesheet_id [String] Identifier for the timesheet
@@ -55,9 +55,42 @@ module XeroRuby::Accounting
55
55
  # UTC timestamp of creation date of bank transfer
56
56
  attr_accessor :created_date_utc
57
57
 
58
+ # AUTHORISED or DELETED (read-only). New bank transfers will have a status of AUTHORISED.
59
+ attr_accessor :status
60
+ AUTHORISED ||= "AUTHORISED".freeze
61
+ DELETED ||= "DELETED".freeze
62
+
63
+ # Optional Tracking Category for the source account – see Tracking. A bank transfer can have a maximum of 2 tracking categories per account.
64
+ attr_accessor :from_tracking
65
+
66
+ # Optional Tracking Category for the destination account – see Tracking. A bank transfer can have a maximum of 2 tracking categories per account.
67
+ attr_accessor :to_tracking
68
+
58
69
  # Displays array of validation error messages from the API
59
70
  attr_accessor :validation_errors
60
71
 
72
+ class EnumAttributeValidator
73
+ attr_reader :datatype
74
+ attr_reader :allowable_values
75
+
76
+ def initialize(datatype, allowable_values)
77
+ @allowable_values = allowable_values.map do |value|
78
+ case datatype.to_s
79
+ when /Integer/i
80
+ value.to_i
81
+ when /Float/i
82
+ value.to_f
83
+ else
84
+ value
85
+ end
86
+ end
87
+ end
88
+
89
+ def valid?(value)
90
+ !value || allowable_values.include?(value)
91
+ end
92
+ end
93
+
61
94
  # Attribute mapping from ruby-style variable name to JSON key.
62
95
  def self.attribute_map
63
96
  {
@@ -74,6 +107,9 @@ module XeroRuby::Accounting
74
107
  :'reference' => :'Reference',
75
108
  :'has_attachments' => :'HasAttachments',
76
109
  :'created_date_utc' => :'CreatedDateUTC',
110
+ :'status' => :'Status',
111
+ :'from_tracking' => :'FromTracking',
112
+ :'to_tracking' => :'ToTracking',
77
113
  :'validation_errors' => :'ValidationErrors'
78
114
  }
79
115
  end
@@ -94,6 +130,9 @@ module XeroRuby::Accounting
94
130
  :'reference' => :'String',
95
131
  :'has_attachments' => :'Boolean',
96
132
  :'created_date_utc' => :'DateTime',
133
+ :'status' => :'String',
134
+ :'from_tracking' => :'Array<TrackingReference>',
135
+ :'to_tracking' => :'Array<TrackingReference>',
97
136
  :'validation_errors' => :'Array<ValidationError>'
98
137
  }
99
138
  end
@@ -171,6 +210,22 @@ module XeroRuby::Accounting
171
210
  self.created_date_utc = attributes[:'created_date_utc']
172
211
  end
173
212
 
213
+ if attributes.key?(:'status')
214
+ self.status = attributes[:'status']
215
+ end
216
+
217
+ if attributes.key?(:'from_tracking')
218
+ if (value = attributes[:'from_tracking']).is_a?(Array)
219
+ self.from_tracking = value
220
+ end
221
+ end
222
+
223
+ if attributes.key?(:'to_tracking')
224
+ if (value = attributes[:'to_tracking']).is_a?(Array)
225
+ self.to_tracking = value
226
+ end
227
+ end
228
+
174
229
  if attributes.key?(:'validation_errors')
175
230
  if (value = attributes[:'validation_errors']).is_a?(Array)
176
231
  self.validation_errors = value
@@ -203,9 +258,21 @@ module XeroRuby::Accounting
203
258
  return false if @from_bank_account.nil?
204
259
  return false if @to_bank_account.nil?
205
260
  return false if @amount.nil?
261
+ status_validator = EnumAttributeValidator.new('String', ["AUTHORISED", "DELETED"])
262
+ return false unless status_validator.valid?(@status)
206
263
  true
207
264
  end
208
265
 
266
+ # Custom attribute writer method checking allowed values (enum).
267
+ # @param [Object] status Object to be assigned
268
+ def status=(status)
269
+ validator = EnumAttributeValidator.new('String', ["AUTHORISED", "DELETED"])
270
+ unless validator.valid?(status)
271
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
272
+ end
273
+ @status = status
274
+ end
275
+
209
276
  # Checks equality by comparing each attribute.
210
277
  # @param [Object] Object to be compared
211
278
  def ==(o)
@@ -224,6 +291,9 @@ module XeroRuby::Accounting
224
291
  reference == o.reference &&
225
292
  has_attachments == o.has_attachments &&
226
293
  created_date_utc == o.created_date_utc &&
294
+ status == o.status &&
295
+ from_tracking == o.from_tracking &&
296
+ to_tracking == o.to_tracking &&
227
297
  validation_errors == o.validation_errors
228
298
  end
229
299
 
@@ -236,7 +306,7 @@ module XeroRuby::Accounting
236
306
  # Calculates hash code according to all attributes.
237
307
  # @return [Integer] Hash code
238
308
  def hash
239
- [from_bank_account, to_bank_account, amount, date, bank_transfer_id, currency_rate, from_bank_transaction_id, to_bank_transaction_id, from_is_reconciled, to_is_reconciled, reference, has_attachments, created_date_utc, validation_errors].hash
309
+ [from_bank_account, to_bank_account, amount, date, bank_transfer_id, currency_rate, from_bank_transaction_id, to_bank_transaction_id, from_is_reconciled, to_is_reconciled, reference, has_attachments, created_date_utc, status, from_tracking, to_tracking, validation_errors].hash
240
310
  end
241
311
 
242
312
  # Builds the object from hash
@@ -0,0 +1,244 @@
1
+ =begin
2
+ #Xero Accounting API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
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::Accounting
16
+ require 'bigdecimal'
17
+
18
+ class BankTransferDelete
19
+ # The Xero identifier for a bank transfer
20
+ attr_accessor :bank_transfer_id
21
+
22
+ # The status of the bank transfer.
23
+ attr_accessor :status
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'bank_transfer_id' => :'BankTransferID',
29
+ :'status' => :'Status'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'bank_transfer_id' => :'String',
37
+ :'status' => :'String'
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::Accounting::BankTransferDelete` 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::Accounting::BankTransferDelete`. 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?(:'bank_transfer_id')
57
+ self.bank_transfer_id = attributes[:'bank_transfer_id']
58
+ end
59
+
60
+ if attributes.key?(:'status')
61
+ self.status = attributes[:'status']
62
+ else
63
+ self.status = 'DELETED'
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 @bank_transfer_id.nil?
72
+ invalid_properties.push('invalid value for "bank_transfer_id", bank_transfer_id cannot be nil.')
73
+ end
74
+
75
+ if @status.nil?
76
+ invalid_properties.push('invalid value for "status", status 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 @bank_transfer_id.nil?
86
+ return false if @status.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
+ bank_transfer_id == o.bank_transfer_id &&
96
+ status == o.status
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
+ [bank_transfer_id, status].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::Accounting.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