patch_ruby 1.11.1 → 1.15.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/Gemfile.lock +1 -1
- data/lib/patch_ruby/api/estimates_api.rb +2 -2
- data/lib/patch_ruby/api/technology_types_api.rb +84 -0
- data/lib/patch_ruby/api_client.rb +1 -1
- data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +14 -2
- data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +13 -1
- data/lib/patch_ruby/models/create_flight_estimate_request.rb +2 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +2 -0
- data/lib/patch_ruby/models/create_shipping_estimate_request.rb +2 -0
- data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +2 -0
- data/lib/patch_ruby/models/order.rb +11 -1
- data/lib/patch_ruby/models/parent_technology_type.rb +240 -0
- data/lib/patch_ruby/models/project.rb +81 -14
- data/lib/patch_ruby/models/technology_type.rb +259 -0
- data/lib/patch_ruby/models/technology_type_list_response.rb +259 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/lib/patch_ruby.rb +4 -0
- data/spec/api/technology_types_api_spec.rb +46 -0
- data/spec/factories/parent_technology_type.rb +8 -0
- data/spec/factories/projects.rb +7 -0
- data/spec/factories/sdgs.rb +10 -0
- data/spec/factories/technology_type.rb +9 -0
- data/spec/integration/estimates_spec.rb +16 -2
- data/spec/integration/orders_spec.rb +3 -2
- data/spec/integration/projects/technology_types_spec.rb +14 -0
- data/spec/integration/projects_spec.rb +18 -1
- data/spec/models/create_mass_estimate_request_spec.rb +1 -1
- data/spec/models/project_spec.rb +10 -2
- metadata +42 -28
@@ -27,12 +27,24 @@ module Patch
|
|
27
27
|
# The description of the project.
|
28
28
|
attr_accessor :description
|
29
29
|
|
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.
|
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
|
+
# A short description of the project.
|
67
|
+
attr_accessor :tagline
|
68
|
+
|
69
|
+
attr_accessor :technology_type
|
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
|
+
:'tagline' => :'tagline',
|
113
|
+
:'technology_type' => :'technology_type'
|
91
114
|
}
|
92
115
|
end
|
93
116
|
|
@@ -104,22 +127,31 @@ 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
|
+
:'tagline' => :'String',
|
142
|
+
:'technology_type' => :'TechnologyType'
|
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',
|
123
155
|
])
|
124
156
|
end
|
125
157
|
|
@@ -170,10 +202,26 @@ module Patch
|
|
170
202
|
self.type = attributes[:'type']
|
171
203
|
end
|
172
204
|
|
205
|
+
if attributes.key?(:'mechanism')
|
206
|
+
self.mechanism = attributes[:'mechanism']
|
207
|
+
end
|
208
|
+
|
173
209
|
if attributes.key?(:'country')
|
174
210
|
self.country = attributes[:'country']
|
175
211
|
end
|
176
212
|
|
213
|
+
if attributes.key?(:'state')
|
214
|
+
self.state = attributes[:'state']
|
215
|
+
end
|
216
|
+
|
217
|
+
if attributes.key?(:'latitude')
|
218
|
+
self.latitude = attributes[:'latitude']
|
219
|
+
end
|
220
|
+
|
221
|
+
if attributes.key?(:'longitude')
|
222
|
+
self.longitude = attributes[:'longitude']
|
223
|
+
end
|
224
|
+
|
177
225
|
if attributes.key?(:'developer')
|
178
226
|
self.developer = attributes[:'developer']
|
179
227
|
end
|
@@ -201,6 +249,14 @@ module Patch
|
|
201
249
|
self.sdgs = value
|
202
250
|
end
|
203
251
|
end
|
252
|
+
|
253
|
+
if attributes.key?(:'tagline')
|
254
|
+
self.tagline = attributes[:'tagline']
|
255
|
+
end
|
256
|
+
|
257
|
+
if attributes.key?(:'technology_type')
|
258
|
+
self.technology_type = attributes[:'technology_type']
|
259
|
+
end
|
204
260
|
end
|
205
261
|
|
206
262
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -239,6 +295,10 @@ module Patch
|
|
239
295
|
invalid_properties.push('invalid value for "remaining_mass_g", remaining_mass_g cannot be nil.')
|
240
296
|
end
|
241
297
|
|
298
|
+
if @technology_type.nil?
|
299
|
+
invalid_properties.push('invalid value for "technology_type", technology_type cannot be nil.')
|
300
|
+
end
|
301
|
+
|
242
302
|
invalid_properties
|
243
303
|
end
|
244
304
|
|
@@ -249,23 +309,24 @@ module Patch
|
|
249
309
|
return false if @production.nil?
|
250
310
|
return false if @name.nil?
|
251
311
|
return false if @description.nil?
|
252
|
-
|
253
|
-
return false unless
|
312
|
+
mechanism_validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
|
313
|
+
return false unless mechanism_validator.valid?(@mechanism)
|
254
314
|
return false if @country.nil?
|
255
315
|
return false if @developer.nil?
|
256
316
|
return false if @average_price_per_tonne_cents_usd.nil?
|
257
317
|
return false if @remaining_mass_g.nil?
|
318
|
+
return false if @technology_type.nil?
|
258
319
|
true
|
259
320
|
end
|
260
321
|
|
261
322
|
# Custom attribute writer method checking allowed values (enum).
|
262
|
-
# @param [Object]
|
263
|
-
def
|
264
|
-
validator = EnumAttributeValidator.new('String', ["
|
265
|
-
unless validator.valid?(
|
266
|
-
fail ArgumentError, "invalid value for \"
|
323
|
+
# @param [Object] mechanism Object to be assigned
|
324
|
+
def mechanism=(mechanism)
|
325
|
+
validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
|
326
|
+
unless validator.valid?(mechanism)
|
327
|
+
fail ArgumentError, "invalid value for \"mechanism\", must be one of #{validator.allowable_values}."
|
267
328
|
end
|
268
|
-
@
|
329
|
+
@mechanism = mechanism
|
269
330
|
end
|
270
331
|
|
271
332
|
# Checks equality by comparing each attribute.
|
@@ -278,13 +339,19 @@ module Patch
|
|
278
339
|
name == o.name &&
|
279
340
|
description == o.description &&
|
280
341
|
type == o.type &&
|
342
|
+
mechanism == o.mechanism &&
|
281
343
|
country == o.country &&
|
344
|
+
state == o.state &&
|
345
|
+
latitude == o.latitude &&
|
346
|
+
longitude == o.longitude &&
|
282
347
|
developer == o.developer &&
|
283
348
|
photos == o.photos &&
|
284
349
|
average_price_per_tonne_cents_usd == o.average_price_per_tonne_cents_usd &&
|
285
350
|
remaining_mass_g == o.remaining_mass_g &&
|
286
351
|
standard == o.standard &&
|
287
|
-
sdgs == o.sdgs
|
352
|
+
sdgs == o.sdgs &&
|
353
|
+
tagline == o.tagline &&
|
354
|
+
technology_type == o.technology_type
|
288
355
|
end
|
289
356
|
|
290
357
|
# @see the `==` method
|
@@ -296,7 +363,7 @@ module Patch
|
|
296
363
|
# Calculates hash code according to all attributes.
|
297
364
|
# @return [Integer] Hash code
|
298
365
|
def hash
|
299
|
-
[id, production, name, description, type, country, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard, sdgs].hash
|
366
|
+
[id, production, name, description, type, mechanism, country, state, latitude, longitude, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard, sdgs, tagline, technology_type].hash
|
300
367
|
end
|
301
368
|
|
302
369
|
# 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
|