patch_ruby 1.22.0 → 1.24.1

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