patch_ruby 2.1.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,373 +0,0 @@
1
- =begin
2
- #Patch API V2
3
-
4
- #The core API used to integrate with Patch's service
5
-
6
- The version of the OpenAPI document: 2
7
- Contact: engineering@usepatch.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.3.1
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module Patch
17
- class CreateShippingEstimateRequest
18
- attr_accessor :distance_m
19
-
20
- attr_accessor :package_mass_g
21
-
22
- attr_accessor :transportation_method
23
-
24
- attr_accessor :project_id
25
-
26
- attr_accessor :create_order
27
-
28
- class EnumAttributeValidator
29
- attr_reader :datatype
30
- attr_reader :allowable_values
31
-
32
- def initialize(datatype, allowable_values)
33
- @allowable_values = allowable_values.map do |value|
34
- case datatype.to_s
35
- when /Integer/i
36
- value.to_i
37
- when /Float/i
38
- value.to_f
39
- else
40
- value
41
- end
42
- end
43
- end
44
-
45
- def valid?(value)
46
- !value || allowable_values.include?(value)
47
- end
48
- end
49
-
50
- # Attribute mapping from ruby-style variable name to JSON key.
51
- def self.attribute_map
52
- {
53
- :'distance_m' => :'distance_m',
54
- :'package_mass_g' => :'package_mass_g',
55
- :'transportation_method' => :'transportation_method',
56
- :'project_id' => :'project_id',
57
- :'create_order' => :'create_order'
58
- }
59
- end
60
-
61
- # Returns all the JSON keys this model knows about
62
- def self.acceptable_attributes
63
- attribute_map.values
64
- end
65
-
66
- # Attribute type mapping.
67
- def self.openapi_types
68
- {
69
- :'distance_m' => :'Integer',
70
- :'package_mass_g' => :'Integer',
71
- :'transportation_method' => :'String',
72
- :'project_id' => :'String',
73
- :'create_order' => :'Boolean'
74
- }
75
- end
76
-
77
- # List of attributes with nullable: true
78
- def self.openapi_nullable
79
- Set.new([
80
- :'project_id',
81
- :'create_order'
82
- ])
83
- end
84
-
85
-
86
- # Allows models with corresponding API classes to delegate API operations to those API classes
87
- # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
88
- # Eg. Order.create_order delegates to OrdersApi.new.create_order
89
- def self.method_missing(message, *args, &block)
90
- if Object.const_defined?('Patch::CreateShippingEstimateRequestsApi::OPERATIONS') && Patch::CreateShippingEstimateRequestsApi::OPERATIONS.include?(message)
91
- Patch::CreateShippingEstimateRequestsApi.new.send(message, *args)
92
- else
93
- super
94
- end
95
- end
96
-
97
- # Initializes the object
98
- # @param [Hash] attributes Model attributes in the form of hash
99
- def initialize(attributes = {})
100
- if (!attributes.is_a?(Hash))
101
- fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateShippingEstimateRequest` initialize method"
102
- end
103
-
104
- # check to see if the attribute exists and convert string to symbol for hash key
105
- attributes = attributes.each_with_object({}) { |(k, v), h|
106
- if (!self.class.attribute_map.key?(k.to_sym))
107
- fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateShippingEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
108
- end
109
- h[k.to_sym] = v
110
- }
111
-
112
- if attributes.key?(:'distance_m')
113
- self.distance_m = attributes[:'distance_m']
114
- end
115
-
116
- if attributes.key?(:'package_mass_g')
117
- self.package_mass_g = attributes[:'package_mass_g']
118
- end
119
-
120
- if attributes.key?(:'transportation_method')
121
- self.transportation_method = attributes[:'transportation_method']
122
- end
123
-
124
- if attributes.key?(:'project_id')
125
- self.project_id = attributes[:'project_id']
126
- end
127
-
128
- if attributes.key?(:'create_order')
129
- self.create_order = attributes[:'create_order']
130
- else
131
- self.create_order = false
132
- end
133
- end
134
-
135
- # Show invalid properties with the reasons. Usually used together with valid?
136
- # @return Array for valid properties with the reasons
137
- def list_invalid_properties
138
- invalid_properties = Array.new
139
- if @distance_m.nil?
140
- invalid_properties.push('invalid value for "distance_m", distance_m cannot be nil.')
141
- end
142
-
143
- if @distance_m > 400000000
144
- invalid_properties.push('invalid value for "distance_m", must be smaller than or equal to 400000000.')
145
- end
146
-
147
- if @distance_m < 0
148
- invalid_properties.push('invalid value for "distance_m", must be greater than or equal to 0.')
149
- end
150
-
151
- if @package_mass_g.nil?
152
- invalid_properties.push('invalid value for "package_mass_g", package_mass_g cannot be nil.')
153
- end
154
-
155
- if @package_mass_g > 2000000000
156
- invalid_properties.push('invalid value for "package_mass_g", must be smaller than or equal to 2000000000.')
157
- end
158
-
159
- if @package_mass_g < 0
160
- invalid_properties.push('invalid value for "package_mass_g", must be greater than or equal to 0.')
161
- end
162
-
163
- if @transportation_method.nil?
164
- invalid_properties.push('invalid value for "transportation_method", transportation_method cannot be nil.')
165
- end
166
-
167
- invalid_properties
168
- end
169
-
170
- # Check to see if the all the properties in the model are valid
171
- # @return true if the model is valid
172
- def valid?
173
- return false if @distance_m.nil?
174
- return false if @distance_m > 400000000
175
- return false if @distance_m < 0
176
- return false if @package_mass_g.nil?
177
- return false if @package_mass_g > 2000000000
178
- return false if @package_mass_g < 0
179
- return false if @transportation_method.nil?
180
- transportation_method_validator = EnumAttributeValidator.new('String', ["air", "rail", "road", "sea"])
181
- return false unless transportation_method_validator.valid?(@transportation_method)
182
- true
183
- end
184
-
185
- # Custom attribute writer method with validation
186
- # @param [Object] distance_m Value to be assigned
187
- def distance_m=(distance_m)
188
- if distance_m.nil?
189
- fail ArgumentError, 'distance_m cannot be nil'
190
- end
191
-
192
- if distance_m > 400000000
193
- fail ArgumentError, 'invalid value for "distance_m", must be smaller than or equal to 400000000.'
194
- end
195
-
196
- if distance_m < 0
197
- fail ArgumentError, 'invalid value for "distance_m", must be greater than or equal to 0.'
198
- end
199
-
200
- @distance_m = distance_m
201
- end
202
-
203
- # Custom attribute writer method with validation
204
- # @param [Object] package_mass_g Value to be assigned
205
- def package_mass_g=(package_mass_g)
206
- if package_mass_g.nil?
207
- fail ArgumentError, 'package_mass_g cannot be nil'
208
- end
209
-
210
- if package_mass_g > 2000000000
211
- fail ArgumentError, 'invalid value for "package_mass_g", must be smaller than or equal to 2000000000.'
212
- end
213
-
214
- if package_mass_g < 0
215
- fail ArgumentError, 'invalid value for "package_mass_g", must be greater than or equal to 0.'
216
- end
217
-
218
- @package_mass_g = package_mass_g
219
- end
220
-
221
- # Custom attribute writer method checking allowed values (enum).
222
- # @param [Object] transportation_method Object to be assigned
223
- def transportation_method=(transportation_method)
224
- validator = EnumAttributeValidator.new('String', ["air", "rail", "road", "sea"])
225
- unless validator.valid?(transportation_method)
226
- fail ArgumentError, "invalid value for \"transportation_method\", must be one of #{validator.allowable_values}."
227
- end
228
- @transportation_method = transportation_method
229
- end
230
-
231
- # Checks equality by comparing each attribute.
232
- # @param [Object] Object to be compared
233
- def ==(o)
234
- return true if self.equal?(o)
235
- self.class == o.class &&
236
- distance_m == o.distance_m &&
237
- package_mass_g == o.package_mass_g &&
238
- transportation_method == o.transportation_method &&
239
- project_id == o.project_id &&
240
- create_order == o.create_order
241
- end
242
-
243
- # @see the `==` method
244
- # @param [Object] Object to be compared
245
- def eql?(o)
246
- self == o
247
- end
248
-
249
- # Calculates hash code according to all attributes.
250
- # @return [Integer] Hash code
251
- def hash
252
- [distance_m, package_mass_g, transportation_method, project_id, create_order].hash
253
- end
254
-
255
- # Builds the object from hash
256
- # @param [Hash] attributes Model attributes in the form of hash
257
- # @return [Object] Returns the model itself
258
- def self.build_from_hash(attributes)
259
- new.build_from_hash(attributes)
260
- end
261
-
262
- # Builds the object from hash
263
- # @param [Hash] attributes Model attributes in the form of hash
264
- # @return [Object] Returns the model itself
265
- def build_from_hash(attributes)
266
- return nil unless attributes.is_a?(Hash)
267
- self.class.openapi_types.each_pair do |key, type|
268
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
269
- self.send("#{key}=", nil)
270
- elsif type =~ /\AArray<(.*)>/i
271
- # check to ensure the input is an array given that the attribute
272
- # is documented as an array but the input is not
273
- if attributes[self.class.attribute_map[key]].is_a?(Array)
274
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
275
- end
276
- elsif !attributes[self.class.attribute_map[key]].nil?
277
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
278
- end
279
- end
280
-
281
- self
282
- end
283
-
284
- # Deserializes the data based on type
285
- # @param string type Data type
286
- # @param string value Value to be deserialized
287
- # @return [Object] Deserialized data
288
- def _deserialize(type, value)
289
- case type.to_sym
290
- when :Time
291
- Time.parse(value)
292
- when :Date
293
- Date.parse(value)
294
- when :String
295
- value.to_s
296
- when :Integer
297
- value.to_i
298
- when :Float
299
- value.to_f
300
- when :Boolean
301
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
302
- true
303
- else
304
- false
305
- end
306
- when :Object
307
- # generic object (usually a Hash), return directly
308
- value
309
- when /\AArray<(?<inner_type>.+)>\z/
310
- inner_type = Regexp.last_match[:inner_type]
311
- value.map { |v| _deserialize(inner_type, v) }
312
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
313
- k_type = Regexp.last_match[:k_type]
314
- v_type = Regexp.last_match[:v_type]
315
- {}.tap do |hash|
316
- value.each do |k, v|
317
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
318
- end
319
- end
320
- else # model
321
- # models (e.g. Pet) or oneOf
322
- klass = Patch.const_get(type)
323
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
324
- end
325
- end
326
-
327
- # Returns the string representation of the object
328
- # @return [String] String presentation of the object
329
- def to_s
330
- to_hash.to_s
331
- end
332
-
333
- # to_body is an alias to to_hash (backward compatibility)
334
- # @return [Hash] Returns the object in the form of hash
335
- def to_body
336
- to_hash
337
- end
338
-
339
- # Returns the object in the form of hash
340
- # @return [Hash] Returns the object in the form of hash
341
- def to_hash
342
- hash = {}
343
- self.class.attribute_map.each_pair do |attr, param|
344
- value = self.send(attr)
345
- if value.nil?
346
- is_nullable = self.class.openapi_nullable.include?(attr)
347
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
348
- end
349
-
350
- hash[param] = _to_hash(value)
351
- end
352
- hash
353
- end
354
-
355
- # Outputs non-array value in the form of hash
356
- # For object, use to_hash. Otherwise, just return the value
357
- # @param [Object] value Any valid value
358
- # @return [Hash] Returns the value in the form of hash
359
- def _to_hash(value)
360
- if value.is_a?(Array)
361
- value.compact.map { |v| _to_hash(v) }
362
- elsif value.is_a?(Hash)
363
- {}.tap do |hash|
364
- value.each { |k, v| hash[k] = _to_hash(v) }
365
- end
366
- elsif value.respond_to? :to_hash
367
- value.to_hash
368
- else
369
- value
370
- end
371
- end
372
- end
373
- end
@@ -1,328 +0,0 @@
1
- =begin
2
- #Patch API V2
3
-
4
- #The core API used to integrate with Patch's service
5
-
6
- The version of the OpenAPI document: 2
7
- Contact: engineering@usepatch.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.3.1
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module Patch
17
- class CreateVehicleEstimateRequest
18
- attr_accessor :distance_m
19
-
20
- attr_accessor :make
21
-
22
- attr_accessor :model
23
-
24
- attr_accessor :year
25
-
26
- attr_accessor :project_id
27
-
28
- attr_accessor :create_order
29
-
30
- # Attribute mapping from ruby-style variable name to JSON key.
31
- def self.attribute_map
32
- {
33
- :'distance_m' => :'distance_m',
34
- :'make' => :'make',
35
- :'model' => :'model',
36
- :'year' => :'year',
37
- :'project_id' => :'project_id',
38
- :'create_order' => :'create_order'
39
- }
40
- end
41
-
42
- # Returns all the JSON keys this model knows about
43
- def self.acceptable_attributes
44
- attribute_map.values
45
- end
46
-
47
- # Attribute type mapping.
48
- def self.openapi_types
49
- {
50
- :'distance_m' => :'Integer',
51
- :'make' => :'String',
52
- :'model' => :'String',
53
- :'year' => :'Integer',
54
- :'project_id' => :'String',
55
- :'create_order' => :'Boolean'
56
- }
57
- end
58
-
59
- # List of attributes with nullable: true
60
- def self.openapi_nullable
61
- Set.new([
62
- :'make',
63
- :'model',
64
- :'year',
65
- :'project_id',
66
- :'create_order'
67
- ])
68
- end
69
-
70
-
71
- # Allows models with corresponding API classes to delegate API operations to those API classes
72
- # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
73
- # Eg. Order.create_order delegates to OrdersApi.new.create_order
74
- def self.method_missing(message, *args, &block)
75
- if Object.const_defined?('Patch::CreateVehicleEstimateRequestsApi::OPERATIONS') && Patch::CreateVehicleEstimateRequestsApi::OPERATIONS.include?(message)
76
- Patch::CreateVehicleEstimateRequestsApi.new.send(message, *args)
77
- else
78
- super
79
- end
80
- end
81
-
82
- # Initializes the object
83
- # @param [Hash] attributes Model attributes in the form of hash
84
- def initialize(attributes = {})
85
- if (!attributes.is_a?(Hash))
86
- fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateVehicleEstimateRequest` initialize method"
87
- end
88
-
89
- # check to see if the attribute exists and convert string to symbol for hash key
90
- attributes = attributes.each_with_object({}) { |(k, v), h|
91
- if (!self.class.attribute_map.key?(k.to_sym))
92
- fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateVehicleEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
93
- end
94
- h[k.to_sym] = v
95
- }
96
-
97
- if attributes.key?(:'distance_m')
98
- self.distance_m = attributes[:'distance_m']
99
- end
100
-
101
- if attributes.key?(:'make')
102
- self.make = attributes[:'make']
103
- end
104
-
105
- if attributes.key?(:'model')
106
- self.model = attributes[:'model']
107
- end
108
-
109
- if attributes.key?(:'year')
110
- self.year = attributes[:'year']
111
- end
112
-
113
- if attributes.key?(:'project_id')
114
- self.project_id = attributes[:'project_id']
115
- end
116
-
117
- if attributes.key?(:'create_order')
118
- self.create_order = attributes[:'create_order']
119
- else
120
- self.create_order = false
121
- end
122
- end
123
-
124
- # Show invalid properties with the reasons. Usually used together with valid?
125
- # @return Array for valid properties with the reasons
126
- def list_invalid_properties
127
- invalid_properties = Array.new
128
- if @distance_m.nil?
129
- invalid_properties.push('invalid value for "distance_m", distance_m cannot be nil.')
130
- end
131
-
132
- if @distance_m > 400000000
133
- invalid_properties.push('invalid value for "distance_m", must be smaller than or equal to 400000000.')
134
- end
135
-
136
- if @distance_m < 0
137
- invalid_properties.push('invalid value for "distance_m", must be greater than or equal to 0.')
138
- end
139
-
140
- if !@year.nil? && @year < 1900
141
- invalid_properties.push('invalid value for "year", must be greater than or equal to 1900.')
142
- end
143
-
144
- invalid_properties
145
- end
146
-
147
- # Check to see if the all the properties in the model are valid
148
- # @return true if the model is valid
149
- def valid?
150
- return false if @distance_m.nil?
151
- return false if @distance_m > 400000000
152
- return false if @distance_m < 0
153
- return false if !@year.nil? && @year < 1900
154
- true
155
- end
156
-
157
- # Custom attribute writer method with validation
158
- # @param [Object] distance_m Value to be assigned
159
- def distance_m=(distance_m)
160
- if distance_m.nil?
161
- fail ArgumentError, 'distance_m cannot be nil'
162
- end
163
-
164
- if distance_m > 400000000
165
- fail ArgumentError, 'invalid value for "distance_m", must be smaller than or equal to 400000000.'
166
- end
167
-
168
- if distance_m < 0
169
- fail ArgumentError, 'invalid value for "distance_m", must be greater than or equal to 0.'
170
- end
171
-
172
- @distance_m = distance_m
173
- end
174
-
175
- # Custom attribute writer method with validation
176
- # @param [Object] year Value to be assigned
177
- def year=(year)
178
- if !year.nil? && year < 1900
179
- fail ArgumentError, 'invalid value for "year", must be greater than or equal to 1900.'
180
- end
181
-
182
- @year = year
183
- end
184
-
185
- # Checks equality by comparing each attribute.
186
- # @param [Object] Object to be compared
187
- def ==(o)
188
- return true if self.equal?(o)
189
- self.class == o.class &&
190
- distance_m == o.distance_m &&
191
- make == o.make &&
192
- model == o.model &&
193
- year == o.year &&
194
- project_id == o.project_id &&
195
- create_order == o.create_order
196
- end
197
-
198
- # @see the `==` method
199
- # @param [Object] Object to be compared
200
- def eql?(o)
201
- self == o
202
- end
203
-
204
- # Calculates hash code according to all attributes.
205
- # @return [Integer] Hash code
206
- def hash
207
- [distance_m, make, model, year, project_id, create_order].hash
208
- end
209
-
210
- # Builds the object from hash
211
- # @param [Hash] attributes Model attributes in the form of hash
212
- # @return [Object] Returns the model itself
213
- def self.build_from_hash(attributes)
214
- new.build_from_hash(attributes)
215
- end
216
-
217
- # Builds the object from hash
218
- # @param [Hash] attributes Model attributes in the form of hash
219
- # @return [Object] Returns the model itself
220
- def build_from_hash(attributes)
221
- return nil unless attributes.is_a?(Hash)
222
- self.class.openapi_types.each_pair do |key, type|
223
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
224
- self.send("#{key}=", nil)
225
- elsif type =~ /\AArray<(.*)>/i
226
- # check to ensure the input is an array given that the attribute
227
- # is documented as an array but the input is not
228
- if attributes[self.class.attribute_map[key]].is_a?(Array)
229
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
230
- end
231
- elsif !attributes[self.class.attribute_map[key]].nil?
232
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
233
- end
234
- end
235
-
236
- self
237
- end
238
-
239
- # Deserializes the data based on type
240
- # @param string type Data type
241
- # @param string value Value to be deserialized
242
- # @return [Object] Deserialized data
243
- def _deserialize(type, value)
244
- case type.to_sym
245
- when :Time
246
- Time.parse(value)
247
- when :Date
248
- Date.parse(value)
249
- when :String
250
- value.to_s
251
- when :Integer
252
- value.to_i
253
- when :Float
254
- value.to_f
255
- when :Boolean
256
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
257
- true
258
- else
259
- false
260
- end
261
- when :Object
262
- # generic object (usually a Hash), return directly
263
- value
264
- when /\AArray<(?<inner_type>.+)>\z/
265
- inner_type = Regexp.last_match[:inner_type]
266
- value.map { |v| _deserialize(inner_type, v) }
267
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
268
- k_type = Regexp.last_match[:k_type]
269
- v_type = Regexp.last_match[:v_type]
270
- {}.tap do |hash|
271
- value.each do |k, v|
272
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
273
- end
274
- end
275
- else # model
276
- # models (e.g. Pet) or oneOf
277
- klass = Patch.const_get(type)
278
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
279
- end
280
- end
281
-
282
- # Returns the string representation of the object
283
- # @return [String] String presentation of the object
284
- def to_s
285
- to_hash.to_s
286
- end
287
-
288
- # to_body is an alias to to_hash (backward compatibility)
289
- # @return [Hash] Returns the object in the form of hash
290
- def to_body
291
- to_hash
292
- end
293
-
294
- # Returns the object in the form of hash
295
- # @return [Hash] Returns the object in the form of hash
296
- def to_hash
297
- hash = {}
298
- self.class.attribute_map.each_pair do |attr, param|
299
- value = self.send(attr)
300
- if value.nil?
301
- is_nullable = self.class.openapi_nullable.include?(attr)
302
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
303
- end
304
-
305
- hash[param] = _to_hash(value)
306
- end
307
- hash
308
- end
309
-
310
- # Outputs non-array value in the form of hash
311
- # For object, use to_hash. Otherwise, just return the value
312
- # @param [Object] value Any valid value
313
- # @return [Hash] Returns the value in the form of hash
314
- def _to_hash(value)
315
- if value.is_a?(Array)
316
- value.compact.map { |v| _to_hash(v) }
317
- elsif value.is_a?(Hash)
318
- {}.tap do |hash|
319
- value.each { |k, v| hash[k] = _to_hash(v) }
320
- end
321
- elsif value.respond_to? :to_hash
322
- value.to_hash
323
- else
324
- value
325
- end
326
- end
327
- end
328
- end