patch_ruby 2.3.0 → 2.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 +20 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +29 -16
- data/lib/patch_ruby/api/estimates_api.rb +1 -151
- data/lib/patch_ruby/api/order_line_items_api.rb +1 -1
- data/lib/patch_ruby/api/orders_api.rb +1 -1
- data/lib/patch_ruby/api/projects_api.rb +1 -1
- data/lib/patch_ruby/api/technology_types_api.rb +1 -1
- data/lib/patch_ruby/api_client.rb +1 -1
- data/lib/patch_ruby/configuration.rb +1 -2
- data/lib/patch_ruby/version.rb +1 -1
- data/lib/patch_ruby.rb +0 -2
- data/patch_ruby.gemspec +1 -1
- data/spec/integration/estimates_spec.rb +0 -29
- metadata +22 -24
- data/lib/patch_ruby/models/create_ecommerce_estimate_request.rb +0 -373
- data/lib/patch_ruby/models/create_hotel_estimate_request.rb +0 -300
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72dbfba7072374e513325586e0b97747ed704411eb94757c8e99d1a6118a3581
|
4
|
+
data.tar.gz: d6de008d7638027888cecec5ea3252da1ab2551cd621e562ff3b41821683d250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64a89d7316c018533bb2d654906020e1f1182dc6007c096caed3af86be478df00d44149fb90b7804701e3e7f2acbb3a41f256b3da41c8fd54b913120a496760e
|
7
|
+
data.tar.gz: '030669673243f9d01079cb3f1b013941680a64fbb73d09169a46b8157e445ecf557ffddb943e876432618d11e46ddeecee81c8812a39e6e91d5b367d987447aa'
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [2.4.0] - 2025-05-16
|
9
|
+
|
10
|
+
### Removed
|
11
|
+
|
12
|
+
- Removes `Patch::Estimate.create_hotel_estimate` method
|
13
|
+
|
14
|
+
## [2.3.1] - 2025-04-28
|
15
|
+
|
16
|
+
### Removed
|
17
|
+
|
18
|
+
- Removes `Patch::Estimate.create_ecommerce_estimate` method
|
19
|
+
|
20
|
+
## [2.3.0] - 2025-01-10
|
21
|
+
|
22
|
+
### Removed
|
23
|
+
|
24
|
+
- Removes `Patch::Estimate.create_ethereum_estimate` method
|
25
|
+
- Removes `Patch::Estimate.create_shipping_estimate` method
|
26
|
+
- Removes `Patch::Estimate.create_vehicle_estimate` method
|
27
|
+
|
8
28
|
## [2.1.1] - 2023-04-18
|
9
29
|
|
10
30
|
### Added
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
patch_ruby (2.
|
4
|
+
patch_ruby (2.4.0)
|
5
5
|
typhoeus (~> 1.0, >= 1.0.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
i18n (>= 1.6, < 2)
|
13
13
|
minitest (>= 5.1)
|
14
14
|
tzinfo (~> 2.0)
|
15
|
-
ast (2.4.
|
15
|
+
ast (2.4.3)
|
16
16
|
byebug (11.1.3)
|
17
17
|
coderay (1.1.3)
|
18
18
|
concurrent-ruby (1.2.2)
|
@@ -21,24 +21,29 @@ GEM
|
|
21
21
|
ffi (>= 1.15.0)
|
22
22
|
factory_bot (6.2.0)
|
23
23
|
activesupport (>= 5.0.0)
|
24
|
-
ffi (1.17.
|
24
|
+
ffi (1.17.2)
|
25
25
|
i18n (1.12.0)
|
26
26
|
concurrent-ruby (~> 1.0)
|
27
|
-
|
27
|
+
json (2.12.0)
|
28
|
+
language_server-protocol (3.17.0.5)
|
29
|
+
lint_roller (1.1.0)
|
28
30
|
method_source (1.0.0)
|
29
31
|
minitest (5.18.0)
|
30
|
-
parallel (1.
|
31
|
-
parser (3.
|
32
|
+
parallel (1.27.0)
|
33
|
+
parser (3.3.8.0)
|
32
34
|
ast (~> 2.4.1)
|
35
|
+
racc
|
36
|
+
prism (1.4.0)
|
33
37
|
pry (0.14.1)
|
34
38
|
coderay (~> 1.1)
|
35
39
|
method_source (~> 1.0)
|
36
40
|
pry-byebug (3.8.0)
|
37
41
|
byebug (~> 11.0)
|
38
42
|
pry (~> 0.10)
|
39
|
-
|
40
|
-
rainbow (3.
|
43
|
+
racc (1.8.1)
|
44
|
+
rainbow (3.1.1)
|
41
45
|
rake (13.0.6)
|
46
|
+
regexp_parser (2.10.0)
|
42
47
|
rspec (3.10.0)
|
43
48
|
rspec-core (~> 3.10.0)
|
44
49
|
rspec-expectations (~> 3.10.0)
|
@@ -52,20 +57,28 @@ GEM
|
|
52
57
|
diff-lcs (>= 1.2.0, < 2.0)
|
53
58
|
rspec-support (~> 3.10.0)
|
54
59
|
rspec-support (3.10.2)
|
55
|
-
rubocop (
|
56
|
-
|
60
|
+
rubocop (1.75.6)
|
61
|
+
json (~> 2.3)
|
62
|
+
language_server-protocol (~> 3.17.0.2)
|
63
|
+
lint_roller (~> 1.1.0)
|
57
64
|
parallel (~> 1.10)
|
58
|
-
parser (>=
|
59
|
-
psych (>= 3.1.0)
|
65
|
+
parser (>= 3.3.0.2)
|
60
66
|
rainbow (>= 2.2.2, < 4.0)
|
67
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
68
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
61
69
|
ruby-progressbar (~> 1.7)
|
62
|
-
unicode-display_width (>=
|
63
|
-
|
70
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
71
|
+
rubocop-ast (1.44.1)
|
72
|
+
parser (>= 3.3.7.2)
|
73
|
+
prism (~> 1.4)
|
74
|
+
ruby-progressbar (1.13.0)
|
64
75
|
typhoeus (1.4.1)
|
65
76
|
ethon (>= 0.9.0)
|
66
77
|
tzinfo (2.0.6)
|
67
78
|
concurrent-ruby (~> 1.0)
|
68
|
-
unicode-display_width (1.
|
79
|
+
unicode-display_width (3.1.4)
|
80
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
81
|
+
unicode-emoji (4.0.4)
|
69
82
|
|
70
83
|
PLATFORMS
|
71
84
|
arm64-darwin-20
|
@@ -83,7 +96,7 @@ DEPENDENCIES
|
|
83
96
|
pry-byebug
|
84
97
|
rake (~> 13.0.1)
|
85
98
|
rspec (~> 3.6, >= 3.6.0)
|
86
|
-
rubocop (~>
|
99
|
+
rubocop (~> 1.75.6)
|
87
100
|
|
88
101
|
BUNDLED WITH
|
89
102
|
2.3.9
|
@@ -17,9 +17,7 @@ module Patch
|
|
17
17
|
OPERATIONS = [
|
18
18
|
:create_air_shipping_estimate,
|
19
19
|
:create_bitcoin_estimate,
|
20
|
-
:create_ecommerce_estimate,
|
21
20
|
:create_flight_estimate,
|
22
|
-
:create_hotel_estimate,
|
23
21
|
:create_mass_estimate,
|
24
22
|
:create_rail_shipping_estimate,
|
25
23
|
:create_road_shipping_estimate,
|
@@ -181,80 +179,6 @@ module Patch
|
|
181
179
|
return data, status_code, headers
|
182
180
|
end
|
183
181
|
|
184
|
-
# Create an e-commerce estimate given the distance traveled in meters, package weight, and transportation method.
|
185
|
-
# Creates a e-commerce estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters.
|
186
|
-
# @param create_ecommerce_estimate_request [CreateEcommerceEstimateRequest]
|
187
|
-
# @param [Hash] opts the optional parameters
|
188
|
-
# @option opts [Integer] :patch_version
|
189
|
-
# @return [EstimateResponse]
|
190
|
-
def create_ecommerce_estimate(create_ecommerce_estimate_request = {}, opts = {})
|
191
|
-
_create_ecommerce_estimate_request = Patch::CreateEcommerceEstimateRequest.new(create_ecommerce_estimate_request)
|
192
|
-
data, _status_code, _headers = create_ecommerce_estimate_with_http_info(_create_ecommerce_estimate_request, opts)
|
193
|
-
data
|
194
|
-
end
|
195
|
-
|
196
|
-
# Create an e-commerce estimate given the distance traveled in meters, package weight, and transportation method.
|
197
|
-
# Creates a e-commerce estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters.
|
198
|
-
# @param create_ecommerce_estimate_request [CreateEcommerceEstimateRequest]
|
199
|
-
# @param [Hash] opts the optional parameters
|
200
|
-
# @option opts [Integer] :patch_version
|
201
|
-
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
202
|
-
def create_ecommerce_estimate_with_http_info(create_ecommerce_estimate_request, opts = {})
|
203
|
-
if @api_client.config.debugging
|
204
|
-
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_ecommerce_estimate ...'
|
205
|
-
end
|
206
|
-
# verify the required parameter 'create_ecommerce_estimate_request' is set
|
207
|
-
if @api_client.config.client_side_validation && create_ecommerce_estimate_request.nil?
|
208
|
-
fail ArgumentError, "Missing the required parameter 'create_ecommerce_estimate_request' when calling EstimatesApi.create_ecommerce_estimate"
|
209
|
-
end
|
210
|
-
# resource path
|
211
|
-
local_var_path = '/v1/estimates/ecommerce'
|
212
|
-
|
213
|
-
# query parameters
|
214
|
-
query_params = opts[:query_params] || {}
|
215
|
-
|
216
|
-
# header parameters
|
217
|
-
header_params = opts[:header_params] || {}
|
218
|
-
|
219
|
-
# HTTP header 'Accept' (if needed)
|
220
|
-
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
221
|
-
# HTTP header 'Content-Type'
|
222
|
-
content_type = @api_client.select_header_content_type(['application/json'])
|
223
|
-
if !content_type.nil?
|
224
|
-
header_params['Content-Type'] = content_type
|
225
|
-
end
|
226
|
-
header_params['Patch-Version'] = 2
|
227
|
-
header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil?
|
228
|
-
|
229
|
-
# form parameters
|
230
|
-
form_params = opts[:form_params] || {}
|
231
|
-
|
232
|
-
# http body (model)
|
233
|
-
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_ecommerce_estimate_request)
|
234
|
-
|
235
|
-
# return_type
|
236
|
-
return_type = opts[:debug_return_type] || 'EstimateResponse'
|
237
|
-
|
238
|
-
# auth_names
|
239
|
-
auth_names = opts[:debug_auth_names] || ['bearer_auth']
|
240
|
-
|
241
|
-
new_options = opts.merge(
|
242
|
-
:operation => :"EstimatesApi.create_ecommerce_estimate",
|
243
|
-
:header_params => header_params,
|
244
|
-
:query_params => query_params,
|
245
|
-
:form_params => form_params,
|
246
|
-
:body => post_body,
|
247
|
-
:auth_names => auth_names,
|
248
|
-
:return_type => return_type
|
249
|
-
)
|
250
|
-
|
251
|
-
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
252
|
-
if @api_client.config.debugging
|
253
|
-
@api_client.config.logger.debug "API called: EstimatesApi#create_ecommerce_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
254
|
-
end
|
255
|
-
return data, status_code, headers
|
256
|
-
end
|
257
|
-
|
258
182
|
# Create a flight estimate given the distance traveled in meters
|
259
183
|
# Creates a flight estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
|
260
184
|
# @param create_flight_estimate_request [CreateFlightEstimateRequest]
|
@@ -329,80 +253,6 @@ module Patch
|
|
329
253
|
return data, status_code, headers
|
330
254
|
end
|
331
255
|
|
332
|
-
# Create a hotel estimate.
|
333
|
-
# Creates a hotel estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters.
|
334
|
-
# @param create_hotel_estimate_request [CreateHotelEstimateRequest]
|
335
|
-
# @param [Hash] opts the optional parameters
|
336
|
-
# @option opts [Integer] :patch_version
|
337
|
-
# @return [EstimateResponse]
|
338
|
-
def create_hotel_estimate(create_hotel_estimate_request = {}, opts = {})
|
339
|
-
_create_hotel_estimate_request = Patch::CreateHotelEstimateRequest.new(create_hotel_estimate_request)
|
340
|
-
data, _status_code, _headers = create_hotel_estimate_with_http_info(_create_hotel_estimate_request, opts)
|
341
|
-
data
|
342
|
-
end
|
343
|
-
|
344
|
-
# Create a hotel estimate.
|
345
|
-
# Creates a hotel estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters.
|
346
|
-
# @param create_hotel_estimate_request [CreateHotelEstimateRequest]
|
347
|
-
# @param [Hash] opts the optional parameters
|
348
|
-
# @option opts [Integer] :patch_version
|
349
|
-
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
350
|
-
def create_hotel_estimate_with_http_info(create_hotel_estimate_request, opts = {})
|
351
|
-
if @api_client.config.debugging
|
352
|
-
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_hotel_estimate ...'
|
353
|
-
end
|
354
|
-
# verify the required parameter 'create_hotel_estimate_request' is set
|
355
|
-
if @api_client.config.client_side_validation && create_hotel_estimate_request.nil?
|
356
|
-
fail ArgumentError, "Missing the required parameter 'create_hotel_estimate_request' when calling EstimatesApi.create_hotel_estimate"
|
357
|
-
end
|
358
|
-
# resource path
|
359
|
-
local_var_path = '/v1/estimates/hotel'
|
360
|
-
|
361
|
-
# query parameters
|
362
|
-
query_params = opts[:query_params] || {}
|
363
|
-
|
364
|
-
# header parameters
|
365
|
-
header_params = opts[:header_params] || {}
|
366
|
-
|
367
|
-
# HTTP header 'Accept' (if needed)
|
368
|
-
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
369
|
-
# HTTP header 'Content-Type'
|
370
|
-
content_type = @api_client.select_header_content_type(['application/json'])
|
371
|
-
if !content_type.nil?
|
372
|
-
header_params['Content-Type'] = content_type
|
373
|
-
end
|
374
|
-
header_params['Patch-Version'] = 2
|
375
|
-
header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil?
|
376
|
-
|
377
|
-
# form parameters
|
378
|
-
form_params = opts[:form_params] || {}
|
379
|
-
|
380
|
-
# http body (model)
|
381
|
-
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_hotel_estimate_request)
|
382
|
-
|
383
|
-
# return_type
|
384
|
-
return_type = opts[:debug_return_type] || 'EstimateResponse'
|
385
|
-
|
386
|
-
# auth_names
|
387
|
-
auth_names = opts[:debug_auth_names] || ['bearer_auth']
|
388
|
-
|
389
|
-
new_options = opts.merge(
|
390
|
-
:operation => :"EstimatesApi.create_hotel_estimate",
|
391
|
-
:header_params => header_params,
|
392
|
-
:query_params => query_params,
|
393
|
-
:form_params => form_params,
|
394
|
-
:body => post_body,
|
395
|
-
:auth_names => auth_names,
|
396
|
-
:return_type => return_type
|
397
|
-
)
|
398
|
-
|
399
|
-
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
400
|
-
if @api_client.config.debugging
|
401
|
-
@api_client.config.logger.debug "API called: EstimatesApi#create_hotel_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
402
|
-
end
|
403
|
-
return data, status_code, headers
|
404
|
-
end
|
405
|
-
|
406
256
|
# Create an estimate based on mass of CO2
|
407
257
|
# Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate.
|
408
258
|
# @param create_mass_estimate_request [CreateMassEstimateRequest]
|
@@ -834,4 +684,4 @@ module Patch
|
|
834
684
|
return data, status_code, headers
|
835
685
|
end
|
836
686
|
end
|
837
|
-
end
|
687
|
+
end
|
@@ -31,7 +31,7 @@ module Patch
|
|
31
31
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
32
32
|
def initialize(config = Configuration.default)
|
33
33
|
@config = config
|
34
|
-
@user_agent = "patch-ruby/2.
|
34
|
+
@user_agent = "patch-ruby/2.4.0"
|
35
35
|
@default_headers = {
|
36
36
|
'Content-Type' => 'application/json',
|
37
37
|
'User-Agent' => @user_agent
|
data/lib/patch_ruby/version.rb
CHANGED
data/lib/patch_ruby.rb
CHANGED
@@ -19,9 +19,7 @@ require 'patch_ruby/configuration'
|
|
19
19
|
# Models
|
20
20
|
require 'patch_ruby/models/create_air_shipping_estimate_request'
|
21
21
|
require 'patch_ruby/models/create_bitcoin_estimate_request'
|
22
|
-
require 'patch_ruby/models/create_ecommerce_estimate_request'
|
23
22
|
require 'patch_ruby/models/create_flight_estimate_request'
|
24
|
-
require 'patch_ruby/models/create_hotel_estimate_request'
|
25
23
|
require 'patch_ruby/models/create_mass_estimate_request'
|
26
24
|
require 'patch_ruby/models/create_order_line_item_request'
|
27
25
|
require 'patch_ruby/models/create_order_request'
|
data/patch_ruby.gemspec
CHANGED
@@ -91,35 +91,6 @@ RSpec.describe 'Estimates Integration' do
|
|
91
91
|
expect(bitcoin_estimate_1.data.mass_g).to be < bitcoin_estimate_2.data.mass_g
|
92
92
|
end
|
93
93
|
|
94
|
-
it 'supports creating hotel estimates' do
|
95
|
-
create_estimate_response = Patch::Estimate.create_hotel_estimate(
|
96
|
-
country_code: "US",
|
97
|
-
city: "Denver",
|
98
|
-
star_rating: 5,
|
99
|
-
number_of_nights: 2,
|
100
|
-
number_of_rooms: 2
|
101
|
-
)
|
102
|
-
|
103
|
-
expect(create_estimate_response.success).to eq(true)
|
104
|
-
expect(create_estimate_response.data.type).to eq 'hotel'
|
105
|
-
expect(create_estimate_response.data.mass_g).to be >= 100_000
|
106
|
-
expect(create_estimate_response.data.id).not_to be_nil
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'supports creating ecommerce estimates' do
|
110
|
-
distance_m = 100_000_000
|
111
|
-
package_mass_g = 10_000
|
112
|
-
create_estimate_response = Patch::Estimate.create_ecommerce_estimate(
|
113
|
-
distance_m: distance_m,
|
114
|
-
package_mass_g: package_mass_g,
|
115
|
-
transportation_method: 'rail',
|
116
|
-
create_order: false
|
117
|
-
)
|
118
|
-
|
119
|
-
expect(create_estimate_response.data.type).to eq 'ecommerce'
|
120
|
-
expect(create_estimate_response.data.mass_g).to be >= 10_000
|
121
|
-
end
|
122
|
-
|
123
94
|
context "when creating an air shipping estimate" do
|
124
95
|
it "supports creating an estimate using airports" do
|
125
96
|
air_shipping_estimate = Patch::Estimate.create_air_shipping_estimate(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patch_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patch Technology
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -103,9 +103,7 @@ files:
|
|
103
103
|
- lib/patch_ruby/configuration.rb
|
104
104
|
- lib/patch_ruby/models/create_air_shipping_estimate_request.rb
|
105
105
|
- lib/patch_ruby/models/create_bitcoin_estimate_request.rb
|
106
|
-
- lib/patch_ruby/models/create_ecommerce_estimate_request.rb
|
107
106
|
- lib/patch_ruby/models/create_flight_estimate_request.rb
|
108
|
-
- lib/patch_ruby/models/create_hotel_estimate_request.rb
|
109
107
|
- lib/patch_ruby/models/create_mass_estimate_request.rb
|
110
108
|
- lib/patch_ruby/models/create_order_line_item_request.rb
|
111
109
|
- lib/patch_ruby/models/create_order_request.rb
|
@@ -212,46 +210,46 @@ specification_version: 4
|
|
212
210
|
summary: Ruby wrapper for the Patch API
|
213
211
|
test_files:
|
214
212
|
- spec/api/order_line_items_api_spec.rb
|
215
|
-
- spec/api/technology_types_api_spec.rb
|
216
213
|
- spec/api/projects_api_spec.rb
|
217
|
-
- spec/api/orders_api_spec.rb
|
218
214
|
- spec/api/estimates_api_spec.rb
|
215
|
+
- spec/api/technology_types_api_spec.rb
|
216
|
+
- spec/api/orders_api_spec.rb
|
219
217
|
- spec/api_client_spec.rb
|
220
218
|
- spec/configuration_spec.rb
|
221
219
|
- spec/constants.rb
|
222
|
-
- spec/factories/estimates.rb
|
223
|
-
- spec/factories/parent_technology_type.rb
|
224
220
|
- spec/factories/meta_index_objects.rb
|
225
|
-
- spec/factories/project_responses.rb
|
226
221
|
- spec/factories/technology_type.rb
|
227
222
|
- spec/factories/orders.rb
|
223
|
+
- spec/factories/error_responses.rb
|
224
|
+
- spec/factories/project_responses.rb
|
228
225
|
- spec/factories/estimate_list_responses.rb
|
229
|
-
- spec/factories/estimate_responses.rb
|
230
226
|
- spec/factories/projects.rb
|
231
|
-
- spec/factories/create_order_requests.rb
|
232
|
-
- spec/factories/order_responses.rb
|
233
|
-
- spec/factories/create_mass_estimate_requests.rb
|
234
|
-
- spec/factories/sdgs.rb
|
235
227
|
- spec/factories/order_list_responses.rb
|
236
|
-
- spec/factories/
|
228
|
+
- spec/factories/order_responses.rb
|
229
|
+
- spec/factories/estimate_responses.rb
|
230
|
+
- spec/factories/parent_technology_type.rb
|
237
231
|
- spec/factories/project_list_responses.rb
|
232
|
+
- spec/factories/sdgs.rb
|
233
|
+
- spec/factories/create_mass_estimate_requests.rb
|
234
|
+
- spec/factories/create_order_requests.rb
|
235
|
+
- spec/factories/estimates.rb
|
236
|
+
- spec/integration/projects/technology_types_spec.rb
|
238
237
|
- spec/integration/projects_spec.rb
|
239
238
|
- spec/integration/orders_spec.rb
|
240
|
-
- spec/integration/projects/technology_types_spec.rb
|
241
239
|
- spec/integration/estimates_spec.rb
|
242
|
-
- spec/models/
|
240
|
+
- spec/models/create_mass_estimate_request_spec.rb
|
241
|
+
- spec/models/create_order_request_spec.rb
|
243
242
|
- spec/models/meta_index_object_spec.rb
|
243
|
+
- spec/models/estimate_list_response_spec.rb
|
244
|
+
- spec/models/order_response_spec.rb
|
245
|
+
- spec/models/project_spec.rb
|
244
246
|
- spec/models/order_spec.rb
|
245
|
-
- spec/models/
|
247
|
+
- spec/models/order_list_response_spec.rb
|
246
248
|
- spec/models/estimate_spec.rb
|
247
|
-
- spec/models/order_response_spec.rb
|
248
|
-
- spec/models/estimate_list_response_spec.rb
|
249
249
|
- spec/models/estimate_response_spec.rb
|
250
|
+
- spec/models/project_response_spec.rb
|
250
251
|
- spec/models/error_response_spec.rb
|
251
|
-
- spec/models/
|
252
|
-
- spec/models/project_spec.rb
|
253
|
-
- spec/models/order_list_response_spec.rb
|
254
|
-
- spec/models/create_order_request_spec.rb
|
252
|
+
- spec/models/project_list_response_spec.rb
|
255
253
|
- spec/patch_ruby_spec.rb
|
256
254
|
- spec/spec_helper.rb
|
257
255
|
- spec/support/shared/generated_classes.rb
|
@@ -1,373 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
#Patch API V2
|
3
|
-
|
4
|
-
#The core API used to integrate with Patch's service
|
5
|
-
|
6
|
-
The version of the OpenAPI document: 2
|
7
|
-
Contact: engineering@usepatch.com
|
8
|
-
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 5.3.1
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
require 'time'
|
15
|
-
|
16
|
-
module Patch
|
17
|
-
class CreateEcommerceEstimateRequest
|
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::CreateEcommerceEstimateRequestsApi::OPERATIONS') && Patch::CreateEcommerceEstimateRequestsApi::OPERATIONS.include?(message)
|
91
|
-
Patch::CreateEcommerceEstimateRequestsApi.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::CreateEcommerceEstimateRequest` 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::CreateEcommerceEstimateRequest`. 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
|
-
else
|
131
|
-
self.create_order = false
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
136
|
-
# @return Array for valid properties with the reasons
|
137
|
-
def list_invalid_properties
|
138
|
-
invalid_properties = Array.new
|
139
|
-
if @distance_m.nil?
|
140
|
-
invalid_properties.push('invalid value for "distance_m", distance_m cannot be nil.')
|
141
|
-
end
|
142
|
-
|
143
|
-
if @distance_m > 400000000
|
144
|
-
invalid_properties.push('invalid value for "distance_m", must be smaller than or equal to 400000000.')
|
145
|
-
end
|
146
|
-
|
147
|
-
if @distance_m < 0
|
148
|
-
invalid_properties.push('invalid value for "distance_m", must be greater than or equal to 0.')
|
149
|
-
end
|
150
|
-
|
151
|
-
if @package_mass_g.nil?
|
152
|
-
invalid_properties.push('invalid value for "package_mass_g", package_mass_g cannot be nil.')
|
153
|
-
end
|
154
|
-
|
155
|
-
if @package_mass_g > 2000000000
|
156
|
-
invalid_properties.push('invalid value for "package_mass_g", must be smaller than or equal to 2000000000.')
|
157
|
-
end
|
158
|
-
|
159
|
-
if @package_mass_g < 0
|
160
|
-
invalid_properties.push('invalid value for "package_mass_g", must be greater than or equal to 0.')
|
161
|
-
end
|
162
|
-
|
163
|
-
if @transportation_method.nil?
|
164
|
-
invalid_properties.push('invalid value for "transportation_method", transportation_method cannot be nil.')
|
165
|
-
end
|
166
|
-
|
167
|
-
invalid_properties
|
168
|
-
end
|
169
|
-
|
170
|
-
# Check to see if the all the properties in the model are valid
|
171
|
-
# @return true if the model is valid
|
172
|
-
def valid?
|
173
|
-
return false if @distance_m.nil?
|
174
|
-
return false if @distance_m > 400000000
|
175
|
-
return false if @distance_m < 0
|
176
|
-
return false if @package_mass_g.nil?
|
177
|
-
return false if @package_mass_g > 2000000000
|
178
|
-
return false if @package_mass_g < 0
|
179
|
-
return false if @transportation_method.nil?
|
180
|
-
transportation_method_validator = EnumAttributeValidator.new('String', ["air", "rail", "road", "sea"])
|
181
|
-
return false unless transportation_method_validator.valid?(@transportation_method)
|
182
|
-
true
|
183
|
-
end
|
184
|
-
|
185
|
-
# Custom attribute writer method with validation
|
186
|
-
# @param [Object] distance_m Value to be assigned
|
187
|
-
def distance_m=(distance_m)
|
188
|
-
if distance_m.nil?
|
189
|
-
fail ArgumentError, 'distance_m cannot be nil'
|
190
|
-
end
|
191
|
-
|
192
|
-
if distance_m > 400000000
|
193
|
-
fail ArgumentError, 'invalid value for "distance_m", must be smaller than or equal to 400000000.'
|
194
|
-
end
|
195
|
-
|
196
|
-
if distance_m < 0
|
197
|
-
fail ArgumentError, 'invalid value for "distance_m", must be greater than or equal to 0.'
|
198
|
-
end
|
199
|
-
|
200
|
-
@distance_m = distance_m
|
201
|
-
end
|
202
|
-
|
203
|
-
# Custom attribute writer method with validation
|
204
|
-
# @param [Object] package_mass_g Value to be assigned
|
205
|
-
def package_mass_g=(package_mass_g)
|
206
|
-
if package_mass_g.nil?
|
207
|
-
fail ArgumentError, 'package_mass_g cannot be nil'
|
208
|
-
end
|
209
|
-
|
210
|
-
if package_mass_g > 2000000000
|
211
|
-
fail ArgumentError, 'invalid value for "package_mass_g", must be smaller than or equal to 2000000000.'
|
212
|
-
end
|
213
|
-
|
214
|
-
if package_mass_g < 0
|
215
|
-
fail ArgumentError, 'invalid value for "package_mass_g", must be greater than or equal to 0.'
|
216
|
-
end
|
217
|
-
|
218
|
-
@package_mass_g = package_mass_g
|
219
|
-
end
|
220
|
-
|
221
|
-
# Custom attribute writer method checking allowed values (enum).
|
222
|
-
# @param [Object] transportation_method Object to be assigned
|
223
|
-
def transportation_method=(transportation_method)
|
224
|
-
validator = EnumAttributeValidator.new('String', ["air", "rail", "road", "sea"])
|
225
|
-
unless validator.valid?(transportation_method)
|
226
|
-
fail ArgumentError, "invalid value for \"transportation_method\", must be one of #{validator.allowable_values}."
|
227
|
-
end
|
228
|
-
@transportation_method = transportation_method
|
229
|
-
end
|
230
|
-
|
231
|
-
# Checks equality by comparing each attribute.
|
232
|
-
# @param [Object] Object to be compared
|
233
|
-
def ==(o)
|
234
|
-
return true if self.equal?(o)
|
235
|
-
self.class == o.class &&
|
236
|
-
distance_m == o.distance_m &&
|
237
|
-
package_mass_g == o.package_mass_g &&
|
238
|
-
transportation_method == o.transportation_method &&
|
239
|
-
project_id == o.project_id &&
|
240
|
-
create_order == o.create_order
|
241
|
-
end
|
242
|
-
|
243
|
-
# @see the `==` method
|
244
|
-
# @param [Object] Object to be compared
|
245
|
-
def eql?(o)
|
246
|
-
self == o
|
247
|
-
end
|
248
|
-
|
249
|
-
# Calculates hash code according to all attributes.
|
250
|
-
# @return [Integer] Hash code
|
251
|
-
def hash
|
252
|
-
[distance_m, package_mass_g, transportation_method, project_id, create_order].hash
|
253
|
-
end
|
254
|
-
|
255
|
-
# Builds the object from hash
|
256
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
257
|
-
# @return [Object] Returns the model itself
|
258
|
-
def self.build_from_hash(attributes)
|
259
|
-
new.build_from_hash(attributes)
|
260
|
-
end
|
261
|
-
|
262
|
-
# Builds the object from hash
|
263
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
264
|
-
# @return [Object] Returns the model itself
|
265
|
-
def build_from_hash(attributes)
|
266
|
-
return nil unless attributes.is_a?(Hash)
|
267
|
-
self.class.openapi_types.each_pair do |key, type|
|
268
|
-
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
269
|
-
self.send("#{key}=", nil)
|
270
|
-
elsif type =~ /\AArray<(.*)>/i
|
271
|
-
# check to ensure the input is an array given that the attribute
|
272
|
-
# is documented as an array but the input is not
|
273
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
274
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
275
|
-
end
|
276
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
277
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
self
|
282
|
-
end
|
283
|
-
|
284
|
-
# Deserializes the data based on type
|
285
|
-
# @param string type Data type
|
286
|
-
# @param string value Value to be deserialized
|
287
|
-
# @return [Object] Deserialized data
|
288
|
-
def _deserialize(type, value)
|
289
|
-
case type.to_sym
|
290
|
-
when :Time
|
291
|
-
Time.parse(value)
|
292
|
-
when :Date
|
293
|
-
Date.parse(value)
|
294
|
-
when :String
|
295
|
-
value.to_s
|
296
|
-
when :Integer
|
297
|
-
value.to_i
|
298
|
-
when :Float
|
299
|
-
value.to_f
|
300
|
-
when :Boolean
|
301
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
302
|
-
true
|
303
|
-
else
|
304
|
-
false
|
305
|
-
end
|
306
|
-
when :Object
|
307
|
-
# generic object (usually a Hash), return directly
|
308
|
-
value
|
309
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
310
|
-
inner_type = Regexp.last_match[:inner_type]
|
311
|
-
value.map { |v| _deserialize(inner_type, v) }
|
312
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
313
|
-
k_type = Regexp.last_match[:k_type]
|
314
|
-
v_type = Regexp.last_match[:v_type]
|
315
|
-
{}.tap do |hash|
|
316
|
-
value.each do |k, v|
|
317
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
318
|
-
end
|
319
|
-
end
|
320
|
-
else # model
|
321
|
-
# models (e.g. Pet) or oneOf
|
322
|
-
klass = Patch.const_get(type)
|
323
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
324
|
-
end
|
325
|
-
end
|
326
|
-
|
327
|
-
# Returns the string representation of the object
|
328
|
-
# @return [String] String presentation of the object
|
329
|
-
def to_s
|
330
|
-
to_hash.to_s
|
331
|
-
end
|
332
|
-
|
333
|
-
# to_body is an alias to to_hash (backward compatibility)
|
334
|
-
# @return [Hash] Returns the object in the form of hash
|
335
|
-
def to_body
|
336
|
-
to_hash
|
337
|
-
end
|
338
|
-
|
339
|
-
# Returns the object in the form of hash
|
340
|
-
# @return [Hash] Returns the object in the form of hash
|
341
|
-
def to_hash
|
342
|
-
hash = {}
|
343
|
-
self.class.attribute_map.each_pair do |attr, param|
|
344
|
-
value = self.send(attr)
|
345
|
-
if value.nil?
|
346
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
347
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
348
|
-
end
|
349
|
-
|
350
|
-
hash[param] = _to_hash(value)
|
351
|
-
end
|
352
|
-
hash
|
353
|
-
end
|
354
|
-
|
355
|
-
# Outputs non-array value in the form of hash
|
356
|
-
# For object, use to_hash. Otherwise, just return the value
|
357
|
-
# @param [Object] value Any valid value
|
358
|
-
# @return [Hash] Returns the value in the form of hash
|
359
|
-
def _to_hash(value)
|
360
|
-
if value.is_a?(Array)
|
361
|
-
value.compact.map { |v| _to_hash(v) }
|
362
|
-
elsif value.is_a?(Hash)
|
363
|
-
{}.tap do |hash|
|
364
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
365
|
-
end
|
366
|
-
elsif value.respond_to? :to_hash
|
367
|
-
value.to_hash
|
368
|
-
else
|
369
|
-
value
|
370
|
-
end
|
371
|
-
end
|
372
|
-
end
|
373
|
-
end
|
@@ -1,300 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
#Patch API V2
|
3
|
-
|
4
|
-
#The core API used to integrate with Patch's service
|
5
|
-
|
6
|
-
The version of the OpenAPI document: 2
|
7
|
-
Contact: engineering@usepatch.com
|
8
|
-
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 5.3.1
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
require 'time'
|
15
|
-
|
16
|
-
module Patch
|
17
|
-
class CreateHotelEstimateRequest
|
18
|
-
attr_accessor :country_code
|
19
|
-
|
20
|
-
attr_accessor :city
|
21
|
-
|
22
|
-
attr_accessor :region
|
23
|
-
|
24
|
-
attr_accessor :star_rating
|
25
|
-
|
26
|
-
attr_accessor :number_of_nights
|
27
|
-
|
28
|
-
attr_accessor :number_of_rooms
|
29
|
-
|
30
|
-
attr_accessor :project_id
|
31
|
-
|
32
|
-
attr_accessor :create_order
|
33
|
-
|
34
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
35
|
-
def self.attribute_map
|
36
|
-
{
|
37
|
-
:'country_code' => :'country_code',
|
38
|
-
:'city' => :'city',
|
39
|
-
:'region' => :'region',
|
40
|
-
:'star_rating' => :'star_rating',
|
41
|
-
:'number_of_nights' => :'number_of_nights',
|
42
|
-
:'number_of_rooms' => :'number_of_rooms',
|
43
|
-
:'project_id' => :'project_id',
|
44
|
-
:'create_order' => :'create_order'
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
# Returns all the JSON keys this model knows about
|
49
|
-
def self.acceptable_attributes
|
50
|
-
attribute_map.values
|
51
|
-
end
|
52
|
-
|
53
|
-
# Attribute type mapping.
|
54
|
-
def self.openapi_types
|
55
|
-
{
|
56
|
-
:'country_code' => :'String',
|
57
|
-
:'city' => :'String',
|
58
|
-
:'region' => :'String',
|
59
|
-
:'star_rating' => :'Integer',
|
60
|
-
:'number_of_nights' => :'Integer',
|
61
|
-
:'number_of_rooms' => :'Integer',
|
62
|
-
:'project_id' => :'String',
|
63
|
-
:'create_order' => :'Boolean'
|
64
|
-
}
|
65
|
-
end
|
66
|
-
|
67
|
-
# List of attributes with nullable: true
|
68
|
-
def self.openapi_nullable
|
69
|
-
Set.new([
|
70
|
-
:'project_id',
|
71
|
-
:'create_order'
|
72
|
-
])
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
# Allows models with corresponding API classes to delegate API operations to those API classes
|
77
|
-
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
78
|
-
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
79
|
-
def self.method_missing(message, *args, &block)
|
80
|
-
if Object.const_defined?('Patch::CreateHotelEstimateRequestsApi::OPERATIONS') && Patch::CreateHotelEstimateRequestsApi::OPERATIONS.include?(message)
|
81
|
-
Patch::CreateHotelEstimateRequestsApi.new.send(message, *args)
|
82
|
-
else
|
83
|
-
super
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# Initializes the object
|
88
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
89
|
-
def initialize(attributes = {})
|
90
|
-
if (!attributes.is_a?(Hash))
|
91
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateHotelEstimateRequest` initialize method"
|
92
|
-
end
|
93
|
-
|
94
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
95
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
96
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
97
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateHotelEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
98
|
-
end
|
99
|
-
h[k.to_sym] = v
|
100
|
-
}
|
101
|
-
|
102
|
-
if attributes.key?(:'country_code')
|
103
|
-
self.country_code = attributes[:'country_code']
|
104
|
-
end
|
105
|
-
|
106
|
-
if attributes.key?(:'city')
|
107
|
-
self.city = attributes[:'city']
|
108
|
-
end
|
109
|
-
|
110
|
-
if attributes.key?(:'region')
|
111
|
-
self.region = attributes[:'region']
|
112
|
-
end
|
113
|
-
|
114
|
-
if attributes.key?(:'star_rating')
|
115
|
-
self.star_rating = attributes[:'star_rating']
|
116
|
-
end
|
117
|
-
|
118
|
-
if attributes.key?(:'number_of_nights')
|
119
|
-
self.number_of_nights = attributes[:'number_of_nights']
|
120
|
-
end
|
121
|
-
|
122
|
-
if attributes.key?(:'number_of_rooms')
|
123
|
-
self.number_of_rooms = attributes[:'number_of_rooms']
|
124
|
-
end
|
125
|
-
|
126
|
-
if attributes.key?(:'project_id')
|
127
|
-
self.project_id = attributes[:'project_id']
|
128
|
-
end
|
129
|
-
|
130
|
-
if attributes.key?(:'create_order')
|
131
|
-
self.create_order = attributes[:'create_order']
|
132
|
-
else
|
133
|
-
self.create_order = false
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
138
|
-
# @return Array for valid properties with the reasons
|
139
|
-
def list_invalid_properties
|
140
|
-
invalid_properties = Array.new
|
141
|
-
if @country_code.nil?
|
142
|
-
invalid_properties.push('invalid value for "country_code", country_code cannot be nil.')
|
143
|
-
end
|
144
|
-
|
145
|
-
invalid_properties
|
146
|
-
end
|
147
|
-
|
148
|
-
# Check to see if the all the properties in the model are valid
|
149
|
-
# @return true if the model is valid
|
150
|
-
def valid?
|
151
|
-
return false if @country_code.nil?
|
152
|
-
true
|
153
|
-
end
|
154
|
-
|
155
|
-
# Checks equality by comparing each attribute.
|
156
|
-
# @param [Object] Object to be compared
|
157
|
-
def ==(o)
|
158
|
-
return true if self.equal?(o)
|
159
|
-
self.class == o.class &&
|
160
|
-
country_code == o.country_code &&
|
161
|
-
city == o.city &&
|
162
|
-
region == o.region &&
|
163
|
-
star_rating == o.star_rating &&
|
164
|
-
number_of_nights == o.number_of_nights &&
|
165
|
-
number_of_rooms == o.number_of_rooms &&
|
166
|
-
project_id == o.project_id &&
|
167
|
-
create_order == o.create_order
|
168
|
-
end
|
169
|
-
|
170
|
-
# @see the `==` method
|
171
|
-
# @param [Object] Object to be compared
|
172
|
-
def eql?(o)
|
173
|
-
self == o
|
174
|
-
end
|
175
|
-
|
176
|
-
# Calculates hash code according to all attributes.
|
177
|
-
# @return [Integer] Hash code
|
178
|
-
def hash
|
179
|
-
[country_code, city, region, star_rating, number_of_nights, number_of_rooms, project_id, create_order].hash
|
180
|
-
end
|
181
|
-
|
182
|
-
# Builds the object from hash
|
183
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
184
|
-
# @return [Object] Returns the model itself
|
185
|
-
def self.build_from_hash(attributes)
|
186
|
-
new.build_from_hash(attributes)
|
187
|
-
end
|
188
|
-
|
189
|
-
# Builds the object from hash
|
190
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
191
|
-
# @return [Object] Returns the model itself
|
192
|
-
def build_from_hash(attributes)
|
193
|
-
return nil unless attributes.is_a?(Hash)
|
194
|
-
self.class.openapi_types.each_pair do |key, type|
|
195
|
-
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
196
|
-
self.send("#{key}=", nil)
|
197
|
-
elsif type =~ /\AArray<(.*)>/i
|
198
|
-
# check to ensure the input is an array given that the attribute
|
199
|
-
# is documented as an array but the input is not
|
200
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
201
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
202
|
-
end
|
203
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
204
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
self
|
209
|
-
end
|
210
|
-
|
211
|
-
# Deserializes the data based on type
|
212
|
-
# @param string type Data type
|
213
|
-
# @param string value Value to be deserialized
|
214
|
-
# @return [Object] Deserialized data
|
215
|
-
def _deserialize(type, value)
|
216
|
-
case type.to_sym
|
217
|
-
when :Time
|
218
|
-
Time.parse(value)
|
219
|
-
when :Date
|
220
|
-
Date.parse(value)
|
221
|
-
when :String
|
222
|
-
value.to_s
|
223
|
-
when :Integer
|
224
|
-
value.to_i
|
225
|
-
when :Float
|
226
|
-
value.to_f
|
227
|
-
when :Boolean
|
228
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
229
|
-
true
|
230
|
-
else
|
231
|
-
false
|
232
|
-
end
|
233
|
-
when :Object
|
234
|
-
# generic object (usually a Hash), return directly
|
235
|
-
value
|
236
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
237
|
-
inner_type = Regexp.last_match[:inner_type]
|
238
|
-
value.map { |v| _deserialize(inner_type, v) }
|
239
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
240
|
-
k_type = Regexp.last_match[:k_type]
|
241
|
-
v_type = Regexp.last_match[:v_type]
|
242
|
-
{}.tap do |hash|
|
243
|
-
value.each do |k, v|
|
244
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
245
|
-
end
|
246
|
-
end
|
247
|
-
else # model
|
248
|
-
# models (e.g. Pet) or oneOf
|
249
|
-
klass = Patch.const_get(type)
|
250
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
# Returns the string representation of the object
|
255
|
-
# @return [String] String presentation of the object
|
256
|
-
def to_s
|
257
|
-
to_hash.to_s
|
258
|
-
end
|
259
|
-
|
260
|
-
# to_body is an alias to to_hash (backward compatibility)
|
261
|
-
# @return [Hash] Returns the object in the form of hash
|
262
|
-
def to_body
|
263
|
-
to_hash
|
264
|
-
end
|
265
|
-
|
266
|
-
# Returns the object in the form of hash
|
267
|
-
# @return [Hash] Returns the object in the form of hash
|
268
|
-
def to_hash
|
269
|
-
hash = {}
|
270
|
-
self.class.attribute_map.each_pair do |attr, param|
|
271
|
-
value = self.send(attr)
|
272
|
-
if value.nil?
|
273
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
274
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
275
|
-
end
|
276
|
-
|
277
|
-
hash[param] = _to_hash(value)
|
278
|
-
end
|
279
|
-
hash
|
280
|
-
end
|
281
|
-
|
282
|
-
# Outputs non-array value in the form of hash
|
283
|
-
# For object, use to_hash. Otherwise, just return the value
|
284
|
-
# @param [Object] value Any valid value
|
285
|
-
# @return [Hash] Returns the value in the form of hash
|
286
|
-
def _to_hash(value)
|
287
|
-
if value.is_a?(Array)
|
288
|
-
value.compact.map { |v| _to_hash(v) }
|
289
|
-
elsif value.is_a?(Hash)
|
290
|
-
{}.tap do |hash|
|
291
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
292
|
-
end
|
293
|
-
elsif value.respond_to? :to_hash
|
294
|
-
value.to_hash
|
295
|
-
else
|
296
|
-
value
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|