patch_ruby 1.22.0 → 1.24.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,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.
@@ -24,7 +24,7 @@ module Patch
24
24
  # DEPRECATED, use `amount` and `unit` fields instead. The amount of carbon offsets in grams purchased through this order.
25
25
  attr_accessor :mass_g
26
26
 
27
- # A boolean indicating if this order is a production or test mode order.
27
+ # A boolean indicating if this order is a production or demo mode order.
28
28
  attr_accessor :production
29
29
 
30
30
  # The current state of the order.
@@ -66,6 +66,9 @@ module Patch
66
66
  # An array containing the inventory allocated for this order. Inventory is grouped by project, vintage year, and price.
67
67
  attr_accessor :inventory
68
68
 
69
+ # An object containing the name & email of the party the inventory will be issued to.
70
+ attr_accessor :issued_to
71
+
69
72
  class EnumAttributeValidator
70
73
  attr_reader :datatype
71
74
  attr_reader :allowable_values
@@ -107,7 +110,8 @@ module Patch
107
110
  :'allocations' => :'allocations',
108
111
  :'registry_url' => :'registry_url',
109
112
  :'metadata' => :'metadata',
110
- :'inventory' => :'inventory'
113
+ :'inventory' => :'inventory',
114
+ :'issued_to' => :'issued_to'
111
115
  }
112
116
  end
113
117
 
@@ -135,7 +139,8 @@ module Patch
135
139
  :'allocations' => :'Array<Allocation>',
136
140
  :'registry_url' => :'String',
137
141
  :'metadata' => :'Object',
138
- :'inventory' => :'Array<OrderInventory>'
142
+ :'inventory' => :'Array<OrderInventory>',
143
+ :'issued_to' => :'OrderIssuedTo'
139
144
  }
140
145
  end
141
146
 
@@ -245,6 +250,13 @@ module Patch
245
250
  self.inventory = value
246
251
  end
247
252
  end
253
+
254
+ if attributes.key?(:'issued_to')
255
+ if (value = attributes[:'issued_to']).is_a?(Hash)
256
+ self.issued_to = value
257
+ end
258
+ self.issued_to = attributes[:'issued_to']
259
+ end
248
260
  end
249
261
 
250
262
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -323,7 +335,7 @@ module Patch
323
335
  return false if @mass_g < 0
324
336
  return false if @production.nil?
325
337
  return false if @state.nil?
326
- state_validator = EnumAttributeValidator.new('String', ["draft", "placed", "processing", "complete", "cancelled"])
338
+ state_validator = EnumAttributeValidator.new('String', ["draft", "reserved", "placed", "processing", "complete", "cancelled"])
327
339
  return false unless state_validator.valid?(@state)
328
340
  return false if @amount.nil?
329
341
  return false if @amount > 100000000000
@@ -360,7 +372,7 @@ module Patch
360
372
  # Custom attribute writer method checking allowed values (enum).
361
373
  # @param [Object] state Object to be assigned
362
374
  def state=(state)
363
- validator = EnumAttributeValidator.new('String', ["draft", "placed", "processing", "complete", "cancelled"])
375
+ validator = EnumAttributeValidator.new('String', ["draft", "reserved", "placed", "processing", "complete", "cancelled"])
364
376
  unless validator.valid?(state)
365
377
  fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}."
366
378
  end
@@ -416,7 +428,8 @@ module Patch
416
428
  allocations == o.allocations &&
417
429
  registry_url == o.registry_url &&
418
430
  metadata == o.metadata &&
419
- inventory == o.inventory
431
+ inventory == o.inventory &&
432
+ issued_to == o.issued_to
420
433
  end
421
434
 
422
435
  # @see the `==` method
@@ -428,7 +441,7 @@ module Patch
428
441
  # Calculates hash code according to all attributes.
429
442
  # @return [Integer] Hash code
430
443
  def hash
431
- [id, created_at, mass_g, production, state, amount, unit, price, patch_fee, currency, allocation_state, price_cents_usd, patch_fee_cents_usd, allocations, registry_url, metadata, inventory].hash
444
+ [id, created_at, mass_g, production, state, amount, unit, price, patch_fee, currency, allocation_state, price_cents_usd, patch_fee_cents_usd, allocations, registry_url, metadata, inventory, issued_to].hash
432
445
  end
433
446
 
434
447
  # Builds the object from hash