patch_ruby 1.22.0 → 1.24.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +1 -1
- data/README.md +32 -2
- data/lib/patch_ruby/api/estimates_api.rb +287 -7
- data/lib/patch_ruby/api/orders_api.rb +11 -4
- data/lib/patch_ruby/api/projects_api.rb +2 -2
- data/lib/patch_ruby/api_client.rb +1 -1
- data/lib/patch_ruby/models/allocation.rb +1 -1
- data/lib/patch_ruby/models/create_air_shipping_estimate_request.rb +374 -0
- data/lib/patch_ruby/models/create_order_request.rb +16 -7
- data/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb +404 -0
- data/lib/patch_ruby/models/create_road_shipping_estimate_request.rb +507 -0
- data/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb +461 -0
- data/lib/patch_ruby/models/estimate.rb +1 -1
- data/lib/patch_ruby/models/order.rb +20 -7
- data/lib/patch_ruby/models/order_issued_to.rb +242 -0
- data/lib/patch_ruby/models/place_order_request.rb +228 -0
- data/lib/patch_ruby/models/project.rb +2 -2
- data/lib/patch_ruby/version.rb +1 -1
- data/lib/patch_ruby.rb +6 -0
- data/spec/integration/estimates_spec.rb +151 -0
- data/spec/integration/orders_spec.rb +34 -0
- data/spec/integration/projects_spec.rb +2 -2
- metadata +31 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8151d33b8621b00c4852c6cfa7f26231d222259da797ce9d88ae2555af7b335d
|
4
|
+
data.tar.gz: a5e3a388d5c6c3bf39d705f140eabb0f2704404b5d10062fc6abe2f2ef20e6a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c32a8e2fb7bd6960a9adbf29a99628a2f9d5b0ee7f022c50ea0adb744d0a8767d73f33949198a40c3591f00cb3df08d02769e163e9d350443b08d8ccad739696
|
7
|
+
data.tar.gz: ca74e3e739f5edca1f4c3afaa0e63849d19e23822955440299be82bf05a07f7ee5d3135d22b99289dbbb903e41c037158a1cb7b7bf46e5e13324f89b21ee7dfb
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,21 @@ 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
|
+
## [1.24.0] - 2022-07-22
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Adds `Patch::Estimate.create_air_shipping_estimate` method
|
13
|
+
- Adds `Patch::Estimate.create_rail_shipping_estimate` method
|
14
|
+
- Adds `Patch::Estimate.create_road_shipping_estimate` method
|
15
|
+
- Adds `Patch::Estimate.create_sea_shipping_estimate` method
|
16
|
+
|
17
|
+
## [1.23.0] - 2022-06-03
|
18
|
+
|
19
|
+
### Added
|
20
|
+
|
21
|
+
- Adds support for the `issued_to` parameter on `orders`, to add support for creating and placing orders on behalf of another party.
|
22
|
+
|
8
23
|
## [1.22.0] - 2022-05-16
|
9
24
|
|
10
25
|
### Added
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -74,6 +74,12 @@ total_price = 5_00 # Pass in the total price in smallest currency unit (ie cents
|
|
74
74
|
currency = "USD"
|
75
75
|
Patch::Order.create_order(total_price: total_price, currency: currency)
|
76
76
|
|
77
|
+
# Create an order with issued_to field (optional)
|
78
|
+
total_price = 5_00 # Pass in the total price in smallest currency unit (ie cents for USD).
|
79
|
+
currency = "USD"
|
80
|
+
issued_to = {email: "envimpact@companya.com", name: "Company A"}
|
81
|
+
Patch::Order.create_order(total_price: total_price, currency: currency, issued_to: issued_to)
|
82
|
+
|
77
83
|
## You can also specify a project-id field (optional) to be used instead of the preferred one
|
78
84
|
project_id = 'pro_test_1234' # Pass in the project's ID
|
79
85
|
Patch::Order.create_order(amount: amount, unit: unit, project_id: project_id)
|
@@ -90,6 +96,11 @@ Patch::Order.retrieve_order(order_id)
|
|
90
96
|
order_id = 'ord_test_1234' # Pass in the order's id
|
91
97
|
Patch::Order.place_order(order_id)
|
92
98
|
|
99
|
+
## Placing an order on behalf of another party with the issued_to field (optional)
|
100
|
+
order_id = 'ord_test_1234' # Pass in the order's id
|
101
|
+
issued_to = {email: "envimpact@companya.com", name: "Company A"}
|
102
|
+
Patch::Order.place_order(order_id, issued_to: issued_to)
|
103
|
+
|
93
104
|
# Cancel an order
|
94
105
|
order_id = 'ord_test_1234' # Pass in the order's id
|
95
106
|
Patch::Order.cancel_order(order_id)
|
@@ -191,12 +202,12 @@ minimum_available_mass = 100
|
|
191
202
|
Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
|
192
203
|
|
193
204
|
# Retrieve a project in a different language
|
194
|
-
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
205
|
+
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
195
206
|
project_id = 'pro_test_1234'
|
196
207
|
Patch::Project.retrieve_project(project_id, accept_language: 'fr')
|
197
208
|
|
198
209
|
# Retrieve a list of projects in a different language
|
199
|
-
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
210
|
+
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
200
211
|
Patch::Project.retrieve_projects(accept_language: 'fr')
|
201
212
|
```
|
202
213
|
## Contributing
|
@@ -219,6 +230,25 @@ This will create a .gem file. To install the local gem:
|
|
219
230
|
gem install patch_ruby-1.x.x.gem
|
220
231
|
```
|
221
232
|
|
233
|
+
Once you have installed the gem, you can easily test with `irb`. Here's an example of testing Order creation:
|
234
|
+
```bash
|
235
|
+
brett@Bretts-MacBook-Pro patch-ruby $ irb
|
236
|
+
irb(main):001:0> require 'patch_ruby'
|
237
|
+
=> true
|
238
|
+
irb(main):002:0>
|
239
|
+
irb(main):003:1* Patch.configure do |config|
|
240
|
+
irb(main):004:1* # Configure the Patch gem with your API key here
|
241
|
+
irb(main):005:1* config.access_token = ENV['SANDBOX_API_KEY']
|
242
|
+
irb(main):006:0> end
|
243
|
+
=> "[REDACTED]"
|
244
|
+
irb(main):007:0> total_price = 5_00
|
245
|
+
=> 500
|
246
|
+
irb(main):008:0> currency = "USD"
|
247
|
+
=> "USD"
|
248
|
+
irb(main):009:0> issued_to = {email: "envimpact@companya.com", name: "Company A"}
|
249
|
+
irb(main):010:0> Patch::Order.create_order(total_price: total_price, currency: currency, issued_to: issued_to)
|
250
|
+
```
|
251
|
+
|
222
252
|
### Running tests
|
223
253
|
|
224
254
|
Set up the required environment variable.
|
@@ -15,11 +15,15 @@ require 'cgi'
|
|
15
15
|
module Patch
|
16
16
|
class EstimatesApi
|
17
17
|
OPERATIONS = [
|
18
|
+
:create_air_shipping_estimate,
|
18
19
|
:create_bitcoin_estimate,
|
19
20
|
:create_ethereum_estimate,
|
20
21
|
:create_flight_estimate,
|
21
22
|
:create_hotel_estimate,
|
22
23
|
:create_mass_estimate,
|
24
|
+
:create_rail_shipping_estimate,
|
25
|
+
:create_road_shipping_estimate,
|
26
|
+
:create_sea_shipping_estimate,
|
23
27
|
:create_shipping_estimate,
|
24
28
|
:create_vehicle_estimate,
|
25
29
|
:retrieve_estimate,
|
@@ -31,6 +35,75 @@ module Patch
|
|
31
35
|
def initialize(api_client = ApiClient.default)
|
32
36
|
@api_client = api_client
|
33
37
|
end
|
38
|
+
# Creates a GLEC air shipping estimate given freight mass and logistics
|
39
|
+
# 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.
|
40
|
+
# @param create_air_shipping_estimate_request [CreateAirShippingEstimateRequest]
|
41
|
+
# @param [Hash] opts the optional parameters
|
42
|
+
# @return [EstimateResponse]
|
43
|
+
def create_air_shipping_estimate(create_air_shipping_estimate_request = {}, opts = {})
|
44
|
+
_create_air_shipping_estimate_request = Patch::CreateAirShippingEstimateRequest.new(create_air_shipping_estimate_request)
|
45
|
+
data, _status_code, _headers = create_air_shipping_estimate_with_http_info(_create_air_shipping_estimate_request, opts)
|
46
|
+
data
|
47
|
+
end
|
48
|
+
|
49
|
+
# Creates a GLEC air shipping estimate given freight mass and logistics
|
50
|
+
# 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.
|
51
|
+
# @param create_air_shipping_estimate_request [CreateAirShippingEstimateRequest]
|
52
|
+
# @param [Hash] opts the optional parameters
|
53
|
+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
54
|
+
def create_air_shipping_estimate_with_http_info(create_air_shipping_estimate_request, opts = {})
|
55
|
+
if @api_client.config.debugging
|
56
|
+
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_air_shipping_estimate ...'
|
57
|
+
end
|
58
|
+
# verify the required parameter 'create_air_shipping_estimate_request' is set
|
59
|
+
if @api_client.config.client_side_validation && create_air_shipping_estimate_request.nil?
|
60
|
+
fail ArgumentError, "Missing the required parameter 'create_air_shipping_estimate_request' when calling EstimatesApi.create_air_shipping_estimate"
|
61
|
+
end
|
62
|
+
# resource path
|
63
|
+
local_var_path = '/v1/estimates/shipping/air'
|
64
|
+
|
65
|
+
# query parameters
|
66
|
+
query_params = opts[:query_params] || {}
|
67
|
+
|
68
|
+
# header parameters
|
69
|
+
header_params = opts[:header_params] || {}
|
70
|
+
# HTTP header 'Accept' (if needed)
|
71
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
72
|
+
# HTTP header 'Content-Type'
|
73
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
74
|
+
if !content_type.nil?
|
75
|
+
header_params['Content-Type'] = content_type
|
76
|
+
end
|
77
|
+
|
78
|
+
# form parameters
|
79
|
+
form_params = opts[:form_params] || {}
|
80
|
+
|
81
|
+
# http body (model)
|
82
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_air_shipping_estimate_request)
|
83
|
+
|
84
|
+
# return_type
|
85
|
+
return_type = opts[:debug_return_type] || 'EstimateResponse'
|
86
|
+
|
87
|
+
# auth_names
|
88
|
+
auth_names = opts[:debug_auth_names] || ['bearer_auth']
|
89
|
+
|
90
|
+
new_options = opts.merge(
|
91
|
+
:operation => :"EstimatesApi.create_air_shipping_estimate",
|
92
|
+
:header_params => header_params,
|
93
|
+
:query_params => query_params,
|
94
|
+
:form_params => form_params,
|
95
|
+
:body => post_body,
|
96
|
+
:auth_names => auth_names,
|
97
|
+
:return_type => return_type
|
98
|
+
)
|
99
|
+
|
100
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
101
|
+
if @api_client.config.debugging
|
102
|
+
@api_client.config.logger.debug "API called: EstimatesApi#create_air_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
103
|
+
end
|
104
|
+
return data, status_code, headers
|
105
|
+
end
|
106
|
+
|
34
107
|
# Create a bitcoin estimate given a timestamp and transaction value
|
35
108
|
# 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.
|
36
109
|
# @param create_bitcoin_estimate_request [CreateBitcoinEstimateRequest]
|
@@ -43,7 +116,7 @@ module Patch
|
|
43
116
|
end
|
44
117
|
|
45
118
|
# Create a bitcoin estimate given a timestamp and transaction value
|
46
|
-
# Creates a bitcoin estimate for the amount of CO2 to be compensated. An order in the
|
119
|
+
# 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.
|
47
120
|
# @param create_bitcoin_estimate_request [CreateBitcoinEstimateRequest]
|
48
121
|
# @param [Hash] opts the optional parameters
|
49
122
|
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
@@ -112,7 +185,7 @@ module Patch
|
|
112
185
|
end
|
113
186
|
|
114
187
|
# Create an ethereum estimate
|
115
|
-
# Creates an ethereum estimate for the amount of CO2 to be compensated. An order in the
|
188
|
+
# Creates an ethereum 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.
|
116
189
|
# @param create_ethereum_estimate_request [CreateEthereumEstimateRequest]
|
117
190
|
# @param [Hash] opts the optional parameters
|
118
191
|
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
@@ -181,7 +254,7 @@ module Patch
|
|
181
254
|
end
|
182
255
|
|
183
256
|
# Create a flight estimate given the distance traveled in meters
|
184
|
-
# Creates a flight estimate for the amount of CO2 to be compensated. An order in the
|
257
|
+
# 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.
|
185
258
|
# @param create_flight_estimate_request [CreateFlightEstimateRequest]
|
186
259
|
# @param [Hash] opts the optional parameters
|
187
260
|
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
@@ -250,7 +323,7 @@ module Patch
|
|
250
323
|
end
|
251
324
|
|
252
325
|
# Create a hotel estimate.
|
253
|
-
# Creates a hotel estimate for the amount of CO2 to be compensated. An order in the
|
326
|
+
# 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.
|
254
327
|
# @param create_hotel_estimate_request [CreateHotelEstimateRequest]
|
255
328
|
# @param [Hash] opts the optional parameters
|
256
329
|
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
@@ -319,7 +392,7 @@ module Patch
|
|
319
392
|
end
|
320
393
|
|
321
394
|
# Create an estimate based on mass of CO2
|
322
|
-
# Creates an estimate for the mass of CO2 to be compensated. An order in the
|
395
|
+
# 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.
|
323
396
|
# @param create_mass_estimate_request [CreateMassEstimateRequest]
|
324
397
|
# @param [Hash] opts the optional parameters
|
325
398
|
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
@@ -376,6 +449,213 @@ module Patch
|
|
376
449
|
return data, status_code, headers
|
377
450
|
end
|
378
451
|
|
452
|
+
# Creates a GLEC rail shipping estimate given freight mass and logistics
|
453
|
+
# 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.
|
454
|
+
# @param create_rail_shipping_estimate_request [CreateRailShippingEstimateRequest]
|
455
|
+
# @param [Hash] opts the optional parameters
|
456
|
+
# @return [EstimateResponse]
|
457
|
+
def create_rail_shipping_estimate(create_rail_shipping_estimate_request = {}, opts = {})
|
458
|
+
_create_rail_shipping_estimate_request = Patch::CreateRailShippingEstimateRequest.new(create_rail_shipping_estimate_request)
|
459
|
+
data, _status_code, _headers = create_rail_shipping_estimate_with_http_info(_create_rail_shipping_estimate_request, opts)
|
460
|
+
data
|
461
|
+
end
|
462
|
+
|
463
|
+
# Creates a GLEC rail shipping estimate given freight mass and logistics
|
464
|
+
# 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.
|
465
|
+
# @param create_rail_shipping_estimate_request [CreateRailShippingEstimateRequest]
|
466
|
+
# @param [Hash] opts the optional parameters
|
467
|
+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
468
|
+
def create_rail_shipping_estimate_with_http_info(create_rail_shipping_estimate_request, opts = {})
|
469
|
+
if @api_client.config.debugging
|
470
|
+
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_rail_shipping_estimate ...'
|
471
|
+
end
|
472
|
+
# verify the required parameter 'create_rail_shipping_estimate_request' is set
|
473
|
+
if @api_client.config.client_side_validation && create_rail_shipping_estimate_request.nil?
|
474
|
+
fail ArgumentError, "Missing the required parameter 'create_rail_shipping_estimate_request' when calling EstimatesApi.create_rail_shipping_estimate"
|
475
|
+
end
|
476
|
+
# resource path
|
477
|
+
local_var_path = '/v1/estimates/shipping/rail'
|
478
|
+
|
479
|
+
# query parameters
|
480
|
+
query_params = opts[:query_params] || {}
|
481
|
+
|
482
|
+
# header parameters
|
483
|
+
header_params = opts[:header_params] || {}
|
484
|
+
# HTTP header 'Accept' (if needed)
|
485
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
486
|
+
# HTTP header 'Content-Type'
|
487
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
488
|
+
if !content_type.nil?
|
489
|
+
header_params['Content-Type'] = content_type
|
490
|
+
end
|
491
|
+
|
492
|
+
# form parameters
|
493
|
+
form_params = opts[:form_params] || {}
|
494
|
+
|
495
|
+
# http body (model)
|
496
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_rail_shipping_estimate_request)
|
497
|
+
|
498
|
+
# return_type
|
499
|
+
return_type = opts[:debug_return_type] || 'EstimateResponse'
|
500
|
+
|
501
|
+
# auth_names
|
502
|
+
auth_names = opts[:debug_auth_names] || ['bearer_auth']
|
503
|
+
|
504
|
+
new_options = opts.merge(
|
505
|
+
:operation => :"EstimatesApi.create_rail_shipping_estimate",
|
506
|
+
:header_params => header_params,
|
507
|
+
:query_params => query_params,
|
508
|
+
:form_params => form_params,
|
509
|
+
:body => post_body,
|
510
|
+
:auth_names => auth_names,
|
511
|
+
:return_type => return_type
|
512
|
+
)
|
513
|
+
|
514
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
515
|
+
if @api_client.config.debugging
|
516
|
+
@api_client.config.logger.debug "API called: EstimatesApi#create_rail_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
517
|
+
end
|
518
|
+
return data, status_code, headers
|
519
|
+
end
|
520
|
+
|
521
|
+
# Creates a GLEC road shipping estimate given freight mass and logistics
|
522
|
+
# 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.
|
523
|
+
# @param create_road_shipping_estimate_request [CreateRoadShippingEstimateRequest]
|
524
|
+
# @param [Hash] opts the optional parameters
|
525
|
+
# @return [EstimateResponse]
|
526
|
+
def create_road_shipping_estimate(create_road_shipping_estimate_request = {}, opts = {})
|
527
|
+
_create_road_shipping_estimate_request = Patch::CreateRoadShippingEstimateRequest.new(create_road_shipping_estimate_request)
|
528
|
+
data, _status_code, _headers = create_road_shipping_estimate_with_http_info(_create_road_shipping_estimate_request, opts)
|
529
|
+
data
|
530
|
+
end
|
531
|
+
|
532
|
+
# Creates a GLEC road shipping estimate given freight mass and logistics
|
533
|
+
# 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.
|
534
|
+
# @param create_road_shipping_estimate_request [CreateRoadShippingEstimateRequest]
|
535
|
+
# @param [Hash] opts the optional parameters
|
536
|
+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
537
|
+
def create_road_shipping_estimate_with_http_info(create_road_shipping_estimate_request, opts = {})
|
538
|
+
if @api_client.config.debugging
|
539
|
+
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_road_shipping_estimate ...'
|
540
|
+
end
|
541
|
+
# verify the required parameter 'create_road_shipping_estimate_request' is set
|
542
|
+
if @api_client.config.client_side_validation && create_road_shipping_estimate_request.nil?
|
543
|
+
fail ArgumentError, "Missing the required parameter 'create_road_shipping_estimate_request' when calling EstimatesApi.create_road_shipping_estimate"
|
544
|
+
end
|
545
|
+
# resource path
|
546
|
+
local_var_path = '/v1/estimates/shipping/road'
|
547
|
+
|
548
|
+
# query parameters
|
549
|
+
query_params = opts[:query_params] || {}
|
550
|
+
|
551
|
+
# header parameters
|
552
|
+
header_params = opts[:header_params] || {}
|
553
|
+
# HTTP header 'Accept' (if needed)
|
554
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
555
|
+
# HTTP header 'Content-Type'
|
556
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
557
|
+
if !content_type.nil?
|
558
|
+
header_params['Content-Type'] = content_type
|
559
|
+
end
|
560
|
+
|
561
|
+
# form parameters
|
562
|
+
form_params = opts[:form_params] || {}
|
563
|
+
|
564
|
+
# http body (model)
|
565
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_road_shipping_estimate_request)
|
566
|
+
|
567
|
+
# return_type
|
568
|
+
return_type = opts[:debug_return_type] || 'EstimateResponse'
|
569
|
+
|
570
|
+
# auth_names
|
571
|
+
auth_names = opts[:debug_auth_names] || ['bearer_auth']
|
572
|
+
|
573
|
+
new_options = opts.merge(
|
574
|
+
:operation => :"EstimatesApi.create_road_shipping_estimate",
|
575
|
+
:header_params => header_params,
|
576
|
+
:query_params => query_params,
|
577
|
+
:form_params => form_params,
|
578
|
+
:body => post_body,
|
579
|
+
:auth_names => auth_names,
|
580
|
+
:return_type => return_type
|
581
|
+
)
|
582
|
+
|
583
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
584
|
+
if @api_client.config.debugging
|
585
|
+
@api_client.config.logger.debug "API called: EstimatesApi#create_road_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
586
|
+
end
|
587
|
+
return data, status_code, headers
|
588
|
+
end
|
589
|
+
|
590
|
+
# Creates a GLEC sea shipping estimate given freight mass and logistics
|
591
|
+
# 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.
|
592
|
+
# @param create_sea_shipping_estimate_request [CreateSeaShippingEstimateRequest]
|
593
|
+
# @param [Hash] opts the optional parameters
|
594
|
+
# @return [EstimateResponse]
|
595
|
+
def create_sea_shipping_estimate(create_sea_shipping_estimate_request = {}, opts = {})
|
596
|
+
_create_sea_shipping_estimate_request = Patch::CreateSeaShippingEstimateRequest.new(create_sea_shipping_estimate_request)
|
597
|
+
data, _status_code, _headers = create_sea_shipping_estimate_with_http_info(_create_sea_shipping_estimate_request, opts)
|
598
|
+
data
|
599
|
+
end
|
600
|
+
|
601
|
+
# Creates a GLEC sea shipping estimate given freight mass and logistics
|
602
|
+
# 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.
|
603
|
+
# @param create_sea_shipping_estimate_request [CreateSeaShippingEstimateRequest]
|
604
|
+
# @param [Hash] opts the optional parameters
|
605
|
+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
606
|
+
def create_sea_shipping_estimate_with_http_info(create_sea_shipping_estimate_request, opts = {})
|
607
|
+
if @api_client.config.debugging
|
608
|
+
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_sea_shipping_estimate ...'
|
609
|
+
end
|
610
|
+
# verify the required parameter 'create_sea_shipping_estimate_request' is set
|
611
|
+
if @api_client.config.client_side_validation && create_sea_shipping_estimate_request.nil?
|
612
|
+
fail ArgumentError, "Missing the required parameter 'create_sea_shipping_estimate_request' when calling EstimatesApi.create_sea_shipping_estimate"
|
613
|
+
end
|
614
|
+
# resource path
|
615
|
+
local_var_path = '/v1/estimates/shipping/sea'
|
616
|
+
|
617
|
+
# query parameters
|
618
|
+
query_params = opts[:query_params] || {}
|
619
|
+
|
620
|
+
# header parameters
|
621
|
+
header_params = opts[:header_params] || {}
|
622
|
+
# HTTP header 'Accept' (if needed)
|
623
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
624
|
+
# HTTP header 'Content-Type'
|
625
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
626
|
+
if !content_type.nil?
|
627
|
+
header_params['Content-Type'] = content_type
|
628
|
+
end
|
629
|
+
|
630
|
+
# form parameters
|
631
|
+
form_params = opts[:form_params] || {}
|
632
|
+
|
633
|
+
# http body (model)
|
634
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_sea_shipping_estimate_request)
|
635
|
+
|
636
|
+
# return_type
|
637
|
+
return_type = opts[:debug_return_type] || 'EstimateResponse'
|
638
|
+
|
639
|
+
# auth_names
|
640
|
+
auth_names = opts[:debug_auth_names] || ['bearer_auth']
|
641
|
+
|
642
|
+
new_options = opts.merge(
|
643
|
+
:operation => :"EstimatesApi.create_sea_shipping_estimate",
|
644
|
+
:header_params => header_params,
|
645
|
+
:query_params => query_params,
|
646
|
+
:form_params => form_params,
|
647
|
+
:body => post_body,
|
648
|
+
:auth_names => auth_names,
|
649
|
+
:return_type => return_type
|
650
|
+
)
|
651
|
+
|
652
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
653
|
+
if @api_client.config.debugging
|
654
|
+
@api_client.config.logger.debug "API called: EstimatesApi#create_sea_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
655
|
+
end
|
656
|
+
return data, status_code, headers
|
657
|
+
end
|
658
|
+
|
379
659
|
# Create a shipping estimate given the distance traveled in meters, package weight, and transportation method.
|
380
660
|
# 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.
|
381
661
|
# @param create_shipping_estimate_request [CreateShippingEstimateRequest]
|
@@ -388,7 +668,7 @@ module Patch
|
|
388
668
|
end
|
389
669
|
|
390
670
|
# Create a shipping estimate given the distance traveled in meters, package weight, and transportation method.
|
391
|
-
# Creates a shipping estimate for the amount of CO2 to be compensated. An order in the
|
671
|
+
# 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.
|
392
672
|
# @param create_shipping_estimate_request [CreateShippingEstimateRequest]
|
393
673
|
# @param [Hash] opts the optional parameters
|
394
674
|
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
@@ -457,7 +737,7 @@ module Patch
|
|
457
737
|
end
|
458
738
|
|
459
739
|
# Create a vehicle estimate given the distance traveled in meters and the type of vehicle
|
460
|
-
# Creates an estimate and calculates the amount of CO2 to be compensated depending on the distance and the vehicle. An order in the
|
740
|
+
# 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.
|
461
741
|
# @param create_vehicle_estimate_request [CreateVehicleEstimateRequest]
|
462
742
|
# @param [Hash] opts the optional parameters
|
463
743
|
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
@@ -39,7 +39,7 @@ module Patch
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# Cancel an order
|
42
|
-
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the
|
42
|
+
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled.
|
43
43
|
# @param id [String]
|
44
44
|
# @param [Hash] opts the optional parameters
|
45
45
|
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
@@ -103,7 +103,7 @@ module Patch
|
|
103
103
|
end
|
104
104
|
|
105
105
|
# Creates an order
|
106
|
-
# Creates an order in the
|
106
|
+
# Creates an order in the `placed` or `draft` state.
|
107
107
|
# @param create_order_request [CreateOrderRequest]
|
108
108
|
# @param [Hash] opts the optional parameters
|
109
109
|
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
@@ -164,6 +164,7 @@ module Patch
|
|
164
164
|
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
|
165
165
|
# @param id [String]
|
166
166
|
# @param [Hash] opts the optional parameters
|
167
|
+
# @option opts [PlaceOrderRequest] :place_order_request
|
167
168
|
# @return [OrderResponse]
|
168
169
|
def place_order(id, opts = {})
|
169
170
|
|
@@ -172,9 +173,10 @@ module Patch
|
|
172
173
|
end
|
173
174
|
|
174
175
|
# Place an order
|
175
|
-
# Placing an order confirms an order
|
176
|
+
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
|
176
177
|
# @param id [String]
|
177
178
|
# @param [Hash] opts the optional parameters
|
179
|
+
# @option opts [PlaceOrderRequest] :place_order_request
|
178
180
|
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
179
181
|
def place_order_with_http_info(id, opts = {})
|
180
182
|
if @api_client.config.debugging
|
@@ -194,12 +196,17 @@ module Patch
|
|
194
196
|
header_params = opts[:header_params] || {}
|
195
197
|
# HTTP header 'Accept' (if needed)
|
196
198
|
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
199
|
+
# HTTP header 'Content-Type'
|
200
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
201
|
+
if !content_type.nil?
|
202
|
+
header_params['Content-Type'] = content_type
|
203
|
+
end
|
197
204
|
|
198
205
|
# form parameters
|
199
206
|
form_params = opts[:form_params] || {}
|
200
207
|
|
201
208
|
# http body (model)
|
202
|
-
post_body = opts[:debug_body]
|
209
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(opts)
|
203
210
|
|
204
211
|
# return_type
|
205
212
|
return_type = opts[:debug_return_type] || 'OrderResponse'
|
@@ -37,7 +37,7 @@ module Patch
|
|
37
37
|
end
|
38
38
|
|
39
39
|
# Retrieves a project
|
40
|
-
# Retrieves a project available on Patch
|
40
|
+
# Retrieves a project available on Patch's platform.
|
41
41
|
# @param id [String]
|
42
42
|
# @param [Hash] opts the optional parameters
|
43
43
|
# @option opts [String] :accept_language
|
@@ -107,7 +107,7 @@ module Patch
|
|
107
107
|
end
|
108
108
|
|
109
109
|
# Retrieves a list of projects
|
110
|
-
# Retrieves a list of projects available for purchase on Patch
|
110
|
+
# Retrieves a list of projects available for purchase on Patch's platform.
|
111
111
|
# @param [Hash] opts the optional parameters
|
112
112
|
# @option opts [Integer] :page
|
113
113
|
# @option opts [String] :country
|
@@ -31,7 +31,7 @@ module Patch
|
|
31
31
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
32
32
|
def initialize(config = Configuration.default)
|
33
33
|
@config = config
|
34
|
-
@user_agent = "patch-ruby/1.
|
34
|
+
@user_agent = "patch-ruby/1.24.1"
|
35
35
|
@default_headers = {
|
36
36
|
'Content-Type' => 'application/json',
|
37
37
|
'User-Agent' => @user_agent
|
@@ -18,7 +18,7 @@ module Patch
|
|
18
18
|
# A unique uid for the record. UIDs will be prepended by all_prod or all_test depending on the mode it was created in.
|
19
19
|
attr_accessor :id
|
20
20
|
|
21
|
-
# A boolean indicating if this project is a production or
|
21
|
+
# A boolean indicating if this project is a production or demo mode project.
|
22
22
|
attr_accessor :production
|
23
23
|
|
24
24
|
# The amount (in grams) of allocated carbon offsets.
|