Skip to content

Commit

Permalink
Add Hotel estimate method (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
kleinjm authored Apr 5, 2022
1 parent 8770ce7 commit d3063a9
Show file tree
Hide file tree
Showing 8 changed files with 397 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ 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.19.0] - 2022-04-05

### Added

- Adds `Patch::Estimate.create_hotel_estimate` method

## [1.18.0] - 2022-03-22

### Changed

- Adds optional `state` field to `order` creation
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.18.0)
patch_ruby (1.19.0)
typhoeus (~> 1.0, >= 1.0.1)

GEM
Expand Down
1 change: 1 addition & 0 deletions lib/patch_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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_shipping_estimate_request'
Expand Down
70 changes: 70 additions & 0 deletions lib/patch_ruby/api/estimates_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class EstimatesApi
:create_bitcoin_estimate,
:create_ethereum_estimate,
:create_flight_estimate,
:create_hotel_estimate,
:create_mass_estimate,
:create_shipping_estimate,
:create_vehicle_estimate,
Expand Down Expand Up @@ -237,6 +238,75 @@ def create_flight_estimate_with_http_info(create_flight_estimate_request, opts =
return data, status_code, headers
end

# Create a hotel estimate.
# 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.
# @param create_hotel_estimate_request [CreateHotelEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [EstimateResponse]
def create_hotel_estimate(create_hotel_estimate_request = {}, opts = {})
_create_hotel_estimate_request = Patch::CreateHotelEstimateRequest.new(create_hotel_estimate_request)
data, _status_code, _headers = create_hotel_estimate_with_http_info(_create_hotel_estimate_request, opts)
data
end

# Create a hotel estimate.
# 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.
# @param create_hotel_estimate_request [CreateHotelEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
def create_hotel_estimate_with_http_info(create_hotel_estimate_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_hotel_estimate ...'
end
# verify the required parameter 'create_hotel_estimate_request' is set
if @api_client.config.client_side_validation && create_hotel_estimate_request.nil?
fail ArgumentError, "Missing the required parameter 'create_hotel_estimate_request' when calling EstimatesApi.create_hotel_estimate"
end
# resource path
local_var_path = '/v1/estimates/hotel'

# 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_hotel_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_hotel_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_hotel_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Create an estimate based on mass of CO2
# 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.
# @param create_mass_estimate_request [CreateMassEstimateRequest]
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.18.0"
@user_agent = "patch-ruby/1.19.0"
@default_headers = {
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
Expand Down
Loading

0 comments on commit d3063a9

Please sign in to comment.