Skip to content

Commit 6e4fecd

Browse files
committed
Add Patch::Estimate methods for GLEC-certified shipping estimates
1 parent 371e50c commit 6e4fecd

18 files changed

+2561
-17
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.24.0] - 2022-07-22
9+
10+
### Added
11+
12+
- Adds `Patch::Estimate.create_air_shipping_estimate` method
13+
- Adds `Patch::Estimate.create_rail_shipping_estimate` method
14+
- Adds `Patch::Estimate.create_road_shipping_estimate` method
15+
- Adds `Patch::Estimate.create_sea_shipping_estimate` method
16+
817
## [1.23.0] - 2022-06-03
918

1019
### Added

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
patch_ruby (1.23.0)
4+
patch_ruby (1.24.0)
55
typhoeus (~> 1.0, >= 1.0.1)
66

77
GEM

lib/patch_ruby.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818

1919
# Models
2020
require 'patch_ruby/models/allocation'
21+
require 'patch_ruby/models/create_air_shipping_estimate_request'
2122
require 'patch_ruby/models/create_bitcoin_estimate_request'
2223
require 'patch_ruby/models/create_ethereum_estimate_request'
2324
require 'patch_ruby/models/create_flight_estimate_request'
2425
require 'patch_ruby/models/create_hotel_estimate_request'
2526
require 'patch_ruby/models/create_mass_estimate_request'
2627
require 'patch_ruby/models/create_order_request'
28+
require 'patch_ruby/models/create_rail_shipping_estimate_request'
29+
require 'patch_ruby/models/create_road_shipping_estimate_request'
30+
require 'patch_ruby/models/create_sea_shipping_estimate_request'
2731
require 'patch_ruby/models/create_shipping_estimate_request'
2832
require 'patch_ruby/models/create_success_response'
2933
require 'patch_ruby/models/create_vehicle_estimate_request'
@@ -56,6 +60,7 @@
5660
require 'patch_ruby/api/estimates_api'
5761
require 'patch_ruby/api/orders_api'
5862
require 'patch_ruby/api/projects_api'
63+
require 'patch_ruby/api/shipping_api'
5964
require 'patch_ruby/api/technology_types_api'
6065

6166
module Patch

lib/patch_ruby/api/orders_api.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def initialize(api_client = ApiClient.default)
3333
# @param [Hash] opts the optional parameters
3434
# @return [OrderResponse]
3535
def cancel_order(id, opts = {})
36-
3736
data, _status_code, _headers = cancel_order_with_http_info(id, opts)
3837
data
3938
end
@@ -166,9 +165,10 @@ def create_order_with_http_info(create_order_request, opts = {})
166165
# @param [Hash] opts the optional parameters
167166
# @option opts [PlaceOrderRequest] :place_order_request
168167
# @return [OrderResponse]
169-
def place_order(id, place_order_request = {}, opts = {})
170-
_place_order_request = Patch::PlaceOrderRequest.new(place_order_request)
171-
data, _status_code, _headers = place_order_with_http_info(id, opts.merge!({place_order_request: place_order_request}))
168+
def place_order(order_id, opts = {})
169+
place_order_request = Patch::PlaceOrderRequest.new(opts)
170+
opts[:place_order_request] = place_order_request
171+
data, _status_code, _headers = place_order_with_http_info(order_id, opts)
172172
data
173173
end
174174

@@ -237,7 +237,6 @@ def place_order_with_http_info(id, opts = {})
237237
# @param [Hash] opts the optional parameters
238238
# @return [OrderResponse]
239239
def retrieve_order(id, opts = {})
240-
241240
data, _status_code, _headers = retrieve_order_with_http_info(id, opts)
242241
data
243242
end
@@ -304,7 +303,6 @@ def retrieve_order_with_http_info(id, opts = {})
304303
# @option opts [String] :metadata_example2
305304
# @return [OrderListResponse]
306305
def retrieve_orders(opts = {})
307-
308306
data, _status_code, _headers = retrieve_orders_with_http_info(opts)
309307
data
310308
end

lib/patch_ruby/api/shipping_api.rb

Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,305 @@
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 'cgi'
14+
15+
module Patch
16+
class ShippingApi
17+
OPERATIONS = [
18+
:create_air_shipping_estimate,
19+
:create_rail_shipping_estimate,
20+
:create_road_shipping_estimate,
21+
:create_sea_shipping_estimate,
22+
]
23+
24+
attr_accessor :api_client
25+
26+
def initialize(api_client = ApiClient.default)
27+
@api_client = api_client
28+
end
29+
# Creates a GLEC air shipping estimate given freight mass and logistics
30+
# Creates a GLEC air shipping 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.
31+
# @param create_air_shipping_estimate_request [CreateAirShippingEstimateRequest]
32+
# @param [Hash] opts the optional parameters
33+
# @return [EstimateResponse]
34+
def create_air_shipping_estimate(create_air_shipping_estimate_request = {}, opts = {})
35+
_create_air_shipping_estimate_request = Patch::CreateAirShippingEstimateRequest.new(create_air_shipping_estimate_request)
36+
data, _status_code, _headers = create_air_shipping_estimate_with_http_info(_create_air_shipping_estimate_request, opts)
37+
data
38+
end
39+
40+
# Creates a GLEC air shipping estimate given freight mass and logistics
41+
# Creates a GLEC air shipping 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.
42+
# @param create_air_shipping_estimate_request [CreateAirShippingEstimateRequest]
43+
# @param [Hash] opts the optional parameters
44+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
45+
def create_air_shipping_estimate_with_http_info(create_air_shipping_estimate_request, opts = {})
46+
if @api_client.config.debugging
47+
@api_client.config.logger.debug 'Calling API: ShippingApi.create_air_shipping_estimate ...'
48+
end
49+
# verify the required parameter 'create_air_shipping_estimate_request' is set
50+
if @api_client.config.client_side_validation && create_air_shipping_estimate_request.nil?
51+
fail ArgumentError, "Missing the required parameter 'create_air_shipping_estimate_request' when calling ShippingApi.create_air_shipping_estimate"
52+
end
53+
# resource path
54+
local_var_path = '/v1/shipping/air'
55+
56+
# query parameters
57+
query_params = opts[:query_params] || {}
58+
59+
# header parameters
60+
header_params = opts[:header_params] || {}
61+
# HTTP header 'Accept' (if needed)
62+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
63+
# HTTP header 'Content-Type'
64+
content_type = @api_client.select_header_content_type(['application/json'])
65+
if !content_type.nil?
66+
header_params['Content-Type'] = content_type
67+
end
68+
69+
# form parameters
70+
form_params = opts[:form_params] || {}
71+
72+
# http body (model)
73+
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_air_shipping_estimate_request)
74+
75+
# return_type
76+
return_type = opts[:debug_return_type] || 'EstimateResponse'
77+
78+
# auth_names
79+
auth_names = opts[:debug_auth_names] || ['bearer_auth']
80+
81+
new_options = opts.merge(
82+
:operation => :"ShippingApi.create_air_shipping_estimate",
83+
:header_params => header_params,
84+
:query_params => query_params,
85+
:form_params => form_params,
86+
:body => post_body,
87+
:auth_names => auth_names,
88+
:return_type => return_type
89+
)
90+
91+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
92+
if @api_client.config.debugging
93+
@api_client.config.logger.debug "API called: ShippingApi#create_air_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
94+
end
95+
return data, status_code, headers
96+
end
97+
98+
# Creates a GLEC rail shipping estimate given freight mass and logistics
99+
# Creates a GLEC rail shipping 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.
100+
# @param create_rail_shipping_estimate_request [CreateRailShippingEstimateRequest]
101+
# @param [Hash] opts the optional parameters
102+
# @return [EstimateResponse]
103+
def create_rail_shipping_estimate(create_rail_shipping_estimate_request = {}, opts = {})
104+
_create_rail_shipping_estimate_request = Patch::CreateRailShippingEstimateRequest.new(create_rail_shipping_estimate_request)
105+
data, _status_code, _headers = create_rail_shipping_estimate_with_http_info(_create_rail_shipping_estimate_request, opts)
106+
data
107+
end
108+
109+
# Creates a GLEC rail shipping estimate given freight mass and logistics
110+
# Creates a GLEC rail shipping estimate for the amount of CO2 to be compensated. An order in the &#x60;draft&#x60; state may be created based on the parameters, linked to the estimate.
111+
# @param create_rail_shipping_estimate_request [CreateRailShippingEstimateRequest]
112+
# @param [Hash] opts the optional parameters
113+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
114+
def create_rail_shipping_estimate_with_http_info(create_rail_shipping_estimate_request, opts = {})
115+
if @api_client.config.debugging
116+
@api_client.config.logger.debug 'Calling API: ShippingApi.create_rail_shipping_estimate ...'
117+
end
118+
# verify the required parameter 'create_rail_shipping_estimate_request' is set
119+
if @api_client.config.client_side_validation && create_rail_shipping_estimate_request.nil?
120+
fail ArgumentError, "Missing the required parameter 'create_rail_shipping_estimate_request' when calling ShippingApi.create_rail_shipping_estimate"
121+
end
122+
# resource path
123+
local_var_path = '/v1/shipping/rail'
124+
125+
# query parameters
126+
query_params = opts[:query_params] || {}
127+
128+
# header parameters
129+
header_params = opts[:header_params] || {}
130+
# HTTP header 'Accept' (if needed)
131+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
132+
# HTTP header 'Content-Type'
133+
content_type = @api_client.select_header_content_type(['application/json'])
134+
if !content_type.nil?
135+
header_params['Content-Type'] = content_type
136+
end
137+
138+
# form parameters
139+
form_params = opts[:form_params] || {}
140+
141+
# http body (model)
142+
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_rail_shipping_estimate_request)
143+
144+
# return_type
145+
return_type = opts[:debug_return_type] || 'EstimateResponse'
146+
147+
# auth_names
148+
auth_names = opts[:debug_auth_names] || ['bearer_auth']
149+
150+
new_options = opts.merge(
151+
:operation => :"ShippingApi.create_rail_shipping_estimate",
152+
:header_params => header_params,
153+
:query_params => query_params,
154+
:form_params => form_params,
155+
:body => post_body,
156+
:auth_names => auth_names,
157+
:return_type => return_type
158+
)
159+
160+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
161+
if @api_client.config.debugging
162+
@api_client.config.logger.debug "API called: ShippingApi#create_rail_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
163+
end
164+
return data, status_code, headers
165+
end
166+
167+
# Creates a GLEC road shipping estimate given freight mass and logistics
168+
# Creates a GLEC road shipping 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.
169+
# @param create_road_shipping_estimate_request [CreateRoadShippingEstimateRequest]
170+
# @param [Hash] opts the optional parameters
171+
# @return [EstimateResponse]
172+
def create_road_shipping_estimate(create_road_shipping_estimate_request = {}, opts = {})
173+
_create_road_shipping_estimate_request = Patch::CreateRoadShippingEstimateRequest.new(create_road_shipping_estimate_request)
174+
data, _status_code, _headers = create_road_shipping_estimate_with_http_info(_create_road_shipping_estimate_request, opts)
175+
data
176+
end
177+
178+
# Creates a GLEC road shipping estimate given freight mass and logistics
179+
# Creates a GLEC road shipping estimate for the amount of CO2 to be compensated. An order in the &#x60;draft&#x60; state may be created based on the parameters, linked to the estimate.
180+
# @param create_road_shipping_estimate_request [CreateRoadShippingEstimateRequest]
181+
# @param [Hash] opts the optional parameters
182+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
183+
def create_road_shipping_estimate_with_http_info(create_road_shipping_estimate_request, opts = {})
184+
if @api_client.config.debugging
185+
@api_client.config.logger.debug 'Calling API: ShippingApi.create_road_shipping_estimate ...'
186+
end
187+
# verify the required parameter 'create_road_shipping_estimate_request' is set
188+
if @api_client.config.client_side_validation && create_road_shipping_estimate_request.nil?
189+
fail ArgumentError, "Missing the required parameter 'create_road_shipping_estimate_request' when calling ShippingApi.create_road_shipping_estimate"
190+
end
191+
# resource path
192+
local_var_path = '/v1/shipping/road'
193+
194+
# query parameters
195+
query_params = opts[:query_params] || {}
196+
197+
# header parameters
198+
header_params = opts[:header_params] || {}
199+
# HTTP header 'Accept' (if needed)
200+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
201+
# HTTP header 'Content-Type'
202+
content_type = @api_client.select_header_content_type(['application/json'])
203+
if !content_type.nil?
204+
header_params['Content-Type'] = content_type
205+
end
206+
207+
# form parameters
208+
form_params = opts[:form_params] || {}
209+
210+
# http body (model)
211+
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_road_shipping_estimate_request)
212+
213+
# return_type
214+
return_type = opts[:debug_return_type] || 'EstimateResponse'
215+
216+
# auth_names
217+
auth_names = opts[:debug_auth_names] || ['bearer_auth']
218+
219+
new_options = opts.merge(
220+
:operation => :"ShippingApi.create_road_shipping_estimate",
221+
:header_params => header_params,
222+
:query_params => query_params,
223+
:form_params => form_params,
224+
:body => post_body,
225+
:auth_names => auth_names,
226+
:return_type => return_type
227+
)
228+
229+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
230+
if @api_client.config.debugging
231+
@api_client.config.logger.debug "API called: ShippingApi#create_road_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
232+
end
233+
return data, status_code, headers
234+
end
235+
236+
# Creates a GLEC sea shipping estimate given freight mass and logistics
237+
# Creates a GLEC sea shipping 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.
238+
# @param create_sea_shipping_estimate_request [CreateSeaShippingEstimateRequest]
239+
# @param [Hash] opts the optional parameters
240+
# @return [EstimateResponse]
241+
def create_sea_shipping_estimate(create_sea_shipping_estimate_request = {}, opts = {})
242+
_create_sea_shipping_estimate_request = Patch::CreateSeaShippingEstimateRequest.new(create_sea_shipping_estimate_request)
243+
data, _status_code, _headers = create_sea_shipping_estimate_with_http_info(_create_sea_shipping_estimate_request, opts)
244+
data
245+
end
246+
247+
# Creates a GLEC sea shipping estimate given freight mass and logistics
248+
# Creates a GLEC sea shipping estimate for the amount of CO2 to be compensated. An order in the &#x60;draft&#x60; state may be created based on the parameters, linked to the estimate.
249+
# @param create_sea_shipping_estimate_request [CreateSeaShippingEstimateRequest]
250+
# @param [Hash] opts the optional parameters
251+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
252+
def create_sea_shipping_estimate_with_http_info(create_sea_shipping_estimate_request, opts = {})
253+
if @api_client.config.debugging
254+
@api_client.config.logger.debug 'Calling API: ShippingApi.create_sea_shipping_estimate ...'
255+
end
256+
# verify the required parameter 'create_sea_shipping_estimate_request' is set
257+
if @api_client.config.client_side_validation && create_sea_shipping_estimate_request.nil?
258+
fail ArgumentError, "Missing the required parameter 'create_sea_shipping_estimate_request' when calling ShippingApi.create_sea_shipping_estimate"
259+
end
260+
# resource path
261+
local_var_path = '/v1/shipping/sea'
262+
263+
# query parameters
264+
query_params = opts[:query_params] || {}
265+
266+
# header parameters
267+
header_params = opts[:header_params] || {}
268+
# HTTP header 'Accept' (if needed)
269+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
270+
# HTTP header 'Content-Type'
271+
content_type = @api_client.select_header_content_type(['application/json'])
272+
if !content_type.nil?
273+
header_params['Content-Type'] = content_type
274+
end
275+
276+
# form parameters
277+
form_params = opts[:form_params] || {}
278+
279+
# http body (model)
280+
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_sea_shipping_estimate_request)
281+
282+
# return_type
283+
return_type = opts[:debug_return_type] || 'EstimateResponse'
284+
285+
# auth_names
286+
auth_names = opts[:debug_auth_names] || ['bearer_auth']
287+
288+
new_options = opts.merge(
289+
:operation => :"ShippingApi.create_sea_shipping_estimate",
290+
:header_params => header_params,
291+
:query_params => query_params,
292+
:form_params => form_params,
293+
:body => post_body,
294+
:auth_names => auth_names,
295+
:return_type => return_type
296+
)
297+
298+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
299+
if @api_client.config.debugging
300+
@api_client.config.logger.debug "API called: ShippingApi#create_sea_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
301+
end
302+
return data, status_code, headers
303+
end
304+
end
305+
end

0 commit comments

Comments
 (0)