Skip to content

Add Patch::Estimate methods for GLEC-certified shipping estimates #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.24.0] - 2022-07-22

### Added

- Adds `Patch::Estimate.create_air_shipping_estimate` method
- Adds `Patch::Estimate.create_rail_shipping_estimate` method
- Adds `Patch::Estimate.create_road_shipping_estimate` method
- Adds `Patch::Estimate.create_sea_shipping_estimate` method

## [1.23.0] - 2022-06-03

### Added
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
patch_ruby (1.23.0)
patch_ruby (1.24.0)
typhoeus (~> 1.0, >= 1.0.1)

GEM
Expand Down
4 changes: 4 additions & 0 deletions lib/patch_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@

# Models
require 'patch_ruby/models/allocation'
require 'patch_ruby/models/create_air_shipping_estimate_request'
require 'patch_ruby/models/create_bitcoin_estimate_request'
require 'patch_ruby/models/create_ethereum_estimate_request'
require 'patch_ruby/models/create_flight_estimate_request'
require 'patch_ruby/models/create_hotel_estimate_request'
require 'patch_ruby/models/create_mass_estimate_request'
require 'patch_ruby/models/create_order_request'
require 'patch_ruby/models/create_rail_shipping_estimate_request'
require 'patch_ruby/models/create_road_shipping_estimate_request'
require 'patch_ruby/models/create_sea_shipping_estimate_request'
require 'patch_ruby/models/create_shipping_estimate_request'
require 'patch_ruby/models/create_success_response'
require 'patch_ruby/models/create_vehicle_estimate_request'
Expand Down
280 changes: 280 additions & 0 deletions lib/patch_ruby/api/estimates_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
module Patch
class EstimatesApi
OPERATIONS = [
:create_air_shipping_estimate,
:create_bitcoin_estimate,
:create_ethereum_estimate,
:create_flight_estimate,
:create_hotel_estimate,
:create_mass_estimate,
:create_rail_shipping_estimate,
:create_road_shipping_estimate,
:create_sea_shipping_estimate,
:create_shipping_estimate,
:create_vehicle_estimate,
:retrieve_estimate,
Expand All @@ -31,6 +35,75 @@ class EstimatesApi
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Creates a GLEC air shipping estimate given freight mass and logistics
# 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.
# @param create_air_shipping_estimate_request [CreateAirShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [EstimateResponse]
def create_air_shipping_estimate(create_air_shipping_estimate_request = {}, opts = {})
_create_air_shipping_estimate_request = Patch::CreateAirShippingEstimateRequest.new(create_air_shipping_estimate_request)
data, _status_code, _headers = create_air_shipping_estimate_with_http_info(_create_air_shipping_estimate_request, opts)
data
end

# Creates a GLEC air shipping estimate given freight mass and logistics
# 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.
# @param create_air_shipping_estimate_request [CreateAirShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
def create_air_shipping_estimate_with_http_info(create_air_shipping_estimate_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_air_shipping_estimate ...'
end
# verify the required parameter 'create_air_shipping_estimate_request' is set
if @api_client.config.client_side_validation && create_air_shipping_estimate_request.nil?
fail ArgumentError, "Missing the required parameter 'create_air_shipping_estimate_request' when calling EstimatesApi.create_air_shipping_estimate"
end
# resource path
local_var_path = '/v1/estimates/shipping/air'

# query parameters
query_params = opts[:query_params] || {}

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_air_shipping_estimate_request)

# return_type
return_type = opts[:debug_return_type] || 'EstimateResponse'

# auth_names
auth_names = opts[:debug_auth_names] || ['bearer_auth']

new_options = opts.merge(
:operation => :"EstimatesApi.create_air_shipping_estimate",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)

data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: EstimatesApi#create_air_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Create a bitcoin estimate given a timestamp and transaction value
# Creates a bitcoin 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.
# @param create_bitcoin_estimate_request [CreateBitcoinEstimateRequest]
Expand Down Expand Up @@ -376,6 +449,213 @@ def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {})
return data, status_code, headers
end

# Creates a GLEC rail shipping estimate given freight mass and logistics
# 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.
# @param create_rail_shipping_estimate_request [CreateRailShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [EstimateResponse]
def create_rail_shipping_estimate(create_rail_shipping_estimate_request = {}, opts = {})
_create_rail_shipping_estimate_request = Patch::CreateRailShippingEstimateRequest.new(create_rail_shipping_estimate_request)
data, _status_code, _headers = create_rail_shipping_estimate_with_http_info(_create_rail_shipping_estimate_request, opts)
data
end

# Creates a GLEC rail shipping estimate given freight mass and logistics
# 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.
# @param create_rail_shipping_estimate_request [CreateRailShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
def create_rail_shipping_estimate_with_http_info(create_rail_shipping_estimate_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_rail_shipping_estimate ...'
end
# verify the required parameter 'create_rail_shipping_estimate_request' is set
if @api_client.config.client_side_validation && create_rail_shipping_estimate_request.nil?
fail ArgumentError, "Missing the required parameter 'create_rail_shipping_estimate_request' when calling EstimatesApi.create_rail_shipping_estimate"
end
# resource path
local_var_path = '/v1/estimates/shipping/rail'

# query parameters
query_params = opts[:query_params] || {}

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_rail_shipping_estimate_request)

# return_type
return_type = opts[:debug_return_type] || 'EstimateResponse'

# auth_names
auth_names = opts[:debug_auth_names] || ['bearer_auth']

new_options = opts.merge(
:operation => :"EstimatesApi.create_rail_shipping_estimate",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)

data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: EstimatesApi#create_rail_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Creates a GLEC road shipping estimate given freight mass and logistics
# 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.
# @param create_road_shipping_estimate_request [CreateRoadShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [EstimateResponse]
def create_road_shipping_estimate(create_road_shipping_estimate_request = {}, opts = {})
_create_road_shipping_estimate_request = Patch::CreateRoadShippingEstimateRequest.new(create_road_shipping_estimate_request)
data, _status_code, _headers = create_road_shipping_estimate_with_http_info(_create_road_shipping_estimate_request, opts)
data
end

# Creates a GLEC road shipping estimate given freight mass and logistics
# 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.
# @param create_road_shipping_estimate_request [CreateRoadShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
def create_road_shipping_estimate_with_http_info(create_road_shipping_estimate_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_road_shipping_estimate ...'
end
# verify the required parameter 'create_road_shipping_estimate_request' is set
if @api_client.config.client_side_validation && create_road_shipping_estimate_request.nil?
fail ArgumentError, "Missing the required parameter 'create_road_shipping_estimate_request' when calling EstimatesApi.create_road_shipping_estimate"
end
# resource path
local_var_path = '/v1/estimates/shipping/road'

# query parameters
query_params = opts[:query_params] || {}

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_road_shipping_estimate_request)

# return_type
return_type = opts[:debug_return_type] || 'EstimateResponse'

# auth_names
auth_names = opts[:debug_auth_names] || ['bearer_auth']

new_options = opts.merge(
:operation => :"EstimatesApi.create_road_shipping_estimate",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)

data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: EstimatesApi#create_road_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Creates a GLEC sea shipping estimate given freight mass and logistics
# 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.
# @param create_sea_shipping_estimate_request [CreateSeaShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [EstimateResponse]
def create_sea_shipping_estimate(create_sea_shipping_estimate_request = {}, opts = {})
_create_sea_shipping_estimate_request = Patch::CreateSeaShippingEstimateRequest.new(create_sea_shipping_estimate_request)
data, _status_code, _headers = create_sea_shipping_estimate_with_http_info(_create_sea_shipping_estimate_request, opts)
data
end

# Creates a GLEC sea shipping estimate given freight mass and logistics
# 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.
# @param create_sea_shipping_estimate_request [CreateSeaShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
def create_sea_shipping_estimate_with_http_info(create_sea_shipping_estimate_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_sea_shipping_estimate ...'
end
# verify the required parameter 'create_sea_shipping_estimate_request' is set
if @api_client.config.client_side_validation && create_sea_shipping_estimate_request.nil?
fail ArgumentError, "Missing the required parameter 'create_sea_shipping_estimate_request' when calling EstimatesApi.create_sea_shipping_estimate"
end
# resource path
local_var_path = '/v1/estimates/shipping/sea'

# query parameters
query_params = opts[:query_params] || {}

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_sea_shipping_estimate_request)

# return_type
return_type = opts[:debug_return_type] || 'EstimateResponse'

# auth_names
auth_names = opts[:debug_auth_names] || ['bearer_auth']

new_options = opts.merge(
:operation => :"EstimatesApi.create_sea_shipping_estimate",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)

data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: EstimatesApi#create_sea_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Create a shipping estimate given the distance traveled in meters, package weight, and transportation method.
# Creates a shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters.
# @param create_shipping_estimate_request [CreateShippingEstimateRequest]
Expand Down
10 changes: 4 additions & 6 deletions lib/patch_ruby/api/orders_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def initialize(api_client = ApiClient.default)
# @param [Hash] opts the optional parameters
# @return [OrderResponse]
def cancel_order(id, opts = {})

data, _status_code, _headers = cancel_order_with_http_info(id, opts)
data
end
Expand Down Expand Up @@ -166,9 +165,10 @@ def create_order_with_http_info(create_order_request, opts = {})
# @param [Hash] opts the optional parameters
# @option opts [PlaceOrderRequest] :place_order_request
# @return [OrderResponse]
def place_order(id, place_order_request = {}, opts = {})
_place_order_request = Patch::PlaceOrderRequest.new(place_order_request)
data, _status_code, _headers = place_order_with_http_info(id, opts.merge!({place_order_request: place_order_request}))
def place_order(order_id, opts = {})
place_order_request = Patch::PlaceOrderRequest.new(opts)
opts[:place_order_request] = place_order_request
data, _status_code, _headers = place_order_with_http_info(order_id, opts)
Comment on lines -169 to +171
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@holtbp finding out after the fact, but it looks like it's a change you generated manually, is it?

data
end

Expand Down Expand Up @@ -237,7 +237,6 @@ def place_order_with_http_info(id, opts = {})
# @param [Hash] opts the optional parameters
# @return [OrderResponse]
def retrieve_order(id, opts = {})

data, _status_code, _headers = retrieve_order_with_http_info(id, opts)
data
end
Expand Down Expand Up @@ -304,7 +303,6 @@ def retrieve_order_with_http_info(id, opts = {})
# @option opts [String] :metadata_example2
# @return [OrderListResponse]
def retrieve_orders(opts = {})

data, _status_code, _headers = retrieve_orders_with_http_info(opts)
data
end
Expand Down
2 changes: 1 addition & 1 deletion lib/patch_ruby/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ApiClient
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
def initialize(config = Configuration.default)
@config = config
@user_agent = "patch-ruby/1.23.0"
@user_agent = "patch-ruby/1.24.0"
@default_headers = {
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
Expand Down
Loading