xero-ruby 10.1.0 → 11.0.0.pre.alpha1

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,264 @@
1
+ =begin
2
+ #Xero Payroll UK
3
+
4
+ #This is the Xero Payroll API for orgs in the UK region.
5
+
6
+ Contact: api@xero.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 4.3.1
9
+
10
+ =end
11
+
12
+ require 'time'
13
+ require 'date'
14
+
15
+ module XeroRuby::PayrollUk
16
+ require 'bigdecimal'
17
+
18
+ class NICategoryOneOf
19
+
20
+ attr_accessor :ni_category
21
+ F ||= "F".freeze
22
+ I ||= "I".freeze
23
+ L ||= "L".freeze
24
+ S ||= "S".freeze
25
+ N ||= "N".freeze
26
+ E ||= "E".freeze
27
+ D ||= "D".freeze
28
+ K ||= "K".freeze
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'ni_category' => :'niCategory'
56
+ }
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'ni_category' => :'String'
63
+ }
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollUk::NICategoryOneOf` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ attributes = attributes.each_with_object({}) { |(k, v), h|
75
+ if (!self.class.attribute_map.key?(k.to_sym))
76
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollUk::NICategoryOneOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
+ end
78
+ h[k.to_sym] = v
79
+ }
80
+
81
+ if attributes.key?(:'ni_category')
82
+ self.ni_category = attributes[:'ni_category']
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ ni_category_validator = EnumAttributeValidator.new('String', ["F", "I", "L", "S", "N", "E", "D", "K"])
97
+ return false unless ni_category_validator.valid?(@ni_category)
98
+ true
99
+ end
100
+
101
+ # Custom attribute writer method checking allowed values (enum).
102
+ # @param [Object] ni_category Object to be assigned
103
+ def ni_category=(ni_category)
104
+ validator = EnumAttributeValidator.new('String', ["F", "I", "L", "S", "N", "E", "D", "K"])
105
+ unless validator.valid?(ni_category)
106
+ fail ArgumentError, "invalid value for \"ni_category\", must be one of #{validator.allowable_values}."
107
+ end
108
+ @ni_category = ni_category
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ ni_category == o.ni_category
117
+ end
118
+
119
+ # @see the `==` method
120
+ # @param [Object] Object to be compared
121
+ def eql?(o)
122
+ self == o
123
+ end
124
+
125
+ # Calculates hash code according to all attributes.
126
+ # @return [Integer] Hash code
127
+ def hash
128
+ [ni_category].hash
129
+ end
130
+
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def self.build_from_hash(attributes)
135
+ new.build_from_hash(attributes)
136
+ end
137
+
138
+ # Builds the object from hash
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ # @return [Object] Returns the model itself
141
+ def build_from_hash(attributes)
142
+ return nil unless attributes.is_a?(Hash)
143
+ self.class.openapi_types.each_pair do |key, type|
144
+ if type =~ /\AArray<(.*)>/i
145
+ # check to ensure the input is an array given that the attribute
146
+ # is documented as an array but the input is not
147
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
148
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
149
+ end
150
+ elsif !attributes[self.class.attribute_map[key]].nil?
151
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
152
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
153
+ end
154
+
155
+ self
156
+ end
157
+
158
+ # Deserializes the data based on type
159
+ # @param string type Data type
160
+ # @param string value Value to be deserialized
161
+ # @return [Object] Deserialized data
162
+ def _deserialize(type, value)
163
+ case type.to_sym
164
+ when :DateTime
165
+ DateTime.parse(parse_date(value))
166
+ when :Date
167
+ Date.parse(parse_date(value))
168
+ when :String
169
+ value.to_s
170
+ when :Integer
171
+ value.to_i
172
+ when :Float
173
+ value.to_f
174
+ when :BigDecimal
175
+ BigDecimal(value.to_s)
176
+ when :Boolean
177
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
178
+ true
179
+ else
180
+ false
181
+ end
182
+ when :Object
183
+ # generic object (usually a Hash), return directly
184
+ value
185
+ when /\AArray<(?<inner_type>.+)>\z/
186
+ inner_type = Regexp.last_match[:inner_type]
187
+ value.map { |v| _deserialize(inner_type, v) }
188
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
189
+ k_type = Regexp.last_match[:k_type]
190
+ v_type = Regexp.last_match[:v_type]
191
+ {}.tap do |hash|
192
+ value.each do |k, v|
193
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
194
+ end
195
+ end
196
+ else # model
197
+ XeroRuby::PayrollUk.const_get(type).build_from_hash(value)
198
+ end
199
+ end
200
+
201
+ # Returns the string representation of the object
202
+ # @return [String] String presentation of the object
203
+ def to_s
204
+ to_hash.to_s
205
+ end
206
+
207
+ # to_body is an alias to to_hash (backward compatibility)
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_body
210
+ to_hash
211
+ end
212
+
213
+ # Returns the object in the form of hash
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_hash(downcase: false)
216
+ hash = {}
217
+ self.class.attribute_map.each_pair do |attr, param|
218
+ value = self.send(attr)
219
+ next if value.nil?
220
+ key = downcase ? attr : param
221
+ hash[key] = _to_hash(value, downcase: downcase)
222
+ end
223
+ hash
224
+ end
225
+
226
+ # Returns the object in the form of hash with snake_case
227
+ def to_attributes
228
+ to_hash(downcase: true)
229
+ end
230
+
231
+ # Outputs non-array value in the form of hash
232
+ # For object, use to_hash. Otherwise, just return the value
233
+ # @param [Object] value Any valid value
234
+ # @return [Hash] Returns the value in the form of hash
235
+ def _to_hash(value, downcase: false)
236
+ if value.is_a?(Array)
237
+ value.map do |v|
238
+ v.to_hash(downcase: downcase)
239
+ end
240
+ elsif value.is_a?(Hash)
241
+ {}.tap do |hash|
242
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
243
+ end
244
+ elsif value.respond_to? :to_hash
245
+ value.to_hash(downcase: downcase)
246
+ else
247
+ value
248
+ end
249
+ end
250
+
251
+ def parse_date(datestring)
252
+ if datestring.include?('Date')
253
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
254
+ original, date, timezone = *date_pattern.match(datestring)
255
+ date = (date.to_i / 1000)
256
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
257
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
258
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
259
+ else # handle date 'types' for small subset of payroll API's
260
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
261
+ end
262
+ end
263
+ end
264
+ end
@@ -0,0 +1,257 @@
1
+ =begin
2
+ #Xero Payroll UK
3
+
4
+ #This is the Xero Payroll API for orgs in the UK region.
5
+
6
+ Contact: api@xero.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 4.3.1
9
+
10
+ =end
11
+
12
+ require 'time'
13
+ require 'date'
14
+
15
+ module XeroRuby::PayrollUk
16
+ require 'bigdecimal'
17
+
18
+ class NICategoryOneOf1
19
+
20
+ attr_accessor :ni_category
21
+ V ||= "V".freeze
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'ni_category' => :'niCategory'
49
+ }
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.openapi_types
54
+ {
55
+ :'ni_category' => :'String'
56
+ }
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollUk::NICategoryOneOf1` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ attributes = attributes.each_with_object({}) { |(k, v), h|
68
+ if (!self.class.attribute_map.key?(k.to_sym))
69
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollUk::NICategoryOneOf1`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
70
+ end
71
+ h[k.to_sym] = v
72
+ }
73
+
74
+ if attributes.key?(:'ni_category')
75
+ self.ni_category = attributes[:'ni_category']
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ invalid_properties
84
+ end
85
+
86
+ # Check to see if the all the properties in the model are valid
87
+ # @return true if the model is valid
88
+ def valid?
89
+ ni_category_validator = EnumAttributeValidator.new('String', ["V"])
90
+ return false unless ni_category_validator.valid?(@ni_category)
91
+ true
92
+ end
93
+
94
+ # Custom attribute writer method checking allowed values (enum).
95
+ # @param [Object] ni_category Object to be assigned
96
+ def ni_category=(ni_category)
97
+ validator = EnumAttributeValidator.new('String', ["V"])
98
+ unless validator.valid?(ni_category)
99
+ fail ArgumentError, "invalid value for \"ni_category\", must be one of #{validator.allowable_values}."
100
+ end
101
+ @ni_category = ni_category
102
+ end
103
+
104
+ # Checks equality by comparing each attribute.
105
+ # @param [Object] Object to be compared
106
+ def ==(o)
107
+ return true if self.equal?(o)
108
+ self.class == o.class &&
109
+ ni_category == o.ni_category
110
+ end
111
+
112
+ # @see the `==` method
113
+ # @param [Object] Object to be compared
114
+ def eql?(o)
115
+ self == o
116
+ end
117
+
118
+ # Calculates hash code according to all attributes.
119
+ # @return [Integer] Hash code
120
+ def hash
121
+ [ni_category].hash
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def self.build_from_hash(attributes)
128
+ new.build_from_hash(attributes)
129
+ end
130
+
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def build_from_hash(attributes)
135
+ return nil unless attributes.is_a?(Hash)
136
+ self.class.openapi_types.each_pair do |key, type|
137
+ if type =~ /\AArray<(.*)>/i
138
+ # check to ensure the input is an array given that the attribute
139
+ # is documented as an array but the input is not
140
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
141
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
142
+ end
143
+ elsif !attributes[self.class.attribute_map[key]].nil?
144
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
145
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
146
+ end
147
+
148
+ self
149
+ end
150
+
151
+ # Deserializes the data based on type
152
+ # @param string type Data type
153
+ # @param string value Value to be deserialized
154
+ # @return [Object] Deserialized data
155
+ def _deserialize(type, value)
156
+ case type.to_sym
157
+ when :DateTime
158
+ DateTime.parse(parse_date(value))
159
+ when :Date
160
+ Date.parse(parse_date(value))
161
+ when :String
162
+ value.to_s
163
+ when :Integer
164
+ value.to_i
165
+ when :Float
166
+ value.to_f
167
+ when :BigDecimal
168
+ BigDecimal(value.to_s)
169
+ when :Boolean
170
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
171
+ true
172
+ else
173
+ false
174
+ end
175
+ when :Object
176
+ # generic object (usually a Hash), return directly
177
+ value
178
+ when /\AArray<(?<inner_type>.+)>\z/
179
+ inner_type = Regexp.last_match[:inner_type]
180
+ value.map { |v| _deserialize(inner_type, v) }
181
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
182
+ k_type = Regexp.last_match[:k_type]
183
+ v_type = Regexp.last_match[:v_type]
184
+ {}.tap do |hash|
185
+ value.each do |k, v|
186
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
187
+ end
188
+ end
189
+ else # model
190
+ XeroRuby::PayrollUk.const_get(type).build_from_hash(value)
191
+ end
192
+ end
193
+
194
+ # Returns the string representation of the object
195
+ # @return [String] String presentation of the object
196
+ def to_s
197
+ to_hash.to_s
198
+ end
199
+
200
+ # to_body is an alias to to_hash (backward compatibility)
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_body
203
+ to_hash
204
+ end
205
+
206
+ # Returns the object in the form of hash
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_hash(downcase: false)
209
+ hash = {}
210
+ self.class.attribute_map.each_pair do |attr, param|
211
+ value = self.send(attr)
212
+ next if value.nil?
213
+ key = downcase ? attr : param
214
+ hash[key] = _to_hash(value, downcase: downcase)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Returns the object in the form of hash with snake_case
220
+ def to_attributes
221
+ to_hash(downcase: true)
222
+ end
223
+
224
+ # Outputs non-array value in the form of hash
225
+ # For object, use to_hash. Otherwise, just return the value
226
+ # @param [Object] value Any valid value
227
+ # @return [Hash] Returns the value in the form of hash
228
+ def _to_hash(value, downcase: false)
229
+ if value.is_a?(Array)
230
+ value.map do |v|
231
+ v.to_hash(downcase: downcase)
232
+ end
233
+ elsif value.is_a?(Hash)
234
+ {}.tap do |hash|
235
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
236
+ end
237
+ elsif value.respond_to? :to_hash
238
+ value.to_hash(downcase: downcase)
239
+ else
240
+ value
241
+ end
242
+ end
243
+
244
+ def parse_date(datestring)
245
+ if datestring.include?('Date')
246
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
247
+ original, date, timezone = *date_pattern.match(datestring)
248
+ date = (date.to_i / 1000)
249
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
250
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
251
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
252
+ else # handle date 'types' for small subset of payroll API's
253
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
254
+ end
255
+ end
256
+ end
257
+ end
@@ -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: 7.1.0
10
+ The version of the XeroOpenAPI document: 8.0.0
11
11
  =end
12
12
 
13
13
  module XeroRuby
14
- VERSION = '10.1.0'
14
+ VERSION = '11.0.0-alpha1'
15
15
  end
data/lib/xero-ruby.rb CHANGED
@@ -139,6 +139,10 @@ require 'xero-ruby/models/payroll_uk/leave_periods'
139
139
  require 'xero-ruby/models/payroll_uk/leave_type'
140
140
  require 'xero-ruby/models/payroll_uk/leave_type_object'
141
141
  require 'xero-ruby/models/payroll_uk/leave_types'
142
+ require 'xero-ruby/models/payroll_uk/ni_category'
143
+ require 'xero-ruby/models/payroll_uk/ni_category_letter'
144
+ require 'xero-ruby/models/payroll_uk/ni_category_one_of'
145
+ require 'xero-ruby/models/payroll_uk/ni_category_one_of1'
142
146
  require 'xero-ruby/models/payroll_uk/pagination'
143
147
  require 'xero-ruby/models/payroll_uk/pay_run'
144
148
  require 'xero-ruby/models/payroll_uk/pay_run_calendar'