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
@@ -43,6 +43,7 @@ module XeroRuby::Accounting
43
43
  CAD ||= "CAD".freeze
44
44
  CDF ||= "CDF".freeze
45
45
  CHF ||= "CHF".freeze
46
+ CLF ||= "CLF".freeze
46
47
  CLP ||= "CLP".freeze
47
48
  CNY ||= "CNY".freeze
48
49
  COP ||= "COP".freeze
@@ -55,6 +56,7 @@ module XeroRuby::Accounting
55
56
  DKK ||= "DKK".freeze
56
57
  DOP ||= "DOP".freeze
57
58
  DZD ||= "DZD".freeze
59
+ EEK ||= "EEK".freeze
58
60
  EGP ||= "EGP".freeze
59
61
  ERN ||= "ERN".freeze
60
62
  ETB ||= "ETB".freeze
@@ -63,7 +65,6 @@ module XeroRuby::Accounting
63
65
  FKP ||= "FKP".freeze
64
66
  GBP ||= "GBP".freeze
65
67
  GEL ||= "GEL".freeze
66
- GGP ||= "GGP".freeze
67
68
  GHS ||= "GHS".freeze
68
69
  GIP ||= "GIP".freeze
69
70
  GMD ||= "GMD".freeze
@@ -77,12 +78,10 @@ module XeroRuby::Accounting
77
78
  HUF ||= "HUF".freeze
78
79
  IDR ||= "IDR".freeze
79
80
  ILS ||= "ILS".freeze
80
- IMP ||= "IMP".freeze
81
81
  INR ||= "INR".freeze
82
82
  IQD ||= "IQD".freeze
83
83
  IRR ||= "IRR".freeze
84
84
  ISK ||= "ISK".freeze
85
- JEP ||= "JEP".freeze
86
85
  JMD ||= "JMD".freeze
87
86
  JOD ||= "JOD".freeze
88
87
  JPY ||= "JPY".freeze
@@ -101,6 +100,7 @@ module XeroRuby::Accounting
101
100
  LRD ||= "LRD".freeze
102
101
  LSL ||= "LSL".freeze
103
102
  LTL ||= "LTL".freeze
103
+ LVL ||= "LVL".freeze
104
104
  LYD ||= "LYD".freeze
105
105
  MAD ||= "MAD".freeze
106
106
  MDL ||= "MDL".freeze
@@ -109,11 +109,13 @@ module XeroRuby::Accounting
109
109
  MMK ||= "MMK".freeze
110
110
  MNT ||= "MNT".freeze
111
111
  MOP ||= "MOP".freeze
112
+ MRO ||= "MRO".freeze
112
113
  MRU ||= "MRU".freeze
113
114
  MUR ||= "MUR".freeze
114
115
  MVR ||= "MVR".freeze
115
116
  MWK ||= "MWK".freeze
116
117
  MXN ||= "MXN".freeze
118
+ MXV ||= "MXV".freeze
117
119
  MYR ||= "MYR".freeze
118
120
  MZN ||= "MZN".freeze
119
121
  NAD ||= "NAD".freeze
@@ -142,11 +144,13 @@ module XeroRuby::Accounting
142
144
  SEK ||= "SEK".freeze
143
145
  SGD ||= "SGD".freeze
144
146
  SHP ||= "SHP".freeze
147
+ SKK ||= "SKK".freeze
148
+ SLE ||= "SLE".freeze
145
149
  SLL ||= "SLL".freeze
146
150
  SOS ||= "SOS".freeze
147
- SPL ||= "SPL".freeze
148
151
  SRD ||= "SRD".freeze
149
- STN ||= "STN".freeze
152
+ STN ||= "STD".freeze
153
+ STD ||= "STN".freeze
150
154
  SVC ||= "SVC".freeze
151
155
  SYP ||= "SYP".freeze
152
156
  SZL ||= "SZL".freeze
@@ -157,7 +161,6 @@ module XeroRuby::Accounting
157
161
  TOP ||= "TOP".freeze
158
162
  TRY_LIRA ||= "TRY".freeze
159
163
  TTD ||= "TTD".freeze
160
- TVD ||= "TVD".freeze
161
164
  TWD ||= "TWD".freeze
162
165
  TZS ||= "TZS".freeze
163
166
  UAH ||= "UAH".freeze
@@ -166,12 +169,12 @@ module XeroRuby::Accounting
166
169
  UYU ||= "UYU".freeze
167
170
  UZS ||= "UZS".freeze
168
171
  VEF ||= "VEF".freeze
172
+ VES ||= "VES".freeze
169
173
  VND ||= "VND".freeze
170
174
  VUV ||= "VUV".freeze
171
175
  WST ||= "WST".freeze
172
176
  XAF ||= "XAF".freeze
173
177
  XCD ||= "XCD".freeze
174
- XDR ||= "XDR".freeze
175
178
  XOF ||= "XOF".freeze
176
179
  XPF ||= "XPF".freeze
177
180
  YER ||= "YER".freeze
@@ -179,7 +182,6 @@ module XeroRuby::Accounting
179
182
  ZMW ||= "ZMW".freeze
180
183
  ZMK ||= "ZMK".freeze
181
184
  ZWD ||= "ZWD".freeze
182
- EMPTY_CURRENCY ||= "".freeze
183
185
 
184
186
  # Builds the enum from string
185
187
  # @param [String] The enum value in the form of the string
@@ -150,6 +150,9 @@ module XeroRuby::Accounting
150
150
  # Displays array of warning messages from the API
151
151
  attr_accessor :warnings
152
152
 
153
+ # An array of addresses used to auto calculate sales tax
154
+ attr_accessor :invoice_addresses
155
+
153
156
  class EnumAttributeValidator
154
157
  attr_reader :datatype
155
158
  attr_reader :allowable_values
@@ -214,7 +217,8 @@ module XeroRuby::Accounting
214
217
  :'has_errors' => :'HasErrors',
215
218
  :'status_attribute_string' => :'StatusAttributeString',
216
219
  :'validation_errors' => :'ValidationErrors',
217
- :'warnings' => :'Warnings'
220
+ :'warnings' => :'Warnings',
221
+ :'invoice_addresses' => :'InvoiceAddresses'
218
222
  }
219
223
  end
220
224
 
@@ -260,7 +264,8 @@ module XeroRuby::Accounting
260
264
  :'has_errors' => :'Boolean',
261
265
  :'status_attribute_string' => :'String',
262
266
  :'validation_errors' => :'Array<ValidationError>',
263
- :'warnings' => :'Array<ValidationError>'
267
+ :'warnings' => :'Array<ValidationError>',
268
+ :'invoice_addresses' => :'Array<InvoiceAddress>'
264
269
  }
265
270
  end
266
271
 
@@ -458,6 +463,12 @@ module XeroRuby::Accounting
458
463
  self.warnings = value
459
464
  end
460
465
  end
466
+
467
+ if attributes.key?(:'invoice_addresses')
468
+ if (value = attributes[:'invoice_addresses']).is_a?(Array)
469
+ self.invoice_addresses = value
470
+ end
471
+ end
461
472
  end
462
473
 
463
474
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -556,7 +567,8 @@ module XeroRuby::Accounting
556
567
  has_errors == o.has_errors &&
557
568
  status_attribute_string == o.status_attribute_string &&
558
569
  validation_errors == o.validation_errors &&
559
- warnings == o.warnings
570
+ warnings == o.warnings &&
571
+ invoice_addresses == o.invoice_addresses
560
572
  end
561
573
 
562
574
  # @see the `==` method
@@ -568,7 +580,7 @@ module XeroRuby::Accounting
568
580
  # Calculates hash code according to all attributes.
569
581
  # @return [Integer] Hash code
570
582
  def hash
571
- [type, contact, line_items, date, due_date, line_amount_types, invoice_number, reference, branding_theme_id, url, currency_code, currency_rate, status, sent_to_contact, expected_payment_date, planned_payment_date, cis_deduction, cis_rate, sub_total, total_tax, total, total_discount, invoice_id, repeating_invoice_id, has_attachments, is_discounted, payments, prepayments, overpayments, amount_due, amount_paid, fully_paid_on_date, amount_credited, updated_date_utc, credit_notes, attachments, has_errors, status_attribute_string, validation_errors, warnings].hash
583
+ [type, contact, line_items, date, due_date, line_amount_types, invoice_number, reference, branding_theme_id, url, currency_code, currency_rate, status, sent_to_contact, expected_payment_date, planned_payment_date, cis_deduction, cis_rate, sub_total, total_tax, total, total_discount, invoice_id, repeating_invoice_id, has_attachments, is_discounted, payments, prepayments, overpayments, amount_due, amount_paid, fully_paid_on_date, amount_credited, updated_date_utc, credit_notes, attachments, has_errors, status_attribute_string, validation_errors, warnings, invoice_addresses].hash
572
584
  end
573
585
 
574
586
  # Builds the object from hash
@@ -0,0 +1,338 @@
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 InvoiceAddress
19
+ # Indicates whether the address is defined as origin (FROM) or destination (TO)
20
+ attr_accessor :invoice_address_type
21
+ FROM ||= "FROM".freeze
22
+ TO ||= "TO".freeze
23
+
24
+ # First line of a physical address
25
+ attr_accessor :address_line1
26
+
27
+ # Second line of a physical address
28
+ attr_accessor :address_line2
29
+
30
+ # Third line of a physical address
31
+ attr_accessor :address_line3
32
+
33
+ # Fourth line of a physical address
34
+ attr_accessor :address_line4
35
+
36
+ # City of a physical address
37
+ attr_accessor :city
38
+
39
+ # Region or state of a physical address
40
+ attr_accessor :region
41
+
42
+ # Postal code of a physical address
43
+ attr_accessor :postal_code
44
+
45
+ # Country of a physical address
46
+ attr_accessor :country
47
+
48
+ class EnumAttributeValidator
49
+ attr_reader :datatype
50
+ attr_reader :allowable_values
51
+
52
+ def initialize(datatype, allowable_values)
53
+ @allowable_values = allowable_values.map do |value|
54
+ case datatype.to_s
55
+ when /Integer/i
56
+ value.to_i
57
+ when /Float/i
58
+ value.to_f
59
+ else
60
+ value
61
+ end
62
+ end
63
+ end
64
+
65
+ def valid?(value)
66
+ !value || allowable_values.include?(value)
67
+ end
68
+ end
69
+
70
+ # Attribute mapping from ruby-style variable name to JSON key.
71
+ def self.attribute_map
72
+ {
73
+ :'invoice_address_type' => :'InvoiceAddressType',
74
+ :'address_line1' => :'AddressLine1',
75
+ :'address_line2' => :'AddressLine2',
76
+ :'address_line3' => :'AddressLine3',
77
+ :'address_line4' => :'AddressLine4',
78
+ :'city' => :'City',
79
+ :'region' => :'Region',
80
+ :'postal_code' => :'PostalCode',
81
+ :'country' => :'Country'
82
+ }
83
+ end
84
+
85
+ # Attribute type mapping.
86
+ def self.openapi_types
87
+ {
88
+ :'invoice_address_type' => :'String',
89
+ :'address_line1' => :'String',
90
+ :'address_line2' => :'String',
91
+ :'address_line3' => :'String',
92
+ :'address_line4' => :'String',
93
+ :'city' => :'String',
94
+ :'region' => :'String',
95
+ :'postal_code' => :'String',
96
+ :'country' => :'String'
97
+ }
98
+ end
99
+
100
+ # Initializes the object
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ def initialize(attributes = {})
103
+ if (!attributes.is_a?(Hash))
104
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Accounting::InvoiceAddress` initialize method"
105
+ end
106
+
107
+ # check to see if the attribute exists and convert string to symbol for hash key
108
+ attributes = attributes.each_with_object({}) { |(k, v), h|
109
+ if (!self.class.attribute_map.key?(k.to_sym))
110
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Accounting::InvoiceAddress`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
111
+ end
112
+ h[k.to_sym] = v
113
+ }
114
+
115
+ if attributes.key?(:'invoice_address_type')
116
+ self.invoice_address_type = attributes[:'invoice_address_type']
117
+ end
118
+
119
+ if attributes.key?(:'address_line1')
120
+ self.address_line1 = attributes[:'address_line1']
121
+ end
122
+
123
+ if attributes.key?(:'address_line2')
124
+ self.address_line2 = attributes[:'address_line2']
125
+ end
126
+
127
+ if attributes.key?(:'address_line3')
128
+ self.address_line3 = attributes[:'address_line3']
129
+ end
130
+
131
+ if attributes.key?(:'address_line4')
132
+ self.address_line4 = attributes[:'address_line4']
133
+ end
134
+
135
+ if attributes.key?(:'city')
136
+ self.city = attributes[:'city']
137
+ end
138
+
139
+ if attributes.key?(:'region')
140
+ self.region = attributes[:'region']
141
+ end
142
+
143
+ if attributes.key?(:'postal_code')
144
+ self.postal_code = attributes[:'postal_code']
145
+ end
146
+
147
+ if attributes.key?(:'country')
148
+ self.country = attributes[:'country']
149
+ end
150
+ end
151
+
152
+ # Show invalid properties with the reasons. Usually used together with valid?
153
+ # @return Array for valid properties with the reasons
154
+ def list_invalid_properties
155
+ invalid_properties = Array.new
156
+ invalid_properties
157
+ end
158
+
159
+ # Check to see if the all the properties in the model are valid
160
+ # @return true if the model is valid
161
+ def valid?
162
+ invoice_address_type_validator = EnumAttributeValidator.new('String', ["FROM", "TO"])
163
+ return false unless invoice_address_type_validator.valid?(@invoice_address_type)
164
+ true
165
+ end
166
+
167
+ # Custom attribute writer method checking allowed values (enum).
168
+ # @param [Object] invoice_address_type Object to be assigned
169
+ def invoice_address_type=(invoice_address_type)
170
+ validator = EnumAttributeValidator.new('String', ["FROM", "TO"])
171
+ unless validator.valid?(invoice_address_type)
172
+ fail ArgumentError, "invalid value for \"invoice_address_type\", must be one of #{validator.allowable_values}."
173
+ end
174
+ @invoice_address_type = invoice_address_type
175
+ end
176
+
177
+ # Checks equality by comparing each attribute.
178
+ # @param [Object] Object to be compared
179
+ def ==(o)
180
+ return true if self.equal?(o)
181
+ self.class == o.class &&
182
+ invoice_address_type == o.invoice_address_type &&
183
+ address_line1 == o.address_line1 &&
184
+ address_line2 == o.address_line2 &&
185
+ address_line3 == o.address_line3 &&
186
+ address_line4 == o.address_line4 &&
187
+ city == o.city &&
188
+ region == o.region &&
189
+ postal_code == o.postal_code &&
190
+ country == o.country
191
+ end
192
+
193
+ # @see the `==` method
194
+ # @param [Object] Object to be compared
195
+ def eql?(o)
196
+ self == o
197
+ end
198
+
199
+ # Calculates hash code according to all attributes.
200
+ # @return [Integer] Hash code
201
+ def hash
202
+ [invoice_address_type, address_line1, address_line2, address_line3, address_line4, city, region, postal_code, country].hash
203
+ end
204
+
205
+ # Builds the object from hash
206
+ # @param [Hash] attributes Model attributes in the form of hash
207
+ # @return [Object] Returns the model itself
208
+ def self.build_from_hash(attributes)
209
+ new.build_from_hash(attributes)
210
+ end
211
+
212
+ # Builds the object from hash
213
+ # @param [Hash] attributes Model attributes in the form of hash
214
+ # @return [Object] Returns the model itself
215
+ def build_from_hash(attributes)
216
+ return nil unless attributes.is_a?(Hash)
217
+ self.class.openapi_types.each_pair do |key, type|
218
+ if type =~ /\AArray<(.*)>/i
219
+ # check to ensure the input is an array given that the attribute
220
+ # is documented as an array but the input is not
221
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
222
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
223
+ end
224
+ elsif !attributes[self.class.attribute_map[key]].nil?
225
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
226
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
227
+ end
228
+
229
+ self
230
+ end
231
+
232
+ # Deserializes the data based on type
233
+ # @param string type Data type
234
+ # @param string value Value to be deserialized
235
+ # @return [Object] Deserialized data
236
+ def _deserialize(type, value)
237
+ case type.to_sym
238
+ when :DateTime
239
+ DateTime.parse(parse_date(value))
240
+ when :Date
241
+ Date.parse(parse_date(value))
242
+ when :String
243
+ value.to_s
244
+ when :Integer
245
+ value.to_i
246
+ when :Float
247
+ value.to_f
248
+ when :BigDecimal
249
+ BigDecimal(value.to_s)
250
+ when :Boolean
251
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
252
+ true
253
+ else
254
+ false
255
+ end
256
+ when :Object
257
+ # generic object (usually a Hash), return directly
258
+ value
259
+ when /\AArray<(?<inner_type>.+)>\z/
260
+ inner_type = Regexp.last_match[:inner_type]
261
+ value.map { |v| _deserialize(inner_type, v) }
262
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
263
+ k_type = Regexp.last_match[:k_type]
264
+ v_type = Regexp.last_match[:v_type]
265
+ {}.tap do |hash|
266
+ value.each do |k, v|
267
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
268
+ end
269
+ end
270
+ else # model
271
+ XeroRuby::Accounting.const_get(type).build_from_hash(value)
272
+ end
273
+ end
274
+
275
+ # Returns the string representation of the object
276
+ # @return [String] String presentation of the object
277
+ def to_s
278
+ to_hash.to_s
279
+ end
280
+
281
+ # to_body is an alias to to_hash (backward compatibility)
282
+ # @return [Hash] Returns the object in the form of hash
283
+ def to_body
284
+ to_hash
285
+ end
286
+
287
+ # Returns the object in the form of hash
288
+ # @return [Hash] Returns the object in the form of hash
289
+ def to_hash(downcase: false)
290
+ hash = {}
291
+ self.class.attribute_map.each_pair do |attr, param|
292
+ value = self.send(attr)
293
+ next if value.nil?
294
+ key = downcase ? attr : param
295
+ hash[key] = _to_hash(value, downcase: downcase)
296
+ end
297
+ hash
298
+ end
299
+
300
+ # Returns the object in the form of hash with snake_case
301
+ def to_attributes
302
+ to_hash(downcase: true)
303
+ end
304
+
305
+ # Outputs non-array value in the form of hash
306
+ # For object, use to_hash. Otherwise, just return the value
307
+ # @param [Object] value Any valid value
308
+ # @return [Hash] Returns the value in the form of hash
309
+ def _to_hash(value, downcase: false)
310
+ if value.is_a?(Array)
311
+ value.map do |v|
312
+ v.to_hash(downcase: downcase)
313
+ end
314
+ elsif value.is_a?(Hash)
315
+ {}.tap do |hash|
316
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
317
+ end
318
+ elsif value.respond_to? :to_hash
319
+ value.to_hash(downcase: downcase)
320
+ else
321
+ value
322
+ end
323
+ end
324
+
325
+ def parse_date(datestring)
326
+ if datestring.include?('Date')
327
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
328
+ original, date, timezone = *date_pattern.match(datestring)
329
+ date = (date.to_i / 1000)
330
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
331
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
332
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
333
+ else # handle date 'types' for small subset of payroll API's
334
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
335
+ end
336
+ end
337
+ end
338
+ end
@@ -17,11 +17,19 @@ module XeroRuby::Accounting
17
17
 
18
18
  class Invoices
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 :invoices
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
  :'invoices' => :'Invoices'
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
  :'invoices' => :'Array<Invoice>'
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?(:'invoices')
52
72
  if (value = attributes[:'invoices']).is_a?(Array)
53
73
  self.invoices = 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
  invoices == o.invoices
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
- [invoices].hash
110
+ [pagination, warnings, invoices].hash
89
111
  end
90
112
 
91
113
  # Builds the object from hash
@@ -16,12 +16,16 @@ module XeroRuby::Accounting
16
16
  require 'bigdecimal'
17
17
 
18
18
  class Journals
19
+ # Displays array of warning messages from the API
20
+ attr_accessor :warnings
21
+
19
22
 
20
23
  attr_accessor :journals
21
24
 
22
25
  # Attribute mapping from ruby-style variable name to JSON key.
23
26
  def self.attribute_map
24
27
  {
28
+ :'warnings' => :'Warnings',
25
29
  :'journals' => :'Journals'
26
30
  }
27
31
  end
@@ -29,6 +33,7 @@ module XeroRuby::Accounting
29
33
  # Attribute type mapping.
30
34
  def self.openapi_types
31
35
  {
36
+ :'warnings' => :'Array<ValidationError>',
32
37
  :'journals' => :'Array<Journal>'
33
38
  }
34
39
  end
@@ -48,6 +53,12 @@ module XeroRuby::Accounting
48
53
  h[k.to_sym] = v
49
54
  }
50
55
 
56
+ if attributes.key?(:'warnings')
57
+ if (value = attributes[:'warnings']).is_a?(Array)
58
+ self.warnings = value
59
+ end
60
+ end
61
+
51
62
  if attributes.key?(:'journals')
52
63
  if (value = attributes[:'journals']).is_a?(Array)
53
64
  self.journals = value
@@ -73,6 +84,7 @@ module XeroRuby::Accounting
73
84
  def ==(o)
74
85
  return true if self.equal?(o)
75
86
  self.class == o.class &&
87
+ warnings == o.warnings &&
76
88
  journals == o.journals
77
89
  end
78
90
 
@@ -85,7 +97,7 @@ module XeroRuby::Accounting
85
97
  # Calculates hash code according to all attributes.
86
98
  # @return [Integer] Hash code
87
99
  def hash
88
- [journals].hash
100
+ [warnings, journals].hash
89
101
  end
90
102
 
91
103
  # Builds the object from hash