patch_ruby 1.11.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/Gemfile.lock +1 -1
- data/lib/patch_ruby/api/estimates_api.rb +22 -14
- data/lib/patch_ruby/api/orders_api.rb +7 -2
- data/lib/patch_ruby/api/preferences_api.rb +6 -2
- data/lib/patch_ruby/api/projects_api.rb +2 -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 +239 -0
- data/lib/patch_ruby/models/project.rb +80 -5
- data/lib/patch_ruby/models/technology_type.rb +248 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/lib/patch_ruby.rb +2 -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_spec.rb +18 -1
- data/spec/models/create_mass_estimate_request_spec.rb +1 -1
- data/spec/models/project_spec.rb +10 -2
- metadata +36 -28
@@ -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
|
data/lib/patch_ruby/version.rb
CHANGED
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'
|