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,242 @@
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
+ # An object containing the name & email of the party the inventory will be issued to.
18
+ class IssuedTo
19
+ # Name provided for the issuee
20
+ attr_accessor :name
21
+
22
+ # Email address provided for the issuee
23
+ attr_accessor :email
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'name' => :'name',
29
+ :'email' => :'email'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'name' => :'String',
42
+ :'email' => :'String'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ :'name',
50
+ :'email'
51
+ ])
52
+ end
53
+
54
+
55
+ # Allows models with corresponding API classes to delegate API operations to those API classes
56
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
57
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
58
+ def self.method_missing(message, *args, &block)
59
+ if Object.const_defined?('Patch::IssuedTosApi::OPERATIONS') && Patch::IssuedTosApi::OPERATIONS.include?(message)
60
+ Patch::IssuedTosApi.new.send(message, *args)
61
+ else
62
+ super
63
+ end
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 `Patch::IssuedTo` 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 `Patch::IssuedTo`. 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?(:'name')
82
+ self.name = attributes[:'name']
83
+ end
84
+
85
+ if attributes.key?(:'email')
86
+ self.email = attributes[:'email']
87
+ end
88
+ end
89
+
90
+ # Show invalid properties with the reasons. Usually used together with valid?
91
+ # @return Array for valid properties with the reasons
92
+ def list_invalid_properties
93
+ invalid_properties = Array.new
94
+ invalid_properties
95
+ end
96
+
97
+ # Check to see if the all the properties in the model are valid
98
+ # @return true if the model is valid
99
+ def valid?
100
+ true
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(o)
106
+ return true if self.equal?(o)
107
+ self.class == o.class &&
108
+ name == o.name &&
109
+ email == o.email
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
+ [name, email].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 attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
138
+ self.send("#{key}=", nil)
139
+ elsif type =~ /\AArray<(.*)>/i
140
+ # check to ensure the input is an array given that the attribute
141
+ # is documented as an array but the input is not
142
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
143
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
144
+ end
145
+ elsif !attributes[self.class.attribute_map[key]].nil?
146
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
147
+ end
148
+ end
149
+
150
+ self
151
+ end
152
+
153
+ # Deserializes the data based on type
154
+ # @param string type Data type
155
+ # @param string value Value to be deserialized
156
+ # @return [Object] Deserialized data
157
+ def _deserialize(type, value)
158
+ case type.to_sym
159
+ when :Time
160
+ Time.parse(value)
161
+ when :Date
162
+ Date.parse(value)
163
+ when :String
164
+ value.to_s
165
+ when :Integer
166
+ value.to_i
167
+ when :Float
168
+ value.to_f
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
+ # models (e.g. Pet) or oneOf
191
+ klass = Patch.const_get(type)
192
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
193
+ end
194
+ end
195
+
196
+ # Returns the string representation of the object
197
+ # @return [String] String presentation of the object
198
+ def to_s
199
+ to_hash.to_s
200
+ end
201
+
202
+ # to_body is an alias to to_hash (backward compatibility)
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_body
205
+ to_hash
206
+ end
207
+
208
+ # Returns the object in the form of hash
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_hash
211
+ hash = {}
212
+ self.class.attribute_map.each_pair do |attr, param|
213
+ value = self.send(attr)
214
+ if value.nil?
215
+ is_nullable = self.class.openapi_nullable.include?(attr)
216
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
217
+ end
218
+
219
+ hash[param] = _to_hash(value)
220
+ end
221
+ hash
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)
229
+ if value.is_a?(Array)
230
+ value.compact.map { |v| _to_hash(v) }
231
+ elsif value.is_a?(Hash)
232
+ {}.tap do |hash|
233
+ value.each { |k, v| hash[k] = _to_hash(v) }
234
+ end
235
+ elsif value.respond_to? :to_hash
236
+ value.to_hash
237
+ else
238
+ value
239
+ end
240
+ end
241
+ end
242
+ end
@@ -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,8 @@ 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
+ attr_accessor :issued_to
70
+
69
71
  class EnumAttributeValidator
70
72
  attr_reader :datatype
71
73
  attr_reader :allowable_values
@@ -107,7 +109,8 @@ module Patch
107
109
  :'allocations' => :'allocations',
108
110
  :'registry_url' => :'registry_url',
109
111
  :'metadata' => :'metadata',
110
- :'inventory' => :'inventory'
112
+ :'inventory' => :'inventory',
113
+ :'issued_to' => :'issued_to'
111
114
  }
112
115
  end
113
116
 
@@ -135,7 +138,8 @@ module Patch
135
138
  :'allocations' => :'Array<Allocation>',
136
139
  :'registry_url' => :'String',
137
140
  :'metadata' => :'Object',
138
- :'inventory' => :'Array<OrderInventory>'
141
+ :'inventory' => :'Array<OrderInventory>',
142
+ :'issued_to' => :'IssuedTo'
139
143
  }
140
144
  end
141
145
 
@@ -245,6 +249,10 @@ module Patch
245
249
  self.inventory = value
246
250
  end
247
251
  end
252
+
253
+ if attributes.key?(:'issued_to')
254
+ self.issued_to = attributes[:'issued_to']
255
+ end
248
256
  end
249
257
 
250
258
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -323,7 +331,7 @@ module Patch
323
331
  return false if @mass_g < 0
324
332
  return false if @production.nil?
325
333
  return false if @state.nil?
326
- state_validator = EnumAttributeValidator.new('String', ["draft", "placed", "processing", "complete", "cancelled"])
334
+ state_validator = EnumAttributeValidator.new('String', ["draft", "reserved", "placed", "processing", "complete", "cancelled"])
327
335
  return false unless state_validator.valid?(@state)
328
336
  return false if @amount.nil?
329
337
  return false if @amount > 100000000000
@@ -360,7 +368,7 @@ module Patch
360
368
  # Custom attribute writer method checking allowed values (enum).
361
369
  # @param [Object] state Object to be assigned
362
370
  def state=(state)
363
- validator = EnumAttributeValidator.new('String', ["draft", "placed", "processing", "complete", "cancelled"])
371
+ validator = EnumAttributeValidator.new('String', ["draft", "reserved", "placed", "processing", "complete", "cancelled"])
364
372
  unless validator.valid?(state)
365
373
  fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}."
366
374
  end
@@ -416,7 +424,8 @@ module Patch
416
424
  allocations == o.allocations &&
417
425
  registry_url == o.registry_url &&
418
426
  metadata == o.metadata &&
419
- inventory == o.inventory
427
+ inventory == o.inventory &&
428
+ issued_to == o.issued_to
420
429
  end
421
430
 
422
431
  # @see the `==` method
@@ -428,7 +437,7 @@ module Patch
428
437
  # Calculates hash code according to all attributes.
429
438
  # @return [Integer] Hash code
430
439
  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
440
+ [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
441
  end
433
442
 
434
443
  # Builds the object from hash
@@ -0,0 +1,229 @@
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 PlaceOrderRequest
18
+ attr_accessor :issued_to
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'issued_to' => :'issued_to'
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'issued_to' => :'V1OrdersIssuedTo'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ :'issued_to'
43
+ ])
44
+ end
45
+
46
+
47
+ # Allows models with corresponding API classes to delegate API operations to those API classes
48
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
49
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
50
+ def self.method_missing(message, *args, &block)
51
+ if Object.const_defined?('Patch::PlaceOrderRequestsApi::OPERATIONS') && Patch::PlaceOrderRequestsApi::OPERATIONS.include?(message)
52
+ Patch::PlaceOrderRequestsApi.new.send(message, *args)
53
+ else
54
+ super
55
+ end
56
+ end
57
+
58
+ # Initializes the object
59
+ # @param [Hash] attributes Model attributes in the form of hash
60
+ def initialize(attributes = {})
61
+ if (!attributes.is_a?(Hash))
62
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::PlaceOrderRequest` initialize method"
63
+ end
64
+
65
+ # check to see if the attribute exists and convert string to symbol for hash key
66
+ attributes = attributes.each_with_object({}) { |(k, v), h|
67
+ if (!self.class.attribute_map.key?(k.to_sym))
68
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::PlaceOrderRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
69
+ end
70
+ h[k.to_sym] = v
71
+ }
72
+
73
+ if attributes.key?(:'issued_to')
74
+ self.issued_to = attributes[:'issued_to']
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ issued_to == o.issued_to
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [issued_to].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ new.build_from_hash(attributes)
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ self.class.openapi_types.each_pair do |key, type|
124
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
125
+ self.send("#{key}=", nil)
126
+ elsif type =~ /\AArray<(.*)>/i
127
+ # check to ensure the input is an array given that the attribute
128
+ # is documented as an array but the input is not
129
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
130
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
131
+ end
132
+ elsif !attributes[self.class.attribute_map[key]].nil?
133
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
134
+ end
135
+ end
136
+
137
+ self
138
+ end
139
+
140
+ # Deserializes the data based on type
141
+ # @param string type Data type
142
+ # @param string value Value to be deserialized
143
+ # @return [Object] Deserialized data
144
+ def _deserialize(type, value)
145
+ case type.to_sym
146
+ when :Time
147
+ Time.parse(value)
148
+ when :Date
149
+ Date.parse(value)
150
+ when :String
151
+ value.to_s
152
+ when :Integer
153
+ value.to_i
154
+ when :Float
155
+ value.to_f
156
+ when :Boolean
157
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
165
+ when /\AArray<(?<inner_type>.+)>\z/
166
+ inner_type = Regexp.last_match[:inner_type]
167
+ value.map { |v| _deserialize(inner_type, v) }
168
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
169
+ k_type = Regexp.last_match[:k_type]
170
+ v_type = Regexp.last_match[:v_type]
171
+ {}.tap do |hash|
172
+ value.each do |k, v|
173
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
174
+ end
175
+ end
176
+ else # model
177
+ # models (e.g. Pet) or oneOf
178
+ klass = Patch.const_get(type)
179
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
180
+ end
181
+ end
182
+
183
+ # Returns the string representation of the object
184
+ # @return [String] String presentation of the object
185
+ def to_s
186
+ to_hash.to_s
187
+ end
188
+
189
+ # to_body is an alias to to_hash (backward compatibility)
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_body
192
+ to_hash
193
+ end
194
+
195
+ # Returns the object in the form of hash
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_hash
198
+ hash = {}
199
+ self.class.attribute_map.each_pair do |attr, param|
200
+ value = self.send(attr)
201
+ if value.nil?
202
+ is_nullable = self.class.openapi_nullable.include?(attr)
203
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
204
+ end
205
+
206
+ hash[param] = _to_hash(value)
207
+ end
208
+ hash
209
+ end
210
+
211
+ # Outputs non-array value in the form of hash
212
+ # For object, use to_hash. Otherwise, just return the value
213
+ # @param [Object] value Any valid value
214
+ # @return [Hash] Returns the value in the form of hash
215
+ def _to_hash(value)
216
+ if value.is_a?(Array)
217
+ value.compact.map { |v| _to_hash(v) }
218
+ elsif value.is_a?(Hash)
219
+ {}.tap do |hash|
220
+ value.each { |k, v| hash[k] = _to_hash(v) }
221
+ end
222
+ elsif value.respond_to? :to_hash
223
+ value.to_hash
224
+ else
225
+ value
226
+ end
227
+ end
228
+ end
229
+ end
@@ -18,7 +18,7 @@ module Patch
18
18
  # A unique uid for the record. UIDs will be prepended by pro_prod or pro_test depending on the mode it was created in.
19
19
  attr_accessor :id
20
20
 
21
- # A boolean indicating if this project is a production or test mode project.
21
+ # A boolean indicating if this project is a production or demo mode project.
22
22
  attr_accessor :production
23
23
 
24
24
  # The name of the project.
@@ -30,7 +30,7 @@ module Patch
30
30
  # DEPRECATED. Favor the technology_type field instead.
31
31
  attr_accessor :type
32
32
 
33
- # The mechanism of the project. Either removal or avoidance.
33
+ # The mechanism of the project. One of: removal, avoidance, avoidance_and_removal.
34
34
  attr_accessor :mechanism
35
35
 
36
36
  # The country of origin of the project.
@@ -77,28 +77,6 @@ module Patch
77
77
  # An array of objects containing available inventory for a project. Available inventory is grouped by a project's vintage year and returns amount and pricing available for a given vintage year.
78
78
  attr_accessor :inventory
79
79
 
80
- class EnumAttributeValidator
81
- attr_reader :datatype
82
- attr_reader :allowable_values
83
-
84
- def initialize(datatype, allowable_values)
85
- @allowable_values = allowable_values.map do |value|
86
- case datatype.to_s
87
- when /Integer/i
88
- value.to_i
89
- when /Float/i
90
- value.to_f
91
- else
92
- value
93
- end
94
- end
95
- end
96
-
97
- def valid?(value)
98
- !value || allowable_values.include?(value)
99
- end
100
- end
101
-
102
80
  # Attribute mapping from ruby-style variable name to JSON key.
103
81
  def self.attribute_map
104
82
  {
@@ -351,8 +329,6 @@ module Patch
351
329
  return false if @production.nil?
352
330
  return false if @name.nil?
353
331
  return false if @description.nil?
354
- mechanism_validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
355
- return false unless mechanism_validator.valid?(@mechanism)
356
332
  return false if @country.nil?
357
333
  return false if @developer.nil?
358
334
  return false if @average_price_per_tonne_cents_usd.nil?
@@ -363,16 +339,6 @@ module Patch
363
339
  true
364
340
  end
365
341
 
366
- # Custom attribute writer method checking allowed values (enum).
367
- # @param [Object] mechanism Object to be assigned
368
- def mechanism=(mechanism)
369
- validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
370
- unless validator.valid?(mechanism)
371
- fail ArgumentError, "invalid value for \"mechanism\", must be one of #{validator.allowable_values}."
372
- end
373
- @mechanism = mechanism
374
- end
375
-
376
342
  # Checks equality by comparing each attribute.
377
343
  # @param [Object] Object to be compared
378
344
  def ==(o)