patch_ruby 1.2.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -2
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +19 -3
  5. data/Makefile +10 -0
  6. data/README.md +61 -4
  7. data/lib/patch_ruby/api/estimates_api.rb +195 -0
  8. data/lib/patch_ruby/api/projects_api.rb +9 -0
  9. data/lib/patch_ruby/models/allocation.rb +10 -0
  10. data/lib/patch_ruby/models/create_mass_estimate_request.rb +19 -1
  11. data/lib/patch_ruby/models/create_order_request.rb +38 -16
  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 +30 -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 +30 -4
  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 +40 -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/sdg.rb +269 -0
  29. data/lib/patch_ruby/models/standard.rb +10 -0
  30. data/lib/patch_ruby/version.rb +1 -1
  31. data/spec/constants.rb +3 -0
  32. data/spec/factories/allocations.rb +7 -0
  33. data/spec/factories/create_mass_estimate_requests.rb +6 -0
  34. data/spec/factories/create_order_requests.rb +8 -0
  35. data/spec/factories/create_preference_requests.rb +5 -0
  36. data/spec/factories/error_responses.rb +7 -0
  37. data/spec/factories/estimate_list_responses.rb +8 -0
  38. data/spec/factories/estimate_responses.rb +7 -0
  39. data/spec/factories/estimates.rb +8 -0
  40. data/spec/factories/meta_index_objects.rb +6 -0
  41. data/spec/factories/order_list_responses.rb +8 -0
  42. data/spec/factories/order_responses.rb +7 -0
  43. data/spec/factories/orders.rb +12 -0
  44. data/spec/factories/preference_list_responses.rb +8 -0
  45. data/spec/factories/preference_responses.rb +7 -0
  46. data/spec/factories/preferences.rb +7 -0
  47. data/spec/factories/project_list_responses.rb +8 -0
  48. data/spec/factories/project_responses.rb +7 -0
  49. data/spec/factories/projects.rb +15 -0
  50. data/spec/integration/estimates_spec.rb +53 -9
  51. data/spec/integration/orders_spec.rb +42 -5
  52. data/spec/integration/preferences_spec.rb +7 -3
  53. data/spec/integration/projects_spec.rb +21 -1
  54. data/spec/models/allocation_spec.rb +8 -1
  55. data/spec/models/create_mass_estimate_request_spec.rb +7 -1
  56. data/spec/models/create_order_request_spec.rb +7 -1
  57. data/spec/models/create_preference_request_spec.rb +8 -1
  58. data/spec/models/error_response_spec.rb +7 -1
  59. data/spec/models/estimate_list_response_spec.rb +7 -1
  60. data/spec/models/estimate_response_spec.rb +7 -1
  61. data/spec/models/estimate_spec.rb +8 -1
  62. data/spec/models/meta_index_object_spec.rb +7 -1
  63. data/spec/models/order_list_response_spec.rb +7 -1
  64. data/spec/models/order_response_spec.rb +7 -1
  65. data/spec/models/order_spec.rb +18 -1
  66. data/spec/models/preference_list_response_spec.rb +7 -1
  67. data/spec/models/preference_response_spec.rb +7 -1
  68. data/spec/models/preference_spec.rb +7 -1
  69. data/spec/models/project_list_response_spec.rb +7 -1
  70. data/spec/models/project_response_spec.rb +7 -1
  71. data/spec/models/project_spec.rb +21 -1
  72. data/spec/spec_helper.rb +11 -0
  73. data/spec/support/shared/generated_classes.rb +13 -0
  74. metadata +56 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c6fea9c586a5bafe867ad4910ca99e8d794eceb17965adbca02f5767f986b69
4
- data.tar.gz: f4afe79ee1e0afdede909be37c1f0aa6b56e4fc018e35a9f2cad3c6d886e6f12
3
+ metadata.gz: 01dd6e1760357bf0a43bc0244e3bd6dddb5dbfe30917f5882e78faf8e76b0c70
4
+ data.tar.gz: be17b49e72c7132fbc7a4b6a5dbe19704eda14fd17ef5dc4a89c7fdbd154547a
5
5
  SHA512:
6
- metadata.gz: 9e8f1dadfd649f383d4961ff69bf00392972c5c6eac5cf78d51203965771245c5b8e44e8a4be76a3a3779fb41f020403f8d86596e62ddc6baf17e279d521a96b
7
- data.tar.gz: a46785a949700cfa7268424959162baabae59a959254a3a057ae0cddda972e5ad7d71a4b1bbe46abfa1943767752b612c01900c1229260105bc459cc4f07fe46
6
+ metadata.gz: 04d0e212d6aac27ebf643a1800e2a34ac3b9f2f37c5439e3497bf2d690cf106f01899e59efbafa7b9e6ab01de76b25603e83e469e0462c8a091e81a3e8130acb
7
+ data.tar.gz: '08d93d9433299ba112efca8ecd0a1838016684cb05a2b3a80d8c44249c2fda6ed7dc6f1684bad9b5f37a3121ab7ab2a60bd91ab0a5566d8c85e4863cd8f7dccc'
data/CHANGELOG.md CHANGED
@@ -5,7 +5,48 @@ 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.4.0] - 2021-02-15
9
+
10
+ ### Added
11
+
12
+ - Adds Sustainable Development Goals (SDGs) field to projects
13
+ - Adds filtering to Projects by country, type, minimum_available_mass
14
+
15
+ ### Changed
16
+
17
+ - vehicle estimates now support optional `make`, `model` and `year` fields.
18
+
19
+ ## [1.3.0] - 2021-02-08
20
+
21
+ ### Added
22
+
23
+ - Adds support for creating carbon emission estimates for flights, shipping, and vehicles. See the [docs](https://docs.usepatch.com/#/?id=estimates) for more information.
24
+
25
+ ## [1.2.5] - 2020-01-08
26
+
27
+ ### Fixed
28
+
29
+ - 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.
30
+ - 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.
31
+ - Fixes a spec that was failing due to a Patch core change.
32
+ - Add spec factories and refactor generated method specs to shared examples.
33
+
34
+ ## [1.2.4] - 2020-10-14
35
+
36
+ ### Added
37
+
38
+ - `total_price_cents_usd` field to `orders`
39
+ - allows users to create an order by total price
40
+
41
+ ### Changed
42
+
43
+ - order creation requires either `mass_g` or `total_price_cents_usd`, but not both
44
+
45
+ ## [1.2.3] - 2020-10-05
46
+
47
+ ### Added
48
+
49
+ - `patch_fee_cents_usd` field to `orders`
9
50
 
10
51
  ## [1.2.2] - 2020-09-18
11
52
 
@@ -49,4 +90,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
49
90
 
50
91
  - Pre-release of v1 Gem
51
92
  - Adds support for Orders, Estimates, Projects and Preferences
52
-
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.2.2)
4
+ patch_ruby (1.4.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)
17
- ffi (1.13.1)
18
- json (2.3.1)
24
+ factory_bot (6.1.0)
25
+ activesupport (>= 5.0.0)
26
+ ffi (1.14.2)
27
+ i18n (1.8.7)
28
+ concurrent-ruby (~> 1.0)
29
+ json (2.5.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
@@ -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
+ 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
+
48
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)
@@ -85,10 +98,36 @@ Estimates allow API users to get a quote for the cost of compensating a certain
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,6 +144,12 @@ 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
 
147
+ When fetching Projects, you can add filters to the query to narrow the result. Currently supported filters are:
148
+
149
+ - `country`
150
+ - `type`
151
+ - `minimum_available_mass`
152
+
108
153
  [API Reference](https://docs.usepatch.com/#/?id=projects)
109
154
 
110
155
  #### Examples
@@ -116,6 +161,18 @@ Patch::Project.retrieve_project(project_id)
116
161
  # Retrieve a list of projects
117
162
  page = 1 # Pass in which page of projects you'd like
118
163
  Patch::Project.retrieve_projects(page: page)
164
+
165
+ # Retrieve all projects from the United States
166
+ country = 'US'
167
+ Patch::Project.retrieve_projects(country: country)
168
+
169
+ # Retrieve all biomass projects
170
+ type = 'biomass'
171
+ Patch::Project.retrieve_projects(type: type)
172
+
173
+ # Retrieve a list of projects with at least 100 grams of available offsets
174
+ minimum_available_mass = 100
175
+ Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
119
176
  ```
120
177
 
121
178
  ### Preferences
@@ -161,7 +218,7 @@ $ bundle install
161
218
 
162
219
  Set up required environment variables:
163
220
  ```
164
- $ export PATCH_RUBY_API_KEY=<SANDBOX API KEY>
221
+ $ export SANDBOX_API_KEY=<SANDBOX API KEY>
165
222
  ```
166
223
 
167
224
  Run tests:
@@ -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]