patch_ruby 1.2.2 → 1.4.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 +42 -2
- data/Gemfile +1 -0
- data/Gemfile.lock +19 -3
- data/Makefile +10 -0
- data/README.md +61 -4
- data/lib/patch_ruby/api/estimates_api.rb +195 -0
- data/lib/patch_ruby/api/projects_api.rb +9 -0
- data/lib/patch_ruby/models/allocation.rb +10 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +19 -1
- data/lib/patch_ruby/models/create_order_request.rb +38 -16
- data/lib/patch_ruby/models/create_preference_request.rb +7 -0
- data/lib/patch_ruby/models/error_response.rb +9 -0
- data/lib/patch_ruby/models/estimate.rb +24 -1
- data/lib/patch_ruby/models/estimate_list_response.rb +9 -0
- data/lib/patch_ruby/models/estimate_response.rb +9 -0
- data/lib/patch_ruby/models/meta_index_object.rb +11 -0
- data/lib/patch_ruby/models/order.rb +30 -1
- data/lib/patch_ruby/models/order_list_response.rb +9 -0
- data/lib/patch_ruby/models/order_response.rb +9 -0
- data/lib/patch_ruby/models/photo.rb +30 -4
- data/lib/patch_ruby/models/preference.rb +10 -0
- data/lib/patch_ruby/models/preference_list_response.rb +9 -0
- data/lib/patch_ruby/models/preference_response.rb +9 -0
- data/lib/patch_ruby/models/project.rb +40 -4
- data/lib/patch_ruby/models/project_list_response.rb +9 -0
- data/lib/patch_ruby/models/project_response.rb +9 -0
- data/lib/patch_ruby/models/sdg.rb +269 -0
- data/lib/patch_ruby/models/standard.rb +10 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/spec/constants.rb +3 -0
- data/spec/factories/allocations.rb +7 -0
- data/spec/factories/create_mass_estimate_requests.rb +6 -0
- data/spec/factories/create_order_requests.rb +8 -0
- data/spec/factories/create_preference_requests.rb +5 -0
- data/spec/factories/error_responses.rb +7 -0
- data/spec/factories/estimate_list_responses.rb +8 -0
- data/spec/factories/estimate_responses.rb +7 -0
- data/spec/factories/estimates.rb +8 -0
- data/spec/factories/meta_index_objects.rb +6 -0
- data/spec/factories/order_list_responses.rb +8 -0
- data/spec/factories/order_responses.rb +7 -0
- data/spec/factories/orders.rb +12 -0
- data/spec/factories/preference_list_responses.rb +8 -0
- data/spec/factories/preference_responses.rb +7 -0
- data/spec/factories/preferences.rb +7 -0
- data/spec/factories/project_list_responses.rb +8 -0
- data/spec/factories/project_responses.rb +7 -0
- data/spec/factories/projects.rb +15 -0
- data/spec/integration/estimates_spec.rb +53 -9
- data/spec/integration/orders_spec.rb +42 -5
- data/spec/integration/preferences_spec.rb +7 -3
- data/spec/integration/projects_spec.rb +21 -1
- data/spec/models/allocation_spec.rb +8 -1
- data/spec/models/create_mass_estimate_request_spec.rb +7 -1
- data/spec/models/create_order_request_spec.rb +7 -1
- data/spec/models/create_preference_request_spec.rb +8 -1
- data/spec/models/error_response_spec.rb +7 -1
- data/spec/models/estimate_list_response_spec.rb +7 -1
- data/spec/models/estimate_response_spec.rb +7 -1
- data/spec/models/estimate_spec.rb +8 -1
- data/spec/models/meta_index_object_spec.rb +7 -1
- data/spec/models/order_list_response_spec.rb +7 -1
- data/spec/models/order_response_spec.rb +7 -1
- data/spec/models/order_spec.rb +18 -1
- data/spec/models/preference_list_response_spec.rb +7 -1
- data/spec/models/preference_response_spec.rb +7 -1
- data/spec/models/preference_spec.rb +7 -1
- data/spec/models/project_list_response_spec.rb +7 -1
- data/spec/models/project_response_spec.rb +7 -1
- data/spec/models/project_spec.rb +21 -1
- data/spec/spec_helper.rb +11 -0
- data/spec/support/shared/generated_classes.rb +13 -0
- metadata +56 -14
@@ -42,6 +42,15 @@ module Patch
|
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
+
# Set with nullable attributes.
|
46
|
+
def self.openapi_nullable
|
47
|
+
nullable_properties = Set.new
|
48
|
+
|
49
|
+
nullable_properties.add("error")
|
50
|
+
|
51
|
+
nullable_properties
|
52
|
+
end
|
53
|
+
|
45
54
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
46
55
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
47
56
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -38,6 +38,15 @@ module Patch
|
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
|
+
# Set with nullable attributes.
|
42
|
+
def self.openapi_nullable
|
43
|
+
nullable_properties = Set.new
|
44
|
+
|
45
|
+
nullable_properties.add("error")
|
46
|
+
|
47
|
+
nullable_properties
|
48
|
+
end
|
49
|
+
|
41
50
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
42
51
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
43
52
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -16,20 +16,31 @@ module Patch
|
|
16
16
|
class Photo
|
17
17
|
attr_accessor :url
|
18
18
|
|
19
|
+
attr_accessor :id
|
20
|
+
|
19
21
|
# Attribute mapping from ruby-style variable name to JSON key.
|
20
22
|
def self.attribute_map
|
21
23
|
{
|
22
|
-
:'url' => :'url'
|
24
|
+
:'url' => :'url',
|
25
|
+
:'id' => :'id'
|
23
26
|
}
|
24
27
|
end
|
25
28
|
|
26
29
|
# Attribute type mapping.
|
27
30
|
def self.openapi_types
|
28
31
|
{
|
29
|
-
:'url' => :'String'
|
32
|
+
:'url' => :'String',
|
33
|
+
:'id' => :'String'
|
30
34
|
}
|
31
35
|
end
|
32
36
|
|
37
|
+
# Set with nullable attributes.
|
38
|
+
def self.openapi_nullable
|
39
|
+
nullable_properties = Set.new
|
40
|
+
|
41
|
+
nullable_properties
|
42
|
+
end
|
43
|
+
|
33
44
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
34
45
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
35
46
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -59,18 +70,32 @@ module Patch
|
|
59
70
|
if attributes.key?(:'url')
|
60
71
|
self.url = attributes[:'url']
|
61
72
|
end
|
73
|
+
|
74
|
+
if attributes.key?(:'id')
|
75
|
+
self.id = attributes[:'id']
|
76
|
+
end
|
62
77
|
end
|
63
78
|
|
64
79
|
# Show invalid properties with the reasons. Usually used together with valid?
|
65
80
|
# @return Array for valid properties with the reasons
|
66
81
|
def list_invalid_properties
|
67
82
|
invalid_properties = Array.new
|
83
|
+
if @url.nil?
|
84
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
85
|
+
end
|
86
|
+
|
87
|
+
if @id.nil?
|
88
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
89
|
+
end
|
90
|
+
|
68
91
|
invalid_properties
|
69
92
|
end
|
70
93
|
|
71
94
|
# Check to see if the all the properties in the model are valid
|
72
95
|
# @return true if the model is valid
|
73
96
|
def valid?
|
97
|
+
return false if @url.nil?
|
98
|
+
return false if @id.nil?
|
74
99
|
true
|
75
100
|
end
|
76
101
|
|
@@ -79,7 +104,8 @@ module Patch
|
|
79
104
|
def ==(o)
|
80
105
|
return true if self.equal?(o)
|
81
106
|
self.class == o.class &&
|
82
|
-
url == o.url
|
107
|
+
url == o.url &&
|
108
|
+
id == o.id
|
83
109
|
end
|
84
110
|
|
85
111
|
# @see the `==` method
|
@@ -91,7 +117,7 @@ module Patch
|
|
91
117
|
# Calculates hash code according to all attributes.
|
92
118
|
# @return [Integer] Hash code
|
93
119
|
def hash
|
94
|
-
[url].hash
|
120
|
+
[url, id].hash
|
95
121
|
end
|
96
122
|
|
97
123
|
# Builds the object from hash
|
@@ -14,10 +14,13 @@ require 'date'
|
|
14
14
|
|
15
15
|
module Patch
|
16
16
|
class Preference
|
17
|
+
# A unique uid for the record. UIDs will be prepended by pre_prod or pre_test depending on the mode it was created in.
|
17
18
|
attr_accessor :id
|
18
19
|
|
20
|
+
# Percentage of total purchased offsets that should go to a project. Default is 100%.
|
19
21
|
attr_accessor :allocation_percentage
|
20
22
|
|
23
|
+
# An object returning the Project record this Preference is associated with. See the [Project section](/?id=projects) for the full schema.
|
21
24
|
attr_accessor :project
|
22
25
|
|
23
26
|
# Attribute mapping from ruby-style variable name to JSON key.
|
@@ -38,6 +41,13 @@ module Patch
|
|
38
41
|
}
|
39
42
|
end
|
40
43
|
|
44
|
+
# Set with nullable attributes.
|
45
|
+
def self.openapi_nullable
|
46
|
+
nullable_properties = Set.new
|
47
|
+
|
48
|
+
nullable_properties
|
49
|
+
end
|
50
|
+
|
41
51
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
42
52
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
43
53
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -42,6 +42,15 @@ module Patch
|
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
+
# Set with nullable attributes.
|
46
|
+
def self.openapi_nullable
|
47
|
+
nullable_properties = Set.new
|
48
|
+
|
49
|
+
nullable_properties.add("error")
|
50
|
+
|
51
|
+
nullable_properties
|
52
|
+
end
|
53
|
+
|
45
54
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
46
55
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
47
56
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -38,6 +38,15 @@ module Patch
|
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
|
+
# Set with nullable attributes.
|
42
|
+
def self.openapi_nullable
|
43
|
+
nullable_properties = Set.new
|
44
|
+
|
45
|
+
nullable_properties.add("error")
|
46
|
+
|
47
|
+
nullable_properties
|
48
|
+
end
|
49
|
+
|
41
50
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
42
51
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
43
52
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -14,28 +14,42 @@ require 'date'
|
|
14
14
|
|
15
15
|
module Patch
|
16
16
|
class Project
|
17
|
+
# A unique uid for the record. UIDs will be prepended by pro_prod or pro_test depending on the mode it was created in.
|
17
18
|
attr_accessor :id
|
18
19
|
|
20
|
+
# A boolean indicating if this project is a production or test mode project.
|
19
21
|
attr_accessor :production
|
20
22
|
|
23
|
+
# The name of the project.
|
21
24
|
attr_accessor :name
|
22
25
|
|
26
|
+
# The description of the project.
|
23
27
|
attr_accessor :description
|
24
28
|
|
29
|
+
# The type of carbon removal project, currently available project types are Biomass, Dac, Forestry, Mineralization, Ocean, Soil.
|
25
30
|
attr_accessor :type
|
26
31
|
|
32
|
+
# The country of origin of the project.
|
27
33
|
attr_accessor :country
|
28
34
|
|
35
|
+
# The name of the project developer.
|
29
36
|
attr_accessor :developer
|
30
37
|
|
38
|
+
# An array of URLs for photos of the project.
|
31
39
|
attr_accessor :photos
|
32
40
|
|
41
|
+
# The average price per tonne in USD cents for carbon offsets supplied by this project.
|
33
42
|
attr_accessor :average_price_per_tonne_cents_usd
|
34
43
|
|
44
|
+
# The remaining mass in grams available for purchase for this project.
|
35
45
|
attr_accessor :remaining_mass_g
|
36
46
|
|
47
|
+
# An object returning the Standard associated with this project.
|
37
48
|
attr_accessor :standard
|
38
49
|
|
50
|
+
# An array returning the UN Sustainable Development Goals associated with this project.
|
51
|
+
attr_accessor :sdgs
|
52
|
+
|
39
53
|
class EnumAttributeValidator
|
40
54
|
attr_reader :datatype
|
41
55
|
attr_reader :allowable_values
|
@@ -71,7 +85,8 @@ module Patch
|
|
71
85
|
:'photos' => :'photos',
|
72
86
|
:'average_price_per_tonne_cents_usd' => :'average_price_per_tonne_cents_usd',
|
73
87
|
:'remaining_mass_g' => :'remaining_mass_g',
|
74
|
-
:'standard' => :'standard'
|
88
|
+
:'standard' => :'standard',
|
89
|
+
:'sdgs' => :'sdgs'
|
75
90
|
}
|
76
91
|
end
|
77
92
|
|
@@ -88,10 +103,24 @@ module Patch
|
|
88
103
|
:'photos' => :'Array<Photo>',
|
89
104
|
:'average_price_per_tonne_cents_usd' => :'Integer',
|
90
105
|
:'remaining_mass_g' => :'Integer',
|
91
|
-
:'standard' => :'Standard'
|
106
|
+
:'standard' => :'Standard',
|
107
|
+
:'sdgs' => :'Array<Sdg>'
|
92
108
|
}
|
93
109
|
end
|
94
110
|
|
111
|
+
# Set with nullable attributes.
|
112
|
+
def self.openapi_nullable
|
113
|
+
nullable_properties = Set.new
|
114
|
+
|
115
|
+
nullable_properties.add("photos")
|
116
|
+
|
117
|
+
nullable_properties.add("standard")
|
118
|
+
|
119
|
+
nullable_properties.add("sdgs")
|
120
|
+
|
121
|
+
nullable_properties
|
122
|
+
end
|
123
|
+
|
95
124
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
96
125
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
97
126
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -163,6 +192,12 @@ module Patch
|
|
163
192
|
if attributes.key?(:'standard')
|
164
193
|
self.standard = attributes[:'standard']
|
165
194
|
end
|
195
|
+
|
196
|
+
if attributes.key?(:'sdgs')
|
197
|
+
if (value = attributes[:'sdgs']).is_a?(Array)
|
198
|
+
self.sdgs = value
|
199
|
+
end
|
200
|
+
end
|
166
201
|
end
|
167
202
|
|
168
203
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -245,7 +280,8 @@ module Patch
|
|
245
280
|
photos == o.photos &&
|
246
281
|
average_price_per_tonne_cents_usd == o.average_price_per_tonne_cents_usd &&
|
247
282
|
remaining_mass_g == o.remaining_mass_g &&
|
248
|
-
standard == o.standard
|
283
|
+
standard == o.standard &&
|
284
|
+
sdgs == o.sdgs
|
249
285
|
end
|
250
286
|
|
251
287
|
# @see the `==` method
|
@@ -257,7 +293,7 @@ module Patch
|
|
257
293
|
# Calculates hash code according to all attributes.
|
258
294
|
# @return [Integer] Hash code
|
259
295
|
def hash
|
260
|
-
[id, production, name, description, type, country, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard].hash
|
296
|
+
[id, production, name, description, type, country, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard, sdgs].hash
|
261
297
|
end
|
262
298
|
|
263
299
|
# Builds the object from hash
|
@@ -42,6 +42,15 @@ module Patch
|
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
+
# Set with nullable attributes.
|
46
|
+
def self.openapi_nullable
|
47
|
+
nullable_properties = Set.new
|
48
|
+
|
49
|
+
nullable_properties.add("error")
|
50
|
+
|
51
|
+
nullable_properties
|
52
|
+
end
|
53
|
+
|
45
54
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
46
55
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
47
56
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -38,6 +38,15 @@ module Patch
|
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
|
+
# Set with nullable attributes.
|
42
|
+
def self.openapi_nullable
|
43
|
+
nullable_properties = Set.new
|
44
|
+
|
45
|
+
nullable_properties.add("error")
|
46
|
+
|
47
|
+
nullable_properties
|
48
|
+
end
|
49
|
+
|
41
50
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
42
51
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
43
52
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -0,0 +1,269 @@
|
|
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: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Patch
|
16
|
+
class Sdg
|
17
|
+
# The title of the Sustainable Development Goal.
|
18
|
+
attr_accessor :title
|
19
|
+
|
20
|
+
# The Sustainable Development Goal number.
|
21
|
+
attr_accessor :number
|
22
|
+
|
23
|
+
# The description of the Sustainable Development Goal.
|
24
|
+
attr_accessor :description
|
25
|
+
|
26
|
+
# The url to an information page for the Sustainable Development Goal.
|
27
|
+
attr_accessor :url
|
28
|
+
|
29
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
30
|
+
def self.attribute_map
|
31
|
+
{
|
32
|
+
:'title' => :'title',
|
33
|
+
:'number' => :'number',
|
34
|
+
:'description' => :'description',
|
35
|
+
:'url' => :'url'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Attribute type mapping.
|
40
|
+
def self.openapi_types
|
41
|
+
{
|
42
|
+
:'title' => :'String',
|
43
|
+
:'number' => :'Integer',
|
44
|
+
:'description' => :'String',
|
45
|
+
:'url' => :'String'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# Set with nullable attributes.
|
50
|
+
def self.openapi_nullable
|
51
|
+
nullable_properties = Set.new
|
52
|
+
|
53
|
+
nullable_properties
|
54
|
+
end
|
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::SdgsApi::OPERATIONS') && Patch::SdgsApi::OPERATIONS.include?(message)
|
61
|
+
Patch::SdgsApi.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::Sdg` 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::Sdg`. 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?(:'title')
|
83
|
+
self.title = attributes[:'title']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:'number')
|
87
|
+
self.number = attributes[:'number']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:'description')
|
91
|
+
self.description = attributes[:'description']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'url')
|
95
|
+
self.url = attributes[:'url']
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
100
|
+
# @return Array for valid properties with the reasons
|
101
|
+
def list_invalid_properties
|
102
|
+
invalid_properties = Array.new
|
103
|
+
if @title.nil?
|
104
|
+
invalid_properties.push('invalid value for "title", title cannot be nil.')
|
105
|
+
end
|
106
|
+
|
107
|
+
if @number.nil?
|
108
|
+
invalid_properties.push('invalid value for "number", number cannot be nil.')
|
109
|
+
end
|
110
|
+
|
111
|
+
if @description.nil?
|
112
|
+
invalid_properties.push('invalid value for "description", description cannot be nil.')
|
113
|
+
end
|
114
|
+
|
115
|
+
if @url.nil?
|
116
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
117
|
+
end
|
118
|
+
|
119
|
+
invalid_properties
|
120
|
+
end
|
121
|
+
|
122
|
+
# Check to see if the all the properties in the model are valid
|
123
|
+
# @return true if the model is valid
|
124
|
+
def valid?
|
125
|
+
return false if @title.nil?
|
126
|
+
return false if @number.nil?
|
127
|
+
return false if @description.nil?
|
128
|
+
return false if @url.nil?
|
129
|
+
true
|
130
|
+
end
|
131
|
+
|
132
|
+
# Checks equality by comparing each attribute.
|
133
|
+
# @param [Object] Object to be compared
|
134
|
+
def ==(o)
|
135
|
+
return true if self.equal?(o)
|
136
|
+
self.class == o.class &&
|
137
|
+
title == o.title &&
|
138
|
+
number == o.number &&
|
139
|
+
description == o.description &&
|
140
|
+
url == o.url
|
141
|
+
end
|
142
|
+
|
143
|
+
# @see the `==` method
|
144
|
+
# @param [Object] Object to be compared
|
145
|
+
def eql?(o)
|
146
|
+
self == o
|
147
|
+
end
|
148
|
+
|
149
|
+
# Calculates hash code according to all attributes.
|
150
|
+
# @return [Integer] Hash code
|
151
|
+
def hash
|
152
|
+
[title, number, description, url].hash
|
153
|
+
end
|
154
|
+
|
155
|
+
# Builds the object from hash
|
156
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
157
|
+
# @return [Object] Returns the model itself
|
158
|
+
def self.build_from_hash(attributes)
|
159
|
+
new.build_from_hash(attributes)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Builds the object from hash
|
163
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
164
|
+
# @return [Object] Returns the model itself
|
165
|
+
def build_from_hash(attributes)
|
166
|
+
return nil unless attributes.is_a?(Hash)
|
167
|
+
self.class.openapi_types.each_pair do |key, type|
|
168
|
+
if type =~ /\AArray<(.*)>/i
|
169
|
+
# check to ensure the input is an array given that the attribute
|
170
|
+
# is documented as an array but the input is not
|
171
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
172
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
173
|
+
end
|
174
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
175
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
176
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
177
|
+
end
|
178
|
+
|
179
|
+
self
|
180
|
+
end
|
181
|
+
|
182
|
+
# Deserializes the data based on type
|
183
|
+
# @param string type Data type
|
184
|
+
# @param string value Value to be deserialized
|
185
|
+
# @return [Object] Deserialized data
|
186
|
+
def _deserialize(type, value)
|
187
|
+
case type.to_sym
|
188
|
+
when :DateTime
|
189
|
+
DateTime.parse(value)
|
190
|
+
when :Date
|
191
|
+
Date.parse(value)
|
192
|
+
when :String
|
193
|
+
value.to_s
|
194
|
+
when :Integer
|
195
|
+
value.to_i
|
196
|
+
when :Float
|
197
|
+
value.to_f
|
198
|
+
when :Boolean
|
199
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
200
|
+
true
|
201
|
+
else
|
202
|
+
false
|
203
|
+
end
|
204
|
+
when :Object
|
205
|
+
# generic object (usually a Hash), return directly
|
206
|
+
value
|
207
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
208
|
+
inner_type = Regexp.last_match[:inner_type]
|
209
|
+
value.map { |v| _deserialize(inner_type, v) }
|
210
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
211
|
+
k_type = Regexp.last_match[:k_type]
|
212
|
+
v_type = Regexp.last_match[:v_type]
|
213
|
+
{}.tap do |hash|
|
214
|
+
value.each do |k, v|
|
215
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
else # model
|
219
|
+
Patch.const_get(type).build_from_hash(value)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the string representation of the object
|
224
|
+
# @return [String] String presentation of the object
|
225
|
+
def to_s
|
226
|
+
to_hash.to_s
|
227
|
+
end
|
228
|
+
|
229
|
+
# to_body is an alias to to_hash (backward compatibility)
|
230
|
+
# @return [Hash] Returns the object in the form of hash
|
231
|
+
def to_body
|
232
|
+
to_hash
|
233
|
+
end
|
234
|
+
|
235
|
+
# Returns the object in the form of hash
|
236
|
+
# @return [Hash] Returns the object in the form of hash
|
237
|
+
def to_hash
|
238
|
+
hash = {}
|
239
|
+
self.class.attribute_map.each_pair do |attr, param|
|
240
|
+
value = self.send(attr)
|
241
|
+
if value.nil?
|
242
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
243
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
244
|
+
end
|
245
|
+
|
246
|
+
hash[param] = _to_hash(value)
|
247
|
+
end
|
248
|
+
hash
|
249
|
+
end
|
250
|
+
|
251
|
+
# Outputs non-array value in the form of hash
|
252
|
+
# For object, use to_hash. Otherwise, just return the value
|
253
|
+
# @param [Object] value Any valid value
|
254
|
+
# @return [Hash] Returns the value in the form of hash
|
255
|
+
def _to_hash(value)
|
256
|
+
if value.is_a?(Array)
|
257
|
+
value.compact.map { |v| _to_hash(v) }
|
258
|
+
elsif value.is_a?(Hash)
|
259
|
+
{}.tap do |hash|
|
260
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
261
|
+
end
|
262
|
+
elsif value.respond_to? :to_hash
|
263
|
+
value.to_hash
|
264
|
+
else
|
265
|
+
value
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|