patch_ruby 1.21.0 → 1.24.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,461 @@
1
+ =begin
2
+ #Patch API V1
3
+
4
+ #The core API used to integrate with Patch's service
5
+
6
+ The version of the OpenAPI document: v1
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 CreateSeaShippingEstimateRequest
18
+ attr_accessor :destination_country_code
19
+
20
+ attr_accessor :destination_locode
21
+
22
+ attr_accessor :destination_postal_code
23
+
24
+ attr_accessor :origin_country_code
25
+
26
+ attr_accessor :origin_locode
27
+
28
+ attr_accessor :origin_postal_code
29
+
30
+ attr_accessor :container_size_code
31
+
32
+ attr_accessor :emissions_scope
33
+
34
+ attr_accessor :freight_mass_g
35
+
36
+ attr_accessor :freight_volume_cubic_m
37
+
38
+ attr_accessor :number_of_containers
39
+
40
+ attr_accessor :vessel_imo
41
+
42
+ attr_accessor :project_id
43
+
44
+ attr_accessor :create_order
45
+
46
+ class EnumAttributeValidator
47
+ attr_reader :datatype
48
+ attr_reader :allowable_values
49
+
50
+ def initialize(datatype, allowable_values)
51
+ @allowable_values = allowable_values.map do |value|
52
+ case datatype.to_s
53
+ when /Integer/i
54
+ value.to_i
55
+ when /Float/i
56
+ value.to_f
57
+ else
58
+ value
59
+ end
60
+ end
61
+ end
62
+
63
+ def valid?(value)
64
+ !value || allowable_values.include?(value)
65
+ end
66
+ end
67
+
68
+ # Attribute mapping from ruby-style variable name to JSON key.
69
+ def self.attribute_map
70
+ {
71
+ :'destination_country_code' => :'destination_country_code',
72
+ :'destination_locode' => :'destination_locode',
73
+ :'destination_postal_code' => :'destination_postal_code',
74
+ :'origin_country_code' => :'origin_country_code',
75
+ :'origin_locode' => :'origin_locode',
76
+ :'origin_postal_code' => :'origin_postal_code',
77
+ :'container_size_code' => :'container_size_code',
78
+ :'emissions_scope' => :'emissions_scope',
79
+ :'freight_mass_g' => :'freight_mass_g',
80
+ :'freight_volume_cubic_m' => :'freight_volume_cubic_m',
81
+ :'number_of_containers' => :'number_of_containers',
82
+ :'vessel_imo' => :'vessel_imo',
83
+ :'project_id' => :'project_id',
84
+ :'create_order' => :'create_order'
85
+ }
86
+ end
87
+
88
+ # Returns all the JSON keys this model knows about
89
+ def self.acceptable_attributes
90
+ attribute_map.values
91
+ end
92
+
93
+ # Attribute type mapping.
94
+ def self.openapi_types
95
+ {
96
+ :'destination_country_code' => :'String',
97
+ :'destination_locode' => :'String',
98
+ :'destination_postal_code' => :'String',
99
+ :'origin_country_code' => :'String',
100
+ :'origin_locode' => :'String',
101
+ :'origin_postal_code' => :'String',
102
+ :'container_size_code' => :'String',
103
+ :'emissions_scope' => :'String',
104
+ :'freight_mass_g' => :'Integer',
105
+ :'freight_volume_cubic_m' => :'Integer',
106
+ :'number_of_containers' => :'Integer',
107
+ :'vessel_imo' => :'Integer',
108
+ :'project_id' => :'String',
109
+ :'create_order' => :'Boolean'
110
+ }
111
+ end
112
+
113
+ # List of attributes with nullable: true
114
+ def self.openapi_nullable
115
+ Set.new([
116
+ :'destination_country_code',
117
+ :'destination_locode',
118
+ :'destination_postal_code',
119
+ :'origin_country_code',
120
+ :'origin_locode',
121
+ :'origin_postal_code',
122
+ :'emissions_scope',
123
+ :'freight_volume_cubic_m',
124
+ :'number_of_containers',
125
+ :'vessel_imo',
126
+ :'project_id',
127
+ :'create_order'
128
+ ])
129
+ end
130
+
131
+
132
+ # Allows models with corresponding API classes to delegate API operations to those API classes
133
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
134
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
135
+ def self.method_missing(message, *args, &block)
136
+ if Object.const_defined?('Patch::CreateSeaShippingEstimateRequestsApi::OPERATIONS') && Patch::CreateSeaShippingEstimateRequestsApi::OPERATIONS.include?(message)
137
+ Patch::CreateSeaShippingEstimateRequestsApi.new.send(message, *args)
138
+ else
139
+ super
140
+ end
141
+ end
142
+
143
+ # Initializes the object
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ def initialize(attributes = {})
146
+ if (!attributes.is_a?(Hash))
147
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateSeaShippingEstimateRequest` initialize method"
148
+ end
149
+
150
+ # check to see if the attribute exists and convert string to symbol for hash key
151
+ attributes = attributes.each_with_object({}) { |(k, v), h|
152
+ if (!self.class.attribute_map.key?(k.to_sym))
153
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateSeaShippingEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
154
+ end
155
+ h[k.to_sym] = v
156
+ }
157
+
158
+ if attributes.key?(:'destination_country_code')
159
+ self.destination_country_code = attributes[:'destination_country_code']
160
+ end
161
+
162
+ if attributes.key?(:'destination_locode')
163
+ self.destination_locode = attributes[:'destination_locode']
164
+ end
165
+
166
+ if attributes.key?(:'destination_postal_code')
167
+ self.destination_postal_code = attributes[:'destination_postal_code']
168
+ end
169
+
170
+ if attributes.key?(:'origin_country_code')
171
+ self.origin_country_code = attributes[:'origin_country_code']
172
+ end
173
+
174
+ if attributes.key?(:'origin_locode')
175
+ self.origin_locode = attributes[:'origin_locode']
176
+ end
177
+
178
+ if attributes.key?(:'origin_postal_code')
179
+ self.origin_postal_code = attributes[:'origin_postal_code']
180
+ end
181
+
182
+ if attributes.key?(:'container_size_code')
183
+ self.container_size_code = attributes[:'container_size_code']
184
+ end
185
+
186
+ if attributes.key?(:'emissions_scope')
187
+ self.emissions_scope = attributes[:'emissions_scope']
188
+ else
189
+ self.emissions_scope = 'wtw'
190
+ end
191
+
192
+ if attributes.key?(:'freight_mass_g')
193
+ self.freight_mass_g = attributes[:'freight_mass_g']
194
+ end
195
+
196
+ if attributes.key?(:'freight_volume_cubic_m')
197
+ self.freight_volume_cubic_m = attributes[:'freight_volume_cubic_m']
198
+ end
199
+
200
+ if attributes.key?(:'number_of_containers')
201
+ self.number_of_containers = attributes[:'number_of_containers']
202
+ end
203
+
204
+ if attributes.key?(:'vessel_imo')
205
+ self.vessel_imo = attributes[:'vessel_imo']
206
+ end
207
+
208
+ if attributes.key?(:'project_id')
209
+ self.project_id = attributes[:'project_id']
210
+ end
211
+
212
+ if attributes.key?(:'create_order')
213
+ self.create_order = attributes[:'create_order']
214
+ else
215
+ self.create_order = false
216
+ end
217
+ end
218
+
219
+ # Show invalid properties with the reasons. Usually used together with valid?
220
+ # @return Array for valid properties with the reasons
221
+ def list_invalid_properties
222
+ invalid_properties = Array.new
223
+ if !@freight_mass_g.nil? && @freight_mass_g > 2000000000
224
+ invalid_properties.push('invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.')
225
+ end
226
+
227
+ if !@freight_mass_g.nil? && @freight_mass_g < 0
228
+ invalid_properties.push('invalid value for "freight_mass_g", must be greater than or equal to 0.')
229
+ end
230
+
231
+ if !@freight_volume_cubic_m.nil? && @freight_volume_cubic_m < 0
232
+ invalid_properties.push('invalid value for "freight_volume_cubic_m", must be greater than or equal to 0.')
233
+ end
234
+
235
+ if !@number_of_containers.nil? && @number_of_containers < 0
236
+ invalid_properties.push('invalid value for "number_of_containers", must be greater than or equal to 0.')
237
+ end
238
+
239
+ invalid_properties
240
+ end
241
+
242
+ # Check to see if the all the properties in the model are valid
243
+ # @return true if the model is valid
244
+ def valid?
245
+ container_size_code_validator = EnumAttributeValidator.new('String', ["20GP", "40GP", "22G1", "42G1", "40HC", "45G1"])
246
+ return false unless container_size_code_validator.valid?(@container_size_code)
247
+ emissions_scope_validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"])
248
+ return false unless emissions_scope_validator.valid?(@emissions_scope)
249
+ return false if !@freight_mass_g.nil? && @freight_mass_g > 2000000000
250
+ return false if !@freight_mass_g.nil? && @freight_mass_g < 0
251
+ return false if !@freight_volume_cubic_m.nil? && @freight_volume_cubic_m < 0
252
+ return false if !@number_of_containers.nil? && @number_of_containers < 0
253
+ true
254
+ end
255
+
256
+ # Custom attribute writer method checking allowed values (enum).
257
+ # @param [Object] container_size_code Object to be assigned
258
+ def container_size_code=(container_size_code)
259
+ validator = EnumAttributeValidator.new('String', ["20GP", "40GP", "22G1", "42G1", "40HC", "45G1"])
260
+ unless validator.valid?(container_size_code)
261
+ fail ArgumentError, "invalid value for \"container_size_code\", must be one of #{validator.allowable_values}."
262
+ end
263
+ @container_size_code = container_size_code
264
+ end
265
+
266
+ # Custom attribute writer method checking allowed values (enum).
267
+ # @param [Object] emissions_scope Object to be assigned
268
+ def emissions_scope=(emissions_scope)
269
+ validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"])
270
+ unless validator.valid?(emissions_scope)
271
+ fail ArgumentError, "invalid value for \"emissions_scope\", must be one of #{validator.allowable_values}."
272
+ end
273
+ @emissions_scope = emissions_scope
274
+ end
275
+
276
+ # Custom attribute writer method with validation
277
+ # @param [Object] freight_mass_g Value to be assigned
278
+ def freight_mass_g=(freight_mass_g)
279
+ if !freight_mass_g.nil? && freight_mass_g > 2000000000
280
+ fail ArgumentError, 'invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.'
281
+ end
282
+
283
+ if !freight_mass_g.nil? && freight_mass_g < 0
284
+ fail ArgumentError, 'invalid value for "freight_mass_g", must be greater than or equal to 0.'
285
+ end
286
+
287
+ @freight_mass_g = freight_mass_g
288
+ end
289
+
290
+ # Custom attribute writer method with validation
291
+ # @param [Object] freight_volume_cubic_m Value to be assigned
292
+ def freight_volume_cubic_m=(freight_volume_cubic_m)
293
+ if !freight_volume_cubic_m.nil? && freight_volume_cubic_m < 0
294
+ fail ArgumentError, 'invalid value for "freight_volume_cubic_m", must be greater than or equal to 0.'
295
+ end
296
+
297
+ @freight_volume_cubic_m = freight_volume_cubic_m
298
+ end
299
+
300
+ # Custom attribute writer method with validation
301
+ # @param [Object] number_of_containers Value to be assigned
302
+ def number_of_containers=(number_of_containers)
303
+ if !number_of_containers.nil? && number_of_containers < 0
304
+ fail ArgumentError, 'invalid value for "number_of_containers", must be greater than or equal to 0.'
305
+ end
306
+
307
+ @number_of_containers = number_of_containers
308
+ end
309
+
310
+ # Checks equality by comparing each attribute.
311
+ # @param [Object] Object to be compared
312
+ def ==(o)
313
+ return true if self.equal?(o)
314
+ self.class == o.class &&
315
+ destination_country_code == o.destination_country_code &&
316
+ destination_locode == o.destination_locode &&
317
+ destination_postal_code == o.destination_postal_code &&
318
+ origin_country_code == o.origin_country_code &&
319
+ origin_locode == o.origin_locode &&
320
+ origin_postal_code == o.origin_postal_code &&
321
+ container_size_code == o.container_size_code &&
322
+ emissions_scope == o.emissions_scope &&
323
+ freight_mass_g == o.freight_mass_g &&
324
+ freight_volume_cubic_m == o.freight_volume_cubic_m &&
325
+ number_of_containers == o.number_of_containers &&
326
+ vessel_imo == o.vessel_imo &&
327
+ project_id == o.project_id &&
328
+ create_order == o.create_order
329
+ end
330
+
331
+ # @see the `==` method
332
+ # @param [Object] Object to be compared
333
+ def eql?(o)
334
+ self == o
335
+ end
336
+
337
+ # Calculates hash code according to all attributes.
338
+ # @return [Integer] Hash code
339
+ def hash
340
+ [destination_country_code, destination_locode, destination_postal_code, origin_country_code, origin_locode, origin_postal_code, container_size_code, emissions_scope, freight_mass_g, freight_volume_cubic_m, number_of_containers, vessel_imo, project_id, create_order].hash
341
+ end
342
+
343
+ # Builds the object from hash
344
+ # @param [Hash] attributes Model attributes in the form of hash
345
+ # @return [Object] Returns the model itself
346
+ def self.build_from_hash(attributes)
347
+ new.build_from_hash(attributes)
348
+ end
349
+
350
+ # Builds the object from hash
351
+ # @param [Hash] attributes Model attributes in the form of hash
352
+ # @return [Object] Returns the model itself
353
+ def build_from_hash(attributes)
354
+ return nil unless attributes.is_a?(Hash)
355
+ self.class.openapi_types.each_pair do |key, type|
356
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
357
+ self.send("#{key}=", nil)
358
+ elsif type =~ /\AArray<(.*)>/i
359
+ # check to ensure the input is an array given that the attribute
360
+ # is documented as an array but the input is not
361
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
362
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
363
+ end
364
+ elsif !attributes[self.class.attribute_map[key]].nil?
365
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
366
+ end
367
+ end
368
+
369
+ self
370
+ end
371
+
372
+ # Deserializes the data based on type
373
+ # @param string type Data type
374
+ # @param string value Value to be deserialized
375
+ # @return [Object] Deserialized data
376
+ def _deserialize(type, value)
377
+ case type.to_sym
378
+ when :Time
379
+ Time.parse(value)
380
+ when :Date
381
+ Date.parse(value)
382
+ when :String
383
+ value.to_s
384
+ when :Integer
385
+ value.to_i
386
+ when :Float
387
+ value.to_f
388
+ when :Boolean
389
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
390
+ true
391
+ else
392
+ false
393
+ end
394
+ when :Object
395
+ # generic object (usually a Hash), return directly
396
+ value
397
+ when /\AArray<(?<inner_type>.+)>\z/
398
+ inner_type = Regexp.last_match[:inner_type]
399
+ value.map { |v| _deserialize(inner_type, v) }
400
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
401
+ k_type = Regexp.last_match[:k_type]
402
+ v_type = Regexp.last_match[:v_type]
403
+ {}.tap do |hash|
404
+ value.each do |k, v|
405
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
406
+ end
407
+ end
408
+ else # model
409
+ # models (e.g. Pet) or oneOf
410
+ klass = Patch.const_get(type)
411
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
412
+ end
413
+ end
414
+
415
+ # Returns the string representation of the object
416
+ # @return [String] String presentation of the object
417
+ def to_s
418
+ to_hash.to_s
419
+ end
420
+
421
+ # to_body is an alias to to_hash (backward compatibility)
422
+ # @return [Hash] Returns the object in the form of hash
423
+ def to_body
424
+ to_hash
425
+ end
426
+
427
+ # Returns the object in the form of hash
428
+ # @return [Hash] Returns the object in the form of hash
429
+ def to_hash
430
+ hash = {}
431
+ self.class.attribute_map.each_pair do |attr, param|
432
+ value = self.send(attr)
433
+ if value.nil?
434
+ is_nullable = self.class.openapi_nullable.include?(attr)
435
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
436
+ end
437
+
438
+ hash[param] = _to_hash(value)
439
+ end
440
+ hash
441
+ end
442
+
443
+ # Outputs non-array value in the form of hash
444
+ # For object, use to_hash. Otherwise, just return the value
445
+ # @param [Object] value Any valid value
446
+ # @return [Hash] Returns the value in the form of hash
447
+ def _to_hash(value)
448
+ if value.is_a?(Array)
449
+ value.compact.map { |v| _to_hash(v) }
450
+ elsif value.is_a?(Hash)
451
+ {}.tap do |hash|
452
+ value.each { |k, v| hash[k] = _to_hash(v) }
453
+ end
454
+ elsif value.respond_to? :to_hash
455
+ value.to_hash
456
+ else
457
+ value
458
+ end
459
+ end
460
+ end
461
+ end
@@ -18,7 +18,7 @@ module Patch
18
18
  # A unique uid for the record. UIDs will be prepended by est_prod or est_test depending on the mode it was created in.
19
19
  attr_accessor :id
20
20
 
21
- # A boolean indicating if this estimate is a production or test mode estimate.
21
+ # A boolean indicating if this estimate is a production or demo mode estimate.
22
22
  attr_accessor :production
23
23
 
24
24
  # The type of estimate. Available types are mass, flight, shipping, vehicle, and crypto.