xero-ruby 3.16.0 → 10.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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xero-ruby/api/accounting_api.rb +645 -3
  3. data/lib/xero-ruby/api/app_store_api.rb +6 -0
  4. data/lib/xero-ruby/api/asset_api.rb +16 -6
  5. data/lib/xero-ruby/api/files_api.rb +156 -20
  6. data/lib/xero-ruby/api/payroll_au_api.rb +326 -30
  7. data/lib/xero-ruby/api/payroll_nz_api.rb +417 -7
  8. data/lib/xero-ruby/api/payroll_uk_api.rb +81 -0
  9. data/lib/xero-ruby/api/project_api.rb +21 -0
  10. data/lib/xero-ruby/api_client.rb +7 -7
  11. data/lib/xero-ruby/models/accounting/account_type.rb +0 -4
  12. data/lib/xero-ruby/models/accounting/allocation.rb +21 -1
  13. data/lib/xero-ruby/models/accounting/bank_transactions.rb +23 -1
  14. data/lib/xero-ruby/models/accounting/contact.rb +1 -11
  15. data/lib/xero-ruby/models/accounting/contacts.rb +23 -1
  16. data/lib/xero-ruby/models/accounting/credit_note.rb +17 -5
  17. data/lib/xero-ruby/models/accounting/credit_notes.rb +23 -1
  18. data/lib/xero-ruby/models/accounting/currency_code.rb +10 -8
  19. data/lib/xero-ruby/models/accounting/invoice.rb +16 -4
  20. data/lib/xero-ruby/models/accounting/invoice_address.rb +338 -0
  21. data/lib/xero-ruby/models/accounting/invoices.rb +23 -1
  22. data/lib/xero-ruby/models/accounting/journals.rb +13 -1
  23. data/lib/xero-ruby/models/accounting/line_item.rb +75 -4
  24. data/lib/xero-ruby/models/accounting/manual_journals.rb +23 -1
  25. data/lib/xero-ruby/models/accounting/organisation.rb +9 -2
  26. data/lib/xero-ruby/models/accounting/overpayments.rb +23 -1
  27. data/lib/xero-ruby/models/accounting/pagination.rb +252 -0
  28. data/lib/xero-ruby/models/accounting/payment.rb +16 -4
  29. data/lib/xero-ruby/models/accounting/payments.rb +23 -1
  30. data/lib/xero-ruby/models/accounting/prepayments.rb +23 -1
  31. data/lib/xero-ruby/models/accounting/purchase_orders.rb +23 -1
  32. data/lib/xero-ruby/models/accounting/tax_breakdown_component.rb +351 -0
  33. data/lib/xero-ruby/models/accounting/tax_rate.rb +13 -6
  34. data/lib/xero-ruby/models/accounting/tax_type.rb +45 -4
  35. data/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb +75 -4
  36. data/lib/xero-ruby/models/files/association.rb +31 -1
  37. data/lib/xero-ruby/models/finance/current_statement_response.rb +1 -1
  38. data/lib/xero-ruby/models/finance/data_source_response.rb +13 -43
  39. data/lib/xero-ruby/models/finance/problem_type.rb +1 -0
  40. data/lib/xero-ruby/models/finance/statement_line_response.rb +11 -1
  41. data/lib/xero-ruby/models/finance/statement_response.rb +24 -4
  42. data/lib/xero-ruby/models/payroll_au/allowance_type.rb +0 -1
  43. data/lib/xero-ruby/models/payroll_au/country_of_residence.rb +0 -1
  44. data/lib/xero-ruby/models/payroll_au/earnings_rate.rb +21 -1
  45. data/lib/xero-ruby/models/payroll_au/leave_application.rb +11 -1
  46. data/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb +14 -4
  47. data/lib/xero-ruby/models/payroll_au/leave_line_calculation_type.rb +0 -1
  48. data/lib/xero-ruby/models/payroll_au/leave_period_status.rb +2 -0
  49. data/lib/xero-ruby/models/payroll_au/opening_balances.rb +16 -4
  50. data/lib/xero-ruby/models/payroll_au/paid_leave_earnings_line.rb +272 -0
  51. data/lib/xero-ruby/models/payroll_au/pay_out_type.rb +36 -0
  52. data/lib/xero-ruby/models/payroll_nz/employee.rb +34 -4
  53. data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +56 -6
  54. data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +47 -7
  55. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern.rb +242 -0
  56. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks.rb +254 -0
  57. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks_object.rb +242 -0
  58. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks_request.rb +244 -0
  59. data/lib/xero-ruby/models/payroll_nz/employee_working_patterns_object.rb +244 -0
  60. data/lib/xero-ruby/models/payroll_nz/employment.rb +24 -4
  61. data/lib/xero-ruby/models/payroll_nz/leave_period.rb +35 -4
  62. data/lib/xero-ruby/models/payroll_nz/leave_type.rb +24 -4
  63. data/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb +28 -4
  64. data/lib/xero-ruby/models/payroll_nz/working_week.rb +317 -0
  65. data/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +3 -3
  66. data/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb +14 -4
  67. data/lib/xero-ruby/models/projects/currency_code.rb +0 -1
  68. data/lib/xero-ruby/version.rb +2 -2
  69. data/lib/xero-ruby/where.rb +37 -37
  70. data/lib/xero-ruby.rb +11 -0
  71. data/spec/api_client_spec.rb +56 -56
  72. data/spec/api_error_spec.rb +1 -1
  73. data/spec/configuration_spec.rb +2 -2
  74. data/spec/helper_methods_spec.rb +3 -3
  75. data/spec/where_spec.rb +2 -2
  76. metadata +38 -27
@@ -61,6 +61,42 @@ module XeroRuby::Accounting
61
61
  # The Xero identifier for a Repeating Invoice
62
62
  attr_accessor :repeating_invoice_id
63
63
 
64
+ # The type of taxability
65
+ attr_accessor :taxability
66
+ TAXABLE ||= "TAXABLE".freeze
67
+ NON_TAXABLE ||= "NON_TAXABLE".freeze
68
+ EXEMPT ||= "EXEMPT".freeze
69
+ PART_TAXABLE ||= "PART_TAXABLE".freeze
70
+ NOT_APPLICABLE ||= "NOT_APPLICABLE".freeze
71
+
72
+ # The ID of the sales tax code
73
+ attr_accessor :sales_tax_code_id
74
+
75
+ # An array of tax components defined for this line item
76
+ attr_accessor :tax_breakdown
77
+
78
+ class EnumAttributeValidator
79
+ attr_reader :datatype
80
+ attr_reader :allowable_values
81
+
82
+ def initialize(datatype, allowable_values)
83
+ @allowable_values = allowable_values.map do |value|
84
+ case datatype.to_s
85
+ when /Integer/i
86
+ value.to_i
87
+ when /Float/i
88
+ value.to_f
89
+ else
90
+ value
91
+ end
92
+ end
93
+ end
94
+
95
+ def valid?(value)
96
+ !value || allowable_values.include?(value)
97
+ end
98
+ end
99
+
64
100
  # Attribute mapping from ruby-style variable name to JSON key.
65
101
  def self.attribute_map
66
102
  {
@@ -78,7 +114,10 @@ module XeroRuby::Accounting
78
114
  :'tracking' => :'Tracking',
79
115
  :'discount_rate' => :'DiscountRate',
80
116
  :'discount_amount' => :'DiscountAmount',
81
- :'repeating_invoice_id' => :'RepeatingInvoiceID'
117
+ :'repeating_invoice_id' => :'RepeatingInvoiceID',
118
+ :'taxability' => :'Taxability',
119
+ :'sales_tax_code_id' => :'SalesTaxCodeId',
120
+ :'tax_breakdown' => :'TaxBreakdown'
82
121
  }
83
122
  end
84
123
 
@@ -99,7 +138,10 @@ module XeroRuby::Accounting
99
138
  :'tracking' => :'Array<LineItemTracking>',
100
139
  :'discount_rate' => :'BigDecimal',
101
140
  :'discount_amount' => :'BigDecimal',
102
- :'repeating_invoice_id' => :'String'
141
+ :'repeating_invoice_id' => :'String',
142
+ :'taxability' => :'String',
143
+ :'sales_tax_code_id' => :'Float',
144
+ :'tax_breakdown' => :'Array<TaxBreakdownComponent>'
103
145
  }
104
146
  end
105
147
 
@@ -179,6 +221,20 @@ module XeroRuby::Accounting
179
221
  if attributes.key?(:'repeating_invoice_id')
180
222
  self.repeating_invoice_id = attributes[:'repeating_invoice_id']
181
223
  end
224
+
225
+ if attributes.key?(:'taxability')
226
+ self.taxability = attributes[:'taxability']
227
+ end
228
+
229
+ if attributes.key?(:'sales_tax_code_id')
230
+ self.sales_tax_code_id = attributes[:'sales_tax_code_id']
231
+ end
232
+
233
+ if attributes.key?(:'tax_breakdown')
234
+ if (value = attributes[:'tax_breakdown']).is_a?(Array)
235
+ self.tax_breakdown = value
236
+ end
237
+ end
182
238
  end
183
239
 
184
240
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -191,9 +247,21 @@ module XeroRuby::Accounting
191
247
  # Check to see if the all the properties in the model are valid
192
248
  # @return true if the model is valid
193
249
  def valid?
250
+ taxability_validator = EnumAttributeValidator.new('String', ["TAXABLE", "NON_TAXABLE", "EXEMPT", "PART_TAXABLE", "NOT_APPLICABLE"])
251
+ return false unless taxability_validator.valid?(@taxability)
194
252
  true
195
253
  end
196
254
 
255
+ # Custom attribute writer method checking allowed values (enum).
256
+ # @param [Object] taxability Object to be assigned
257
+ def taxability=(taxability)
258
+ validator = EnumAttributeValidator.new('String', ["TAXABLE", "NON_TAXABLE", "EXEMPT", "PART_TAXABLE", "NOT_APPLICABLE"])
259
+ unless validator.valid?(taxability)
260
+ fail ArgumentError, "invalid value for \"taxability\", must be one of #{validator.allowable_values}."
261
+ end
262
+ @taxability = taxability
263
+ end
264
+
197
265
  # Checks equality by comparing each attribute.
198
266
  # @param [Object] Object to be compared
199
267
  def ==(o)
@@ -213,7 +281,10 @@ module XeroRuby::Accounting
213
281
  tracking == o.tracking &&
214
282
  discount_rate == o.discount_rate &&
215
283
  discount_amount == o.discount_amount &&
216
- repeating_invoice_id == o.repeating_invoice_id
284
+ repeating_invoice_id == o.repeating_invoice_id &&
285
+ taxability == o.taxability &&
286
+ sales_tax_code_id == o.sales_tax_code_id &&
287
+ tax_breakdown == o.tax_breakdown
217
288
  end
218
289
 
219
290
  # @see the `==` method
@@ -225,7 +296,7 @@ module XeroRuby::Accounting
225
296
  # Calculates hash code according to all attributes.
226
297
  # @return [Integer] Hash code
227
298
  def hash
228
- [line_item_id, description, quantity, unit_amount, item_code, account_code, account_id, tax_type, tax_amount, item, line_amount, tracking, discount_rate, discount_amount, repeating_invoice_id].hash
299
+ [line_item_id, description, quantity, unit_amount, item_code, account_code, account_id, tax_type, tax_amount, item, line_amount, tracking, discount_rate, discount_amount, repeating_invoice_id, taxability, sales_tax_code_id, tax_breakdown].hash
229
300
  end
230
301
 
231
302
  # Builds the object from hash
@@ -17,11 +17,19 @@ module XeroRuby::Accounting
17
17
 
18
18
  class ManualJournals
19
19
 
20
+ attr_accessor :pagination
21
+
22
+ # Displays array of warning messages from the API
23
+ attr_accessor :warnings
24
+
25
+
20
26
  attr_accessor :manual_journals
21
27
 
22
28
  # Attribute mapping from ruby-style variable name to JSON key.
23
29
  def self.attribute_map
24
30
  {
31
+ :'pagination' => :'pagination',
32
+ :'warnings' => :'Warnings',
25
33
  :'manual_journals' => :'ManualJournals'
26
34
  }
27
35
  end
@@ -29,6 +37,8 @@ module XeroRuby::Accounting
29
37
  # Attribute type mapping.
30
38
  def self.openapi_types
31
39
  {
40
+ :'pagination' => :'Pagination',
41
+ :'warnings' => :'Array<ValidationError>',
32
42
  :'manual_journals' => :'Array<ManualJournal>'
33
43
  }
34
44
  end
@@ -48,6 +58,16 @@ module XeroRuby::Accounting
48
58
  h[k.to_sym] = v
49
59
  }
50
60
 
61
+ if attributes.key?(:'pagination')
62
+ self.pagination = attributes[:'pagination']
63
+ end
64
+
65
+ if attributes.key?(:'warnings')
66
+ if (value = attributes[:'warnings']).is_a?(Array)
67
+ self.warnings = value
68
+ end
69
+ end
70
+
51
71
  if attributes.key?(:'manual_journals')
52
72
  if (value = attributes[:'manual_journals']).is_a?(Array)
53
73
  self.manual_journals = value
@@ -73,6 +93,8 @@ module XeroRuby::Accounting
73
93
  def ==(o)
74
94
  return true if self.equal?(o)
75
95
  self.class == o.class &&
96
+ pagination == o.pagination &&
97
+ warnings == o.warnings &&
76
98
  manual_journals == o.manual_journals
77
99
  end
78
100
 
@@ -85,7 +107,7 @@ module XeroRuby::Accounting
85
107
  # Calculates hash code according to all attributes.
86
108
  # @return [Integer] Hash code
87
109
  def hash
88
- [manual_journals].hash
110
+ [pagination, warnings, manual_journals].hash
89
111
  end
90
112
 
91
113
  # Builds the object from hash
@@ -168,6 +168,13 @@ module XeroRuby::Accounting
168
168
  NON_GST_CASHBOOK ||= "NON_GST_CASHBOOK".freeze
169
169
  ULTIMATE ||= "ULTIMATE".freeze
170
170
  LITE ||= "LITE".freeze
171
+ ULTIMATE_10 ||= "ULTIMATE_10".freeze
172
+ ULTIMATE_20 ||= "ULTIMATE_20".freeze
173
+ ULTIMATE_50 ||= "ULTIMATE_50".freeze
174
+ ULTIMATE_100 ||= "ULTIMATE_100".freeze
175
+ IGNITE ||= "IGNITE".freeze
176
+ GROW ||= "GROW".freeze
177
+ COMPREHENSIVE ||= "COMPREHENSIVE".freeze
171
178
 
172
179
  # BUSINESS or PARTNER. Partner edition organisations are sold exclusively through accounting partners and have restricted functionality (e.g. no access to invoicing)
173
180
  attr_accessor :edition
@@ -463,7 +470,7 @@ module XeroRuby::Accounting
463
470
  return false unless sales_tax_period_validator.valid?(@sales_tax_period)
464
471
  organisation_entity_type_validator = EnumAttributeValidator.new('String', ["ACCOUNTING_PRACTICE", "COMPANY", "CHARITY", "CLUB_OR_SOCIETY", "INDIVIDUAL", "LOOK_THROUGH_COMPANY", "NOT_FOR_PROFIT", "PARTNERSHIP", "S_CORPORATION", "SELF_MANAGED_SUPERANNUATION_FUND", "SOLE_TRADER", "SUPERANNUATION_FUND", "TRUST"])
465
472
  return false unless organisation_entity_type_validator.valid?(@organisation_entity_type)
466
- _class_validator = EnumAttributeValidator.new('String', ["DEMO", "TRIAL", "STARTER", "STANDARD", "PREMIUM", "PREMIUM_20", "PREMIUM_50", "PREMIUM_100", "LEDGER", "GST_CASHBOOK", "NON_GST_CASHBOOK", "ULTIMATE", "LITE"])
473
+ _class_validator = EnumAttributeValidator.new('String', ["DEMO", "TRIAL", "STARTER", "STANDARD", "PREMIUM", "PREMIUM_20", "PREMIUM_50", "PREMIUM_100", "LEDGER", "GST_CASHBOOK", "NON_GST_CASHBOOK", "ULTIMATE", "LITE", "ULTIMATE_10", "ULTIMATE_20", "ULTIMATE_50", "ULTIMATE_100", "IGNITE", "GROW", "COMPREHENSIVE"])
467
474
  return false unless _class_validator.valid?(@_class)
468
475
  edition_validator = EnumAttributeValidator.new('String', ["BUSINESS", "PARTNER"])
469
476
  return false unless edition_validator.valid?(@edition)
@@ -523,7 +530,7 @@ module XeroRuby::Accounting
523
530
  # Custom attribute writer method checking allowed values (enum).
524
531
  # @param [Object] _class Object to be assigned
525
532
  def _class=(_class)
526
- validator = EnumAttributeValidator.new('String', ["DEMO", "TRIAL", "STARTER", "STANDARD", "PREMIUM", "PREMIUM_20", "PREMIUM_50", "PREMIUM_100", "LEDGER", "GST_CASHBOOK", "NON_GST_CASHBOOK", "ULTIMATE", "LITE"])
533
+ validator = EnumAttributeValidator.new('String', ["DEMO", "TRIAL", "STARTER", "STANDARD", "PREMIUM", "PREMIUM_20", "PREMIUM_50", "PREMIUM_100", "LEDGER", "GST_CASHBOOK", "NON_GST_CASHBOOK", "ULTIMATE", "LITE", "ULTIMATE_10", "ULTIMATE_20", "ULTIMATE_50", "ULTIMATE_100", "IGNITE", "GROW", "COMPREHENSIVE"])
527
534
  unless validator.valid?(_class)
528
535
  fail ArgumentError, "invalid value for \"_class\", must be one of #{validator.allowable_values}."
529
536
  end
@@ -17,11 +17,19 @@ module XeroRuby::Accounting
17
17
 
18
18
  class Overpayments
19
19
 
20
+ attr_accessor :pagination
21
+
22
+ # Displays array of warning messages from the API
23
+ attr_accessor :warnings
24
+
25
+
20
26
  attr_accessor :overpayments
21
27
 
22
28
  # Attribute mapping from ruby-style variable name to JSON key.
23
29
  def self.attribute_map
24
30
  {
31
+ :'pagination' => :'pagination',
32
+ :'warnings' => :'Warnings',
25
33
  :'overpayments' => :'Overpayments'
26
34
  }
27
35
  end
@@ -29,6 +37,8 @@ module XeroRuby::Accounting
29
37
  # Attribute type mapping.
30
38
  def self.openapi_types
31
39
  {
40
+ :'pagination' => :'Pagination',
41
+ :'warnings' => :'Array<ValidationError>',
32
42
  :'overpayments' => :'Array<Overpayment>'
33
43
  }
34
44
  end
@@ -48,6 +58,16 @@ module XeroRuby::Accounting
48
58
  h[k.to_sym] = v
49
59
  }
50
60
 
61
+ if attributes.key?(:'pagination')
62
+ self.pagination = attributes[:'pagination']
63
+ end
64
+
65
+ if attributes.key?(:'warnings')
66
+ if (value = attributes[:'warnings']).is_a?(Array)
67
+ self.warnings = value
68
+ end
69
+ end
70
+
51
71
  if attributes.key?(:'overpayments')
52
72
  if (value = attributes[:'overpayments']).is_a?(Array)
53
73
  self.overpayments = value
@@ -73,6 +93,8 @@ module XeroRuby::Accounting
73
93
  def ==(o)
74
94
  return true if self.equal?(o)
75
95
  self.class == o.class &&
96
+ pagination == o.pagination &&
97
+ warnings == o.warnings &&
76
98
  overpayments == o.overpayments
77
99
  end
78
100
 
@@ -85,7 +107,7 @@ module XeroRuby::Accounting
85
107
  # Calculates hash code according to all attributes.
86
108
  # @return [Integer] Hash code
87
109
  def hash
88
- [overpayments].hash
110
+ [pagination, warnings, overpayments].hash
89
111
  end
90
112
 
91
113
  # Builds the object from hash
@@ -0,0 +1,252 @@
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 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::Accounting::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::Accounting::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::Accounting.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
@@ -107,6 +107,9 @@ module XeroRuby::Accounting
107
107
  # Displays array of validation error messages from the API
108
108
  attr_accessor :validation_errors
109
109
 
110
+ # Displays array of warning messages from the API
111
+ attr_accessor :warnings
112
+
110
113
  class EnumAttributeValidator
111
114
  attr_reader :datatype
112
115
  attr_reader :allowable_values
@@ -158,7 +161,8 @@ module XeroRuby::Accounting
158
161
  :'has_account' => :'HasAccount',
159
162
  :'has_validation_errors' => :'HasValidationErrors',
160
163
  :'status_attribute_string' => :'StatusAttributeString',
161
- :'validation_errors' => :'ValidationErrors'
164
+ :'validation_errors' => :'ValidationErrors',
165
+ :'warnings' => :'Warnings'
162
166
  }
163
167
  end
164
168
 
@@ -191,7 +195,8 @@ module XeroRuby::Accounting
191
195
  :'has_account' => :'Boolean',
192
196
  :'has_validation_errors' => :'Boolean',
193
197
  :'status_attribute_string' => :'String',
194
- :'validation_errors' => :'Array<ValidationError>'
198
+ :'validation_errors' => :'Array<ValidationError>',
199
+ :'warnings' => :'Array<ValidationError>'
195
200
  }
196
201
  end
197
202
 
@@ -323,6 +328,12 @@ module XeroRuby::Accounting
323
328
  self.validation_errors = value
324
329
  end
325
330
  end
331
+
332
+ if attributes.key?(:'warnings')
333
+ if (value = attributes[:'warnings']).is_a?(Array)
334
+ self.warnings = value
335
+ end
336
+ end
326
337
  end
327
338
 
328
339
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -393,7 +404,8 @@ module XeroRuby::Accounting
393
404
  has_account == o.has_account &&
394
405
  has_validation_errors == o.has_validation_errors &&
395
406
  status_attribute_string == o.status_attribute_string &&
396
- validation_errors == o.validation_errors
407
+ validation_errors == o.validation_errors &&
408
+ warnings == o.warnings
397
409
  end
398
410
 
399
411
  # @see the `==` method
@@ -405,7 +417,7 @@ module XeroRuby::Accounting
405
417
  # Calculates hash code according to all attributes.
406
418
  # @return [Integer] Hash code
407
419
  def hash
408
- [invoice, credit_note, prepayment, overpayment, invoice_number, credit_note_number, batch_payment, account, code, date, currency_rate, amount, bank_amount, reference, is_reconciled, status, payment_type, updated_date_utc, payment_id, batch_payment_id, bank_account_number, particulars, details, has_account, has_validation_errors, status_attribute_string, validation_errors].hash
420
+ [invoice, credit_note, prepayment, overpayment, invoice_number, credit_note_number, batch_payment, account, code, date, currency_rate, amount, bank_amount, reference, is_reconciled, status, payment_type, updated_date_utc, payment_id, batch_payment_id, bank_account_number, particulars, details, has_account, has_validation_errors, status_attribute_string, validation_errors, warnings].hash
409
421
  end
410
422
 
411
423
  # Builds the object from hash
@@ -17,11 +17,19 @@ module XeroRuby::Accounting
17
17
 
18
18
  class Payments
19
19
 
20
+ attr_accessor :pagination
21
+
22
+ # Displays array of warning messages from the API
23
+ attr_accessor :warnings
24
+
25
+
20
26
  attr_accessor :payments
21
27
 
22
28
  # Attribute mapping from ruby-style variable name to JSON key.
23
29
  def self.attribute_map
24
30
  {
31
+ :'pagination' => :'pagination',
32
+ :'warnings' => :'Warnings',
25
33
  :'payments' => :'Payments'
26
34
  }
27
35
  end
@@ -29,6 +37,8 @@ module XeroRuby::Accounting
29
37
  # Attribute type mapping.
30
38
  def self.openapi_types
31
39
  {
40
+ :'pagination' => :'Pagination',
41
+ :'warnings' => :'Array<ValidationError>',
32
42
  :'payments' => :'Array<Payment>'
33
43
  }
34
44
  end
@@ -48,6 +58,16 @@ module XeroRuby::Accounting
48
58
  h[k.to_sym] = v
49
59
  }
50
60
 
61
+ if attributes.key?(:'pagination')
62
+ self.pagination = attributes[:'pagination']
63
+ end
64
+
65
+ if attributes.key?(:'warnings')
66
+ if (value = attributes[:'warnings']).is_a?(Array)
67
+ self.warnings = value
68
+ end
69
+ end
70
+
51
71
  if attributes.key?(:'payments')
52
72
  if (value = attributes[:'payments']).is_a?(Array)
53
73
  self.payments = value
@@ -73,6 +93,8 @@ module XeroRuby::Accounting
73
93
  def ==(o)
74
94
  return true if self.equal?(o)
75
95
  self.class == o.class &&
96
+ pagination == o.pagination &&
97
+ warnings == o.warnings &&
76
98
  payments == o.payments
77
99
  end
78
100
 
@@ -85,7 +107,7 @@ module XeroRuby::Accounting
85
107
  # Calculates hash code according to all attributes.
86
108
  # @return [Integer] Hash code
87
109
  def hash
88
- [payments].hash
110
+ [pagination, warnings, payments].hash
89
111
  end
90
112
 
91
113
  # Builds the object from hash