patch_ruby 1.13.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e0f99b9d07fa162edae9b17a6391f12bd47b8ebe600c554d9a563453b8e0e7a
4
- data.tar.gz: 541bc276ca90a671cc9e823d3a9c0320faf1dcaaf95c78ad28599a5bc9956ea6
3
+ metadata.gz: 983c0272228fcb5224e71c3004a104f5312d3288963e5915bc3d7b793b3c8f7a
4
+ data.tar.gz: 83e8d6569fc5ce0cb705de13de8d5de3d2f0dfc4a2ca132167d2a1cc8f67b206
5
5
  SHA512:
6
- metadata.gz: 753deee059cd95468bb42ae4f0b3d1658e2a7bbbc0447d9f3565921232a7551848876dab16afcd4e720381d618e37cfa2d108cc02085858bf604afd62c7612ed
7
- data.tar.gz: 882c8eb7b5ca22f529d216627cbde573f188d2878ee230140d13ce6e5c7cea10d8959331355ffe33fc9327ef2979a4aab5c18e8532e66d70dc28822236fe2b2f
6
+ metadata.gz: 444ac13006a538ae0f84673b82ca88b840a57b342614d4f7e4acac672e25b6176e2ce3449a9c3fe4a4b2dd06a355f423eeb40f87c2ef12cffab93080358a846c
7
+ data.tar.gz: cc20f9980d10d998f16d5db881311f3413584c119e249df48d42751f31962710131f4b422cabaa1861cd0b74592fc748db7a5058a74e97dbdefd36d5e2d1f7fd
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.14.0] - 2021-09-21
9
+
10
+ ### Added
11
+
12
+ - Adds mechanism, tagline, state, latitude, longitude, and technology_type to project responses
13
+
8
14
  ## [1.13.0] - 2021-09-10
9
15
 
10
16
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patch_ruby (1.13.0)
4
+ patch_ruby (1.14.0)
5
5
  typhoeus (~> 1.0, >= 1.0.1)
6
6
 
7
7
  GEM
@@ -31,7 +31,7 @@ module Patch
31
31
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
32
32
  def initialize(config = Configuration.default)
33
33
  @config = config
34
- @user_agent = "patch-ruby/1.13.0"
34
+ @user_agent = "patch-ruby/1.14.0"
35
35
  @default_headers = {
36
36
  'Content-Type' => 'application/json',
37
37
  'User-Agent' => @user_agent
@@ -0,0 +1,239 @@
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
+ class ParentTechnologyType
18
+ # Unique identifier for this type of technology.
19
+ attr_accessor :slug
20
+
21
+ # Name of this technology type.
22
+ attr_accessor :name
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'slug' => :'slug',
28
+ :'name' => :'name'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'slug' => :'String',
41
+ :'name' => :'String'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+
52
+ # Allows models with corresponding API classes to delegate API operations to those API classes
53
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
54
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
55
+ def self.method_missing(message, *args, &block)
56
+ if Object.const_defined?('Patch::ParentTechnologyTypesApi::OPERATIONS') && Patch::ParentTechnologyTypesApi::OPERATIONS.include?(message)
57
+ Patch::ParentTechnologyTypesApi.new.send(message, *args)
58
+ else
59
+ super
60
+ end
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::ParentTechnologyType` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!self.class.attribute_map.key?(k.to_sym))
73
+ 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
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'slug')
79
+ self.slug = attributes[:'slug']
80
+ end
81
+
82
+ if attributes.key?(:'name')
83
+ self.name = attributes[:'name']
84
+ end
85
+ end
86
+
87
+ # Show invalid properties with the reasons. Usually used together with valid?
88
+ # @return Array for valid properties with the reasons
89
+ def list_invalid_properties
90
+ invalid_properties = Array.new
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ true
98
+ end
99
+
100
+ # Checks equality by comparing each attribute.
101
+ # @param [Object] Object to be compared
102
+ def ==(o)
103
+ return true if self.equal?(o)
104
+ self.class == o.class &&
105
+ slug == o.slug &&
106
+ name == o.name
107
+ end
108
+
109
+ # @see the `==` method
110
+ # @param [Object] Object to be compared
111
+ def eql?(o)
112
+ self == o
113
+ end
114
+
115
+ # Calculates hash code according to all attributes.
116
+ # @return [Integer] Hash code
117
+ def hash
118
+ [slug, name].hash
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def self.build_from_hash(attributes)
125
+ new.build_from_hash(attributes)
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def build_from_hash(attributes)
132
+ return nil unless attributes.is_a?(Hash)
133
+ self.class.openapi_types.each_pair do |key, type|
134
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
135
+ self.send("#{key}=", nil)
136
+ elsif type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
140
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
141
+ end
142
+ elsif !attributes[self.class.attribute_map[key]].nil?
143
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
144
+ end
145
+ end
146
+
147
+ self
148
+ end
149
+
150
+ # Deserializes the data based on type
151
+ # @param string type Data type
152
+ # @param string value Value to be deserialized
153
+ # @return [Object] Deserialized data
154
+ def _deserialize(type, value)
155
+ case type.to_sym
156
+ when :Time
157
+ Time.parse(value)
158
+ when :Date
159
+ Date.parse(value)
160
+ when :String
161
+ value.to_s
162
+ when :Integer
163
+ value.to_i
164
+ when :Float
165
+ value.to_f
166
+ when :Boolean
167
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
168
+ true
169
+ else
170
+ false
171
+ end
172
+ when :Object
173
+ # generic object (usually a Hash), return directly
174
+ value
175
+ when /\AArray<(?<inner_type>.+)>\z/
176
+ inner_type = Regexp.last_match[:inner_type]
177
+ value.map { |v| _deserialize(inner_type, v) }
178
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
179
+ k_type = Regexp.last_match[:k_type]
180
+ v_type = Regexp.last_match[:v_type]
181
+ {}.tap do |hash|
182
+ value.each do |k, v|
183
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
184
+ end
185
+ end
186
+ else # model
187
+ # models (e.g. Pet) or oneOf
188
+ klass = Patch.const_get(type)
189
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ if value.nil?
212
+ is_nullable = self.class.openapi_nullable.include?(attr)
213
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
214
+ end
215
+
216
+ hash[param] = _to_hash(value)
217
+ end
218
+ hash
219
+ end
220
+
221
+ # Outputs non-array value in the form of hash
222
+ # For object, use to_hash. Otherwise, just return the value
223
+ # @param [Object] value Any valid value
224
+ # @return [Hash] Returns the value in the form of hash
225
+ def _to_hash(value)
226
+ if value.is_a?(Array)
227
+ value.compact.map { |v| _to_hash(v) }
228
+ elsif value.is_a?(Hash)
229
+ {}.tap do |hash|
230
+ value.each { |k, v| hash[k] = _to_hash(v) }
231
+ end
232
+ elsif value.respond_to? :to_hash
233
+ value.to_hash
234
+ else
235
+ value
236
+ end
237
+ end
238
+ end
239
+ end
@@ -30,9 +30,21 @@ module Patch
30
30
  # The type of carbon removal project, currently available project types are Biomass, Dac, Forestry, Mineralization, Ocean, Renewables, Soil.
31
31
  attr_accessor :type
32
32
 
33
+ # The mechanism of the project. 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
 
@@ -51,6 +63,11 @@ module Patch
51
63
  # An array returning the UN Sustainable Development Goals associated with this project.
52
64
  attr_accessor :sdgs
53
65
 
66
+ attr_accessor :technology_type
67
+
68
+ # A short description of the project
69
+ attr_accessor :tagline
70
+
54
71
  class EnumAttributeValidator
55
72
  attr_reader :datatype
56
73
  attr_reader :allowable_values
@@ -81,13 +98,19 @@ module Patch
81
98
  :'name' => :'name',
82
99
  :'description' => :'description',
83
100
  :'type' => :'type',
101
+ :'mechanism' => :'mechanism',
84
102
  :'country' => :'country',
103
+ :'state' => :'state',
104
+ :'latitude' => :'latitude',
105
+ :'longitude' => :'longitude',
85
106
  :'developer' => :'developer',
86
107
  :'photos' => :'photos',
87
108
  :'average_price_per_tonne_cents_usd' => :'average_price_per_tonne_cents_usd',
88
109
  :'remaining_mass_g' => :'remaining_mass_g',
89
110
  :'standard' => :'standard',
90
- :'sdgs' => :'sdgs'
111
+ :'sdgs' => :'sdgs',
112
+ :'technology_type' => :'technology_type',
113
+ :'tagline' => :'tagline'
91
114
  }
92
115
  end
93
116
 
@@ -104,22 +127,32 @@ module Patch
104
127
  :'name' => :'String',
105
128
  :'description' => :'String',
106
129
  :'type' => :'String',
130
+ :'mechanism' => :'String',
107
131
  :'country' => :'String',
132
+ :'state' => :'String',
133
+ :'latitude' => :'Float',
134
+ :'longitude' => :'Float',
108
135
  :'developer' => :'String',
109
136
  :'photos' => :'Array<Photo>',
110
137
  :'average_price_per_tonne_cents_usd' => :'Integer',
111
138
  :'remaining_mass_g' => :'Integer',
112
139
  :'standard' => :'Standard',
113
- :'sdgs' => :'Array<Sdg>'
140
+ :'sdgs' => :'Array<Sdg>',
141
+ :'technology_type' => :'TechnologyType',
142
+ :'tagline' => :'String'
114
143
  }
115
144
  end
116
145
 
117
146
  # List of attributes with nullable: true
118
147
  def self.openapi_nullable
119
148
  Set.new([
149
+ :'state',
150
+ :'latitude',
151
+ :'longitude',
120
152
  :'photos',
121
153
  :'standard',
122
- :'sdgs'
154
+ :'sdgs',
155
+ :'tagline'
123
156
  ])
124
157
  end
125
158
 
@@ -170,10 +203,26 @@ module Patch
170
203
  self.type = attributes[:'type']
171
204
  end
172
205
 
206
+ if attributes.key?(:'mechanism')
207
+ self.mechanism = attributes[:'mechanism']
208
+ end
209
+
173
210
  if attributes.key?(:'country')
174
211
  self.country = attributes[:'country']
175
212
  end
176
213
 
214
+ if attributes.key?(:'state')
215
+ self.state = attributes[:'state']
216
+ end
217
+
218
+ if attributes.key?(:'latitude')
219
+ self.latitude = attributes[:'latitude']
220
+ end
221
+
222
+ if attributes.key?(:'longitude')
223
+ self.longitude = attributes[:'longitude']
224
+ end
225
+
177
226
  if attributes.key?(:'developer')
178
227
  self.developer = attributes[:'developer']
179
228
  end
@@ -201,6 +250,14 @@ module Patch
201
250
  self.sdgs = value
202
251
  end
203
252
  end
253
+
254
+ if attributes.key?(:'technology_type')
255
+ self.technology_type = attributes[:'technology_type']
256
+ end
257
+
258
+ if attributes.key?(:'tagline')
259
+ self.tagline = attributes[:'tagline']
260
+ end
204
261
  end
205
262
 
206
263
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -251,6 +308,8 @@ module Patch
251
308
  return false if @description.nil?
252
309
  type_validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "renewables", "soil"])
253
310
  return false unless type_validator.valid?(@type)
311
+ mechanism_validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
312
+ return false unless mechanism_validator.valid?(@mechanism)
254
313
  return false if @country.nil?
255
314
  return false if @developer.nil?
256
315
  return false if @average_price_per_tonne_cents_usd.nil?
@@ -268,6 +327,16 @@ module Patch
268
327
  @type = type
269
328
  end
270
329
 
330
+ # Custom attribute writer method checking allowed values (enum).
331
+ # @param [Object] mechanism Object to be assigned
332
+ def mechanism=(mechanism)
333
+ validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
334
+ unless validator.valid?(mechanism)
335
+ fail ArgumentError, "invalid value for \"mechanism\", must be one of #{validator.allowable_values}."
336
+ end
337
+ @mechanism = mechanism
338
+ end
339
+
271
340
  # Checks equality by comparing each attribute.
272
341
  # @param [Object] Object to be compared
273
342
  def ==(o)
@@ -278,13 +347,19 @@ module Patch
278
347
  name == o.name &&
279
348
  description == o.description &&
280
349
  type == o.type &&
350
+ mechanism == o.mechanism &&
281
351
  country == o.country &&
352
+ state == o.state &&
353
+ latitude == o.latitude &&
354
+ longitude == o.longitude &&
282
355
  developer == o.developer &&
283
356
  photos == o.photos &&
284
357
  average_price_per_tonne_cents_usd == o.average_price_per_tonne_cents_usd &&
285
358
  remaining_mass_g == o.remaining_mass_g &&
286
359
  standard == o.standard &&
287
- sdgs == o.sdgs
360
+ sdgs == o.sdgs &&
361
+ technology_type == o.technology_type &&
362
+ tagline == o.tagline
288
363
  end
289
364
 
290
365
  # @see the `==` method
@@ -296,7 +371,7 @@ module Patch
296
371
  # Calculates hash code according to all attributes.
297
372
  # @return [Integer] Hash code
298
373
  def hash
299
- [id, production, name, description, type, country, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard, sdgs].hash
374
+ [id, production, name, description, type, mechanism, country, state, latitude, longitude, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard, sdgs, technology_type, tagline].hash
300
375
  end
301
376
 
302
377
  # Builds the object from hash
@@ -0,0 +1,248 @@
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
+ class TechnologyType
18
+ # Unique identifier for this type of technology.
19
+ attr_accessor :slug
20
+
21
+ # Name of this technology type.
22
+ attr_accessor :name
23
+
24
+ attr_accessor :parent_technology_type
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'slug' => :'slug',
30
+ :'name' => :'name',
31
+ :'parent_technology_type' => :'parent_technology_type'
32
+ }
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'slug' => :'String',
44
+ :'name' => :'String',
45
+ :'parent_technology_type' => :'ParentTechnologyType'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
52
+ ])
53
+ end
54
+
55
+
56
+ # Allows models with corresponding API classes to delegate API operations to those API classes
57
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
58
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
59
+ def self.method_missing(message, *args, &block)
60
+ if Object.const_defined?('Patch::TechnologyTypesApi::OPERATIONS') && Patch::TechnologyTypesApi::OPERATIONS.include?(message)
61
+ Patch::TechnologyTypesApi.new.send(message, *args)
62
+ else
63
+ super
64
+ end
65
+ end
66
+
67
+ # Initializes the object
68
+ # @param [Hash] attributes Model attributes in the form of hash
69
+ def initialize(attributes = {})
70
+ if (!attributes.is_a?(Hash))
71
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::TechnologyType` initialize method"
72
+ end
73
+
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!self.class.attribute_map.key?(k.to_sym))
77
+ 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
78
+ end
79
+ h[k.to_sym] = v
80
+ }
81
+
82
+ if attributes.key?(:'slug')
83
+ self.slug = attributes[:'slug']
84
+ end
85
+
86
+ if attributes.key?(:'name')
87
+ self.name = attributes[:'name']
88
+ end
89
+
90
+ if attributes.key?(:'parent_technology_type')
91
+ self.parent_technology_type = attributes[:'parent_technology_type']
92
+ end
93
+ end
94
+
95
+ # Show invalid properties with the reasons. Usually used together with valid?
96
+ # @return Array for valid properties with the reasons
97
+ def list_invalid_properties
98
+ invalid_properties = Array.new
99
+ invalid_properties
100
+ end
101
+
102
+ # Check to see if the all the properties in the model are valid
103
+ # @return true if the model is valid
104
+ def valid?
105
+ true
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(o)
111
+ return true if self.equal?(o)
112
+ self.class == o.class &&
113
+ slug == o.slug &&
114
+ name == o.name &&
115
+ parent_technology_type == o.parent_technology_type
116
+ end
117
+
118
+ # @see the `==` method
119
+ # @param [Object] Object to be compared
120
+ def eql?(o)
121
+ self == o
122
+ end
123
+
124
+ # Calculates hash code according to all attributes.
125
+ # @return [Integer] Hash code
126
+ def hash
127
+ [slug, name, parent_technology_type].hash
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def self.build_from_hash(attributes)
134
+ new.build_from_hash(attributes)
135
+ end
136
+
137
+ # Builds the object from hash
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ # @return [Object] Returns the model itself
140
+ def build_from_hash(attributes)
141
+ return nil unless attributes.is_a?(Hash)
142
+ self.class.openapi_types.each_pair do |key, type|
143
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
144
+ self.send("#{key}=", nil)
145
+ elsif type =~ /\AArray<(.*)>/i
146
+ # check to ensure the input is an array given that the attribute
147
+ # is documented as an array but the input is not
148
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
149
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
150
+ end
151
+ elsif !attributes[self.class.attribute_map[key]].nil?
152
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
153
+ end
154
+ end
155
+
156
+ self
157
+ end
158
+
159
+ # Deserializes the data based on type
160
+ # @param string type Data type
161
+ # @param string value Value to be deserialized
162
+ # @return [Object] Deserialized data
163
+ def _deserialize(type, value)
164
+ case type.to_sym
165
+ when :Time
166
+ Time.parse(value)
167
+ when :Date
168
+ Date.parse(value)
169
+ when :String
170
+ value.to_s
171
+ when :Integer
172
+ value.to_i
173
+ when :Float
174
+ value.to_f
175
+ when :Boolean
176
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
177
+ true
178
+ else
179
+ false
180
+ end
181
+ when :Object
182
+ # generic object (usually a Hash), return directly
183
+ value
184
+ when /\AArray<(?<inner_type>.+)>\z/
185
+ inner_type = Regexp.last_match[:inner_type]
186
+ value.map { |v| _deserialize(inner_type, v) }
187
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
188
+ k_type = Regexp.last_match[:k_type]
189
+ v_type = Regexp.last_match[:v_type]
190
+ {}.tap do |hash|
191
+ value.each do |k, v|
192
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
193
+ end
194
+ end
195
+ else # model
196
+ # models (e.g. Pet) or oneOf
197
+ klass = Patch.const_get(type)
198
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
199
+ end
200
+ end
201
+
202
+ # Returns the string representation of the object
203
+ # @return [String] String presentation of the object
204
+ def to_s
205
+ to_hash.to_s
206
+ end
207
+
208
+ # to_body is an alias to to_hash (backward compatibility)
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_body
211
+ to_hash
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = self.send(attr)
220
+ if value.nil?
221
+ is_nullable = self.class.openapi_nullable.include?(attr)
222
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
223
+ end
224
+
225
+ hash[param] = _to_hash(value)
226
+ end
227
+ hash
228
+ end
229
+
230
+ # Outputs non-array value in the form of hash
231
+ # For object, use to_hash. Otherwise, just return the value
232
+ # @param [Object] value Any valid value
233
+ # @return [Hash] Returns the value in the form of hash
234
+ def _to_hash(value)
235
+ if value.is_a?(Array)
236
+ value.compact.map { |v| _to_hash(v) }
237
+ elsif value.is_a?(Hash)
238
+ {}.tap do |hash|
239
+ value.each { |k, v| hash[k] = _to_hash(v) }
240
+ end
241
+ elsif value.respond_to? :to_hash
242
+ value.to_hash
243
+ else
244
+ value
245
+ end
246
+ end
247
+ end
248
+ end
@@ -11,5 +11,5 @@ OpenAPI Generator version: 5.2.1
11
11
  =end
12
12
 
13
13
  module Patch
14
- VERSION = '1.13.0'
14
+ VERSION = '1.14.0'
15
15
  end
data/lib/patch_ruby.rb CHANGED
@@ -35,6 +35,7 @@ require 'patch_ruby/models/meta_index_object'
35
35
  require 'patch_ruby/models/order'
36
36
  require 'patch_ruby/models/order_list_response'
37
37
  require 'patch_ruby/models/order_response'
38
+ require 'patch_ruby/models/parent_technology_type'
38
39
  require 'patch_ruby/models/photo'
39
40
  require 'patch_ruby/models/preference'
40
41
  require 'patch_ruby/models/preference_list_response'
@@ -44,6 +45,7 @@ require 'patch_ruby/models/project_list_response'
44
45
  require 'patch_ruby/models/project_response'
45
46
  require 'patch_ruby/models/sdg'
46
47
  require 'patch_ruby/models/standard'
48
+ require 'patch_ruby/models/technology_type'
47
49
 
48
50
  # APIs
49
51
  require 'patch_ruby/api/estimates_api'
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :parent_technology_type, class: Patch::ParentTechnologyType do
5
+ slug { "forestry" }
6
+ name { "Forestry" }
7
+ end
8
+ end
@@ -1,6 +1,9 @@
1
1
  FactoryBot.define do
2
2
  factory :project, class: Patch::Project do
3
3
  sequence(:id) { |n| n }
4
+ association(:technology_type)
5
+ sdgs { build_list(:sdg, 1) }
6
+
4
7
  production { false }
5
8
  name { "New Project" }
6
9
  description { "New Descirption" }
@@ -11,5 +14,9 @@ FactoryBot.define do
11
14
  average_price_per_tonne_cents_usd { 120 }
12
15
  remaining_mass_g { 1_000 }
13
16
  standard { 'european_biochar_certificate' }
17
+ state { 'CO' }
18
+ latitude { 45.0 }
19
+ longitude { 45.0 }
20
+ mechanism { 'removal' }
14
21
  end
15
22
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :sdg, class: Patch::Sdg do
5
+ description { "Take urgent action to combat climate change and its impacts." }
6
+ number { 13 }
7
+ title { "Climate Action" }
8
+ url { "https://sdgs.un.org/goals/goal13" }
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :technology_type, class: Patch::TechnologyType do
5
+ slug { "reforestation" }
6
+ name { "Reforestation" }
7
+ association(:parent_technology_type)
8
+ end
9
+ end
@@ -42,9 +42,26 @@ RSpec.describe 'Projects Integration' do
42
42
  it 'returns the expected fields' do
43
43
  project = Patch::Project.retrieve_projects(page: 1).data.first
44
44
 
45
+ keys = attributes_for(:project).keys
46
+ expect(project.to_hash.keys).to include(*keys)
47
+
45
48
  expect(project.photos).to be_an_instance_of(Array)
46
- expect(project.average_price_per_tonne_cents_usd).to be_an_instance_of(Integer)
49
+ expect(project.average_price_per_tonne_cents_usd)
50
+ .to be_an_instance_of(Integer)
47
51
  expect(project.remaining_mass_g).to be_an_instance_of(Integer)
52
+ expect(project.state).to be_an_instance_of(String)
53
+ expect(project.longitude).to be_an_instance_of(Float)
54
+ expect(project.latitude).to be_an_instance_of(Float)
55
+
56
+ expect(project.technology_type)
57
+ .to be_an_instance_of(Patch::TechnologyType)
58
+ expect(project.technology_type.name).to be_an_instance_of(String)
59
+ expect(project.technology_type.slug).to be_an_instance_of(String)
60
+
61
+ parent_type = project.technology_type.parent_technology_type
62
+ expect(parent_type).to be_an_instance_of(Patch::ParentTechnologyType)
63
+ expect(parent_type.name).to be_an_instance_of(String)
64
+ expect(parent_type.slug).to be_an_instance_of(String)
48
65
  end
49
66
  end
50
67
  end
@@ -41,10 +41,18 @@ describe 'Project' do
41
41
  photos: @instance.photos,
42
42
  average_price_per_tonne_cents_usd: @instance.average_price_per_tonne_cents_usd,
43
43
  remaining_mass_g: @instance.remaining_mass_g,
44
- standard: @instance.standard
44
+ state: @instance.state,
45
+ longitude: @instance.longitude,
46
+ latitude: @instance.latitude,
47
+ standard: @instance.standard,
48
+ mechanism: @instance.mechanism,
49
+ technology_type: @instance.technology_type.to_hash,
50
+ sdgs: @instance.sdgs.map(&:to_hash)
45
51
  }
46
52
  }
47
- let(:nullable_properties) { Set.new([:photos, :standard, :sdgs]) }
53
+ let(:nullable_properties) do
54
+ Set.new(%i[photos standard sdgs state latitude longitude tagline])
55
+ end
48
56
  end
49
57
 
50
58
  describe 'test an instance of Project' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patch_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patch Technology
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-10 00:00:00.000000000 Z
11
+ date: 2021-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -118,6 +118,7 @@ files:
118
118
  - lib/patch_ruby/models/order.rb
119
119
  - lib/patch_ruby/models/order_list_response.rb
120
120
  - lib/patch_ruby/models/order_response.rb
121
+ - lib/patch_ruby/models/parent_technology_type.rb
121
122
  - lib/patch_ruby/models/photo.rb
122
123
  - lib/patch_ruby/models/preference.rb
123
124
  - lib/patch_ruby/models/preference_list_response.rb
@@ -127,6 +128,7 @@ files:
127
128
  - lib/patch_ruby/models/project_response.rb
128
129
  - lib/patch_ruby/models/sdg.rb
129
130
  - lib/patch_ruby/models/standard.rb
131
+ - lib/patch_ruby/models/technology_type.rb
130
132
  - lib/patch_ruby/version.rb
131
133
  - patch_ruby.gemspec
132
134
  - spec/api/estimates_api_spec.rb
@@ -148,12 +150,15 @@ files:
148
150
  - spec/factories/order_list_responses.rb
149
151
  - spec/factories/order_responses.rb
150
152
  - spec/factories/orders.rb
153
+ - spec/factories/parent_technology_type.rb
151
154
  - spec/factories/preference_list_responses.rb
152
155
  - spec/factories/preference_responses.rb
153
156
  - spec/factories/preferences.rb
154
157
  - spec/factories/project_list_responses.rb
155
158
  - spec/factories/project_responses.rb
156
159
  - spec/factories/projects.rb
160
+ - spec/factories/sdgs.rb
161
+ - spec/factories/technology_type.rb
157
162
  - spec/integration/estimates_spec.rb
158
163
  - spec/integration/orders_spec.rb
159
164
  - spec/integration/preferences_spec.rb
@@ -203,53 +208,56 @@ signing_key:
203
208
  specification_version: 4
204
209
  summary: Ruby wrapper for the Patch API
205
210
  test_files:
206
- - spec/api/orders_api_spec.rb
207
211
  - spec/api/projects_api_spec.rb
208
- - spec/api/preferences_api_spec.rb
209
212
  - spec/api/estimates_api_spec.rb
213
+ - spec/api/preferences_api_spec.rb
214
+ - spec/api/orders_api_spec.rb
210
215
  - spec/api_client_spec.rb
211
216
  - spec/configuration_spec.rb
212
217
  - spec/constants.rb
213
- - spec/factories/preferences.rb
214
- - spec/factories/create_order_requests.rb
215
- - spec/factories/order_list_responses.rb
216
- - spec/factories/projects.rb
217
- - spec/factories/estimate_list_responses.rb
218
218
  - spec/factories/create_preference_requests.rb
219
- - spec/factories/preference_responses.rb
220
- - spec/factories/error_responses.rb
219
+ - spec/factories/preference_list_responses.rb
220
+ - spec/factories/allocations.rb
221
221
  - spec/factories/estimates.rb
222
- - spec/factories/order_responses.rb
223
222
  - spec/factories/create_mass_estimate_requests.rb
224
- - spec/factories/preference_list_responses.rb
225
- - spec/factories/estimate_responses.rb
226
- - spec/factories/meta_index_objects.rb
227
223
  - spec/factories/project_responses.rb
228
- - spec/factories/orders.rb
224
+ - spec/factories/estimate_list_responses.rb
225
+ - spec/factories/meta_index_objects.rb
229
226
  - spec/factories/project_list_responses.rb
230
- - spec/factories/allocations.rb
227
+ - spec/factories/orders.rb
228
+ - spec/factories/preference_responses.rb
229
+ - spec/factories/error_responses.rb
230
+ - spec/factories/estimate_responses.rb
231
+ - spec/factories/order_responses.rb
232
+ - spec/factories/technology_type.rb
233
+ - spec/factories/preferences.rb
234
+ - spec/factories/order_list_responses.rb
235
+ - spec/factories/projects.rb
236
+ - spec/factories/create_order_requests.rb
237
+ - spec/factories/parent_technology_type.rb
238
+ - spec/factories/sdgs.rb
239
+ - spec/integration/estimates_spec.rb
231
240
  - spec/integration/projects_spec.rb
232
241
  - spec/integration/preferences_spec.rb
233
- - spec/integration/estimates_spec.rb
234
242
  - spec/integration/orders_spec.rb
235
- - spec/models/error_response_spec.rb
236
243
  - spec/models/create_order_request_spec.rb
237
- - spec/models/create_mass_estimate_request_spec.rb
244
+ - spec/models/project_list_response_spec.rb
238
245
  - spec/models/preference_list_response_spec.rb
246
+ - spec/models/order_list_response_spec.rb
239
247
  - spec/models/project_response_spec.rb
240
- - spec/models/estimate_spec.rb
241
- - spec/models/project_list_response_spec.rb
248
+ - spec/models/create_mass_estimate_request_spec.rb
249
+ - spec/models/order_spec.rb
242
250
  - spec/models/preference_spec.rb
251
+ - spec/models/error_response_spec.rb
252
+ - spec/models/allocation_spec.rb
243
253
  - spec/models/order_response_spec.rb
244
- - spec/models/estimate_list_response_spec.rb
245
- - spec/models/order_list_response_spec.rb
254
+ - spec/models/estimate_response_spec.rb
246
255
  - spec/models/create_preference_request_spec.rb
256
+ - spec/models/project_spec.rb
257
+ - spec/models/estimate_list_response_spec.rb
258
+ - spec/models/estimate_spec.rb
247
259
  - spec/models/meta_index_object_spec.rb
248
- - spec/models/order_spec.rb
249
260
  - spec/models/preference_response_spec.rb
250
- - spec/models/estimate_response_spec.rb
251
- - spec/models/project_spec.rb
252
- - spec/models/allocation_spec.rb
253
261
  - spec/patch_ruby_spec.rb
254
262
  - spec/spec_helper.rb
255
263
  - spec/support/shared/generated_classes.rb