patch_ruby 1.2.5 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -2
- data/Gemfile.lock +4 -4
- data/README.md +72 -8
- data/lib/patch_ruby.rb +1 -0
- data/lib/patch_ruby/api/estimates_api.rb +195 -0
- data/lib/patch_ruby/api/projects_api.rb +9 -0
- data/lib/patch_ruby/configuration.rb +2 -2
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +17 -6
- data/lib/patch_ruby/models/create_order_request.rb +5 -5
- data/lib/patch_ruby/models/estimate.rb +13 -3
- data/lib/patch_ruby/models/order.rb +5 -5
- data/lib/patch_ruby/models/photo.rb +4 -0
- data/lib/patch_ruby/models/project.rb +21 -7
- data/lib/patch_ruby/models/sdg.rb +269 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/patch_ruby.gemspec +1 -1
- data/spec/configuration_spec.rb +3 -3
- data/spec/integration/estimates_spec.rb +55 -0
- data/spec/integration/orders_spec.rb +6 -5
- data/spec/integration/preferences_spec.rb +6 -2
- data/spec/integration/projects_spec.rb +20 -0
- data/spec/models/create_mass_estimate_request_spec.rb +1 -1
- data/spec/models/project_spec.rb +1 -1
- data/spec/patch_ruby_spec.rb +18 -0
- metadata +35 -32
@@ -90,6 +90,9 @@ module Patch
|
|
90
90
|
# Retrieves a list of projects available for purchase on Patch's platform.
|
91
91
|
# @param [Hash] opts the optional parameters
|
92
92
|
# @option opts [Integer] :page
|
93
|
+
# @option opts [String] :country
|
94
|
+
# @option opts [String] :type
|
95
|
+
# @option opts [Integer] :minimum_available_mass
|
93
96
|
# @return [ProjectListResponse]
|
94
97
|
def retrieve_projects(opts = {})
|
95
98
|
data, _status_code, _headers = retrieve_projects_with_http_info(opts)
|
@@ -100,6 +103,9 @@ module Patch
|
|
100
103
|
# Retrieves a list of projects available for purchase on Patch's platform.
|
101
104
|
# @param [Hash] opts the optional parameters
|
102
105
|
# @option opts [Integer] :page
|
106
|
+
# @option opts [String] :country
|
107
|
+
# @option opts [String] :type
|
108
|
+
# @option opts [Integer] :minimum_available_mass
|
103
109
|
# @return [Array<(ProjectListResponse, Integer, Hash)>] ProjectListResponse data, response status code and response headers
|
104
110
|
def retrieve_projects_with_http_info(opts = {})
|
105
111
|
if @api_client.config.debugging
|
@@ -111,6 +117,9 @@ module Patch
|
|
111
117
|
# query parameters
|
112
118
|
query_params = opts[:query_params] || {}
|
113
119
|
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
|
120
|
+
query_params[:'country'] = opts[:'country'] if !opts[:'country'].nil?
|
121
|
+
query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
|
122
|
+
query_params[:'minimum_available_mass'] = opts[:'minimum_available_mass'] if !opts[:'minimum_available_mass'].nil?
|
114
123
|
|
115
124
|
# header parameters
|
116
125
|
header_params = opts[:header_params] || {}
|
@@ -127,7 +127,7 @@ module Patch
|
|
127
127
|
|
128
128
|
def initialize
|
129
129
|
@scheme = 'https'
|
130
|
-
@host = 'api.
|
130
|
+
@host = 'api.patch.io'
|
131
131
|
@base_path = ''
|
132
132
|
@api_key = {}
|
133
133
|
@api_key_prefix = {}
|
@@ -212,7 +212,7 @@ module Patch
|
|
212
212
|
variables: {
|
213
213
|
defaultHost: {
|
214
214
|
description: "No description provided",
|
215
|
-
default_value: "api.
|
215
|
+
default_value: "api.patch.io",
|
216
216
|
}
|
217
217
|
}
|
218
218
|
}
|
@@ -16,12 +16,15 @@ module Patch
|
|
16
16
|
class CreateMassEstimateRequest
|
17
17
|
attr_accessor :mass_g
|
18
18
|
|
19
|
+
attr_accessor :create_order
|
20
|
+
|
19
21
|
attr_accessor :project_id
|
20
22
|
|
21
23
|
# Attribute mapping from ruby-style variable name to JSON key.
|
22
24
|
def self.attribute_map
|
23
25
|
{
|
24
26
|
:'mass_g' => :'mass_g',
|
27
|
+
:'create_order' => :'create_order',
|
25
28
|
:'project_id' => :'project_id'
|
26
29
|
}
|
27
30
|
end
|
@@ -30,6 +33,7 @@ module Patch
|
|
30
33
|
def self.openapi_types
|
31
34
|
{
|
32
35
|
:'mass_g' => :'Integer',
|
36
|
+
:'create_order' => :'Boolean',
|
33
37
|
:'project_id' => :'String'
|
34
38
|
}
|
35
39
|
end
|
@@ -38,6 +42,8 @@ module Patch
|
|
38
42
|
def self.openapi_nullable
|
39
43
|
nullable_properties = Set.new
|
40
44
|
|
45
|
+
nullable_properties.add("create_order")
|
46
|
+
|
41
47
|
nullable_properties
|
42
48
|
end
|
43
49
|
|
@@ -71,6 +77,10 @@ module Patch
|
|
71
77
|
self.mass_g = attributes[:'mass_g']
|
72
78
|
end
|
73
79
|
|
80
|
+
if attributes.key?(:'create_order')
|
81
|
+
self.create_order = attributes[:'create_order']
|
82
|
+
end
|
83
|
+
|
74
84
|
if attributes.key?(:'project_id')
|
75
85
|
self.project_id = attributes[:'project_id']
|
76
86
|
end
|
@@ -88,8 +98,8 @@ module Patch
|
|
88
98
|
invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 2000000000.')
|
89
99
|
end
|
90
100
|
|
91
|
-
if @mass_g <
|
92
|
-
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to
|
101
|
+
if @mass_g < 0
|
102
|
+
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 0.')
|
93
103
|
end
|
94
104
|
|
95
105
|
invalid_properties
|
@@ -100,7 +110,7 @@ module Patch
|
|
100
110
|
def valid?
|
101
111
|
return false if @mass_g.nil?
|
102
112
|
return false if @mass_g > 2000000000
|
103
|
-
return false if @mass_g <
|
113
|
+
return false if @mass_g < 0
|
104
114
|
true
|
105
115
|
end
|
106
116
|
|
@@ -115,8 +125,8 @@ module Patch
|
|
115
125
|
fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 2000000000.'
|
116
126
|
end
|
117
127
|
|
118
|
-
if mass_g <
|
119
|
-
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to
|
128
|
+
if mass_g < 0
|
129
|
+
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 0.'
|
120
130
|
end
|
121
131
|
|
122
132
|
@mass_g = mass_g
|
@@ -128,6 +138,7 @@ module Patch
|
|
128
138
|
return true if self.equal?(o)
|
129
139
|
self.class == o.class &&
|
130
140
|
mass_g == o.mass_g &&
|
141
|
+
create_order == o.create_order &&
|
131
142
|
project_id == o.project_id
|
132
143
|
end
|
133
144
|
|
@@ -140,7 +151,7 @@ module Patch
|
|
140
151
|
# Calculates hash code according to all attributes.
|
141
152
|
# @return [Integer] Hash code
|
142
153
|
def hash
|
143
|
-
[mass_g, project_id].hash
|
154
|
+
[mass_g, create_order, project_id].hash
|
144
155
|
end
|
145
156
|
|
146
157
|
# Builds the object from hash
|
@@ -100,8 +100,8 @@ module Patch
|
|
100
100
|
invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 2000000000.')
|
101
101
|
end
|
102
102
|
|
103
|
-
if !@mass_g.nil? && @mass_g <
|
104
|
-
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to
|
103
|
+
if !@mass_g.nil? && @mass_g < 0
|
104
|
+
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 0.')
|
105
105
|
end
|
106
106
|
|
107
107
|
if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1
|
@@ -115,7 +115,7 @@ module Patch
|
|
115
115
|
# @return true if the model is valid
|
116
116
|
def valid?
|
117
117
|
return false if !@mass_g.nil? && @mass_g > 2000000000
|
118
|
-
return false if !@mass_g.nil? && @mass_g <
|
118
|
+
return false if !@mass_g.nil? && @mass_g < 0
|
119
119
|
return false if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1
|
120
120
|
true
|
121
121
|
end
|
@@ -127,8 +127,8 @@ module Patch
|
|
127
127
|
fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 2000000000.'
|
128
128
|
end
|
129
129
|
|
130
|
-
if !mass_g.nil? && mass_g <
|
131
|
-
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to
|
130
|
+
if !mass_g.nil? && mass_g < 0
|
131
|
+
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 0.'
|
132
132
|
end
|
133
133
|
|
134
134
|
@mass_g = mass_g
|
@@ -20,9 +20,12 @@ module Patch
|
|
20
20
|
# A boolean indicating if this estimate is a production or test mode estimate.
|
21
21
|
attr_accessor :production
|
22
22
|
|
23
|
-
# The type of estimate.
|
23
|
+
# The type of estimate. Available types are mass, flight, shipping, and vehicle.
|
24
24
|
attr_accessor :type
|
25
25
|
|
26
|
+
# The estimated mass in grams for this estimate.
|
27
|
+
attr_accessor :mass_g
|
28
|
+
|
26
29
|
# An object returning the order associated with this estimate. See the [Order section](/?id=orders) for the full schema.
|
27
30
|
attr_accessor :order
|
28
31
|
|
@@ -32,6 +35,7 @@ module Patch
|
|
32
35
|
:'id' => :'id',
|
33
36
|
:'production' => :'production',
|
34
37
|
:'type' => :'type',
|
38
|
+
:'mass_g' => :'mass_g',
|
35
39
|
:'order' => :'order'
|
36
40
|
}
|
37
41
|
end
|
@@ -42,6 +46,7 @@ module Patch
|
|
42
46
|
:'id' => :'String',
|
43
47
|
:'production' => :'Boolean',
|
44
48
|
:'type' => :'String',
|
49
|
+
:'mass_g' => :'Integer',
|
45
50
|
:'order' => :'Order'
|
46
51
|
}
|
47
52
|
end
|
@@ -93,6 +98,10 @@ module Patch
|
|
93
98
|
self.type = attributes[:'type']
|
94
99
|
end
|
95
100
|
|
101
|
+
if attributes.key?(:'mass_g')
|
102
|
+
self.mass_g = attributes[:'mass_g']
|
103
|
+
end
|
104
|
+
|
96
105
|
if attributes.key?(:'order')
|
97
106
|
self.order = attributes[:'order']
|
98
107
|
end
|
@@ -134,6 +143,7 @@ module Patch
|
|
134
143
|
id == o.id &&
|
135
144
|
production == o.production &&
|
136
145
|
type == o.type &&
|
146
|
+
mass_g == o.mass_g &&
|
137
147
|
order == o.order
|
138
148
|
end
|
139
149
|
|
@@ -146,7 +156,7 @@ module Patch
|
|
146
156
|
# Calculates hash code according to all attributes.
|
147
157
|
# @return [Integer] Hash code
|
148
158
|
def hash
|
149
|
-
[id, production, type, order].hash
|
159
|
+
[id, production, type, mass_g, order].hash
|
150
160
|
end
|
151
161
|
|
152
162
|
# Builds the object from hash
|
@@ -239,7 +249,7 @@ module Patch
|
|
239
249
|
is_nullable = self.class.openapi_nullable.include?(attr)
|
240
250
|
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
241
251
|
end
|
242
|
-
|
252
|
+
|
243
253
|
hash[param] = _to_hash(value)
|
244
254
|
end
|
245
255
|
hash
|
@@ -185,8 +185,8 @@ module Patch
|
|
185
185
|
invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 2000000000.')
|
186
186
|
end
|
187
187
|
|
188
|
-
if @mass_g <
|
189
|
-
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to
|
188
|
+
if @mass_g < 0
|
189
|
+
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 0.')
|
190
190
|
end
|
191
191
|
|
192
192
|
if @production.nil?
|
@@ -218,7 +218,7 @@ module Patch
|
|
218
218
|
return false if @id.nil?
|
219
219
|
return false if @mass_g.nil?
|
220
220
|
return false if @mass_g > 2000000000
|
221
|
-
return false if @mass_g <
|
221
|
+
return false if @mass_g < 0
|
222
222
|
return false if @production.nil?
|
223
223
|
return false if @state.nil?
|
224
224
|
state_validator = EnumAttributeValidator.new('String', ["draft", "placed", "complete", "cancelled"])
|
@@ -242,8 +242,8 @@ module Patch
|
|
242
242
|
fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 2000000000.'
|
243
243
|
end
|
244
244
|
|
245
|
-
if mass_g <
|
246
|
-
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to
|
245
|
+
if mass_g < 0
|
246
|
+
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 0.'
|
247
247
|
end
|
248
248
|
|
249
249
|
@mass_g = mass_g
|
@@ -26,7 +26,7 @@ module Patch
|
|
26
26
|
# The description of the project.
|
27
27
|
attr_accessor :description
|
28
28
|
|
29
|
-
# The type of carbon removal project, currently available project types are Biomass, Dac, Forestry, Mineralization, Ocean, Soil.
|
29
|
+
# The type of carbon removal project, currently available project types are Biomass, Dac, Forestry, Mineralization, Ocean, Renewables, Soil.
|
30
30
|
attr_accessor :type
|
31
31
|
|
32
32
|
# The country of origin of the project.
|
@@ -47,6 +47,9 @@ module Patch
|
|
47
47
|
# An object returning the Standard associated with this project.
|
48
48
|
attr_accessor :standard
|
49
49
|
|
50
|
+
# An array returning the UN Sustainable Development Goals associated with this project.
|
51
|
+
attr_accessor :sdgs
|
52
|
+
|
50
53
|
class EnumAttributeValidator
|
51
54
|
attr_reader :datatype
|
52
55
|
attr_reader :allowable_values
|
@@ -82,7 +85,8 @@ module Patch
|
|
82
85
|
:'photos' => :'photos',
|
83
86
|
:'average_price_per_tonne_cents_usd' => :'average_price_per_tonne_cents_usd',
|
84
87
|
:'remaining_mass_g' => :'remaining_mass_g',
|
85
|
-
:'standard' => :'standard'
|
88
|
+
:'standard' => :'standard',
|
89
|
+
:'sdgs' => :'sdgs'
|
86
90
|
}
|
87
91
|
end
|
88
92
|
|
@@ -99,7 +103,8 @@ module Patch
|
|
99
103
|
:'photos' => :'Array<Photo>',
|
100
104
|
:'average_price_per_tonne_cents_usd' => :'Integer',
|
101
105
|
:'remaining_mass_g' => :'Integer',
|
102
|
-
:'standard' => :'Standard'
|
106
|
+
:'standard' => :'Standard',
|
107
|
+
:'sdgs' => :'Array<Sdg>'
|
103
108
|
}
|
104
109
|
end
|
105
110
|
|
@@ -111,6 +116,8 @@ module Patch
|
|
111
116
|
|
112
117
|
nullable_properties.add("standard")
|
113
118
|
|
119
|
+
nullable_properties.add("sdgs")
|
120
|
+
|
114
121
|
nullable_properties
|
115
122
|
end
|
116
123
|
|
@@ -185,6 +192,12 @@ module Patch
|
|
185
192
|
if attributes.key?(:'standard')
|
186
193
|
self.standard = attributes[:'standard']
|
187
194
|
end
|
195
|
+
|
196
|
+
if attributes.key?(:'sdgs')
|
197
|
+
if (value = attributes[:'sdgs']).is_a?(Array)
|
198
|
+
self.sdgs = value
|
199
|
+
end
|
200
|
+
end
|
188
201
|
end
|
189
202
|
|
190
203
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -233,7 +246,7 @@ module Patch
|
|
233
246
|
return false if @production.nil?
|
234
247
|
return false if @name.nil?
|
235
248
|
return false if @description.nil?
|
236
|
-
type_validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "soil"])
|
249
|
+
type_validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "renewables", "soil"])
|
237
250
|
return false unless type_validator.valid?(@type)
|
238
251
|
return false if @country.nil?
|
239
252
|
return false if @developer.nil?
|
@@ -245,7 +258,7 @@ module Patch
|
|
245
258
|
# Custom attribute writer method checking allowed values (enum).
|
246
259
|
# @param [Object] type Object to be assigned
|
247
260
|
def type=(type)
|
248
|
-
validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "soil"])
|
261
|
+
validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "renewables", "soil"])
|
249
262
|
unless validator.valid?(type)
|
250
263
|
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
251
264
|
end
|
@@ -267,7 +280,8 @@ module Patch
|
|
267
280
|
photos == o.photos &&
|
268
281
|
average_price_per_tonne_cents_usd == o.average_price_per_tonne_cents_usd &&
|
269
282
|
remaining_mass_g == o.remaining_mass_g &&
|
270
|
-
standard == o.standard
|
283
|
+
standard == o.standard &&
|
284
|
+
sdgs == o.sdgs
|
271
285
|
end
|
272
286
|
|
273
287
|
# @see the `==` method
|
@@ -279,7 +293,7 @@ module Patch
|
|
279
293
|
# Calculates hash code according to all attributes.
|
280
294
|
# @return [Integer] Hash code
|
281
295
|
def hash
|
282
|
-
[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
|
283
297
|
end
|
284
298
|
|
285
299
|
# Builds the object from hash
|
@@ -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
|