patch_ruby 1.12.0 → 1.15.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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/Gemfile.lock +2 -2
  4. data/lib/patch_ruby/api/estimates_api.rb +2 -2
  5. data/lib/patch_ruby/api/technology_types_api.rb +84 -0
  6. data/lib/patch_ruby/api_client.rb +1 -1
  7. data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +13 -1
  8. data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +13 -1
  9. data/lib/patch_ruby/models/create_flight_estimate_request.rb +2 -0
  10. data/lib/patch_ruby/models/create_mass_estimate_request.rb +2 -0
  11. data/lib/patch_ruby/models/create_shipping_estimate_request.rb +2 -0
  12. data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +2 -0
  13. data/lib/patch_ruby/models/order.rb +1 -1
  14. data/lib/patch_ruby/models/parent_technology_type.rb +240 -0
  15. data/lib/patch_ruby/models/project.rb +92 -15
  16. data/lib/patch_ruby/models/technology_type.rb +259 -0
  17. data/lib/patch_ruby/models/technology_type_list_response.rb +259 -0
  18. data/lib/patch_ruby/version.rb +1 -1
  19. data/lib/patch_ruby.rb +4 -0
  20. data/spec/api/technology_types_api_spec.rb +46 -0
  21. data/spec/factories/parent_technology_type.rb +8 -0
  22. data/spec/factories/projects.rb +7 -0
  23. data/spec/factories/sdgs.rb +10 -0
  24. data/spec/factories/technology_type.rb +9 -0
  25. data/spec/integration/estimates_spec.rb +16 -2
  26. data/spec/integration/orders_spec.rb +2 -2
  27. data/spec/integration/projects/technology_types_spec.rb +14 -0
  28. data/spec/integration/projects_spec.rb +17 -1
  29. data/spec/models/create_mass_estimate_request_spec.rb +1 -1
  30. data/spec/models/project_spec.rb +10 -2
  31. metadata +41 -27
@@ -27,12 +27,24 @@ module Patch
27
27
  # The description of the project.
28
28
  attr_accessor :description
29
29
 
30
- # The type of carbon removal project, currently available project types are Biomass, Dac, Forestry, Mineralization, Ocean, Renewables, Soil.
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.
34
+ attr_accessor :mechanism
35
+
33
36
  # The country of origin of the project.
34
37
  attr_accessor :country
35
38
 
39
+ # The state where this project is located.
40
+ attr_accessor :state
41
+
42
+ # The latitude at which this project is located.
43
+ attr_accessor :latitude
44
+
45
+ # The longitude at which this project is located.
46
+ attr_accessor :longitude
47
+
36
48
  # The name of the project developer.
37
49
  attr_accessor :developer
38
50
 
@@ -45,12 +57,20 @@ module Patch
45
57
  # The remaining mass in grams available for purchase for this project.
46
58
  attr_accessor :remaining_mass_g
47
59
 
48
- # An object returning the Standard associated with this project.
60
+ # The name of the project verifier. A verifier is the organization that verifies the calculations of the actual amount of greenhouse gas emissions that have been avoided or sequestered through implementation of the project.
61
+ attr_accessor :verifier
62
+
63
+ # An object returning the Standard associated with this project. Standards provide guidance on GHG quantification, monitoring, and reporting. Standards can include protocols/methodologies and guidance documents.
49
64
  attr_accessor :standard
50
65
 
51
66
  # An array returning the UN Sustainable Development Goals associated with this project.
52
67
  attr_accessor :sdgs
53
68
 
69
+ # A short description of the project.
70
+ attr_accessor :tagline
71
+
72
+ attr_accessor :technology_type
73
+
54
74
  class EnumAttributeValidator
55
75
  attr_reader :datatype
56
76
  attr_reader :allowable_values
@@ -81,13 +101,20 @@ module Patch
81
101
  :'name' => :'name',
82
102
  :'description' => :'description',
83
103
  :'type' => :'type',
104
+ :'mechanism' => :'mechanism',
84
105
  :'country' => :'country',
106
+ :'state' => :'state',
107
+ :'latitude' => :'latitude',
108
+ :'longitude' => :'longitude',
85
109
  :'developer' => :'developer',
86
110
  :'photos' => :'photos',
87
111
  :'average_price_per_tonne_cents_usd' => :'average_price_per_tonne_cents_usd',
88
112
  :'remaining_mass_g' => :'remaining_mass_g',
113
+ :'verifier' => :'verifier',
89
114
  :'standard' => :'standard',
90
- :'sdgs' => :'sdgs'
115
+ :'sdgs' => :'sdgs',
116
+ :'tagline' => :'tagline',
117
+ :'technology_type' => :'technology_type'
91
118
  }
92
119
  end
93
120
 
@@ -104,22 +131,32 @@ module Patch
104
131
  :'name' => :'String',
105
132
  :'description' => :'String',
106
133
  :'type' => :'String',
134
+ :'mechanism' => :'String',
107
135
  :'country' => :'String',
136
+ :'state' => :'String',
137
+ :'latitude' => :'Float',
138
+ :'longitude' => :'Float',
108
139
  :'developer' => :'String',
109
140
  :'photos' => :'Array<Photo>',
110
141
  :'average_price_per_tonne_cents_usd' => :'Integer',
111
142
  :'remaining_mass_g' => :'Integer',
143
+ :'verifier' => :'String',
112
144
  :'standard' => :'Standard',
113
- :'sdgs' => :'Array<Sdg>'
145
+ :'sdgs' => :'Array<Sdg>',
146
+ :'tagline' => :'String',
147
+ :'technology_type' => :'TechnologyType'
114
148
  }
115
149
  end
116
150
 
117
151
  # List of attributes with nullable: true
118
152
  def self.openapi_nullable
119
153
  Set.new([
154
+ :'state',
155
+ :'latitude',
156
+ :'longitude',
120
157
  :'photos',
121
158
  :'standard',
122
- :'sdgs'
159
+ :'sdgs',
123
160
  ])
124
161
  end
125
162
 
@@ -170,10 +207,26 @@ module Patch
170
207
  self.type = attributes[:'type']
171
208
  end
172
209
 
210
+ if attributes.key?(:'mechanism')
211
+ self.mechanism = attributes[:'mechanism']
212
+ end
213
+
173
214
  if attributes.key?(:'country')
174
215
  self.country = attributes[:'country']
175
216
  end
176
217
 
218
+ if attributes.key?(:'state')
219
+ self.state = attributes[:'state']
220
+ end
221
+
222
+ if attributes.key?(:'latitude')
223
+ self.latitude = attributes[:'latitude']
224
+ end
225
+
226
+ if attributes.key?(:'longitude')
227
+ self.longitude = attributes[:'longitude']
228
+ end
229
+
177
230
  if attributes.key?(:'developer')
178
231
  self.developer = attributes[:'developer']
179
232
  end
@@ -192,6 +245,10 @@ module Patch
192
245
  self.remaining_mass_g = attributes[:'remaining_mass_g']
193
246
  end
194
247
 
248
+ if attributes.key?(:'verifier')
249
+ self.verifier = attributes[:'verifier']
250
+ end
251
+
195
252
  if attributes.key?(:'standard')
196
253
  self.standard = attributes[:'standard']
197
254
  end
@@ -201,6 +258,14 @@ module Patch
201
258
  self.sdgs = value
202
259
  end
203
260
  end
261
+
262
+ if attributes.key?(:'tagline')
263
+ self.tagline = attributes[:'tagline']
264
+ end
265
+
266
+ if attributes.key?(:'technology_type')
267
+ self.technology_type = attributes[:'technology_type']
268
+ end
204
269
  end
205
270
 
206
271
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -239,6 +304,10 @@ module Patch
239
304
  invalid_properties.push('invalid value for "remaining_mass_g", remaining_mass_g cannot be nil.')
240
305
  end
241
306
 
307
+ if @technology_type.nil?
308
+ invalid_properties.push('invalid value for "technology_type", technology_type cannot be nil.')
309
+ end
310
+
242
311
  invalid_properties
243
312
  end
244
313
 
@@ -249,23 +318,24 @@ module Patch
249
318
  return false if @production.nil?
250
319
  return false if @name.nil?
251
320
  return false if @description.nil?
252
- type_validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "renewables", "soil"])
253
- return false unless type_validator.valid?(@type)
321
+ mechanism_validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
322
+ return false unless mechanism_validator.valid?(@mechanism)
254
323
  return false if @country.nil?
255
324
  return false if @developer.nil?
256
325
  return false if @average_price_per_tonne_cents_usd.nil?
257
326
  return false if @remaining_mass_g.nil?
327
+ return false if @technology_type.nil?
258
328
  true
259
329
  end
260
330
 
261
331
  # Custom attribute writer method checking allowed values (enum).
262
- # @param [Object] type Object to be assigned
263
- def type=(type)
264
- validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "renewables", "soil"])
265
- unless validator.valid?(type)
266
- fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
332
+ # @param [Object] mechanism Object to be assigned
333
+ def mechanism=(mechanism)
334
+ validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
335
+ unless validator.valid?(mechanism)
336
+ fail ArgumentError, "invalid value for \"mechanism\", must be one of #{validator.allowable_values}."
267
337
  end
268
- @type = type
338
+ @mechanism = mechanism
269
339
  end
270
340
 
271
341
  # Checks equality by comparing each attribute.
@@ -278,13 +348,20 @@ module Patch
278
348
  name == o.name &&
279
349
  description == o.description &&
280
350
  type == o.type &&
351
+ mechanism == o.mechanism &&
281
352
  country == o.country &&
353
+ state == o.state &&
354
+ latitude == o.latitude &&
355
+ longitude == o.longitude &&
282
356
  developer == o.developer &&
283
357
  photos == o.photos &&
284
358
  average_price_per_tonne_cents_usd == o.average_price_per_tonne_cents_usd &&
285
359
  remaining_mass_g == o.remaining_mass_g &&
360
+ verifier == o.verifier &&
286
361
  standard == o.standard &&
287
- sdgs == o.sdgs
362
+ sdgs == o.sdgs &&
363
+ tagline == o.tagline &&
364
+ technology_type == o.technology_type
288
365
  end
289
366
 
290
367
  # @see the `==` method
@@ -296,7 +373,7 @@ module Patch
296
373
  # Calculates hash code according to all attributes.
297
374
  # @return [Integer] Hash code
298
375
  def hash
299
- [id, production, name, description, type, country, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard, sdgs].hash
376
+ [id, production, name, description, type, mechanism, country, state, latitude, longitude, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, verifier, standard, sdgs, tagline, technology_type].hash
300
377
  end
301
378
 
302
379
  # Builds the object from hash
@@ -0,0 +1,259 @@
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: developers@usepatch.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Patch
17
+ # An object containing the technology type's name, slug and parent_technology_type.
18
+ class TechnologyType
19
+ # Unique identifier for this type of technology.
20
+ attr_accessor :slug
21
+
22
+ # Display name of this technology type.
23
+ attr_accessor :name
24
+
25
+ attr_accessor :parent_technology_type
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'slug' => :'slug',
31
+ :'name' => :'name',
32
+ :'parent_technology_type' => :'parent_technology_type'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'slug' => :'String',
45
+ :'name' => :'String',
46
+ :'parent_technology_type' => :'ParentTechnologyType'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+
57
+ # Allows models with corresponding API classes to delegate API operations to those API classes
58
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
59
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
60
+ def self.method_missing(message, *args, &block)
61
+ if Object.const_defined?('Patch::TechnologyTypesApi::OPERATIONS') && Patch::TechnologyTypesApi::OPERATIONS.include?(message)
62
+ Patch::TechnologyTypesApi.new.send(message, *args)
63
+ else
64
+ super
65
+ end
66
+ end
67
+
68
+ # Initializes the object
69
+ # @param [Hash] attributes Model attributes in the form of hash
70
+ def initialize(attributes = {})
71
+ if (!attributes.is_a?(Hash))
72
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::TechnologyType` initialize method"
73
+ end
74
+
75
+ # check to see if the attribute exists and convert string to symbol for hash key
76
+ attributes = attributes.each_with_object({}) { |(k, v), h|
77
+ if (!self.class.attribute_map.key?(k.to_sym))
78
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::TechnologyType`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
79
+ end
80
+ h[k.to_sym] = v
81
+ }
82
+
83
+ if attributes.key?(:'slug')
84
+ self.slug = attributes[:'slug']
85
+ end
86
+
87
+ if attributes.key?(:'name')
88
+ self.name = attributes[:'name']
89
+ end
90
+
91
+ if attributes.key?(:'parent_technology_type')
92
+ self.parent_technology_type = attributes[:'parent_technology_type']
93
+ end
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properties with the reasons
98
+ def list_invalid_properties
99
+ invalid_properties = Array.new
100
+ if @slug.nil?
101
+ invalid_properties.push('invalid value for "slug", slug cannot be nil.')
102
+ end
103
+
104
+ if @name.nil?
105
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
106
+ end
107
+
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ return false if @slug.nil?
115
+ return false if @name.nil?
116
+ true
117
+ end
118
+
119
+ # Checks equality by comparing each attribute.
120
+ # @param [Object] Object to be compared
121
+ def ==(o)
122
+ return true if self.equal?(o)
123
+ self.class == o.class &&
124
+ slug == o.slug &&
125
+ name == o.name &&
126
+ parent_technology_type == o.parent_technology_type
127
+ end
128
+
129
+ # @see the `==` method
130
+ # @param [Object] Object to be compared
131
+ def eql?(o)
132
+ self == o
133
+ end
134
+
135
+ # Calculates hash code according to all attributes.
136
+ # @return [Integer] Hash code
137
+ def hash
138
+ [slug, name, parent_technology_type].hash
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def self.build_from_hash(attributes)
145
+ new.build_from_hash(attributes)
146
+ end
147
+
148
+ # Builds the object from hash
149
+ # @param [Hash] attributes Model attributes in the form of hash
150
+ # @return [Object] Returns the model itself
151
+ def build_from_hash(attributes)
152
+ return nil unless attributes.is_a?(Hash)
153
+ self.class.openapi_types.each_pair do |key, type|
154
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
155
+ self.send("#{key}=", nil)
156
+ elsif type =~ /\AArray<(.*)>/i
157
+ # check to ensure the input is an array given that the attribute
158
+ # is documented as an array but the input is not
159
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
160
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
161
+ end
162
+ elsif !attributes[self.class.attribute_map[key]].nil?
163
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
164
+ end
165
+ end
166
+
167
+ self
168
+ end
169
+
170
+ # Deserializes the data based on type
171
+ # @param string type Data type
172
+ # @param string value Value to be deserialized
173
+ # @return [Object] Deserialized data
174
+ def _deserialize(type, value)
175
+ case type.to_sym
176
+ when :Time
177
+ Time.parse(value)
178
+ when :Date
179
+ Date.parse(value)
180
+ when :String
181
+ value.to_s
182
+ when :Integer
183
+ value.to_i
184
+ when :Float
185
+ value.to_f
186
+ when :Boolean
187
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
188
+ true
189
+ else
190
+ false
191
+ end
192
+ when :Object
193
+ # generic object (usually a Hash), return directly
194
+ value
195
+ when /\AArray<(?<inner_type>.+)>\z/
196
+ inner_type = Regexp.last_match[:inner_type]
197
+ value.map { |v| _deserialize(inner_type, v) }
198
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
199
+ k_type = Regexp.last_match[:k_type]
200
+ v_type = Regexp.last_match[:v_type]
201
+ {}.tap do |hash|
202
+ value.each do |k, v|
203
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
204
+ end
205
+ end
206
+ else # model
207
+ # models (e.g. Pet) or oneOf
208
+ klass = Patch.const_get(type)
209
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
210
+ end
211
+ end
212
+
213
+ # Returns the string representation of the object
214
+ # @return [String] String presentation of the object
215
+ def to_s
216
+ to_hash.to_s
217
+ end
218
+
219
+ # to_body is an alias to to_hash (backward compatibility)
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_body
222
+ to_hash
223
+ end
224
+
225
+ # Returns the object in the form of hash
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_hash
228
+ hash = {}
229
+ self.class.attribute_map.each_pair do |attr, param|
230
+ value = self.send(attr)
231
+ if value.nil?
232
+ is_nullable = self.class.openapi_nullable.include?(attr)
233
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
234
+ end
235
+
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map { |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end
258
+ end
259
+ end