patch_ruby 1.2.5 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -2
- data/Gemfile.lock +4 -4
- data/README.md +72 -8
- data/lib/patch_ruby.rb +1 -0
- data/lib/patch_ruby/api/estimates_api.rb +195 -0
- data/lib/patch_ruby/api/projects_api.rb +9 -0
- data/lib/patch_ruby/configuration.rb +2 -2
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +17 -6
- data/lib/patch_ruby/models/create_order_request.rb +5 -5
- data/lib/patch_ruby/models/estimate.rb +13 -3
- data/lib/patch_ruby/models/order.rb +5 -5
- data/lib/patch_ruby/models/photo.rb +4 -0
- data/lib/patch_ruby/models/project.rb +21 -7
- data/lib/patch_ruby/models/sdg.rb +269 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/patch_ruby.gemspec +1 -1
- data/spec/configuration_spec.rb +3 -3
- data/spec/integration/estimates_spec.rb +55 -0
- data/spec/integration/orders_spec.rb +6 -5
- data/spec/integration/preferences_spec.rb +6 -2
- data/spec/integration/projects_spec.rb +20 -0
- data/spec/models/create_mass_estimate_request_spec.rb +1 -1
- data/spec/models/project_spec.rb +1 -1
- data/spec/patch_ruby_spec.rb +18 -0
- metadata +35 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc6db1f9c2667e24cdcc6e9d1e0f3b4866572a98ffe6131329772cc75c140aa4
|
4
|
+
data.tar.gz: d3db3c6c7ac66a2b41516a52187a373cc8fa8efa9df1bd12e7cb163d6b83a31f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f63cd496d573267bb060c8470ae80856b1b1865a28aea4bbd800866ae19612b05aaf6177cdd5e3155707817d594900dc68a61c014c3485b43615d02090495599
|
7
|
+
data.tar.gz: fa029a9b055376f7b7c0f873691f5adf1530fbd72548aa505d384bf4ceabd8f4a769eb0c90f46c53cff71e198af144ac0ec3a344e48c2b63aa772d6c912824b9
|
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,41 @@ 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
|
-
## [
|
8
|
+
## [1.5.2] - 2021-03-30
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Updated the value validation for certain parameters to match the API
|
13
|
+
- Added the `renewables` type
|
14
|
+
|
15
|
+
## [1.5.1] - 2021-03-02
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
|
19
|
+
- Fixed a `NameError` that was thrown when `Patch::Sdg` was called. Specs have been added to ensure this does not happen again.
|
20
|
+
|
21
|
+
## [1.5.0] - 2021-03-01
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Changed base URL from https://api.usepatch.com to https://api.patch.io
|
26
|
+
|
27
|
+
## [1.4.0] - 2021-02-15
|
28
|
+
|
29
|
+
### Added
|
30
|
+
|
31
|
+
- Adds Sustainable Development Goals (SDGs) field to projects
|
32
|
+
- Adds filtering to Projects by country, type, minimum_available_mass
|
33
|
+
|
34
|
+
### Changed
|
35
|
+
|
36
|
+
- vehicle estimates now support optional `make`, `model` and `year` fields.
|
37
|
+
|
38
|
+
## [1.3.0] - 2021-02-08
|
39
|
+
|
40
|
+
### Added
|
41
|
+
|
42
|
+
- Adds support for creating carbon emission estimates for flights, shipping, and vehicles. See the [docs](https://docs.patch.io/#/?id=estimates) for more information.
|
9
43
|
|
10
44
|
## [1.2.5] - 2020-01-08
|
11
45
|
|
@@ -75,4 +109,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
75
109
|
|
76
110
|
- Pre-release of v1 Gem
|
77
111
|
- Adds support for Orders, Estimates, Projects and Preferences
|
78
|
-
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
patch_ruby (1.2
|
4
|
+
patch_ruby (1.5.2)
|
5
5
|
json (~> 2.1, >= 2.1.0)
|
6
6
|
typhoeus (~> 1.0, >= 1.0.1)
|
7
7
|
|
@@ -23,10 +23,10 @@ GEM
|
|
23
23
|
ffi (>= 1.3.0)
|
24
24
|
factory_bot (6.1.0)
|
25
25
|
activesupport (>= 5.0.0)
|
26
|
-
ffi (1.
|
26
|
+
ffi (1.15.0)
|
27
27
|
i18n (1.8.7)
|
28
28
|
concurrent-ruby (~> 1.0)
|
29
|
-
json (2.
|
29
|
+
json (2.5.1)
|
30
30
|
method_source (1.0.0)
|
31
31
|
minitest (5.14.3)
|
32
32
|
parallel (1.19.2)
|
@@ -86,4 +86,4 @@ DEPENDENCIES
|
|
86
86
|
rubocop
|
87
87
|
|
88
88
|
BUNDLED WITH
|
89
|
-
2.
|
89
|
+
2.2.14
|
data/README.md
CHANGED
@@ -1,31 +1,37 @@
|
|
1
1
|
# Patch Ruby SDK
|
2
|
+
|
2
3
|
![Test](https://github.com/patch-technology/patch-ruby/workflows/Test/badge.svg)
|
3
4
|
[![Gem Version](https://badge.fury.io/rb/patch_ruby.svg)](https://badge.fury.io/rb/patch_ruby)
|
4
5
|
[![Discord](https://img.shields.io/discord/733029448558837792)](https://discord.gg/AU8543D)
|
5
6
|
|
6
|
-
The official Ruby gem for the [Patch API](https://www.
|
7
|
+
The official Ruby gem for the [Patch API](https://www.patch.io)
|
7
8
|
|
8
9
|
## Documentation
|
9
|
-
|
10
|
+
|
11
|
+
For a complete API reference, check out [Patch's API Reference.](https://docs.patch.io/)
|
10
12
|
|
11
13
|
## Installation
|
12
14
|
|
13
15
|
Add the gem to your Gemfile:
|
16
|
+
|
14
17
|
```ruby
|
15
18
|
gem 'patch_ruby'
|
16
19
|
```
|
17
20
|
|
18
21
|
Then run:
|
22
|
+
|
19
23
|
```shell
|
20
24
|
bundle
|
21
25
|
```
|
22
26
|
|
23
27
|
Or install it directly with
|
28
|
+
|
24
29
|
```shell
|
25
30
|
gem install patch_ruby
|
26
31
|
```
|
27
32
|
|
28
33
|
### Requirements
|
34
|
+
|
29
35
|
- Ruby 1.9+
|
30
36
|
|
31
37
|
## Usage
|
@@ -33,6 +39,7 @@ gem install patch_ruby
|
|
33
39
|
### Configuration
|
34
40
|
|
35
41
|
After installing the gem, you'll have to configure it with your API key which is available from the API key page in the Patch dashboard:
|
42
|
+
|
36
43
|
```ruby
|
37
44
|
require 'patch_ruby'
|
38
45
|
|
@@ -43,6 +50,7 @@ end
|
|
43
50
|
```
|
44
51
|
|
45
52
|
### Orders
|
53
|
+
|
46
54
|
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
55
|
|
48
56
|
In Patch, orders represent a purchase of carbon offsets or negative emissions by mass.
|
@@ -51,9 +59,10 @@ If you do not know how much to purchase, use an estimate.
|
|
51
59
|
You can also create an order with a maximum desired price, and we'll allocate enough mass to
|
52
60
|
fulfill the order for you.
|
53
61
|
|
54
|
-
[API Reference](https://docs.
|
62
|
+
[API Reference](https://docs.patch.io/#/?id=orders)
|
55
63
|
|
56
64
|
#### Examples
|
65
|
+
|
57
66
|
```ruby
|
58
67
|
# Create an order - you can create an order
|
59
68
|
# providing either mass_g or total_price_cents_usd, but not both
|
@@ -92,16 +101,44 @@ Patch::Order.retrieve_orders(page: page)
|
|
92
101
|
```
|
93
102
|
|
94
103
|
### Estimates
|
104
|
+
|
95
105
|
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.
|
96
106
|
|
97
|
-
[API Reference](https://docs.
|
107
|
+
[API Reference](https://docs.patch.io/#/?id=estimates)
|
98
108
|
|
99
109
|
#### Examples
|
110
|
+
|
100
111
|
```ruby
|
101
|
-
# Create
|
112
|
+
# Create a mass estimate
|
102
113
|
mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
|
103
114
|
Patch::Estimate.create_mass_estimate(mass_g: mass)
|
104
115
|
|
116
|
+
# Create a flight estimate
|
117
|
+
distance_m = 1_000_000 # Pass in the distance traveled in meters
|
118
|
+
Patch::Estimate.create_flight_estimate(distance_m: distance_m)
|
119
|
+
|
120
|
+
# Create a shipping estimate
|
121
|
+
distance_m = 1_000_000 # Pass in the shipping distance in meters
|
122
|
+
package_mass_g = 10_000 # Pass in the weight of the package shipped in grams
|
123
|
+
transportation_method = "air" # Pass in the transportation method (air, rail, road, sea)
|
124
|
+
Patch::Estimate.create_shipping_estimate(
|
125
|
+
distance_m: distance_m,
|
126
|
+
package_mass_g: package_mass_g,
|
127
|
+
transportation_method: transportation_method
|
128
|
+
)
|
129
|
+
|
130
|
+
# Create a vehicle estimate
|
131
|
+
distance_m = 1_000_000 # Pass in the shipping distance in meters
|
132
|
+
make = "Toyota" # Pass in the car make
|
133
|
+
model = "Corolla" # Pass in the car model
|
134
|
+
year = 2000 # Pass in the car year
|
135
|
+
Patch::Estimate.create_vehicle_estimate(
|
136
|
+
distance_m: distance_m,
|
137
|
+
make: make,
|
138
|
+
model: model,
|
139
|
+
year: year
|
140
|
+
)
|
141
|
+
|
105
142
|
## You can also specify a project-id field (optional) to be used instead of the preferred one
|
106
143
|
project_id = 'pro_test_1234' # Pass in the project's ID
|
107
144
|
Patch::Estimate.create_mass_estimate(mass_g: mass, project_id: project_id)
|
@@ -116,11 +153,19 @@ Patch::Estimate.retrieve_estimates(page: page)
|
|
116
153
|
```
|
117
154
|
|
118
155
|
### Projects
|
156
|
+
|
119
157
|
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.
|
120
158
|
|
121
|
-
|
159
|
+
When fetching Projects, you can add filters to the query to narrow the result. Currently supported filters are:
|
160
|
+
|
161
|
+
- `country`
|
162
|
+
- `type`
|
163
|
+
- `minimum_available_mass`
|
164
|
+
|
165
|
+
[API Reference](https://docs.patch.io/#/?id=projects)
|
122
166
|
|
123
167
|
#### Examples
|
168
|
+
|
124
169
|
```ruby
|
125
170
|
# Retrieve a project
|
126
171
|
project_id = 'pro_test_1234' # Pass in the project's ID
|
@@ -129,14 +174,28 @@ Patch::Project.retrieve_project(project_id)
|
|
129
174
|
# Retrieve a list of projects
|
130
175
|
page = 1 # Pass in which page of projects you'd like
|
131
176
|
Patch::Project.retrieve_projects(page: page)
|
177
|
+
|
178
|
+
# Retrieve all projects from the United States
|
179
|
+
country = 'US'
|
180
|
+
Patch::Project.retrieve_projects(country: country)
|
181
|
+
|
182
|
+
# Retrieve all biomass projects
|
183
|
+
type = 'biomass'
|
184
|
+
Patch::Project.retrieve_projects(type: type)
|
185
|
+
|
186
|
+
# Retrieve a list of projects with at least 100 grams of available offsets
|
187
|
+
minimum_available_mass = 100
|
188
|
+
Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
|
132
189
|
```
|
133
190
|
|
134
191
|
### Preferences
|
135
|
-
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).
|
136
192
|
|
137
|
-
|
193
|
+
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.patch.io/projects).
|
194
|
+
|
195
|
+
[API Reference](https://docs.patch.io/#/?id=preferences)
|
138
196
|
|
139
197
|
#### Examples
|
198
|
+
|
140
199
|
```ruby
|
141
200
|
# Create a preference
|
142
201
|
project_id = 'pro_test_1234' # Pass in the project_id for your preference
|
@@ -158,26 +217,31 @@ Patch::Preference.retrieve_preferences(page: page)
|
|
158
217
|
## Development
|
159
218
|
|
160
219
|
To build the gem locally, run:
|
220
|
+
|
161
221
|
```
|
162
222
|
$ gem build patch_ruby.gemspec
|
163
223
|
```
|
164
224
|
|
165
225
|
This will create a .gem file. To install the local gem:
|
226
|
+
|
166
227
|
```
|
167
228
|
$ gem install patch_ruby-1.x.x.gem
|
168
229
|
```
|
169
230
|
|
170
231
|
Install dependencies:
|
232
|
+
|
171
233
|
```
|
172
234
|
$ bundle install
|
173
235
|
```
|
174
236
|
|
175
237
|
Set up required environment variables:
|
238
|
+
|
176
239
|
```
|
177
240
|
$ export SANDBOX_API_KEY=<SANDBOX API KEY>
|
178
241
|
```
|
179
242
|
|
180
243
|
Run tests:
|
244
|
+
|
181
245
|
```
|
182
246
|
$ bundle exec rspec
|
183
247
|
```
|
data/lib/patch_ruby.rb
CHANGED
@@ -36,6 +36,7 @@ require 'patch_ruby/models/preference_response'
|
|
36
36
|
require 'patch_ruby/models/project'
|
37
37
|
require 'patch_ruby/models/project_list_response'
|
38
38
|
require 'patch_ruby/models/project_response'
|
39
|
+
require 'patch_ruby/models/sdg'
|
39
40
|
require 'patch_ruby/models/standard'
|
40
41
|
|
41
42
|
# APIs
|
@@ -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 `draft` 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 `draft` 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 `draft` 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]
|