patch_ruby 1.17.1 → 1.20.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.lock +1 -1
- data/lib/patch_ruby/api/estimates_api.rb +70 -0
- data/lib/patch_ruby/api/orders_api.rb +2 -2
- data/lib/patch_ruby/api_client.rb +1 -1
- data/lib/patch_ruby/models/create_hotel_estimate_request.rb +300 -0
- data/lib/patch_ruby/models/create_order_request.rb +86 -4
- data/lib/patch_ruby/version.rb +1 -1
- data/lib/patch_ruby.rb +1 -0
- data/spec/integration/estimates_spec.rb +16 -1
- data/spec/integration/orders_spec.rb +19 -0
- data/spec/models/create_order_request_spec.rb +3 -1
- metadata +25 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e38c237237f243dcdefd64f39b87d2f052f5df647ba2c160971f68757bfdfc4
|
4
|
+
data.tar.gz: b129e13caef807d8c28ec975173881fb78a39df1a2c979d55958e3409a262f8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b2e3c8486b47e5a3b7c7f7fd773f83773ffcab9da7c11d0fa04ea0ec29127179b81d76d68e383a2a4816aeb26fef7e23243e2c32b8b48b09f285e1d0f235383
|
7
|
+
data.tar.gz: 0a7d3ce9b60026bfaab7687785e34f4397e7d7c4fb5fe4095b8003918f32cae12bfe092ef426b6ba580ad5cfafae408b02fd2b06675600a400249496294146f7
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,24 @@ 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
|
+
## [1.20.0] - 2022-04-18
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Adds optional `vintage_year` field to `order` creation
|
13
|
+
|
14
|
+
## [1.19.0] - 2022-04-05
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- Adds `Patch::Estimate.create_hotel_estimate` method
|
19
|
+
|
20
|
+
## [1.18.0] - 2022-03-22
|
21
|
+
|
22
|
+
### Changed
|
23
|
+
|
24
|
+
- Adds optional `state` field to `order` creation
|
25
|
+
|
8
26
|
## [1.17.0] - 2022-01-11
|
9
27
|
|
10
28
|
### Changed
|
data/Gemfile.lock
CHANGED
@@ -18,6 +18,7 @@ module Patch
|
|
18
18
|
:create_bitcoin_estimate,
|
19
19
|
:create_ethereum_estimate,
|
20
20
|
:create_flight_estimate,
|
21
|
+
:create_hotel_estimate,
|
21
22
|
:create_mass_estimate,
|
22
23
|
:create_shipping_estimate,
|
23
24
|
:create_vehicle_estimate,
|
@@ -237,6 +238,75 @@ module Patch
|
|
237
238
|
return data, status_code, headers
|
238
239
|
end
|
239
240
|
|
241
|
+
# Create a hotel estimate.
|
242
|
+
# 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.
|
243
|
+
# @param create_hotel_estimate_request [CreateHotelEstimateRequest]
|
244
|
+
# @param [Hash] opts the optional parameters
|
245
|
+
# @return [EstimateResponse]
|
246
|
+
def create_hotel_estimate(create_hotel_estimate_request = {}, opts = {})
|
247
|
+
_create_hotel_estimate_request = Patch::CreateHotelEstimateRequest.new(create_hotel_estimate_request)
|
248
|
+
data, _status_code, _headers = create_hotel_estimate_with_http_info(_create_hotel_estimate_request, opts)
|
249
|
+
data
|
250
|
+
end
|
251
|
+
|
252
|
+
# Create a hotel estimate.
|
253
|
+
# 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.
|
254
|
+
# @param create_hotel_estimate_request [CreateHotelEstimateRequest]
|
255
|
+
# @param [Hash] opts the optional parameters
|
256
|
+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
257
|
+
def create_hotel_estimate_with_http_info(create_hotel_estimate_request, opts = {})
|
258
|
+
if @api_client.config.debugging
|
259
|
+
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_hotel_estimate ...'
|
260
|
+
end
|
261
|
+
# verify the required parameter 'create_hotel_estimate_request' is set
|
262
|
+
if @api_client.config.client_side_validation && create_hotel_estimate_request.nil?
|
263
|
+
fail ArgumentError, "Missing the required parameter 'create_hotel_estimate_request' when calling EstimatesApi.create_hotel_estimate"
|
264
|
+
end
|
265
|
+
# resource path
|
266
|
+
local_var_path = '/v1/estimates/hotel'
|
267
|
+
|
268
|
+
# query parameters
|
269
|
+
query_params = opts[:query_params] || {}
|
270
|
+
|
271
|
+
# header parameters
|
272
|
+
header_params = opts[:header_params] || {}
|
273
|
+
# HTTP header 'Accept' (if needed)
|
274
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
275
|
+
# HTTP header 'Content-Type'
|
276
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
277
|
+
if !content_type.nil?
|
278
|
+
header_params['Content-Type'] = content_type
|
279
|
+
end
|
280
|
+
|
281
|
+
# form parameters
|
282
|
+
form_params = opts[:form_params] || {}
|
283
|
+
|
284
|
+
# http body (model)
|
285
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_hotel_estimate_request)
|
286
|
+
|
287
|
+
# return_type
|
288
|
+
return_type = opts[:debug_return_type] || 'EstimateResponse'
|
289
|
+
|
290
|
+
# auth_names
|
291
|
+
auth_names = opts[:debug_auth_names] || ['bearer_auth']
|
292
|
+
|
293
|
+
new_options = opts.merge(
|
294
|
+
:operation => :"EstimatesApi.create_hotel_estimate",
|
295
|
+
:header_params => header_params,
|
296
|
+
:query_params => query_params,
|
297
|
+
:form_params => form_params,
|
298
|
+
:body => post_body,
|
299
|
+
:auth_names => auth_names,
|
300
|
+
:return_type => return_type
|
301
|
+
)
|
302
|
+
|
303
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
304
|
+
if @api_client.config.debugging
|
305
|
+
@api_client.config.logger.debug "API called: EstimatesApi#create_hotel_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
306
|
+
end
|
307
|
+
return data, status_code, headers
|
308
|
+
end
|
309
|
+
|
240
310
|
# Create an estimate based on mass of CO2
|
241
311
|
# 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.
|
242
312
|
# @param create_mass_estimate_request [CreateMassEstimateRequest]
|
@@ -92,7 +92,7 @@ module Patch
|
|
92
92
|
end
|
93
93
|
|
94
94
|
# Creates an order
|
95
|
-
# Creates an order in the `placed`
|
95
|
+
# Creates an order in the `placed` or `draft` state.
|
96
96
|
# @param create_order_request [CreateOrderRequest]
|
97
97
|
# @param [Hash] opts the optional parameters
|
98
98
|
# @return [OrderResponse]
|
@@ -103,7 +103,7 @@ module Patch
|
|
103
103
|
end
|
104
104
|
|
105
105
|
# Creates an order
|
106
|
-
# Creates an order in the `placed`
|
106
|
+
# Creates an order in the `placed` or `draft` state.
|
107
107
|
# @param create_order_request [CreateOrderRequest]
|
108
108
|
# @param [Hash] opts the optional parameters
|
109
109
|
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
@@ -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/1.
|
34
|
+
@user_agent = "patch-ruby/1.20.0"
|
35
35
|
@default_headers = {
|
36
36
|
'Content-Type' => 'application/json',
|
37
37
|
'User-Agent' => @user_agent
|
@@ -0,0 +1,300 @@
|
|
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: 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
|
@@ -23,13 +23,41 @@ module Patch
|
|
23
23
|
|
24
24
|
attr_accessor :metadata
|
25
25
|
|
26
|
+
attr_accessor :state
|
27
|
+
|
28
|
+
attr_accessor :vintage_year
|
29
|
+
|
30
|
+
class EnumAttributeValidator
|
31
|
+
attr_reader :datatype
|
32
|
+
attr_reader :allowable_values
|
33
|
+
|
34
|
+
def initialize(datatype, allowable_values)
|
35
|
+
@allowable_values = allowable_values.map do |value|
|
36
|
+
case datatype.to_s
|
37
|
+
when /Integer/i
|
38
|
+
value.to_i
|
39
|
+
when /Float/i
|
40
|
+
value.to_f
|
41
|
+
else
|
42
|
+
value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def valid?(value)
|
48
|
+
!value || allowable_values.include?(value)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
26
52
|
# Attribute mapping from ruby-style variable name to JSON key.
|
27
53
|
def self.attribute_map
|
28
54
|
{
|
29
55
|
:'mass_g' => :'mass_g',
|
30
56
|
:'total_price_cents_usd' => :'total_price_cents_usd',
|
31
57
|
:'project_id' => :'project_id',
|
32
|
-
:'metadata' => :'metadata'
|
58
|
+
:'metadata' => :'metadata',
|
59
|
+
:'state' => :'state',
|
60
|
+
:'vintage_year' => :'vintage_year'
|
33
61
|
}
|
34
62
|
end
|
35
63
|
|
@@ -44,13 +72,21 @@ module Patch
|
|
44
72
|
:'mass_g' => :'Integer',
|
45
73
|
:'total_price_cents_usd' => :'Integer',
|
46
74
|
:'project_id' => :'String',
|
47
|
-
:'metadata' => :'Object'
|
75
|
+
:'metadata' => :'Object',
|
76
|
+
:'state' => :'String',
|
77
|
+
:'vintage_year' => :'Integer'
|
48
78
|
}
|
49
79
|
end
|
50
80
|
|
51
81
|
# List of attributes with nullable: true
|
52
82
|
def self.openapi_nullable
|
53
83
|
Set.new([
|
84
|
+
:'mass_g',
|
85
|
+
:'total_price_cents_usd',
|
86
|
+
:'project_id',
|
87
|
+
:'metadata',
|
88
|
+
:'state',
|
89
|
+
:'vintage_year'
|
54
90
|
])
|
55
91
|
end
|
56
92
|
|
@@ -96,6 +132,14 @@ module Patch
|
|
96
132
|
if attributes.key?(:'metadata')
|
97
133
|
self.metadata = attributes[:'metadata']
|
98
134
|
end
|
135
|
+
|
136
|
+
if attributes.key?(:'state')
|
137
|
+
self.state = attributes[:'state']
|
138
|
+
end
|
139
|
+
|
140
|
+
if attributes.key?(:'vintage_year')
|
141
|
+
self.vintage_year = attributes[:'vintage_year']
|
142
|
+
end
|
99
143
|
end
|
100
144
|
|
101
145
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -114,6 +158,14 @@ module Patch
|
|
114
158
|
invalid_properties.push('invalid value for "total_price_cents_usd", must be greater than or equal to 1.')
|
115
159
|
end
|
116
160
|
|
161
|
+
if !@vintage_year.nil? && @vintage_year > 2100
|
162
|
+
invalid_properties.push('invalid value for "vintage_year", must be smaller than or equal to 2100.')
|
163
|
+
end
|
164
|
+
|
165
|
+
if !@vintage_year.nil? && @vintage_year < 1900
|
166
|
+
invalid_properties.push('invalid value for "vintage_year", must be greater than or equal to 1900.')
|
167
|
+
end
|
168
|
+
|
117
169
|
invalid_properties
|
118
170
|
end
|
119
171
|
|
@@ -123,6 +175,10 @@ module Patch
|
|
123
175
|
return false if !@mass_g.nil? && @mass_g > 100000000000
|
124
176
|
return false if !@mass_g.nil? && @mass_g < 0
|
125
177
|
return false if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1
|
178
|
+
state_validator = EnumAttributeValidator.new('String', ["draft", "placed"])
|
179
|
+
return false unless state_validator.valid?(@state)
|
180
|
+
return false if !@vintage_year.nil? && @vintage_year > 2100
|
181
|
+
return false if !@vintage_year.nil? && @vintage_year < 1900
|
126
182
|
true
|
127
183
|
end
|
128
184
|
|
@@ -150,6 +206,30 @@ module Patch
|
|
150
206
|
@total_price_cents_usd = total_price_cents_usd
|
151
207
|
end
|
152
208
|
|
209
|
+
# Custom attribute writer method checking allowed values (enum).
|
210
|
+
# @param [Object] state Object to be assigned
|
211
|
+
def state=(state)
|
212
|
+
validator = EnumAttributeValidator.new('String', ["draft", "placed"])
|
213
|
+
unless validator.valid?(state)
|
214
|
+
fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}."
|
215
|
+
end
|
216
|
+
@state = state
|
217
|
+
end
|
218
|
+
|
219
|
+
# Custom attribute writer method with validation
|
220
|
+
# @param [Object] vintage_year Value to be assigned
|
221
|
+
def vintage_year=(vintage_year)
|
222
|
+
if !vintage_year.nil? && vintage_year > 2100
|
223
|
+
fail ArgumentError, 'invalid value for "vintage_year", must be smaller than or equal to 2100.'
|
224
|
+
end
|
225
|
+
|
226
|
+
if !vintage_year.nil? && vintage_year < 1900
|
227
|
+
fail ArgumentError, 'invalid value for "vintage_year", must be greater than or equal to 1900.'
|
228
|
+
end
|
229
|
+
|
230
|
+
@vintage_year = vintage_year
|
231
|
+
end
|
232
|
+
|
153
233
|
# Checks equality by comparing each attribute.
|
154
234
|
# @param [Object] Object to be compared
|
155
235
|
def ==(o)
|
@@ -158,7 +238,9 @@ module Patch
|
|
158
238
|
mass_g == o.mass_g &&
|
159
239
|
total_price_cents_usd == o.total_price_cents_usd &&
|
160
240
|
project_id == o.project_id &&
|
161
|
-
metadata == o.metadata
|
241
|
+
metadata == o.metadata &&
|
242
|
+
state == o.state &&
|
243
|
+
vintage_year == o.vintage_year
|
162
244
|
end
|
163
245
|
|
164
246
|
# @see the `==` method
|
@@ -170,7 +252,7 @@ module Patch
|
|
170
252
|
# Calculates hash code according to all attributes.
|
171
253
|
# @return [Integer] Hash code
|
172
254
|
def hash
|
173
|
-
[mass_g, total_price_cents_usd, project_id, metadata].hash
|
255
|
+
[mass_g, total_price_cents_usd, project_id, metadata, state, vintage_year].hash
|
174
256
|
end
|
175
257
|
|
176
258
|
# Builds the object from hash
|
data/lib/patch_ruby/version.rb
CHANGED
data/lib/patch_ruby.rb
CHANGED
@@ -21,6 +21,7 @@ require 'patch_ruby/models/allocation'
|
|
21
21
|
require 'patch_ruby/models/create_bitcoin_estimate_request'
|
22
22
|
require 'patch_ruby/models/create_ethereum_estimate_request'
|
23
23
|
require 'patch_ruby/models/create_flight_estimate_request'
|
24
|
+
require 'patch_ruby/models/create_hotel_estimate_request'
|
24
25
|
require 'patch_ruby/models/create_mass_estimate_request'
|
25
26
|
require 'patch_ruby/models/create_order_request'
|
26
27
|
require 'patch_ruby/models/create_shipping_estimate_request'
|
@@ -87,7 +87,7 @@ RSpec.describe 'Estimates Integration' do
|
|
87
87
|
)
|
88
88
|
|
89
89
|
expect(create_estimate_response.data.type).to eq 'shipping'
|
90
|
-
expect(create_estimate_response.data.mass_g).to
|
90
|
+
expect(create_estimate_response.data.mass_g).to be >= 10_000
|
91
91
|
end
|
92
92
|
|
93
93
|
|
@@ -156,4 +156,19 @@ RSpec.describe 'Estimates Integration' do
|
|
156
156
|
expect(ethereum_estimate.data.type).to eq 'ethereum'
|
157
157
|
expect(ethereum_estimate.data.mass_g).to be >= 2_000
|
158
158
|
end
|
159
|
+
|
160
|
+
it 'supports creating hotel estimates' do
|
161
|
+
create_estimate_response = Patch::Estimate.create_hotel_estimate(
|
162
|
+
country_code: "US",
|
163
|
+
city: "Denver",
|
164
|
+
star_rating: 5,
|
165
|
+
number_of_nights: 2,
|
166
|
+
number_of_rooms: 2
|
167
|
+
)
|
168
|
+
|
169
|
+
expect(create_estimate_response.success).to eq(true)
|
170
|
+
expect(create_estimate_response.data.type).to eq 'hotel'
|
171
|
+
expect(create_estimate_response.data.mass_g).to be >= 100_000
|
172
|
+
expect(create_estimate_response.data.id).not_to be_nil
|
173
|
+
end
|
159
174
|
end
|
@@ -84,6 +84,16 @@ RSpec.describe 'Orders Integration' do
|
|
84
84
|
.to all(have_key(:user))
|
85
85
|
end
|
86
86
|
|
87
|
+
it 'supports creation in draft state' do
|
88
|
+
create_order_response =
|
89
|
+
Patch::Order.create_order(mass_g: 100, state: "draft")
|
90
|
+
|
91
|
+
expect(create_order_response.success).to eq true
|
92
|
+
expect(create_order_response.data.id).not_to be_nil
|
93
|
+
expect(create_order_response.data.mass_g).to eq(100)
|
94
|
+
expect(create_order_response.data.state).to eq("draft")
|
95
|
+
end
|
96
|
+
|
87
97
|
it 'supports place and cancel for orders created via an estimate' do
|
88
98
|
create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100, create_order: true)
|
89
99
|
order_to_place_id = create_estimate_to_place_response.data.order.id
|
@@ -97,4 +107,13 @@ RSpec.describe 'Orders Integration' do
|
|
97
107
|
cancel_order_response = Patch::Order.cancel_order(order_to_cancel_id)
|
98
108
|
expect(cancel_order_response.data.state).to eq 'cancelled'
|
99
109
|
end
|
110
|
+
|
111
|
+
it 'supports create with a vintage year' do
|
112
|
+
create_order_response =
|
113
|
+
Patch::Order.create_order(mass_g: 100, vintage_year: 2022)
|
114
|
+
|
115
|
+
expect(create_order_response.success).to eq true
|
116
|
+
expect(create_order_response.data.id).not_to be_nil
|
117
|
+
expect(create_order_response.data.mass_g).to eq(100)
|
118
|
+
end
|
100
119
|
end
|
@@ -30,7 +30,9 @@ describe 'CreateOrderRequest' do
|
|
30
30
|
it_behaves_like "a generated class" do
|
31
31
|
let(:instance) { @instance }
|
32
32
|
let(:instance_hash) { { project_id: @instance.project_id, mass_g: @instance.mass_g, total_price_cents_usd: @instance.total_price_cents_usd, metadata: @instance.metadata } }
|
33
|
-
let(:nullable_properties)
|
33
|
+
let(:nullable_properties) do
|
34
|
+
Set.new(%i[mass_g total_price_cents_usd project_id metadata state vintage_year])
|
35
|
+
end
|
34
36
|
end
|
35
37
|
|
36
38
|
describe 'test an instance of CreateOrderRequest' do
|
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: 1.
|
4
|
+
version: 1.20.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: 2022-
|
11
|
+
date: 2022-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/patch_ruby/models/create_bitcoin_estimate_request.rb
|
105
105
|
- lib/patch_ruby/models/create_ethereum_estimate_request.rb
|
106
106
|
- lib/patch_ruby/models/create_flight_estimate_request.rb
|
107
|
+
- lib/patch_ruby/models/create_hotel_estimate_request.rb
|
107
108
|
- lib/patch_ruby/models/create_mass_estimate_request.rb
|
108
109
|
- lib/patch_ruby/models/create_order_request.rb
|
109
110
|
- lib/patch_ruby/models/create_shipping_estimate_request.rb
|
@@ -205,41 +206,41 @@ test_files:
|
|
205
206
|
- spec/api_client_spec.rb
|
206
207
|
- spec/configuration_spec.rb
|
207
208
|
- spec/constants.rb
|
208
|
-
- spec/factories/
|
209
|
-
- spec/factories/error_responses.rb
|
210
|
-
- spec/factories/sdgs.rb
|
211
|
-
- spec/factories/meta_index_objects.rb
|
209
|
+
- spec/factories/allocations.rb
|
212
210
|
- spec/factories/create_mass_estimate_requests.rb
|
213
|
-
- spec/factories/
|
214
|
-
- spec/factories/
|
211
|
+
- spec/factories/meta_index_objects.rb
|
212
|
+
- spec/factories/estimate_list_responses.rb
|
213
|
+
- spec/factories/order_list_responses.rb
|
215
214
|
- spec/factories/parent_technology_type.rb
|
216
|
-
- spec/factories/
|
215
|
+
- spec/factories/create_order_requests.rb
|
216
|
+
- spec/factories/sdgs.rb
|
217
217
|
- spec/factories/order_responses.rb
|
218
|
-
- spec/factories/estimate_responses.rb
|
219
|
-
- spec/factories/allocations.rb
|
220
|
-
- spec/factories/estimate_list_responses.rb
|
221
218
|
- spec/factories/orders.rb
|
219
|
+
- spec/factories/technology_type.rb
|
220
|
+
- spec/factories/project_responses.rb
|
221
|
+
- spec/factories/estimate_responses.rb
|
222
|
+
- spec/factories/project_list_responses.rb
|
223
|
+
- spec/factories/error_responses.rb
|
222
224
|
- spec/factories/projects.rb
|
223
|
-
- spec/factories/
|
224
|
-
- spec/
|
225
|
+
- spec/factories/estimates.rb
|
226
|
+
- spec/integration/estimates_spec.rb
|
225
227
|
- spec/integration/projects/technology_types_spec.rb
|
226
|
-
- spec/integration/orders_spec.rb
|
227
228
|
- spec/integration/projects_spec.rb
|
228
|
-
- spec/integration/
|
229
|
+
- spec/integration/orders_spec.rb
|
230
|
+
- spec/models/project_response_spec.rb
|
231
|
+
- spec/models/project_list_response_spec.rb
|
232
|
+
- spec/models/create_order_request_spec.rb
|
233
|
+
- spec/models/estimate_list_response_spec.rb
|
234
|
+
- spec/models/estimate_spec.rb
|
229
235
|
- spec/models/project_spec.rb
|
230
236
|
- spec/models/order_response_spec.rb
|
231
|
-
- spec/models/
|
232
|
-
- spec/models/project_response_spec.rb
|
237
|
+
- spec/models/allocation_spec.rb
|
233
238
|
- spec/models/meta_index_object_spec.rb
|
239
|
+
- spec/models/error_response_spec.rb
|
240
|
+
- spec/models/estimate_response_spec.rb
|
234
241
|
- spec/models/create_mass_estimate_request_spec.rb
|
235
|
-
- spec/models/estimate_list_response_spec.rb
|
236
|
-
- spec/models/allocation_spec.rb
|
237
|
-
- spec/models/create_order_request_spec.rb
|
238
242
|
- spec/models/order_list_response_spec.rb
|
239
|
-
- spec/models/project_list_response_spec.rb
|
240
|
-
- spec/models/estimate_spec.rb
|
241
243
|
- spec/models/order_spec.rb
|
242
|
-
- spec/models/estimate_response_spec.rb
|
243
244
|
- spec/patch_ruby_spec.rb
|
244
245
|
- spec/spec_helper.rb
|
245
246
|
- spec/support/shared/generated_classes.rb
|