xero-ruby 9.2.0 → 9.3.0.pre.alpha.1

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.
@@ -0,0 +1,351 @@
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 TaxBreakdownComponent
19
+ # The unique ID number of this component
20
+ attr_accessor :tax_component_id
21
+
22
+ # The type of the jurisdiction
23
+ attr_accessor :type
24
+ USCOUNTRY ||= "SYSGST/USCOUNTRY".freeze
25
+ USSTATE ||= "SYSGST/USSTATE".freeze
26
+ USCOUNTY ||= "SYSGST/USCOUNTY".freeze
27
+ USCITY ||= "SYSGST/USCITY".freeze
28
+ USSPECIAL ||= "SYSGST/USSPECIAL".freeze
29
+
30
+ # The name of the jurisdiction
31
+ attr_accessor :name
32
+
33
+ # The percentage of the tax
34
+ attr_accessor :tax_percentage
35
+
36
+ # The amount of the tax
37
+ attr_accessor :tax_amount
38
+
39
+ # The amount that is taxable
40
+ attr_accessor :taxable_amount
41
+
42
+ # The amount that is not taxable
43
+ attr_accessor :non_taxable_amount
44
+
45
+ # The amount that is exempt
46
+ attr_accessor :exempt_amount
47
+
48
+ # The state assigned number of the jurisdiction
49
+ attr_accessor :state_assigned_no
50
+
51
+ # Name identifying the region within the country
52
+ attr_accessor :jurisdiction_region
53
+
54
+ class EnumAttributeValidator
55
+ attr_reader :datatype
56
+ attr_reader :allowable_values
57
+
58
+ def initialize(datatype, allowable_values)
59
+ @allowable_values = allowable_values.map do |value|
60
+ case datatype.to_s
61
+ when /Integer/i
62
+ value.to_i
63
+ when /Float/i
64
+ value.to_f
65
+ else
66
+ value
67
+ end
68
+ end
69
+ end
70
+
71
+ def valid?(value)
72
+ !value || allowable_values.include?(value)
73
+ end
74
+ end
75
+
76
+ # Attribute mapping from ruby-style variable name to JSON key.
77
+ def self.attribute_map
78
+ {
79
+ :'tax_component_id' => :'TaxComponentId',
80
+ :'type' => :'Type',
81
+ :'name' => :'Name',
82
+ :'tax_percentage' => :'TaxPercentage',
83
+ :'tax_amount' => :'TaxAmount',
84
+ :'taxable_amount' => :'TaxableAmount',
85
+ :'non_taxable_amount' => :'NonTaxableAmount',
86
+ :'exempt_amount' => :'ExemptAmount',
87
+ :'state_assigned_no' => :'StateAssignedNo',
88
+ :'jurisdiction_region' => :'JurisdictionRegion'
89
+ }
90
+ end
91
+
92
+ # Attribute type mapping.
93
+ def self.openapi_types
94
+ {
95
+ :'tax_component_id' => :'String',
96
+ :'type' => :'String',
97
+ :'name' => :'String',
98
+ :'tax_percentage' => :'Float',
99
+ :'tax_amount' => :'Float',
100
+ :'taxable_amount' => :'Float',
101
+ :'non_taxable_amount' => :'Float',
102
+ :'exempt_amount' => :'Float',
103
+ :'state_assigned_no' => :'String',
104
+ :'jurisdiction_region' => :'String'
105
+ }
106
+ end
107
+
108
+ # Initializes the object
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ def initialize(attributes = {})
111
+ if (!attributes.is_a?(Hash))
112
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Accounting::TaxBreakdownComponent` initialize method"
113
+ end
114
+
115
+ # check to see if the attribute exists and convert string to symbol for hash key
116
+ attributes = attributes.each_with_object({}) { |(k, v), h|
117
+ if (!self.class.attribute_map.key?(k.to_sym))
118
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Accounting::TaxBreakdownComponent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
119
+ end
120
+ h[k.to_sym] = v
121
+ }
122
+
123
+ if attributes.key?(:'tax_component_id')
124
+ self.tax_component_id = attributes[:'tax_component_id']
125
+ end
126
+
127
+ if attributes.key?(:'type')
128
+ self.type = attributes[:'type']
129
+ end
130
+
131
+ if attributes.key?(:'name')
132
+ self.name = attributes[:'name']
133
+ end
134
+
135
+ if attributes.key?(:'tax_percentage')
136
+ self.tax_percentage = attributes[:'tax_percentage']
137
+ end
138
+
139
+ if attributes.key?(:'tax_amount')
140
+ self.tax_amount = attributes[:'tax_amount']
141
+ end
142
+
143
+ if attributes.key?(:'taxable_amount')
144
+ self.taxable_amount = attributes[:'taxable_amount']
145
+ end
146
+
147
+ if attributes.key?(:'non_taxable_amount')
148
+ self.non_taxable_amount = attributes[:'non_taxable_amount']
149
+ end
150
+
151
+ if attributes.key?(:'exempt_amount')
152
+ self.exempt_amount = attributes[:'exempt_amount']
153
+ end
154
+
155
+ if attributes.key?(:'state_assigned_no')
156
+ self.state_assigned_no = attributes[:'state_assigned_no']
157
+ end
158
+
159
+ if attributes.key?(:'jurisdiction_region')
160
+ self.jurisdiction_region = attributes[:'jurisdiction_region']
161
+ end
162
+ end
163
+
164
+ # Show invalid properties with the reasons. Usually used together with valid?
165
+ # @return Array for valid properties with the reasons
166
+ def list_invalid_properties
167
+ invalid_properties = Array.new
168
+ invalid_properties
169
+ end
170
+
171
+ # Check to see if the all the properties in the model are valid
172
+ # @return true if the model is valid
173
+ def valid?
174
+ type_validator = EnumAttributeValidator.new('String', ["SYSGST/USCOUNTRY", "SYSGST/USSTATE", "SYSGST/USCOUNTY", "SYSGST/USCITY", "SYSGST/USSPECIAL"])
175
+ return false unless type_validator.valid?(@type)
176
+ true
177
+ end
178
+
179
+ # Custom attribute writer method checking allowed values (enum).
180
+ # @param [Object] type Object to be assigned
181
+ def type=(type)
182
+ validator = EnumAttributeValidator.new('String', ["SYSGST/USCOUNTRY", "SYSGST/USSTATE", "SYSGST/USCOUNTY", "SYSGST/USCITY", "SYSGST/USSPECIAL"])
183
+ unless validator.valid?(type)
184
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
185
+ end
186
+ @type = type
187
+ end
188
+
189
+ # Checks equality by comparing each attribute.
190
+ # @param [Object] Object to be compared
191
+ def ==(o)
192
+ return true if self.equal?(o)
193
+ self.class == o.class &&
194
+ tax_component_id == o.tax_component_id &&
195
+ type == o.type &&
196
+ name == o.name &&
197
+ tax_percentage == o.tax_percentage &&
198
+ tax_amount == o.tax_amount &&
199
+ taxable_amount == o.taxable_amount &&
200
+ non_taxable_amount == o.non_taxable_amount &&
201
+ exempt_amount == o.exempt_amount &&
202
+ state_assigned_no == o.state_assigned_no &&
203
+ jurisdiction_region == o.jurisdiction_region
204
+ end
205
+
206
+ # @see the `==` method
207
+ # @param [Object] Object to be compared
208
+ def eql?(o)
209
+ self == o
210
+ end
211
+
212
+ # Calculates hash code according to all attributes.
213
+ # @return [Integer] Hash code
214
+ def hash
215
+ [tax_component_id, type, name, tax_percentage, tax_amount, taxable_amount, non_taxable_amount, exempt_amount, state_assigned_no, jurisdiction_region].hash
216
+ end
217
+
218
+ # Builds the object from hash
219
+ # @param [Hash] attributes Model attributes in the form of hash
220
+ # @return [Object] Returns the model itself
221
+ def self.build_from_hash(attributes)
222
+ new.build_from_hash(attributes)
223
+ end
224
+
225
+ # Builds the object from hash
226
+ # @param [Hash] attributes Model attributes in the form of hash
227
+ # @return [Object] Returns the model itself
228
+ def build_from_hash(attributes)
229
+ return nil unless attributes.is_a?(Hash)
230
+ self.class.openapi_types.each_pair do |key, type|
231
+ if type =~ /\AArray<(.*)>/i
232
+ # check to ensure the input is an array given that the attribute
233
+ # is documented as an array but the input is not
234
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
235
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
236
+ end
237
+ elsif !attributes[self.class.attribute_map[key]].nil?
238
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
239
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
240
+ end
241
+
242
+ self
243
+ end
244
+
245
+ # Deserializes the data based on type
246
+ # @param string type Data type
247
+ # @param string value Value to be deserialized
248
+ # @return [Object] Deserialized data
249
+ def _deserialize(type, value)
250
+ case type.to_sym
251
+ when :DateTime
252
+ DateTime.parse(parse_date(value))
253
+ when :Date
254
+ Date.parse(parse_date(value))
255
+ when :String
256
+ value.to_s
257
+ when :Integer
258
+ value.to_i
259
+ when :Float
260
+ value.to_f
261
+ when :BigDecimal
262
+ BigDecimal(value.to_s)
263
+ when :Boolean
264
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
265
+ true
266
+ else
267
+ false
268
+ end
269
+ when :Object
270
+ # generic object (usually a Hash), return directly
271
+ value
272
+ when /\AArray<(?<inner_type>.+)>\z/
273
+ inner_type = Regexp.last_match[:inner_type]
274
+ value.map { |v| _deserialize(inner_type, v) }
275
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
276
+ k_type = Regexp.last_match[:k_type]
277
+ v_type = Regexp.last_match[:v_type]
278
+ {}.tap do |hash|
279
+ value.each do |k, v|
280
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
281
+ end
282
+ end
283
+ else # model
284
+ XeroRuby::Accounting.const_get(type).build_from_hash(value)
285
+ end
286
+ end
287
+
288
+ # Returns the string representation of the object
289
+ # @return [String] String presentation of the object
290
+ def to_s
291
+ to_hash.to_s
292
+ end
293
+
294
+ # to_body is an alias to to_hash (backward compatibility)
295
+ # @return [Hash] Returns the object in the form of hash
296
+ def to_body
297
+ to_hash
298
+ end
299
+
300
+ # Returns the object in the form of hash
301
+ # @return [Hash] Returns the object in the form of hash
302
+ def to_hash(downcase: false)
303
+ hash = {}
304
+ self.class.attribute_map.each_pair do |attr, param|
305
+ value = self.send(attr)
306
+ next if value.nil?
307
+ key = downcase ? attr : param
308
+ hash[key] = _to_hash(value, downcase: downcase)
309
+ end
310
+ hash
311
+ end
312
+
313
+ # Returns the object in the form of hash with snake_case
314
+ def to_attributes
315
+ to_hash(downcase: true)
316
+ end
317
+
318
+ # Outputs non-array value in the form of hash
319
+ # For object, use to_hash. Otherwise, just return the value
320
+ # @param [Object] value Any valid value
321
+ # @return [Hash] Returns the value in the form of hash
322
+ def _to_hash(value, downcase: false)
323
+ if value.is_a?(Array)
324
+ value.map do |v|
325
+ v.to_hash(downcase: downcase)
326
+ end
327
+ elsif value.is_a?(Hash)
328
+ {}.tap do |hash|
329
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
330
+ end
331
+ elsif value.respond_to? :to_hash
332
+ value.to_hash(downcase: downcase)
333
+ else
334
+ value
335
+ end
336
+ end
337
+
338
+ def parse_date(datestring)
339
+ if datestring.include?('Date')
340
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
341
+ original, date, timezone = *date_pattern.match(datestring)
342
+ date = (date.to_i / 1000)
343
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
344
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
345
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
346
+ else # handle date 'types' for small subset of payroll API's
347
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
348
+ end
349
+ end
350
+ end
351
+ end
@@ -38,6 +38,9 @@ module XeroRuby::PayrollUk
38
38
  # The number of hours added to the leave balance for every hour worked by the employee. This is normally 0, unless the scheduleOfAccrual chosen is \"OnHourWorked\"
39
39
  attr_accessor :rate_accrued_hourly
40
40
 
41
+ # The date when an employee becomes entitled to their accrual. Only applicable when scheduleOfAccrual is \"OnAnniversaryDate\"
42
+ attr_accessor :schedule_of_accrual_date
43
+
41
44
  class EnumAttributeValidator
42
45
  attr_reader :datatype
43
46
  attr_reader :allowable_values
@@ -68,7 +71,8 @@ module XeroRuby::PayrollUk
68
71
  :'hours_accrued_annually' => :'hoursAccruedAnnually',
69
72
  :'maximum_to_accrue' => :'maximumToAccrue',
70
73
  :'opening_balance' => :'openingBalance',
71
- :'rate_accrued_hourly' => :'rateAccruedHourly'
74
+ :'rate_accrued_hourly' => :'rateAccruedHourly',
75
+ :'schedule_of_accrual_date' => :'scheduleOfAccrualDate'
72
76
  }
73
77
  end
74
78
 
@@ -80,7 +84,8 @@ module XeroRuby::PayrollUk
80
84
  :'hours_accrued_annually' => :'Float',
81
85
  :'maximum_to_accrue' => :'Float',
82
86
  :'opening_balance' => :'Float',
83
- :'rate_accrued_hourly' => :'Float'
87
+ :'rate_accrued_hourly' => :'Float',
88
+ :'schedule_of_accrual_date' => :'Date'
84
89
  }
85
90
  end
86
91
 
@@ -122,6 +127,10 @@ module XeroRuby::PayrollUk
122
127
  if attributes.key?(:'rate_accrued_hourly')
123
128
  self.rate_accrued_hourly = attributes[:'rate_accrued_hourly']
124
129
  end
130
+
131
+ if attributes.key?(:'schedule_of_accrual_date')
132
+ self.schedule_of_accrual_date = attributes[:'schedule_of_accrual_date']
133
+ end
125
134
  end
126
135
 
127
136
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -169,7 +178,8 @@ module XeroRuby::PayrollUk
169
178
  hours_accrued_annually == o.hours_accrued_annually &&
170
179
  maximum_to_accrue == o.maximum_to_accrue &&
171
180
  opening_balance == o.opening_balance &&
172
- rate_accrued_hourly == o.rate_accrued_hourly
181
+ rate_accrued_hourly == o.rate_accrued_hourly &&
182
+ schedule_of_accrual_date == o.schedule_of_accrual_date
173
183
  end
174
184
 
175
185
  # @see the `==` method
@@ -181,7 +191,7 @@ module XeroRuby::PayrollUk
181
191
  # Calculates hash code according to all attributes.
182
192
  # @return [Integer] Hash code
183
193
  def hash
184
- [leave_type_id, schedule_of_accrual, hours_accrued_annually, maximum_to_accrue, opening_balance, rate_accrued_hourly].hash
194
+ [leave_type_id, schedule_of_accrual, hours_accrued_annually, maximum_to_accrue, opening_balance, rate_accrued_hourly, schedule_of_accrual_date].hash
185
195
  end
186
196
 
187
197
  # Builds the object from hash
@@ -7,9 +7,9 @@ Contact: api@xero.com
7
7
  Generated by: https://openapi-generator.tech
8
8
  OpenAPI Generator version: 4.3.1
9
9
 
10
- The version of the XeroOpenAPI document: 6.2.0
10
+ The version of the XeroOpenAPI document: 6.3.0
11
11
  =end
12
12
 
13
13
  module XeroRuby
14
- VERSION = '9.2.0'
14
+ VERSION = '9.3.0-alpha.1'
15
15
  end
@@ -17,51 +17,51 @@ module XeroRuby
17
17
 
18
18
  private
19
19
 
20
- def parameterize_option(key, value)
21
- quoted_key = quote_key(key)
20
+ def parameterize_option(key, value)
21
+ quoted_key = quote_key(key)
22
22
 
23
- case value
24
- when Array
25
- operator, query = value
23
+ case value
24
+ when Array
25
+ operator, query = value
26
26
 
27
- if STRING_FUNCTIONS.include?(camelize_key(operator))
28
- "#{quoted_key}.#{camelize_key(operator)}(#{quote_value(query)})"
27
+ if STRING_FUNCTIONS.include?(camelize_key(operator))
28
+ "#{quoted_key}.#{camelize_key(operator)}(#{quote_value(query)})"
29
+ else
30
+ "#{quoted_key} #{operator} #{quote_value(query)}"
31
+ end
32
+ when Range
33
+ "#{quoted_key} >= #{quote_value(value.first)} AND #{quoted_key} <= #{quote_value(value.last)}"
34
+ when /^\./
35
+ "#{quoted_key}#{value}"
29
36
  else
30
- "#{quoted_key} #{operator} #{quote_value(query)}"
37
+ "#{quoted_key} #{value}"
31
38
  end
32
- when Range
33
- "#{quoted_key} >= #{quote_value(value.first)} AND #{quoted_key} <= #{quote_value(value.last)}"
34
- when /^\./
35
- "#{quoted_key}#{value}"
36
- else
37
- "#{quoted_key} #{value}"
38
39
  end
39
- end
40
40
 
41
- def quote_key(key)
42
- case key
43
- when :contact_id
44
- 'Contact.ContactID'
45
- when :contact_number
46
- 'Contact.ContactNumber'
47
- when :invoice_id
48
- 'Invoice.InvoiceId'
49
- else
50
- camelize_key(key)
41
+ def quote_key(key)
42
+ case key
43
+ when :contact_id
44
+ 'Contact.ContactID'
45
+ when :contact_number
46
+ 'Contact.ContactNumber'
47
+ when :invoice_id
48
+ 'Invoice.InvoiceId'
49
+ else
50
+ camelize_key(key)
51
+ end
51
52
  end
52
- end
53
53
 
54
- def quote_value(value)
55
- case value
56
- when DateTime, Date, Time
57
- "DateTime(#{value.strftime("%Y,%m,%d")})"
58
- when Numeric, false, true
59
- value.to_s
60
- when UUID_REGEXP
61
- %{guid("#{value}")}
62
- else
63
- %{"#{value.to_s.gsub('"', '""')}"}
54
+ def quote_value(value)
55
+ case value
56
+ when DateTime, Date, Time
57
+ "DateTime(#{value.strftime("%Y,%m,%d")})"
58
+ when Numeric, false, true
59
+ value.to_s
60
+ when UUID_REGEXP
61
+ %{guid("#{value}")}
62
+ else
63
+ %{"#{value.to_s.gsub('"', '""')}"}
64
+ end
64
65
  end
65
- end
66
66
  end
67
67
  end
data/lib/xero-ruby.rb CHANGED
@@ -466,6 +466,7 @@ require 'xero-ruby/models/accounting/import_summary_accounts'
466
466
  require 'xero-ruby/models/accounting/import_summary_object'
467
467
  require 'xero-ruby/models/accounting/import_summary_organisation'
468
468
  require 'xero-ruby/models/accounting/invoice'
469
+ require 'xero-ruby/models/accounting/invoice_address'
469
470
  require 'xero-ruby/models/accounting/invoice_reminder'
470
471
  require 'xero-ruby/models/accounting/invoice_reminders'
471
472
  require 'xero-ruby/models/accounting/invoices'
@@ -525,6 +526,7 @@ require 'xero-ruby/models/accounting/row_type'
525
526
  require 'xero-ruby/models/accounting/sales_tracking_category'
526
527
  require 'xero-ruby/models/accounting/schedule'
527
528
  require 'xero-ruby/models/accounting/setup'
529
+ require 'xero-ruby/models/accounting/tax_breakdown_component'
528
530
  require 'xero-ruby/models/accounting/tax_component'
529
531
  require 'xero-ruby/models/accounting/tax_rate'
530
532
  require 'xero-ruby/models/accounting/tax_rates'