patch_ruby 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -1
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +18 -2
  5. data/Makefile +10 -0
  6. data/README.md +48 -9
  7. data/lib/patch_ruby.rb +2 -0
  8. data/lib/patch_ruby/api/estimates_api.rb +195 -0
  9. data/lib/patch_ruby/models/allocation.rb +10 -0
  10. data/lib/patch_ruby/models/create_mass_estimate_request.rb +47 -1
  11. data/lib/patch_ruby/models/create_order_request.rb +54 -4
  12. data/lib/patch_ruby/models/create_preference_request.rb +7 -0
  13. data/lib/patch_ruby/models/error_response.rb +9 -0
  14. data/lib/patch_ruby/models/estimate.rb +24 -1
  15. data/lib/patch_ruby/models/estimate_list_response.rb +9 -0
  16. data/lib/patch_ruby/models/estimate_response.rb +9 -0
  17. data/lib/patch_ruby/models/meta_index_object.rb +11 -0
  18. data/lib/patch_ruby/models/order.rb +58 -1
  19. data/lib/patch_ruby/models/order_list_response.rb +9 -0
  20. data/lib/patch_ruby/models/order_response.rb +9 -0
  21. data/lib/patch_ruby/models/photo.rb +237 -0
  22. data/lib/patch_ruby/models/preference.rb +10 -0
  23. data/lib/patch_ruby/models/preference_list_response.rb +9 -0
  24. data/lib/patch_ruby/models/preference_response.rb +9 -0
  25. data/lib/patch_ruby/models/project.rb +74 -4
  26. data/lib/patch_ruby/models/project_list_response.rb +9 -0
  27. data/lib/patch_ruby/models/project_response.rb +9 -0
  28. data/lib/patch_ruby/models/standard.rb +254 -0
  29. data/lib/patch_ruby/version.rb +1 -1
  30. data/spec/constants.rb +3 -0
  31. data/spec/factories/allocations.rb +7 -0
  32. data/spec/factories/create_mass_estimate_requests.rb +6 -0
  33. data/spec/factories/create_order_requests.rb +8 -0
  34. data/spec/factories/create_preference_requests.rb +5 -0
  35. data/spec/factories/error_responses.rb +7 -0
  36. data/spec/factories/estimate_list_responses.rb +8 -0
  37. data/spec/factories/estimate_responses.rb +7 -0
  38. data/spec/factories/estimates.rb +8 -0
  39. data/spec/factories/meta_index_objects.rb +6 -0
  40. data/spec/factories/order_list_responses.rb +8 -0
  41. data/spec/factories/order_responses.rb +7 -0
  42. data/spec/factories/orders.rb +12 -0
  43. data/spec/factories/preference_list_responses.rb +8 -0
  44. data/spec/factories/preference_responses.rb +7 -0
  45. data/spec/factories/preferences.rb +7 -0
  46. data/spec/factories/project_list_responses.rb +8 -0
  47. data/spec/factories/project_responses.rb +7 -0
  48. data/spec/factories/projects.rb +15 -0
  49. data/spec/integration/estimates_spec.rb +41 -9
  50. data/spec/integration/orders_spec.rb +42 -5
  51. data/spec/integration/preferences_spec.rb +7 -3
  52. data/spec/integration/projects_spec.rb +19 -1
  53. data/spec/models/allocation_spec.rb +8 -1
  54. data/spec/models/create_mass_estimate_request_spec.rb +7 -1
  55. data/spec/models/create_order_request_spec.rb +7 -1
  56. data/spec/models/create_preference_request_spec.rb +8 -1
  57. data/spec/models/error_response_spec.rb +7 -1
  58. data/spec/models/estimate_list_response_spec.rb +7 -1
  59. data/spec/models/estimate_response_spec.rb +7 -1
  60. data/spec/models/estimate_spec.rb +8 -1
  61. data/spec/models/meta_index_object_spec.rb +7 -1
  62. data/spec/models/order_list_response_spec.rb +7 -1
  63. data/spec/models/order_response_spec.rb +7 -1
  64. data/spec/models/order_spec.rb +18 -1
  65. data/spec/models/preference_list_response_spec.rb +7 -1
  66. data/spec/models/preference_response_spec.rb +7 -1
  67. data/spec/models/preference_spec.rb +7 -1
  68. data/spec/models/project_list_response_spec.rb +7 -1
  69. data/spec/models/project_response_spec.rb +7 -1
  70. data/spec/models/project_spec.rb +21 -1
  71. data/spec/spec_helper.rb +11 -0
  72. data/spec/support/shared/generated_classes.rb +13 -0
  73. metadata +60 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d57ecb3d4eed4573df5b34a2fe8b15abff918db6d50343d483a94daeb832ef0
4
- data.tar.gz: 01ef9aced2b39b3fc83e4139682bf2ef4671cd5a1cf22c04486bb5005a8fae50
3
+ metadata.gz: 1dfa80bf469d57550d91fd6347ecc9b98ea263ea3f07c634f1ad8ad5a0061fef
4
+ data.tar.gz: 2464d81c7fb0256e66ac82957c0e1c4915f1f519b711434fa058d165fba225ec
5
5
  SHA512:
6
- metadata.gz: 915adff1e3f63bd96b7cf1c360914faa8f2bb4d901e8960c459c0f74134385c72906f5eb9f06d4d51cccdc023b01a618c1a438a049b8fa1f39e4373682ec711a
7
- data.tar.gz: 3f16c440a5d2e67c4dc864605d6201b9fb10f0c6c28fd10b821b76758b36b8a319a990f124218515265621550f3db273bd75359b6a4579af3bb132b85d4b994f
6
+ metadata.gz: eedc8a08e6518436a8c275b6d9abd27391f16d18cc83d1301b1234bc118e51bd25b0b650b064325aa3d8ec94b0d11a91a35040d31f36d52bf4ce55332a96e14f
7
+ data.tar.gz: 48bf74563009752e9696617c3134d2716c2e75ba28264f2f7af729c3146767ffcf8020b9904fbe35b83d66f685a0d6b0c018ccb2d9c5ece29231cccf476546fa
data/CHANGELOG.md CHANGED
@@ -5,7 +5,58 @@ 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
- ## [Unreleased]
8
+ ## [1.3.0] - 2021-02-08
9
+
10
+ ### Added
11
+
12
+ - Adds support for creating carbon emission estimates for flights, shipping, and vehicles. See the [docs](https://docs.usepatch.com/#/?id=estimates) for more information.
13
+
14
+ ## [1.2.5] - 2020-01-08
15
+
16
+ ### Fixed
17
+
18
+ - Fixes [issues/5](https://github.com/patch-technology/patch-ruby/issues/5). Adds method `.openapi_nullable` which returns a set with all nullable properties. This method is referenced in `#to_hash` which returns a hash representation of the resource.
19
+ - Removes non-deterministic integration spec that is creating an Estimate with a specific project-id. Since we do not control the test data (yet) and make queries against our Test projects, we cannot be sure that we will have offsets available for a project ID. Instead we can rely on Patch core specs to cover this.
20
+ - Fixes a spec that was failing due to a Patch core change.
21
+ - Add spec factories and refactor generated method specs to shared examples.
22
+
23
+ ## [1.2.4] - 2020-10-14
24
+
25
+ ### Added
26
+
27
+ - `total_price_cents_usd` field to `orders`
28
+ - allows users to create an order by total price
29
+
30
+ ### Changed
31
+
32
+ - order creation requires either `mass_g` or `total_price_cents_usd`, but not both
33
+
34
+ ## [1.2.3] - 2020-10-05
35
+
36
+ ### Added
37
+
38
+ - `patch_fee_cents_usd` field to `orders`
39
+
40
+ ## [1.2.2] - 2020-09-18
41
+
42
+ ### Added
43
+
44
+ - `photos` field to `projects`
45
+
46
+ ## [1.2.1] - 2020-09-18
47
+
48
+ ### Fixed
49
+
50
+ - Fixing an issue related to the OpenApi code generator.
51
+
52
+ ## [1.2.0] - 2020-09-17
53
+
54
+ ### Added
55
+
56
+ - `average_price_per_tonne_cents_usd` field to `projects`
57
+ - `remaining_mass_g` field to `projects`
58
+ - `standard` field to `projects`
59
+ - validations on `mass_g` field (has to be greater than 1 and less than 2,000,000,000).
9
60
 
10
61
  ## [1.1.0] - 2020-08-19
11
62
 
data/Gemfile CHANGED
@@ -6,4 +6,5 @@ group :development, :test do
6
6
  gem 'rake', '~> 13.0.1'
7
7
  gem 'pry-byebug'
8
8
  gem 'rubocop'
9
+ gem 'factory_bot'
9
10
  end
data/Gemfile.lock CHANGED
@@ -1,22 +1,34 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patch_ruby (1.1.0)
4
+ patch_ruby (1.3.0)
5
5
  json (~> 2.1, >= 2.1.0)
6
6
  typhoeus (~> 1.0, >= 1.0.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
+ activesupport (6.1.1)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ zeitwerk (~> 2.3)
11
17
  ast (2.4.1)
12
18
  byebug (11.1.3)
13
19
  coderay (1.1.3)
20
+ concurrent-ruby (1.1.7)
14
21
  diff-lcs (1.4.3)
15
22
  ethon (0.12.0)
16
23
  ffi (>= 1.3.0)
24
+ factory_bot (6.1.0)
25
+ activesupport (>= 5.0.0)
17
26
  ffi (1.13.1)
18
- json (2.3.1)
27
+ i18n (1.8.7)
28
+ concurrent-ruby (~> 1.0)
29
+ json (2.4.1)
19
30
  method_source (1.0.0)
31
+ minitest (5.14.3)
20
32
  parallel (1.19.2)
21
33
  parser (2.7.1.4)
22
34
  ast (~> 2.4.1)
@@ -57,12 +69,16 @@ GEM
57
69
  ruby-progressbar (1.10.1)
58
70
  typhoeus (1.4.0)
59
71
  ethon (>= 0.9.0)
72
+ tzinfo (2.0.4)
73
+ concurrent-ruby (~> 1.0)
60
74
  unicode-display_width (1.7.0)
75
+ zeitwerk (2.4.2)
61
76
 
62
77
  PLATFORMS
63
78
  ruby
64
79
 
65
80
  DEPENDENCIES
81
+ factory_bot
66
82
  patch_ruby!
67
83
  pry-byebug
68
84
  rake (~> 13.0.1)
data/Makefile ADDED
@@ -0,0 +1,10 @@
1
+ SHELL = /bin/bash
2
+
3
+ build:
4
+ rubocop -a && \
5
+ bundle install
6
+
7
+ test:
8
+ bundle exec rspec
9
+
10
+ .PHONY: build test
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  The official Ruby gem for the [Patch API](https://www.usepatch.com)
7
7
 
8
8
  ## Documentation
9
- For a complete API reference, check out [Patch's API Reference.](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml)
9
+ For a complete API reference, check out [Patch's API Reference.](https://docs.usepatch.com/)
10
10
 
11
11
  ## Installation
12
12
 
@@ -38,21 +38,34 @@ require 'patch_ruby'
38
38
 
39
39
  Patch.configure do |config|
40
40
  # Configure the Patch gem with your API key here
41
- config.access_token = ENV['PATCH_RUBY_API_KEY']
41
+ config.access_token = ENV['SANDBOX_API_KEY']
42
42
  end
43
43
  ```
44
44
 
45
45
  ### Orders
46
46
  In Patch, orders represent a purchase of carbon offsets or negative emissions by mass. Place orders directly if you know the amount of carbon dioxide you would like to sequester. If you do not know how much to purchase, use an estimate.
47
47
 
48
- [API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1orders/get)
48
+ In Patch, orders represent a purchase of carbon offsets or negative emissions by mass.
49
+ Place orders directly if you know the amount of carbon dioxide you would like to sequester.
50
+ If you do not know how much to purchase, use an estimate.
51
+ You can also create an order with a maximum desired price, and we'll allocate enough mass to
52
+ fulfill the order for you.
53
+
54
+ [API Reference](https://docs.usepatch.com/#/?id=orders)
49
55
 
50
56
  #### Examples
51
57
  ```ruby
52
- # Create an order
58
+ # Create an order - you can create an order
59
+ # providing either mass_g or total_price_cents_usd, but not both
60
+
61
+ # Create order with mass
53
62
  mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
54
63
  Patch::Order.create_order(mass_g: mass)
55
64
 
65
+ # Create an order with maximum total price
66
+ total_price_cents_usd = 5_00 # Pass in the total price in cents (i.e. 5 dollars)
67
+ Patch::Order.create_order(total_price_cents_usd: total_price_cents_usd)
68
+
56
69
  ## You can also specify a project-id field (optional) to be used instead of the preferred one
57
70
  project_id = 'pro_test_1234' # Pass in the project's ID
58
71
  Patch::Order.create_order(mass_g: mass, project_id: project_id)
@@ -81,14 +94,40 @@ Patch::Order.retrieve_orders(page: page)
81
94
  ### Estimates
82
95
  Estimates allow API users to get a quote for the cost of compensating a certain amount of CO2. When creating an estimate, an order in the `draft` state will also be created, reserving the allocation of a project for 5 minutes. If you don't place your draft order within those 5 minutes, the order will automatically be cancelled.
83
96
 
84
- [API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1estimates/get)
97
+ [API Reference](https://docs.usepatch.com/#/?id=estimates)
85
98
 
86
99
  #### Examples
87
100
  ```ruby
88
- # Create an estimate
101
+ # Create a mass estimate
89
102
  mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
90
103
  Patch::Estimate.create_mass_estimate(mass_g: mass)
91
104
 
105
+ # Create a flight estimate
106
+ distance_m = 1_000_000 # Pass in the distance traveled in meters
107
+ Patch::Estimate.create_flight_estimate(distance_m: distance_m)
108
+
109
+ # Create a shipping estimate
110
+ distance_m = 1_000_000 # Pass in the shipping distance in meters
111
+ package_mass_g = 10_000 # Pass in the weight of the package shipped in grams
112
+ transportation_method = "air" # Pass in the transportation method (air, rail, road, sea)
113
+ Patch::Estimate.create_shipping_estimate(
114
+ distance_m: distance_m,
115
+ package_mass_g: package_mass_g,
116
+ transportation_method: transportation_method
117
+ )
118
+
119
+ # Create a vehicle estimate
120
+ distance_m = 1_000_000 # Pass in the shipping distance in meters
121
+ make = "Toyota" # Pass in the car make
122
+ model = "Corolla" # Pass in the car model
123
+ year = 2000 # Pass in the car year
124
+ Patch::Estimate.create_vehicle_estimate(
125
+ distance_m: distance_m,
126
+ make: make,
127
+ model: model,
128
+ year: year
129
+ )
130
+
92
131
  ## You can also specify a project-id field (optional) to be used instead of the preferred one
93
132
  project_id = 'pro_test_1234' # Pass in the project's ID
94
133
  Patch::Estimate.create_mass_estimate(mass_g: mass, project_id: project_id)
@@ -105,7 +144,7 @@ Patch::Estimate.retrieve_estimates(page: page)
105
144
  ### Projects
106
145
  Projects are the ways Patch takes CO2 out of the air. They can represent reforestation, enhanced weathering, direct air carbon capture, etc. When you place an order via Patch, it is allocated to a project.
107
146
 
108
- [API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1projects/get)
147
+ [API Reference](https://docs.usepatch.com/#/?id=projects)
109
148
 
110
149
  #### Examples
111
150
  ```ruby
@@ -121,7 +160,7 @@ Patch::Project.retrieve_projects(page: page)
121
160
  ### Preferences
122
161
  Preferences are how you route your orders in Patch. If you don't have a preference, Patch will allocate your order to the least expensive option. If you do have a preference, all of your orders will be sent to that project. You can set your preferences via API, or through the [Patch Dashboard](https://dashboard.usepatch.com/projects).
123
162
 
124
- [API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1preferences/post)
163
+ [API Reference](https://docs.usepatch.com/#/?id=preferences)
125
164
 
126
165
  #### Examples
127
166
  ```ruby
@@ -161,7 +200,7 @@ $ bundle install
161
200
 
162
201
  Set up required environment variables:
163
202
  ```
164
- $ export PATCH_RUBY_API_KEY=<SANDBOX API KEY>
203
+ $ export SANDBOX_API_KEY=<SANDBOX API KEY>
165
204
  ```
166
205
 
167
206
  Run tests:
data/lib/patch_ruby.rb CHANGED
@@ -29,12 +29,14 @@ require 'patch_ruby/models/meta_index_object'
29
29
  require 'patch_ruby/models/order'
30
30
  require 'patch_ruby/models/order_list_response'
31
31
  require 'patch_ruby/models/order_response'
32
+ require 'patch_ruby/models/photo'
32
33
  require 'patch_ruby/models/preference'
33
34
  require 'patch_ruby/models/preference_list_response'
34
35
  require 'patch_ruby/models/preference_response'
35
36
  require 'patch_ruby/models/project'
36
37
  require 'patch_ruby/models/project_list_response'
37
38
  require 'patch_ruby/models/project_response'
39
+ require 'patch_ruby/models/standard'
38
40
 
39
41
  # APIs
40
42
  require 'patch_ruby/api/estimates_api'
@@ -15,7 +15,10 @@ require 'cgi'
15
15
  module Patch
16
16
  class EstimatesApi
17
17
  OPERATIONS = [
18
+ :create_flight_estimate,
18
19
  :create_mass_estimate,
20
+ :create_shipping_estimate,
21
+ :create_vehicle_estimate,
19
22
  :retrieve_estimate,
20
23
  :retrieve_estimates,
21
24
  ]
@@ -25,6 +28,70 @@ module Patch
25
28
  def initialize(api_client = ApiClient.default)
26
29
  @api_client = api_client
27
30
  end
31
+ # Create a flight estimate given the distance traveled in meters
32
+ # 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.
33
+ # @param create_flight_estimate_request [CreateFlightEstimateRequest]
34
+ # @param [Hash] opts the optional parameters
35
+ # @return [EstimateResponse]
36
+ def create_flight_estimate(create_flight_estimate_request, opts = {})
37
+ data, _status_code, _headers = create_flight_estimate_with_http_info(create_flight_estimate_request, opts)
38
+ data
39
+ end
40
+
41
+ # Create a flight estimate given the distance traveled in meters
42
+ # Creates a flight 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.
43
+ # @param create_flight_estimate_request [CreateFlightEstimateRequest]
44
+ # @param [Hash] opts the optional parameters
45
+ # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
46
+ def create_flight_estimate_with_http_info(create_flight_estimate_request, opts = {})
47
+ if @api_client.config.debugging
48
+ @api_client.config.logger.debug 'Calling API: EstimatesApi.create_flight_estimate ...'
49
+ end
50
+ # verify the required parameter 'create_flight_estimate_request' is set
51
+ if @api_client.config.client_side_validation && create_flight_estimate_request.nil?
52
+ fail ArgumentError, "Missing the required parameter 'create_flight_estimate_request' when calling EstimatesApi.create_flight_estimate"
53
+ end
54
+ # resource path
55
+ local_var_path = '/v1/estimates/flight'
56
+
57
+ # query parameters
58
+ query_params = opts[:query_params] || {}
59
+
60
+ # header parameters
61
+ header_params = opts[:header_params] || {}
62
+ # HTTP header 'Accept' (if needed)
63
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
64
+ # HTTP header 'Content-Type'
65
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
66
+
67
+ # form parameters
68
+ form_params = opts[:form_params] || {}
69
+
70
+ # http body (model)
71
+ post_body = opts[:body] || @api_client.object_to_http_body(create_flight_estimate_request)
72
+
73
+ # return_type
74
+ return_type = opts[:return_type] || 'EstimateResponse'
75
+
76
+ # auth_names
77
+ auth_names = opts[:auth_names] || ['bearer_auth']
78
+
79
+ new_options = opts.merge(
80
+ :header_params => header_params,
81
+ :query_params => query_params,
82
+ :form_params => form_params,
83
+ :body => post_body,
84
+ :auth_names => auth_names,
85
+ :return_type => return_type
86
+ )
87
+
88
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
89
+ if @api_client.config.debugging
90
+ @api_client.config.logger.debug "API called: EstimatesApi#create_flight_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
91
+ end
92
+ return data, status_code, headers
93
+ end
94
+
28
95
  # Create an estimate based on mass of CO2
29
96
  # 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.
30
97
  # @param create_mass_estimate_request [CreateMassEstimateRequest]
@@ -89,6 +156,134 @@ module Patch
89
156
  return data, status_code, headers
90
157
  end
91
158
 
159
+ # Create a shipping estimate given the distance traveled in meters, package weight, and transportation method.
160
+ # 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.
161
+ # @param create_shipping_estimate_request [CreateShippingEstimateRequest]
162
+ # @param [Hash] opts the optional parameters
163
+ # @return [EstimateResponse]
164
+ def create_shipping_estimate(create_shipping_estimate_request, opts = {})
165
+ data, _status_code, _headers = create_shipping_estimate_with_http_info(create_shipping_estimate_request, opts)
166
+ data
167
+ end
168
+
169
+ # Create a shipping estimate given the distance traveled in meters, package weight, and transportation method.
170
+ # Creates a 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.
171
+ # @param create_shipping_estimate_request [CreateShippingEstimateRequest]
172
+ # @param [Hash] opts the optional parameters
173
+ # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
174
+ def create_shipping_estimate_with_http_info(create_shipping_estimate_request, opts = {})
175
+ if @api_client.config.debugging
176
+ @api_client.config.logger.debug 'Calling API: EstimatesApi.create_shipping_estimate ...'
177
+ end
178
+ # verify the required parameter 'create_shipping_estimate_request' is set
179
+ if @api_client.config.client_side_validation && create_shipping_estimate_request.nil?
180
+ fail ArgumentError, "Missing the required parameter 'create_shipping_estimate_request' when calling EstimatesApi.create_shipping_estimate"
181
+ end
182
+ # resource path
183
+ local_var_path = '/v1/estimates/shipping'
184
+
185
+ # query parameters
186
+ query_params = opts[:query_params] || {}
187
+
188
+ # header parameters
189
+ header_params = opts[:header_params] || {}
190
+ # HTTP header 'Accept' (if needed)
191
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
192
+ # HTTP header 'Content-Type'
193
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
194
+
195
+ # form parameters
196
+ form_params = opts[:form_params] || {}
197
+
198
+ # http body (model)
199
+ post_body = opts[:body] || @api_client.object_to_http_body(create_shipping_estimate_request)
200
+
201
+ # return_type
202
+ return_type = opts[:return_type] || 'EstimateResponse'
203
+
204
+ # auth_names
205
+ auth_names = opts[:auth_names] || ['bearer_auth']
206
+
207
+ new_options = opts.merge(
208
+ :header_params => header_params,
209
+ :query_params => query_params,
210
+ :form_params => form_params,
211
+ :body => post_body,
212
+ :auth_names => auth_names,
213
+ :return_type => return_type
214
+ )
215
+
216
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
217
+ if @api_client.config.debugging
218
+ @api_client.config.logger.debug "API called: EstimatesApi#create_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
219
+ end
220
+ return data, status_code, headers
221
+ end
222
+
223
+ # Create a vehicle estimate given the distance traveled in meters and the type of vehicle
224
+ # Creates an estimate and calculates the amount of CO2 to be compensated depending on the distance and the vehicle. An order in the `draft` state may be created based on the parameters, linked to the estimate.
225
+ # @param create_vehicle_estimate_request [CreateVehicleEstimateRequest]
226
+ # @param [Hash] opts the optional parameters
227
+ # @return [EstimateResponse]
228
+ def create_vehicle_estimate(create_vehicle_estimate_request, opts = {})
229
+ data, _status_code, _headers = create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, opts)
230
+ data
231
+ end
232
+
233
+ # Create a vehicle estimate given the distance traveled in meters and the type of vehicle
234
+ # Creates an estimate and calculates the amount of CO2 to be compensated depending on the distance and the vehicle. An order in the &#x60;draft&#x60; state may be created based on the parameters, linked to the estimate.
235
+ # @param create_vehicle_estimate_request [CreateVehicleEstimateRequest]
236
+ # @param [Hash] opts the optional parameters
237
+ # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
238
+ def create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, opts = {})
239
+ if @api_client.config.debugging
240
+ @api_client.config.logger.debug 'Calling API: EstimatesApi.create_vehicle_estimate ...'
241
+ end
242
+ # verify the required parameter 'create_vehicle_estimate_request' is set
243
+ if @api_client.config.client_side_validation && create_vehicle_estimate_request.nil?
244
+ fail ArgumentError, "Missing the required parameter 'create_vehicle_estimate_request' when calling EstimatesApi.create_vehicle_estimate"
245
+ end
246
+ # resource path
247
+ local_var_path = '/v1/estimates/vehicle'
248
+
249
+ # query parameters
250
+ query_params = opts[:query_params] || {}
251
+
252
+ # header parameters
253
+ header_params = opts[:header_params] || {}
254
+ # HTTP header 'Accept' (if needed)
255
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
256
+ # HTTP header 'Content-Type'
257
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
258
+
259
+ # form parameters
260
+ form_params = opts[:form_params] || {}
261
+
262
+ # http body (model)
263
+ post_body = opts[:body] || @api_client.object_to_http_body(create_vehicle_estimate_request)
264
+
265
+ # return_type
266
+ return_type = opts[:return_type] || 'EstimateResponse'
267
+
268
+ # auth_names
269
+ auth_names = opts[:auth_names] || ['bearer_auth']
270
+
271
+ new_options = opts.merge(
272
+ :header_params => header_params,
273
+ :query_params => query_params,
274
+ :form_params => form_params,
275
+ :body => post_body,
276
+ :auth_names => auth_names,
277
+ :return_type => return_type
278
+ )
279
+
280
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
281
+ if @api_client.config.debugging
282
+ @api_client.config.logger.debug "API called: EstimatesApi#create_vehicle_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
283
+ end
284
+ return data, status_code, headers
285
+ end
286
+
92
287
  # Retrieves an estimate
93
288
  # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for.
94
289
  # @param id [String]