patch_ruby 1.13.0 → 1.15.2

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,240 @@
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 parent technology type's name and slug.
18
+ class ParentTechnologyType
19
+ # Unique identifier for this type of technology.
20
+ attr_accessor :slug
21
+
22
+ # Name of this technology type.
23
+ attr_accessor :name
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'slug' => :'slug',
29
+ :'name' => :'name'
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
+ :'slug' => :'String',
42
+ :'name' => :'String'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+
53
+ # Allows models with corresponding API classes to delegate API operations to those API classes
54
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
55
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
56
+ def self.method_missing(message, *args, &block)
57
+ if Object.const_defined?('Patch::ParentTechnologyTypesApi::OPERATIONS') && Patch::ParentTechnologyTypesApi::OPERATIONS.include?(message)
58
+ Patch::ParentTechnologyTypesApi.new.send(message, *args)
59
+ else
60
+ super
61
+ end
62
+ end
63
+
64
+ # Initializes the object
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ def initialize(attributes = {})
67
+ if (!attributes.is_a?(Hash))
68
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::ParentTechnologyType` initialize method"
69
+ end
70
+
71
+ # check to see if the attribute exists and convert string to symbol for hash key
72
+ attributes = attributes.each_with_object({}) { |(k, v), h|
73
+ if (!self.class.attribute_map.key?(k.to_sym))
74
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::ParentTechnologyType`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
75
+ end
76
+ h[k.to_sym] = v
77
+ }
78
+
79
+ if attributes.key?(:'slug')
80
+ self.slug = attributes[:'slug']
81
+ end
82
+
83
+ if attributes.key?(:'name')
84
+ self.name = attributes[:'name']
85
+ end
86
+ end
87
+
88
+ # Show invalid properties with the reasons. Usually used together with valid?
89
+ # @return Array for valid properties with the reasons
90
+ def list_invalid_properties
91
+ invalid_properties = Array.new
92
+ invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ true
99
+ end
100
+
101
+ # Checks equality by comparing each attribute.
102
+ # @param [Object] Object to be compared
103
+ def ==(o)
104
+ return true if self.equal?(o)
105
+ self.class == o.class &&
106
+ slug == o.slug &&
107
+ name == o.name
108
+ end
109
+
110
+ # @see the `==` method
111
+ # @param [Object] Object to be compared
112
+ def eql?(o)
113
+ self == o
114
+ end
115
+
116
+ # Calculates hash code according to all attributes.
117
+ # @return [Integer] Hash code
118
+ def hash
119
+ [slug, name].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def self.build_from_hash(attributes)
126
+ new.build_from_hash(attributes)
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def build_from_hash(attributes)
133
+ return nil unless attributes.is_a?(Hash)
134
+ self.class.openapi_types.each_pair do |key, type|
135
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
136
+ self.send("#{key}=", nil)
137
+ elsif type =~ /\AArray<(.*)>/i
138
+ # check to ensure the input is an array given that the attribute
139
+ # is documented as an array but the input is not
140
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
141
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
142
+ end
143
+ elsif !attributes[self.class.attribute_map[key]].nil?
144
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
145
+ end
146
+ end
147
+
148
+ self
149
+ end
150
+
151
+ # Deserializes the data based on type
152
+ # @param string type Data type
153
+ # @param string value Value to be deserialized
154
+ # @return [Object] Deserialized data
155
+ def _deserialize(type, value)
156
+ case type.to_sym
157
+ when :Time
158
+ Time.parse(value)
159
+ when :Date
160
+ Date.parse(value)
161
+ when :String
162
+ value.to_s
163
+ when :Integer
164
+ value.to_i
165
+ when :Float
166
+ value.to_f
167
+ when :Boolean
168
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
169
+ true
170
+ else
171
+ false
172
+ end
173
+ when :Object
174
+ # generic object (usually a Hash), return directly
175
+ value
176
+ when /\AArray<(?<inner_type>.+)>\z/
177
+ inner_type = Regexp.last_match[:inner_type]
178
+ value.map { |v| _deserialize(inner_type, v) }
179
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
180
+ k_type = Regexp.last_match[:k_type]
181
+ v_type = Regexp.last_match[:v_type]
182
+ {}.tap do |hash|
183
+ value.each do |k, v|
184
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
185
+ end
186
+ end
187
+ else # model
188
+ # models (e.g. Pet) or oneOf
189
+ klass = Patch.const_get(type)
190
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
191
+ end
192
+ end
193
+
194
+ # Returns the string representation of the object
195
+ # @return [String] String presentation of the object
196
+ def to_s
197
+ to_hash.to_s
198
+ end
199
+
200
+ # to_body is an alias to to_hash (backward compatibility)
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_body
203
+ to_hash
204
+ end
205
+
206
+ # Returns the object in the form of hash
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_hash
209
+ hash = {}
210
+ self.class.attribute_map.each_pair do |attr, param|
211
+ value = self.send(attr)
212
+ if value.nil?
213
+ is_nullable = self.class.openapi_nullable.include?(attr)
214
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
215
+ end
216
+
217
+ hash[param] = _to_hash(value)
218
+ end
219
+ hash
220
+ end
221
+
222
+ # Outputs non-array value in the form of hash
223
+ # For object, use to_hash. Otherwise, just return the value
224
+ # @param [Object] value Any valid value
225
+ # @return [Hash] Returns the value in the form of hash
226
+ def _to_hash(value)
227
+ if value.is_a?(Array)
228
+ value.compact.map { |v| _to_hash(v) }
229
+ elsif value.is_a?(Hash)
230
+ {}.tap do |hash|
231
+ value.each { |k, v| hash[k] = _to_hash(v) }
232
+ end
233
+ elsif value.respond_to? :to_hash
234
+ value.to_hash
235
+ else
236
+ value
237
+ end
238
+ end
239
+ end
240
+ end
@@ -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,23 @@ 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
+
74
+ # An array of objects containing the highlight's slug and title. A highlight's title is a short string that spotlights a characteristic about the project.
75
+ attr_accessor :highlights
76
+
54
77
  class EnumAttributeValidator
55
78
  attr_reader :datatype
56
79
  attr_reader :allowable_values
@@ -81,13 +104,21 @@ module Patch
81
104
  :'name' => :'name',
82
105
  :'description' => :'description',
83
106
  :'type' => :'type',
107
+ :'mechanism' => :'mechanism',
84
108
  :'country' => :'country',
109
+ :'state' => :'state',
110
+ :'latitude' => :'latitude',
111
+ :'longitude' => :'longitude',
85
112
  :'developer' => :'developer',
86
113
  :'photos' => :'photos',
87
114
  :'average_price_per_tonne_cents_usd' => :'average_price_per_tonne_cents_usd',
88
115
  :'remaining_mass_g' => :'remaining_mass_g',
116
+ :'verifier' => :'verifier',
89
117
  :'standard' => :'standard',
90
- :'sdgs' => :'sdgs'
118
+ :'sdgs' => :'sdgs',
119
+ :'tagline' => :'tagline',
120
+ :'technology_type' => :'technology_type',
121
+ :'highlights' => :'highlights'
91
122
  }
92
123
  end
93
124
 
@@ -104,22 +135,33 @@ module Patch
104
135
  :'name' => :'String',
105
136
  :'description' => :'String',
106
137
  :'type' => :'String',
138
+ :'mechanism' => :'String',
107
139
  :'country' => :'String',
140
+ :'state' => :'String',
141
+ :'latitude' => :'Float',
142
+ :'longitude' => :'Float',
108
143
  :'developer' => :'String',
109
144
  :'photos' => :'Array<Photo>',
110
145
  :'average_price_per_tonne_cents_usd' => :'Integer',
111
146
  :'remaining_mass_g' => :'Integer',
147
+ :'verifier' => :'String',
112
148
  :'standard' => :'Standard',
113
- :'sdgs' => :'Array<Sdg>'
149
+ :'sdgs' => :'Array<Sdg>',
150
+ :'tagline' => :'String',
151
+ :'technology_type' => :'TechnologyType',
152
+ :'highlights' => :'Array<Highlight>'
114
153
  }
115
154
  end
116
155
 
117
156
  # List of attributes with nullable: true
118
157
  def self.openapi_nullable
119
158
  Set.new([
159
+ :'state',
160
+ :'latitude',
161
+ :'longitude',
120
162
  :'photos',
121
163
  :'standard',
122
- :'sdgs'
164
+ :'sdgs',
123
165
  ])
124
166
  end
125
167
 
@@ -170,10 +212,26 @@ module Patch
170
212
  self.type = attributes[:'type']
171
213
  end
172
214
 
215
+ if attributes.key?(:'mechanism')
216
+ self.mechanism = attributes[:'mechanism']
217
+ end
218
+
173
219
  if attributes.key?(:'country')
174
220
  self.country = attributes[:'country']
175
221
  end
176
222
 
223
+ if attributes.key?(:'state')
224
+ self.state = attributes[:'state']
225
+ end
226
+
227
+ if attributes.key?(:'latitude')
228
+ self.latitude = attributes[:'latitude']
229
+ end
230
+
231
+ if attributes.key?(:'longitude')
232
+ self.longitude = attributes[:'longitude']
233
+ end
234
+
177
235
  if attributes.key?(:'developer')
178
236
  self.developer = attributes[:'developer']
179
237
  end
@@ -192,6 +250,10 @@ module Patch
192
250
  self.remaining_mass_g = attributes[:'remaining_mass_g']
193
251
  end
194
252
 
253
+ if attributes.key?(:'verifier')
254
+ self.verifier = attributes[:'verifier']
255
+ end
256
+
195
257
  if attributes.key?(:'standard')
196
258
  self.standard = attributes[:'standard']
197
259
  end
@@ -201,6 +263,20 @@ module Patch
201
263
  self.sdgs = value
202
264
  end
203
265
  end
266
+
267
+ if attributes.key?(:'tagline')
268
+ self.tagline = attributes[:'tagline']
269
+ end
270
+
271
+ if attributes.key?(:'technology_type')
272
+ self.technology_type = attributes[:'technology_type']
273
+ end
274
+
275
+ if attributes.key?(:'highlights')
276
+ if (value = attributes[:'highlights']).is_a?(Array)
277
+ self.highlights = value
278
+ end
279
+ end
204
280
  end
205
281
 
206
282
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -239,6 +315,14 @@ module Patch
239
315
  invalid_properties.push('invalid value for "remaining_mass_g", remaining_mass_g cannot be nil.')
240
316
  end
241
317
 
318
+ if @technology_type.nil?
319
+ invalid_properties.push('invalid value for "technology_type", technology_type cannot be nil.')
320
+ end
321
+
322
+ if @highlights.nil?
323
+ invalid_properties.push('invalid value for "highlights", highlights cannot be nil.')
324
+ end
325
+
242
326
  invalid_properties
243
327
  end
244
328
 
@@ -249,23 +333,25 @@ module Patch
249
333
  return false if @production.nil?
250
334
  return false if @name.nil?
251
335
  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)
336
+ mechanism_validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
337
+ return false unless mechanism_validator.valid?(@mechanism)
254
338
  return false if @country.nil?
255
339
  return false if @developer.nil?
256
340
  return false if @average_price_per_tonne_cents_usd.nil?
257
341
  return false if @remaining_mass_g.nil?
342
+ return false if @technology_type.nil?
343
+ return false if @highlights.nil?
258
344
  true
259
345
  end
260
346
 
261
347
  # 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}."
348
+ # @param [Object] mechanism Object to be assigned
349
+ def mechanism=(mechanism)
350
+ validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
351
+ unless validator.valid?(mechanism)
352
+ fail ArgumentError, "invalid value for \"mechanism\", must be one of #{validator.allowable_values}."
267
353
  end
268
- @type = type
354
+ @mechanism = mechanism
269
355
  end
270
356
 
271
357
  # Checks equality by comparing each attribute.
@@ -278,13 +364,21 @@ module Patch
278
364
  name == o.name &&
279
365
  description == o.description &&
280
366
  type == o.type &&
367
+ mechanism == o.mechanism &&
281
368
  country == o.country &&
369
+ state == o.state &&
370
+ latitude == o.latitude &&
371
+ longitude == o.longitude &&
282
372
  developer == o.developer &&
283
373
  photos == o.photos &&
284
374
  average_price_per_tonne_cents_usd == o.average_price_per_tonne_cents_usd &&
285
375
  remaining_mass_g == o.remaining_mass_g &&
376
+ verifier == o.verifier &&
286
377
  standard == o.standard &&
287
- sdgs == o.sdgs
378
+ sdgs == o.sdgs &&
379
+ tagline == o.tagline &&
380
+ technology_type == o.technology_type &&
381
+ highlights == o.highlights
288
382
  end
289
383
 
290
384
  # @see the `==` method
@@ -296,7 +390,7 @@ module Patch
296
390
  # Calculates hash code according to all attributes.
297
391
  # @return [Integer] Hash code
298
392
  def hash
299
- [id, production, name, description, type, country, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard, sdgs].hash
393
+ [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, highlights].hash
300
394
  end
301
395
 
302
396
  # Builds the object from hash