patch_ruby 1.9.0 → 1.11.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 +18 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +40 -44
- data/Makefile +2 -2
- data/lib/patch_ruby/api/estimates_api.rb +33 -25
- data/lib/patch_ruby/api/orders_api.rb +21 -16
- data/lib/patch_ruby/api/preferences_api.rb +17 -13
- data/lib/patch_ruby/api/projects_api.rb +9 -7
- data/lib/patch_ruby/api_client.rb +51 -49
- data/lib/patch_ruby/api_error.rb +1 -1
- data/lib/patch_ruby/configuration.rb +38 -9
- data/lib/patch_ruby/models/allocation.rb +21 -11
- data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +25 -19
- data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +26 -21
- data/lib/patch_ruby/models/create_flight_estimate_request.rb +323 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +22 -13
- data/lib/patch_ruby/models/create_order_request.rb +21 -11
- data/lib/patch_ruby/models/create_preference_request.rb +21 -11
- data/lib/patch_ruby/models/create_shipping_estimate_request.rb +371 -0
- data/lib/patch_ruby/models/create_success_response.rb +247 -0
- data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +326 -0
- data/lib/patch_ruby/models/error_response.rb +22 -13
- data/lib/patch_ruby/models/estimate.rb +22 -13
- data/lib/patch_ruby/models/estimate_list_response.rb +22 -13
- data/lib/patch_ruby/models/estimate_response.rb +22 -13
- data/lib/patch_ruby/models/meta_index_object.rb +23 -15
- data/lib/patch_ruby/models/order.rb +23 -15
- data/lib/patch_ruby/models/order_list_response.rb +22 -13
- data/lib/patch_ruby/models/order_response.rb +22 -13
- data/lib/patch_ruby/models/photo.rb +21 -11
- data/lib/patch_ruby/models/preference.rb +21 -11
- data/lib/patch_ruby/models/preference_list_response.rb +22 -13
- data/lib/patch_ruby/models/preference_response.rb +22 -13
- data/lib/patch_ruby/models/project.rb +24 -17
- data/lib/patch_ruby/models/project_list_response.rb +22 -13
- data/lib/patch_ruby/models/project_response.rb +22 -13
- data/lib/patch_ruby/models/sdg.rb +21 -11
- data/lib/patch_ruby/models/standard.rb +21 -11
- data/lib/patch_ruby/version.rb +2 -2
- data/lib/patch_ruby.rb +5 -1
- data/patch_ruby.gemspec +8 -3
- data/spec/api_client_spec.rb +34 -13
- data/spec/configuration_spec.rb +1 -1
- data/spec/integration/estimates_spec.rb +17 -1
- data/spec/integration/preferences_spec.rb +1 -1
- data/spec/models/create_mass_estimate_request_spec.rb +1 -1
- data/spec/models/error_response_spec.rb +1 -1
- data/spec/models/estimate_list_response_spec.rb +1 -1
- data/spec/models/estimate_response_spec.rb +1 -1
- data/spec/models/estimate_spec.rb +1 -1
- data/spec/models/meta_index_object_spec.rb +1 -1
- data/spec/models/order_list_response_spec.rb +1 -1
- data/spec/models/order_response_spec.rb +1 -1
- data/spec/models/order_spec.rb +1 -1
- data/spec/models/preference_list_response_spec.rb +1 -1
- data/spec/models/preference_response_spec.rb +1 -1
- data/spec/models/project_list_response_spec.rb +1 -1
- data/spec/models/project_response_spec.rb +1 -1
- data/spec/models/project_spec.rb +1 -1
- data/spec/spec_helper.rb +69 -61
- metadata +56 -58
- data/lib/patch_ruby/.api_client.rb.un~ +0 -0
- data/lib/patch_ruby/.configuration.rb.un~ +0 -0
- data/lib/patch_ruby/.version.rb.un~ +0 -0
- data/lib/patch_ruby/api/.orders_api.rb.un~ +0 -0
- data/lib/patch_ruby/models/.create_ethereum_estimate_request.rb.un~ +0 -0
- data/spec/.spec_helper.rb.un~ +0 -0
- data/spec/integration/.estimates_spec.rb.un~ +0 -0
- data/spec/integration/.orders_spec.rb.un~ +0 -0
- data/spec/integration/.preferences_spec.rb.un~ +0 -0
- data/spec/integration/.projects_spec.rb.un~ +0 -0
@@ -6,11 +6,12 @@
|
|
6
6
|
The version of the OpenAPI document: v1
|
7
7
|
Contact: developers@usepatch.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version:
|
9
|
+
OpenAPI Generator version: 5.2.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'date'
|
14
|
+
require 'time'
|
14
15
|
|
15
16
|
module Patch
|
16
17
|
class CreateMassEstimateRequest
|
@@ -29,6 +30,11 @@ module Patch
|
|
29
30
|
}
|
30
31
|
end
|
31
32
|
|
33
|
+
# Returns all the JSON keys this model knows about
|
34
|
+
def self.acceptable_attributes
|
35
|
+
attribute_map.values
|
36
|
+
end
|
37
|
+
|
32
38
|
# Attribute type mapping.
|
33
39
|
def self.openapi_types
|
34
40
|
{
|
@@ -38,15 +44,14 @@ module Patch
|
|
38
44
|
}
|
39
45
|
end
|
40
46
|
|
41
|
-
#
|
47
|
+
# List of attributes with nullable: true
|
42
48
|
def self.openapi_nullable
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
nullable_properties
|
49
|
+
Set.new([
|
50
|
+
:'create_order',
|
51
|
+
])
|
48
52
|
end
|
49
53
|
|
54
|
+
|
50
55
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
51
56
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
52
57
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -167,7 +172,9 @@ module Patch
|
|
167
172
|
def build_from_hash(attributes)
|
168
173
|
return nil unless attributes.is_a?(Hash)
|
169
174
|
self.class.openapi_types.each_pair do |key, type|
|
170
|
-
if
|
175
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
176
|
+
self.send("#{key}=", nil)
|
177
|
+
elsif type =~ /\AArray<(.*)>/i
|
171
178
|
# check to ensure the input is an array given that the attribute
|
172
179
|
# is documented as an array but the input is not
|
173
180
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
@@ -175,7 +182,7 @@ module Patch
|
|
175
182
|
end
|
176
183
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
177
184
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
178
|
-
end
|
185
|
+
end
|
179
186
|
end
|
180
187
|
|
181
188
|
self
|
@@ -187,8 +194,8 @@ module Patch
|
|
187
194
|
# @return [Object] Deserialized data
|
188
195
|
def _deserialize(type, value)
|
189
196
|
case type.to_sym
|
190
|
-
when :
|
191
|
-
|
197
|
+
when :Time
|
198
|
+
Time.parse(value)
|
192
199
|
when :Date
|
193
200
|
Date.parse(value)
|
194
201
|
when :String
|
@@ -218,7 +225,9 @@ module Patch
|
|
218
225
|
end
|
219
226
|
end
|
220
227
|
else # model
|
221
|
-
|
228
|
+
# models (e.g. Pet) or oneOf
|
229
|
+
klass = Patch.const_get(type)
|
230
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
222
231
|
end
|
223
232
|
end
|
224
233
|
|
@@ -244,7 +253,7 @@ module Patch
|
|
244
253
|
is_nullable = self.class.openapi_nullable.include?(attr)
|
245
254
|
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
246
255
|
end
|
247
|
-
|
256
|
+
|
248
257
|
hash[param] = _to_hash(value)
|
249
258
|
end
|
250
259
|
hash
|
@@ -6,11 +6,12 @@
|
|
6
6
|
The version of the OpenAPI document: v1
|
7
7
|
Contact: developers@usepatch.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version:
|
9
|
+
OpenAPI Generator version: 5.2.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'date'
|
14
|
+
require 'time'
|
14
15
|
|
15
16
|
module Patch
|
16
17
|
class CreateOrderRequest
|
@@ -32,6 +33,11 @@ module Patch
|
|
32
33
|
}
|
33
34
|
end
|
34
35
|
|
36
|
+
# Returns all the JSON keys this model knows about
|
37
|
+
def self.acceptable_attributes
|
38
|
+
attribute_map.values
|
39
|
+
end
|
40
|
+
|
35
41
|
# Attribute type mapping.
|
36
42
|
def self.openapi_types
|
37
43
|
{
|
@@ -42,13 +48,13 @@ module Patch
|
|
42
48
|
}
|
43
49
|
end
|
44
50
|
|
45
|
-
#
|
51
|
+
# List of attributes with nullable: true
|
46
52
|
def self.openapi_nullable
|
47
|
-
|
48
|
-
|
49
|
-
nullable_properties
|
53
|
+
Set.new([
|
54
|
+
])
|
50
55
|
end
|
51
56
|
|
57
|
+
|
52
58
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
53
59
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
54
60
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -180,7 +186,9 @@ module Patch
|
|
180
186
|
def build_from_hash(attributes)
|
181
187
|
return nil unless attributes.is_a?(Hash)
|
182
188
|
self.class.openapi_types.each_pair do |key, type|
|
183
|
-
if
|
189
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
190
|
+
self.send("#{key}=", nil)
|
191
|
+
elsif type =~ /\AArray<(.*)>/i
|
184
192
|
# check to ensure the input is an array given that the attribute
|
185
193
|
# is documented as an array but the input is not
|
186
194
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
@@ -188,7 +196,7 @@ module Patch
|
|
188
196
|
end
|
189
197
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
190
198
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
191
|
-
end
|
199
|
+
end
|
192
200
|
end
|
193
201
|
|
194
202
|
self
|
@@ -200,8 +208,8 @@ module Patch
|
|
200
208
|
# @return [Object] Deserialized data
|
201
209
|
def _deserialize(type, value)
|
202
210
|
case type.to_sym
|
203
|
-
when :
|
204
|
-
|
211
|
+
when :Time
|
212
|
+
Time.parse(value)
|
205
213
|
when :Date
|
206
214
|
Date.parse(value)
|
207
215
|
when :String
|
@@ -231,7 +239,9 @@ module Patch
|
|
231
239
|
end
|
232
240
|
end
|
233
241
|
else # model
|
234
|
-
|
242
|
+
# models (e.g. Pet) or oneOf
|
243
|
+
klass = Patch.const_get(type)
|
244
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
235
245
|
end
|
236
246
|
end
|
237
247
|
|
@@ -257,7 +267,7 @@ module Patch
|
|
257
267
|
is_nullable = self.class.openapi_nullable.include?(attr)
|
258
268
|
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
259
269
|
end
|
260
|
-
|
270
|
+
|
261
271
|
hash[param] = _to_hash(value)
|
262
272
|
end
|
263
273
|
hash
|
@@ -6,11 +6,12 @@
|
|
6
6
|
The version of the OpenAPI document: v1
|
7
7
|
Contact: developers@usepatch.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version:
|
9
|
+
OpenAPI Generator version: 5.2.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'date'
|
14
|
+
require 'time'
|
14
15
|
|
15
16
|
module Patch
|
16
17
|
class CreatePreferenceRequest
|
@@ -23,6 +24,11 @@ module Patch
|
|
23
24
|
}
|
24
25
|
end
|
25
26
|
|
27
|
+
# Returns all the JSON keys this model knows about
|
28
|
+
def self.acceptable_attributes
|
29
|
+
attribute_map.values
|
30
|
+
end
|
31
|
+
|
26
32
|
# Attribute type mapping.
|
27
33
|
def self.openapi_types
|
28
34
|
{
|
@@ -30,13 +36,13 @@ module Patch
|
|
30
36
|
}
|
31
37
|
end
|
32
38
|
|
33
|
-
#
|
39
|
+
# List of attributes with nullable: true
|
34
40
|
def self.openapi_nullable
|
35
|
-
|
36
|
-
|
37
|
-
nullable_properties
|
41
|
+
Set.new([
|
42
|
+
])
|
38
43
|
end
|
39
44
|
|
45
|
+
|
40
46
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
41
47
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
42
48
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -119,7 +125,9 @@ module Patch
|
|
119
125
|
def build_from_hash(attributes)
|
120
126
|
return nil unless attributes.is_a?(Hash)
|
121
127
|
self.class.openapi_types.each_pair do |key, type|
|
122
|
-
if
|
128
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
129
|
+
self.send("#{key}=", nil)
|
130
|
+
elsif type =~ /\AArray<(.*)>/i
|
123
131
|
# check to ensure the input is an array given that the attribute
|
124
132
|
# is documented as an array but the input is not
|
125
133
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
@@ -127,7 +135,7 @@ module Patch
|
|
127
135
|
end
|
128
136
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
129
137
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
130
|
-
end
|
138
|
+
end
|
131
139
|
end
|
132
140
|
|
133
141
|
self
|
@@ -139,8 +147,8 @@ module Patch
|
|
139
147
|
# @return [Object] Deserialized data
|
140
148
|
def _deserialize(type, value)
|
141
149
|
case type.to_sym
|
142
|
-
when :
|
143
|
-
|
150
|
+
when :Time
|
151
|
+
Time.parse(value)
|
144
152
|
when :Date
|
145
153
|
Date.parse(value)
|
146
154
|
when :String
|
@@ -170,7 +178,9 @@ module Patch
|
|
170
178
|
end
|
171
179
|
end
|
172
180
|
else # model
|
173
|
-
|
181
|
+
# models (e.g. Pet) or oneOf
|
182
|
+
klass = Patch.const_get(type)
|
183
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
174
184
|
end
|
175
185
|
end
|
176
186
|
|
@@ -196,7 +206,7 @@ module Patch
|
|
196
206
|
is_nullable = self.class.openapi_nullable.include?(attr)
|
197
207
|
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
198
208
|
end
|
199
|
-
|
209
|
+
|
200
210
|
hash[param] = _to_hash(value)
|
201
211
|
end
|
202
212
|
hash
|
@@ -0,0 +1,371 @@
|
|
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 CreateShippingEstimateRequest
|
18
|
+
attr_accessor :distance_m
|
19
|
+
|
20
|
+
attr_accessor :package_mass_g
|
21
|
+
|
22
|
+
attr_accessor :transportation_method
|
23
|
+
|
24
|
+
attr_accessor :project_id
|
25
|
+
|
26
|
+
attr_accessor :create_order
|
27
|
+
|
28
|
+
class EnumAttributeValidator
|
29
|
+
attr_reader :datatype
|
30
|
+
attr_reader :allowable_values
|
31
|
+
|
32
|
+
def initialize(datatype, allowable_values)
|
33
|
+
@allowable_values = allowable_values.map do |value|
|
34
|
+
case datatype.to_s
|
35
|
+
when /Integer/i
|
36
|
+
value.to_i
|
37
|
+
when /Float/i
|
38
|
+
value.to_f
|
39
|
+
else
|
40
|
+
value
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def valid?(value)
|
46
|
+
!value || allowable_values.include?(value)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
51
|
+
def self.attribute_map
|
52
|
+
{
|
53
|
+
:'distance_m' => :'distance_m',
|
54
|
+
:'package_mass_g' => :'package_mass_g',
|
55
|
+
:'transportation_method' => :'transportation_method',
|
56
|
+
:'project_id' => :'project_id',
|
57
|
+
:'create_order' => :'create_order'
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns all the JSON keys this model knows about
|
62
|
+
def self.acceptable_attributes
|
63
|
+
attribute_map.values
|
64
|
+
end
|
65
|
+
|
66
|
+
# Attribute type mapping.
|
67
|
+
def self.openapi_types
|
68
|
+
{
|
69
|
+
:'distance_m' => :'Integer',
|
70
|
+
:'package_mass_g' => :'Integer',
|
71
|
+
:'transportation_method' => :'String',
|
72
|
+
:'project_id' => :'String',
|
73
|
+
:'create_order' => :'Boolean'
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
# List of attributes with nullable: true
|
78
|
+
def self.openapi_nullable
|
79
|
+
Set.new([
|
80
|
+
:'project_id',
|
81
|
+
:'create_order'
|
82
|
+
])
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
87
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
88
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
89
|
+
def self.method_missing(message, *args, &block)
|
90
|
+
if Object.const_defined?('Patch::CreateShippingEstimateRequestsApi::OPERATIONS') && Patch::CreateShippingEstimateRequestsApi::OPERATIONS.include?(message)
|
91
|
+
Patch::CreateShippingEstimateRequestsApi.new.send(message, *args)
|
92
|
+
else
|
93
|
+
super
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Initializes the object
|
98
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
99
|
+
def initialize(attributes = {})
|
100
|
+
if (!attributes.is_a?(Hash))
|
101
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateShippingEstimateRequest` initialize method"
|
102
|
+
end
|
103
|
+
|
104
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
105
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
106
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
107
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateShippingEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
108
|
+
end
|
109
|
+
h[k.to_sym] = v
|
110
|
+
}
|
111
|
+
|
112
|
+
if attributes.key?(:'distance_m')
|
113
|
+
self.distance_m = attributes[:'distance_m']
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.key?(:'package_mass_g')
|
117
|
+
self.package_mass_g = attributes[:'package_mass_g']
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes.key?(:'transportation_method')
|
121
|
+
self.transportation_method = attributes[:'transportation_method']
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:'project_id')
|
125
|
+
self.project_id = attributes[:'project_id']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.key?(:'create_order')
|
129
|
+
self.create_order = attributes[:'create_order']
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
134
|
+
# @return Array for valid properties with the reasons
|
135
|
+
def list_invalid_properties
|
136
|
+
invalid_properties = Array.new
|
137
|
+
if @distance_m.nil?
|
138
|
+
invalid_properties.push('invalid value for "distance_m", distance_m cannot be nil.')
|
139
|
+
end
|
140
|
+
|
141
|
+
if @distance_m > 400000000
|
142
|
+
invalid_properties.push('invalid value for "distance_m", must be smaller than or equal to 400000000.')
|
143
|
+
end
|
144
|
+
|
145
|
+
if @distance_m < 0
|
146
|
+
invalid_properties.push('invalid value for "distance_m", must be greater than or equal to 0.')
|
147
|
+
end
|
148
|
+
|
149
|
+
if @package_mass_g.nil?
|
150
|
+
invalid_properties.push('invalid value for "package_mass_g", package_mass_g cannot be nil.')
|
151
|
+
end
|
152
|
+
|
153
|
+
if @package_mass_g > 2000000000
|
154
|
+
invalid_properties.push('invalid value for "package_mass_g", must be smaller than or equal to 2000000000.')
|
155
|
+
end
|
156
|
+
|
157
|
+
if @package_mass_g < 0
|
158
|
+
invalid_properties.push('invalid value for "package_mass_g", must be greater than or equal to 0.')
|
159
|
+
end
|
160
|
+
|
161
|
+
if @transportation_method.nil?
|
162
|
+
invalid_properties.push('invalid value for "transportation_method", transportation_method cannot be nil.')
|
163
|
+
end
|
164
|
+
|
165
|
+
invalid_properties
|
166
|
+
end
|
167
|
+
|
168
|
+
# Check to see if the all the properties in the model are valid
|
169
|
+
# @return true if the model is valid
|
170
|
+
def valid?
|
171
|
+
return false if @distance_m.nil?
|
172
|
+
return false if @distance_m > 400000000
|
173
|
+
return false if @distance_m < 0
|
174
|
+
return false if @package_mass_g.nil?
|
175
|
+
return false if @package_mass_g > 2000000000
|
176
|
+
return false if @package_mass_g < 0
|
177
|
+
return false if @transportation_method.nil?
|
178
|
+
transportation_method_validator = EnumAttributeValidator.new('String', ["air", "rail", "road", "sea"])
|
179
|
+
return false unless transportation_method_validator.valid?(@transportation_method)
|
180
|
+
true
|
181
|
+
end
|
182
|
+
|
183
|
+
# Custom attribute writer method with validation
|
184
|
+
# @param [Object] distance_m Value to be assigned
|
185
|
+
def distance_m=(distance_m)
|
186
|
+
if distance_m.nil?
|
187
|
+
fail ArgumentError, 'distance_m cannot be nil'
|
188
|
+
end
|
189
|
+
|
190
|
+
if distance_m > 400000000
|
191
|
+
fail ArgumentError, 'invalid value for "distance_m", must be smaller than or equal to 400000000.'
|
192
|
+
end
|
193
|
+
|
194
|
+
if distance_m < 0
|
195
|
+
fail ArgumentError, 'invalid value for "distance_m", must be greater than or equal to 0.'
|
196
|
+
end
|
197
|
+
|
198
|
+
@distance_m = distance_m
|
199
|
+
end
|
200
|
+
|
201
|
+
# Custom attribute writer method with validation
|
202
|
+
# @param [Object] package_mass_g Value to be assigned
|
203
|
+
def package_mass_g=(package_mass_g)
|
204
|
+
if package_mass_g.nil?
|
205
|
+
fail ArgumentError, 'package_mass_g cannot be nil'
|
206
|
+
end
|
207
|
+
|
208
|
+
if package_mass_g > 2000000000
|
209
|
+
fail ArgumentError, 'invalid value for "package_mass_g", must be smaller than or equal to 2000000000.'
|
210
|
+
end
|
211
|
+
|
212
|
+
if package_mass_g < 0
|
213
|
+
fail ArgumentError, 'invalid value for "package_mass_g", must be greater than or equal to 0.'
|
214
|
+
end
|
215
|
+
|
216
|
+
@package_mass_g = package_mass_g
|
217
|
+
end
|
218
|
+
|
219
|
+
# Custom attribute writer method checking allowed values (enum).
|
220
|
+
# @param [Object] transportation_method Object to be assigned
|
221
|
+
def transportation_method=(transportation_method)
|
222
|
+
validator = EnumAttributeValidator.new('String', ["air", "rail", "road", "sea"])
|
223
|
+
unless validator.valid?(transportation_method)
|
224
|
+
fail ArgumentError, "invalid value for \"transportation_method\", must be one of #{validator.allowable_values}."
|
225
|
+
end
|
226
|
+
@transportation_method = transportation_method
|
227
|
+
end
|
228
|
+
|
229
|
+
# Checks equality by comparing each attribute.
|
230
|
+
# @param [Object] Object to be compared
|
231
|
+
def ==(o)
|
232
|
+
return true if self.equal?(o)
|
233
|
+
self.class == o.class &&
|
234
|
+
distance_m == o.distance_m &&
|
235
|
+
package_mass_g == o.package_mass_g &&
|
236
|
+
transportation_method == o.transportation_method &&
|
237
|
+
project_id == o.project_id &&
|
238
|
+
create_order == o.create_order
|
239
|
+
end
|
240
|
+
|
241
|
+
# @see the `==` method
|
242
|
+
# @param [Object] Object to be compared
|
243
|
+
def eql?(o)
|
244
|
+
self == o
|
245
|
+
end
|
246
|
+
|
247
|
+
# Calculates hash code according to all attributes.
|
248
|
+
# @return [Integer] Hash code
|
249
|
+
def hash
|
250
|
+
[distance_m, package_mass_g, transportation_method, project_id, create_order].hash
|
251
|
+
end
|
252
|
+
|
253
|
+
# Builds the object from hash
|
254
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
255
|
+
# @return [Object] Returns the model itself
|
256
|
+
def self.build_from_hash(attributes)
|
257
|
+
new.build_from_hash(attributes)
|
258
|
+
end
|
259
|
+
|
260
|
+
# Builds the object from hash
|
261
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
262
|
+
# @return [Object] Returns the model itself
|
263
|
+
def build_from_hash(attributes)
|
264
|
+
return nil unless attributes.is_a?(Hash)
|
265
|
+
self.class.openapi_types.each_pair do |key, type|
|
266
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
267
|
+
self.send("#{key}=", nil)
|
268
|
+
elsif type =~ /\AArray<(.*)>/i
|
269
|
+
# check to ensure the input is an array given that the attribute
|
270
|
+
# is documented as an array but the input is not
|
271
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
272
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
273
|
+
end
|
274
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
275
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
self
|
280
|
+
end
|
281
|
+
|
282
|
+
# Deserializes the data based on type
|
283
|
+
# @param string type Data type
|
284
|
+
# @param string value Value to be deserialized
|
285
|
+
# @return [Object] Deserialized data
|
286
|
+
def _deserialize(type, value)
|
287
|
+
case type.to_sym
|
288
|
+
when :Time
|
289
|
+
Time.parse(value)
|
290
|
+
when :Date
|
291
|
+
Date.parse(value)
|
292
|
+
when :String
|
293
|
+
value.to_s
|
294
|
+
when :Integer
|
295
|
+
value.to_i
|
296
|
+
when :Float
|
297
|
+
value.to_f
|
298
|
+
when :Boolean
|
299
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
300
|
+
true
|
301
|
+
else
|
302
|
+
false
|
303
|
+
end
|
304
|
+
when :Object
|
305
|
+
# generic object (usually a Hash), return directly
|
306
|
+
value
|
307
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
308
|
+
inner_type = Regexp.last_match[:inner_type]
|
309
|
+
value.map { |v| _deserialize(inner_type, v) }
|
310
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
311
|
+
k_type = Regexp.last_match[:k_type]
|
312
|
+
v_type = Regexp.last_match[:v_type]
|
313
|
+
{}.tap do |hash|
|
314
|
+
value.each do |k, v|
|
315
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
else # model
|
319
|
+
# models (e.g. Pet) or oneOf
|
320
|
+
klass = Patch.const_get(type)
|
321
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
# Returns the string representation of the object
|
326
|
+
# @return [String] String presentation of the object
|
327
|
+
def to_s
|
328
|
+
to_hash.to_s
|
329
|
+
end
|
330
|
+
|
331
|
+
# to_body is an alias to to_hash (backward compatibility)
|
332
|
+
# @return [Hash] Returns the object in the form of hash
|
333
|
+
def to_body
|
334
|
+
to_hash
|
335
|
+
end
|
336
|
+
|
337
|
+
# Returns the object in the form of hash
|
338
|
+
# @return [Hash] Returns the object in the form of hash
|
339
|
+
def to_hash
|
340
|
+
hash = {}
|
341
|
+
self.class.attribute_map.each_pair do |attr, param|
|
342
|
+
value = self.send(attr)
|
343
|
+
if value.nil?
|
344
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
345
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
346
|
+
end
|
347
|
+
|
348
|
+
hash[param] = _to_hash(value)
|
349
|
+
end
|
350
|
+
hash
|
351
|
+
end
|
352
|
+
|
353
|
+
# Outputs non-array value in the form of hash
|
354
|
+
# For object, use to_hash. Otherwise, just return the value
|
355
|
+
# @param [Object] value Any valid value
|
356
|
+
# @return [Hash] Returns the value in the form of hash
|
357
|
+
def _to_hash(value)
|
358
|
+
if value.is_a?(Array)
|
359
|
+
value.compact.map { |v| _to_hash(v) }
|
360
|
+
elsif value.is_a?(Hash)
|
361
|
+
{}.tap do |hash|
|
362
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
363
|
+
end
|
364
|
+
elsif value.respond_to? :to_hash
|
365
|
+
value.to_hash
|
366
|
+
else
|
367
|
+
value
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|