patch_ruby 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +72 -0
- data/README.md +54 -0
- data/Rakefile +10 -0
- data/lib/patch_ruby.rb +61 -0
- data/lib/patch_ruby/api/estimates_api.rb +213 -0
- data/lib/patch_ruby/api/orders_api.rb +339 -0
- data/lib/patch_ruby/api/preferences_api.rb +276 -0
- data/lib/patch_ruby/api/projects_api.rb +148 -0
- data/lib/patch_ruby/api_client.rb +388 -0
- data/lib/patch_ruby/api_error.rb +57 -0
- data/lib/patch_ruby/configuration.rb +254 -0
- data/lib/patch_ruby/models/allocation.rb +229 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +216 -0
- data/lib/patch_ruby/models/create_order_request.rb +216 -0
- data/lib/patch_ruby/models/create_preference_request.rb +216 -0
- data/lib/patch_ruby/models/error_response.rb +239 -0
- data/lib/patch_ruby/models/estimate.rb +238 -0
- data/lib/patch_ruby/models/estimate_list_response.rb +255 -0
- data/lib/patch_ruby/models/estimate_response.rb +239 -0
- data/lib/patch_ruby/models/meta_index_object.rb +220 -0
- data/lib/patch_ruby/models/order.rb +313 -0
- data/lib/patch_ruby/models/order_list_response.rb +255 -0
- data/lib/patch_ruby/models/order_response.rb +239 -0
- data/lib/patch_ruby/models/preference.rb +229 -0
- data/lib/patch_ruby/models/preference_list_response.rb +255 -0
- data/lib/patch_ruby/models/preference_response.rb +239 -0
- data/lib/patch_ruby/models/project.rb +283 -0
- data/lib/patch_ruby/models/project_list_response.rb +255 -0
- data/lib/patch_ruby/models/project_response.rb +239 -0
- data/lib/patch_ruby/version.rb +15 -0
- data/patch_ruby.gemspec +39 -0
- data/spec/api/estimates_api_spec.rb +71 -0
- data/spec/api/orders_api_spec.rb +95 -0
- data/spec/api/preferences_api_spec.rb +83 -0
- data/spec/api/projects_api_spec.rb +59 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/fixtures/vcr_cassettes/estimate_orders.yml +276 -0
- data/spec/fixtures/vcr_cassettes/estimates.yml +211 -0
- data/spec/fixtures/vcr_cassettes/orders.yml +229 -0
- data/spec/fixtures/vcr_cassettes/preferences.yml +352 -0
- data/spec/fixtures/vcr_cassettes/projects.yml +143 -0
- data/spec/integration/estimates_spec.rb +31 -0
- data/spec/integration/orders_spec.rb +53 -0
- data/spec/integration/preferences_spec.rb +40 -0
- data/spec/integration/projects_spec.rb +31 -0
- data/spec/models/allocation_spec.rb +53 -0
- data/spec/models/create_mass_estimate_request_spec.rb +41 -0
- data/spec/models/create_order_request_spec.rb +41 -0
- data/spec/models/create_preference_request_spec.rb +41 -0
- data/spec/models/error_response_spec.rb +53 -0
- data/spec/models/estimate_list_response_spec.rb +59 -0
- data/spec/models/estimate_response_spec.rb +53 -0
- data/spec/models/estimate_spec.rb +59 -0
- data/spec/models/meta_index_object_spec.rb +47 -0
- data/spec/models/order_list_response_spec.rb +59 -0
- data/spec/models/order_response_spec.rb +53 -0
- data/spec/models/order_spec.rb +85 -0
- data/spec/models/preference_list_response_spec.rb +59 -0
- data/spec/models/preference_response_spec.rb +53 -0
- data/spec/models/preference_spec.rb +53 -0
- data/spec/models/project_list_response_spec.rb +59 -0
- data/spec/models/project_response_spec.rb +53 -0
- data/spec/models/project_spec.rb +89 -0
- data/spec/spec_helper.rb +122 -0
- metadata +203 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: adcc2ae16ffd8f1fae30c7231ea100282a46b9cb59fa04ef855d37b3c0269b7e
|
4
|
+
data.tar.gz: 87c2e5a75eec03a3d05ccca1bc74201e658f3d1bf1a0eec3759b7df3c6815c77
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0d8c3b806824a51b72215cab36372c1608e46c02b3e6ea007f060871da0c3e22e943edffc7484cbe9a9d551685bedd3e14e2eb35b3655e38dd6cfec8f9abcca6
|
7
|
+
data.tar.gz: b66e6323bfa7932d43d3865b28bc9e09d3cac9a14daa5177fe7a0c1bc5355403e64aed6cee1ba126c5c1fcf3b7c01152dd25408cb7add2742ddf07e20977c129
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
patch_ruby (1.0.0.pre)
|
5
|
+
json (~> 2.1, >= 2.1.0)
|
6
|
+
typhoeus (~> 1.0, >= 1.0.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.4.1)
|
12
|
+
byebug (11.1.3)
|
13
|
+
coderay (1.1.3)
|
14
|
+
diff-lcs (1.4.3)
|
15
|
+
ethon (0.12.0)
|
16
|
+
ffi (>= 1.3.0)
|
17
|
+
ffi (1.13.1)
|
18
|
+
jaro_winkler (1.5.4)
|
19
|
+
json (2.3.1)
|
20
|
+
method_source (1.0.0)
|
21
|
+
parallel (1.19.2)
|
22
|
+
parser (2.7.1.4)
|
23
|
+
ast (~> 2.4.1)
|
24
|
+
pry (0.13.1)
|
25
|
+
coderay (~> 1.1)
|
26
|
+
method_source (~> 1.0)
|
27
|
+
pry-byebug (3.9.0)
|
28
|
+
byebug (~> 11.0)
|
29
|
+
pry (~> 0.13.0)
|
30
|
+
psych (3.1.0)
|
31
|
+
rainbow (3.0.0)
|
32
|
+
rake (13.0.1)
|
33
|
+
rspec (3.9.0)
|
34
|
+
rspec-core (~> 3.9.0)
|
35
|
+
rspec-expectations (~> 3.9.0)
|
36
|
+
rspec-mocks (~> 3.9.0)
|
37
|
+
rspec-core (3.9.2)
|
38
|
+
rspec-support (~> 3.9.3)
|
39
|
+
rspec-expectations (3.9.2)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.9.0)
|
42
|
+
rspec-mocks (3.9.1)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.9.0)
|
45
|
+
rspec-support (3.9.3)
|
46
|
+
rubocop (0.66.0)
|
47
|
+
jaro_winkler (~> 1.5.1)
|
48
|
+
parallel (~> 1.10)
|
49
|
+
parser (>= 2.5, != 2.5.1.1)
|
50
|
+
psych (>= 3.1.0)
|
51
|
+
rainbow (>= 2.2.2, < 4.0)
|
52
|
+
ruby-progressbar (~> 1.7)
|
53
|
+
unicode-display_width (>= 1.4.0, < 1.6)
|
54
|
+
ruby-progressbar (1.10.1)
|
55
|
+
typhoeus (1.4.0)
|
56
|
+
ethon (>= 0.9.0)
|
57
|
+
unicode-display_width (1.5.0)
|
58
|
+
vcr (6.0.0)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
ruby
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
patch_ruby!
|
65
|
+
pry-byebug
|
66
|
+
rake (~> 13.0.1)
|
67
|
+
rspec (~> 3.6, >= 3.6.0)
|
68
|
+
rubocop (~> 0.66.0)
|
69
|
+
vcr (~> 6.0)
|
70
|
+
|
71
|
+
BUNDLED WITH
|
72
|
+
2.1.4
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Patch ruby
|
2
|
+
![Test](https://github.com/patch-technology/patch-ruby/workflows/Test/badge.svg)
|
3
|
+
|
4
|
+
The official Ruby gem for the [Patch API](https://www.usepatch.com)
|
5
|
+
|
6
|
+
## Documentation
|
7
|
+
|
8
|
+
For detailed documentation and examples, see the [Patch API docs](https://www.usepatch.com).
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add the gem to your Gemfile:
|
13
|
+
```ruby
|
14
|
+
gem 'patch_ruby'
|
15
|
+
```
|
16
|
+
|
17
|
+
Then run:
|
18
|
+
```shell
|
19
|
+
bundle
|
20
|
+
```
|
21
|
+
|
22
|
+
Or install it directly with
|
23
|
+
```shell
|
24
|
+
gem install patch_ruby
|
25
|
+
```
|
26
|
+
|
27
|
+
### Requirements
|
28
|
+
- Ruby 1.9+
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
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:
|
33
|
+
```ruby
|
34
|
+
require 'patch_ruby'
|
35
|
+
|
36
|
+
Patch.configure do |config|
|
37
|
+
# Configure the Patch gem with your API key here
|
38
|
+
config.access_token = ENV['PATCH_RUBY_API_KEY']
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
Once configured, you can test it out:
|
43
|
+
```ruby
|
44
|
+
begin
|
45
|
+
orders_response = Patch::Order.retrieve_orders
|
46
|
+
|
47
|
+
orders_response.data.each do |order|
|
48
|
+
puts "Order ID: #{order.id}, Order State: #{order.state}"
|
49
|
+
end
|
50
|
+
# Rescue from any Patch API errors
|
51
|
+
rescue Patch::ApiError => e
|
52
|
+
puts "Failed to retrieve Orders with status code #{e.code}: #{e.message}"
|
53
|
+
end
|
54
|
+
```
|
data/Rakefile
ADDED
data/lib/patch_ruby.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
=begin
|
2
|
+
#Patch API V1
|
3
|
+
|
4
|
+
#The core API used to integrate with Patch's service
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v1
|
7
|
+
Contact: developers@usepatch.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
# Common files
|
14
|
+
require 'patch_ruby/api_client'
|
15
|
+
require 'patch_ruby/api_error'
|
16
|
+
require 'patch_ruby/version'
|
17
|
+
require 'patch_ruby/configuration'
|
18
|
+
|
19
|
+
# Models
|
20
|
+
require 'patch_ruby/models/allocation'
|
21
|
+
require 'patch_ruby/models/create_mass_estimate_request'
|
22
|
+
require 'patch_ruby/models/create_order_request'
|
23
|
+
require 'patch_ruby/models/create_preference_request'
|
24
|
+
require 'patch_ruby/models/error_response'
|
25
|
+
require 'patch_ruby/models/estimate'
|
26
|
+
require 'patch_ruby/models/estimate_list_response'
|
27
|
+
require 'patch_ruby/models/estimate_response'
|
28
|
+
require 'patch_ruby/models/meta_index_object'
|
29
|
+
require 'patch_ruby/models/order'
|
30
|
+
require 'patch_ruby/models/order_list_response'
|
31
|
+
require 'patch_ruby/models/order_response'
|
32
|
+
require 'patch_ruby/models/preference'
|
33
|
+
require 'patch_ruby/models/preference_list_response'
|
34
|
+
require 'patch_ruby/models/preference_response'
|
35
|
+
require 'patch_ruby/models/project'
|
36
|
+
require 'patch_ruby/models/project_list_response'
|
37
|
+
require 'patch_ruby/models/project_response'
|
38
|
+
|
39
|
+
# APIs
|
40
|
+
require 'patch_ruby/api/estimates_api'
|
41
|
+
require 'patch_ruby/api/orders_api'
|
42
|
+
require 'patch_ruby/api/preferences_api'
|
43
|
+
require 'patch_ruby/api/projects_api'
|
44
|
+
|
45
|
+
module Patch
|
46
|
+
class << self
|
47
|
+
# Customize default settings for the SDK using block.
|
48
|
+
# Patch.configure do |config|
|
49
|
+
# config.username = "xxx"
|
50
|
+
# config.password = "xxx"
|
51
|
+
# end
|
52
|
+
# If no block given, return the default Configuration object.
|
53
|
+
def configure
|
54
|
+
if block_given?
|
55
|
+
yield(Configuration.default)
|
56
|
+
else
|
57
|
+
Configuration.default
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
=begin
|
2
|
+
#Patch API V1
|
3
|
+
|
4
|
+
#The core API used to integrate with Patch's service
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v1
|
7
|
+
Contact: developers@usepatch.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'cgi'
|
14
|
+
|
15
|
+
module Patch
|
16
|
+
class EstimatesApi
|
17
|
+
OPERATIONS = [
|
18
|
+
:create_mass_estimate,
|
19
|
+
:retrieve_estimate,
|
20
|
+
:retrieve_estimates,
|
21
|
+
]
|
22
|
+
|
23
|
+
attr_accessor :api_client
|
24
|
+
|
25
|
+
def initialize(api_client = ApiClient.default)
|
26
|
+
@api_client = api_client
|
27
|
+
end
|
28
|
+
# Create an estimate based on mass of CO2
|
29
|
+
# 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
|
+
# @param create_mass_estimate_request [CreateMassEstimateRequest]
|
31
|
+
# @param [Hash] opts the optional parameters
|
32
|
+
# @return [EstimateResponse]
|
33
|
+
def create_mass_estimate(create_mass_estimate_request, opts = {})
|
34
|
+
data, _status_code, _headers = create_mass_estimate_with_http_info(create_mass_estimate_request, opts)
|
35
|
+
data
|
36
|
+
end
|
37
|
+
|
38
|
+
# Create an estimate based on mass of CO2
|
39
|
+
# 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.
|
40
|
+
# @param create_mass_estimate_request [CreateMassEstimateRequest]
|
41
|
+
# @param [Hash] opts the optional parameters
|
42
|
+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
43
|
+
def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {})
|
44
|
+
if @api_client.config.debugging
|
45
|
+
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_mass_estimate ...'
|
46
|
+
end
|
47
|
+
# verify the required parameter 'create_mass_estimate_request' is set
|
48
|
+
if @api_client.config.client_side_validation && create_mass_estimate_request.nil?
|
49
|
+
fail ArgumentError, "Missing the required parameter 'create_mass_estimate_request' when calling EstimatesApi.create_mass_estimate"
|
50
|
+
end
|
51
|
+
# resource path
|
52
|
+
local_var_path = '/v1/estimates/mass'
|
53
|
+
|
54
|
+
# query parameters
|
55
|
+
query_params = opts[:query_params] || {}
|
56
|
+
|
57
|
+
# header parameters
|
58
|
+
header_params = opts[:header_params] || {}
|
59
|
+
# HTTP header 'Accept' (if needed)
|
60
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
61
|
+
# HTTP header 'Content-Type'
|
62
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
63
|
+
|
64
|
+
# form parameters
|
65
|
+
form_params = opts[:form_params] || {}
|
66
|
+
|
67
|
+
# http body (model)
|
68
|
+
post_body = opts[:body] || @api_client.object_to_http_body(create_mass_estimate_request)
|
69
|
+
|
70
|
+
# return_type
|
71
|
+
return_type = opts[:return_type] || 'EstimateResponse'
|
72
|
+
|
73
|
+
# auth_names
|
74
|
+
auth_names = opts[:auth_names] || ['bearer_auth']
|
75
|
+
|
76
|
+
new_options = opts.merge(
|
77
|
+
:header_params => header_params,
|
78
|
+
:query_params => query_params,
|
79
|
+
:form_params => form_params,
|
80
|
+
:body => post_body,
|
81
|
+
:auth_names => auth_names,
|
82
|
+
:return_type => return_type
|
83
|
+
)
|
84
|
+
|
85
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
86
|
+
if @api_client.config.debugging
|
87
|
+
@api_client.config.logger.debug "API called: EstimatesApi#create_mass_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
88
|
+
end
|
89
|
+
return data, status_code, headers
|
90
|
+
end
|
91
|
+
|
92
|
+
# Retrieves an estimate
|
93
|
+
# Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for.
|
94
|
+
# @param id [String]
|
95
|
+
# @param [Hash] opts the optional parameters
|
96
|
+
# @return [EstimateResponse]
|
97
|
+
def retrieve_estimate(id, opts = {})
|
98
|
+
data, _status_code, _headers = retrieve_estimate_with_http_info(id, opts)
|
99
|
+
data
|
100
|
+
end
|
101
|
+
|
102
|
+
# Retrieves an estimate
|
103
|
+
# Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for.
|
104
|
+
# @param id [String]
|
105
|
+
# @param [Hash] opts the optional parameters
|
106
|
+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
107
|
+
def retrieve_estimate_with_http_info(id, opts = {})
|
108
|
+
if @api_client.config.debugging
|
109
|
+
@api_client.config.logger.debug 'Calling API: EstimatesApi.retrieve_estimate ...'
|
110
|
+
end
|
111
|
+
# verify the required parameter 'id' is set
|
112
|
+
if @api_client.config.client_side_validation && id.nil?
|
113
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling EstimatesApi.retrieve_estimate"
|
114
|
+
end
|
115
|
+
# resource path
|
116
|
+
local_var_path = '/v1/estimates/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
|
117
|
+
|
118
|
+
# query parameters
|
119
|
+
query_params = opts[:query_params] || {}
|
120
|
+
|
121
|
+
# header parameters
|
122
|
+
header_params = opts[:header_params] || {}
|
123
|
+
# HTTP header 'Accept' (if needed)
|
124
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
125
|
+
|
126
|
+
# form parameters
|
127
|
+
form_params = opts[:form_params] || {}
|
128
|
+
|
129
|
+
# http body (model)
|
130
|
+
post_body = opts[:body]
|
131
|
+
|
132
|
+
# return_type
|
133
|
+
return_type = opts[:return_type] || 'EstimateResponse'
|
134
|
+
|
135
|
+
# auth_names
|
136
|
+
auth_names = opts[:auth_names] || ['bearer_auth']
|
137
|
+
|
138
|
+
new_options = opts.merge(
|
139
|
+
:header_params => header_params,
|
140
|
+
:query_params => query_params,
|
141
|
+
:form_params => form_params,
|
142
|
+
:body => post_body,
|
143
|
+
:auth_names => auth_names,
|
144
|
+
:return_type => return_type
|
145
|
+
)
|
146
|
+
|
147
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
148
|
+
if @api_client.config.debugging
|
149
|
+
@api_client.config.logger.debug "API called: EstimatesApi#retrieve_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
150
|
+
end
|
151
|
+
return data, status_code, headers
|
152
|
+
end
|
153
|
+
|
154
|
+
# Retrieves a list of estimates
|
155
|
+
# Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for.
|
156
|
+
# @param [Hash] opts the optional parameters
|
157
|
+
# @option opts [Integer] :page
|
158
|
+
# @return [EstimateListResponse]
|
159
|
+
def retrieve_estimates(opts = {})
|
160
|
+
data, _status_code, _headers = retrieve_estimates_with_http_info(opts)
|
161
|
+
data
|
162
|
+
end
|
163
|
+
|
164
|
+
# Retrieves a list of estimates
|
165
|
+
# Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for.
|
166
|
+
# @param [Hash] opts the optional parameters
|
167
|
+
# @option opts [Integer] :page
|
168
|
+
# @return [Array<(EstimateListResponse, Integer, Hash)>] EstimateListResponse data, response status code and response headers
|
169
|
+
def retrieve_estimates_with_http_info(opts = {})
|
170
|
+
if @api_client.config.debugging
|
171
|
+
@api_client.config.logger.debug 'Calling API: EstimatesApi.retrieve_estimates ...'
|
172
|
+
end
|
173
|
+
# resource path
|
174
|
+
local_var_path = '/v1/estimates'
|
175
|
+
|
176
|
+
# query parameters
|
177
|
+
query_params = opts[:query_params] || {}
|
178
|
+
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
|
179
|
+
|
180
|
+
# header parameters
|
181
|
+
header_params = opts[:header_params] || {}
|
182
|
+
# HTTP header 'Accept' (if needed)
|
183
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
184
|
+
|
185
|
+
# form parameters
|
186
|
+
form_params = opts[:form_params] || {}
|
187
|
+
|
188
|
+
# http body (model)
|
189
|
+
post_body = opts[:body]
|
190
|
+
|
191
|
+
# return_type
|
192
|
+
return_type = opts[:return_type] || 'EstimateListResponse'
|
193
|
+
|
194
|
+
# auth_names
|
195
|
+
auth_names = opts[:auth_names] || ['bearer_auth']
|
196
|
+
|
197
|
+
new_options = opts.merge(
|
198
|
+
:header_params => header_params,
|
199
|
+
:query_params => query_params,
|
200
|
+
:form_params => form_params,
|
201
|
+
:body => post_body,
|
202
|
+
:auth_names => auth_names,
|
203
|
+
:return_type => return_type
|
204
|
+
)
|
205
|
+
|
206
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
207
|
+
if @api_client.config.debugging
|
208
|
+
@api_client.config.logger.debug "API called: EstimatesApi#retrieve_estimates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
209
|
+
end
|
210
|
+
return data, status_code, headers
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
@@ -0,0 +1,339 @@
|
|
1
|
+
=begin
|
2
|
+
#Patch API V1
|
3
|
+
|
4
|
+
#The core API used to integrate with Patch's service
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v1
|
7
|
+
Contact: developers@usepatch.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'cgi'
|
14
|
+
|
15
|
+
module Patch
|
16
|
+
class OrdersApi
|
17
|
+
OPERATIONS = [
|
18
|
+
:cancel_order,
|
19
|
+
:create_order,
|
20
|
+
:place_order,
|
21
|
+
:retrieve_order,
|
22
|
+
:retrieve_orders,
|
23
|
+
]
|
24
|
+
|
25
|
+
attr_accessor :api_client
|
26
|
+
|
27
|
+
def initialize(api_client = ApiClient.default)
|
28
|
+
@api_client = api_client
|
29
|
+
end
|
30
|
+
# Cancel an order
|
31
|
+
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled.
|
32
|
+
# @param id [String]
|
33
|
+
# @param [Hash] opts the optional parameters
|
34
|
+
# @return [OrderResponse]
|
35
|
+
def cancel_order(id, opts = {})
|
36
|
+
data, _status_code, _headers = cancel_order_with_http_info(id, opts)
|
37
|
+
data
|
38
|
+
end
|
39
|
+
|
40
|
+
# Cancel an order
|
41
|
+
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled.
|
42
|
+
# @param id [String]
|
43
|
+
# @param [Hash] opts the optional parameters
|
44
|
+
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
45
|
+
def cancel_order_with_http_info(id, opts = {})
|
46
|
+
if @api_client.config.debugging
|
47
|
+
@api_client.config.logger.debug 'Calling API: OrdersApi.cancel_order ...'
|
48
|
+
end
|
49
|
+
# verify the required parameter 'id' is set
|
50
|
+
if @api_client.config.client_side_validation && id.nil?
|
51
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling OrdersApi.cancel_order"
|
52
|
+
end
|
53
|
+
# resource path
|
54
|
+
local_var_path = '/v1/orders/{id}/cancel'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
|
55
|
+
|
56
|
+
# query parameters
|
57
|
+
query_params = opts[:query_params] || {}
|
58
|
+
|
59
|
+
# header parameters
|
60
|
+
header_params = opts[:header_params] || {}
|
61
|
+
# HTTP header 'Accept' (if needed)
|
62
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
63
|
+
|
64
|
+
# form parameters
|
65
|
+
form_params = opts[:form_params] || {}
|
66
|
+
|
67
|
+
# http body (model)
|
68
|
+
post_body = opts[:body]
|
69
|
+
|
70
|
+
# return_type
|
71
|
+
return_type = opts[:return_type] || 'OrderResponse'
|
72
|
+
|
73
|
+
# auth_names
|
74
|
+
auth_names = opts[:auth_names] || ['bearer_auth']
|
75
|
+
|
76
|
+
new_options = opts.merge(
|
77
|
+
:header_params => header_params,
|
78
|
+
:query_params => query_params,
|
79
|
+
:form_params => form_params,
|
80
|
+
:body => post_body,
|
81
|
+
:auth_names => auth_names,
|
82
|
+
:return_type => return_type
|
83
|
+
)
|
84
|
+
|
85
|
+
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
|
86
|
+
if @api_client.config.debugging
|
87
|
+
@api_client.config.logger.debug "API called: OrdersApi#cancel_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
88
|
+
end
|
89
|
+
return data, status_code, headers
|
90
|
+
end
|
91
|
+
|
92
|
+
# Creates an order
|
93
|
+
# Creates an order in the `placed` state. To create a `draft` order, create an estimate first.
|
94
|
+
# @param create_order_request [CreateOrderRequest]
|
95
|
+
# @param [Hash] opts the optional parameters
|
96
|
+
# @return [OrderResponse]
|
97
|
+
def create_order(create_order_request, opts = {})
|
98
|
+
data, _status_code, _headers = create_order_with_http_info(create_order_request, opts)
|
99
|
+
data
|
100
|
+
end
|
101
|
+
|
102
|
+
# Creates an order
|
103
|
+
# Creates an order in the `placed` state. To create a `draft` order, create an estimate first.
|
104
|
+
# @param create_order_request [CreateOrderRequest]
|
105
|
+
# @param [Hash] opts the optional parameters
|
106
|
+
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
107
|
+
def create_order_with_http_info(create_order_request, opts = {})
|
108
|
+
if @api_client.config.debugging
|
109
|
+
@api_client.config.logger.debug 'Calling API: OrdersApi.create_order ...'
|
110
|
+
end
|
111
|
+
# verify the required parameter 'create_order_request' is set
|
112
|
+
if @api_client.config.client_side_validation && create_order_request.nil?
|
113
|
+
fail ArgumentError, "Missing the required parameter 'create_order_request' when calling OrdersApi.create_order"
|
114
|
+
end
|
115
|
+
# resource path
|
116
|
+
local_var_path = '/v1/orders'
|
117
|
+
|
118
|
+
# query parameters
|
119
|
+
query_params = opts[:query_params] || {}
|
120
|
+
|
121
|
+
# header parameters
|
122
|
+
header_params = opts[:header_params] || {}
|
123
|
+
# HTTP header 'Accept' (if needed)
|
124
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
125
|
+
# HTTP header 'Content-Type'
|
126
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
127
|
+
|
128
|
+
# form parameters
|
129
|
+
form_params = opts[:form_params] || {}
|
130
|
+
|
131
|
+
# http body (model)
|
132
|
+
post_body = opts[:body] || @api_client.object_to_http_body(create_order_request)
|
133
|
+
|
134
|
+
# return_type
|
135
|
+
return_type = opts[:return_type] || 'OrderResponse'
|
136
|
+
|
137
|
+
# auth_names
|
138
|
+
auth_names = opts[:auth_names] || ['bearer_auth']
|
139
|
+
|
140
|
+
new_options = opts.merge(
|
141
|
+
:header_params => header_params,
|
142
|
+
:query_params => query_params,
|
143
|
+
:form_params => form_params,
|
144
|
+
:body => post_body,
|
145
|
+
:auth_names => auth_names,
|
146
|
+
:return_type => return_type
|
147
|
+
)
|
148
|
+
|
149
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
150
|
+
if @api_client.config.debugging
|
151
|
+
@api_client.config.logger.debug "API called: OrdersApi#create_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
152
|
+
end
|
153
|
+
return data, status_code, headers
|
154
|
+
end
|
155
|
+
|
156
|
+
# Place an order
|
157
|
+
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
|
158
|
+
# @param id [String]
|
159
|
+
# @param [Hash] opts the optional parameters
|
160
|
+
# @return [OrderResponse]
|
161
|
+
def place_order(id, opts = {})
|
162
|
+
data, _status_code, _headers = place_order_with_http_info(id, opts)
|
163
|
+
data
|
164
|
+
end
|
165
|
+
|
166
|
+
# Place an order
|
167
|
+
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
|
168
|
+
# @param id [String]
|
169
|
+
# @param [Hash] opts the optional parameters
|
170
|
+
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
171
|
+
def place_order_with_http_info(id, opts = {})
|
172
|
+
if @api_client.config.debugging
|
173
|
+
@api_client.config.logger.debug 'Calling API: OrdersApi.place_order ...'
|
174
|
+
end
|
175
|
+
# verify the required parameter 'id' is set
|
176
|
+
if @api_client.config.client_side_validation && id.nil?
|
177
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling OrdersApi.place_order"
|
178
|
+
end
|
179
|
+
# resource path
|
180
|
+
local_var_path = '/v1/orders/{id}/place'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
|
181
|
+
|
182
|
+
# query parameters
|
183
|
+
query_params = opts[:query_params] || {}
|
184
|
+
|
185
|
+
# header parameters
|
186
|
+
header_params = opts[:header_params] || {}
|
187
|
+
# HTTP header 'Accept' (if needed)
|
188
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
189
|
+
|
190
|
+
# form parameters
|
191
|
+
form_params = opts[:form_params] || {}
|
192
|
+
|
193
|
+
# http body (model)
|
194
|
+
post_body = opts[:body]
|
195
|
+
|
196
|
+
# return_type
|
197
|
+
return_type = opts[:return_type] || 'OrderResponse'
|
198
|
+
|
199
|
+
# auth_names
|
200
|
+
auth_names = opts[:auth_names] || ['bearer_auth']
|
201
|
+
|
202
|
+
new_options = opts.merge(
|
203
|
+
:header_params => header_params,
|
204
|
+
:query_params => query_params,
|
205
|
+
:form_params => form_params,
|
206
|
+
:body => post_body,
|
207
|
+
:auth_names => auth_names,
|
208
|
+
:return_type => return_type
|
209
|
+
)
|
210
|
+
|
211
|
+
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
|
212
|
+
if @api_client.config.debugging
|
213
|
+
@api_client.config.logger.debug "API called: OrdersApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
214
|
+
end
|
215
|
+
return data, status_code, headers
|
216
|
+
end
|
217
|
+
|
218
|
+
# Retrieves an order
|
219
|
+
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
|
220
|
+
# @param id [String]
|
221
|
+
# @param [Hash] opts the optional parameters
|
222
|
+
# @return [OrderResponse]
|
223
|
+
def retrieve_order(id, opts = {})
|
224
|
+
data, _status_code, _headers = retrieve_order_with_http_info(id, opts)
|
225
|
+
data
|
226
|
+
end
|
227
|
+
|
228
|
+
# Retrieves an order
|
229
|
+
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
|
230
|
+
# @param id [String]
|
231
|
+
# @param [Hash] opts the optional parameters
|
232
|
+
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
233
|
+
def retrieve_order_with_http_info(id, opts = {})
|
234
|
+
if @api_client.config.debugging
|
235
|
+
@api_client.config.logger.debug 'Calling API: OrdersApi.retrieve_order ...'
|
236
|
+
end
|
237
|
+
# verify the required parameter 'id' is set
|
238
|
+
if @api_client.config.client_side_validation && id.nil?
|
239
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling OrdersApi.retrieve_order"
|
240
|
+
end
|
241
|
+
# resource path
|
242
|
+
local_var_path = '/v1/orders/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
|
243
|
+
|
244
|
+
# query parameters
|
245
|
+
query_params = opts[:query_params] || {}
|
246
|
+
|
247
|
+
# header parameters
|
248
|
+
header_params = opts[:header_params] || {}
|
249
|
+
# HTTP header 'Accept' (if needed)
|
250
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
251
|
+
|
252
|
+
# form parameters
|
253
|
+
form_params = opts[:form_params] || {}
|
254
|
+
|
255
|
+
# http body (model)
|
256
|
+
post_body = opts[:body]
|
257
|
+
|
258
|
+
# return_type
|
259
|
+
return_type = opts[:return_type] || 'OrderResponse'
|
260
|
+
|
261
|
+
# auth_names
|
262
|
+
auth_names = opts[:auth_names] || ['bearer_auth']
|
263
|
+
|
264
|
+
new_options = opts.merge(
|
265
|
+
:header_params => header_params,
|
266
|
+
:query_params => query_params,
|
267
|
+
:form_params => form_params,
|
268
|
+
:body => post_body,
|
269
|
+
:auth_names => auth_names,
|
270
|
+
:return_type => return_type
|
271
|
+
)
|
272
|
+
|
273
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
274
|
+
if @api_client.config.debugging
|
275
|
+
@api_client.config.logger.debug "API called: OrdersApi#retrieve_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
276
|
+
end
|
277
|
+
return data, status_code, headers
|
278
|
+
end
|
279
|
+
|
280
|
+
# Retrieves a list of orders
|
281
|
+
# Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
|
282
|
+
# @param [Hash] opts the optional parameters
|
283
|
+
# @option opts [Integer] :page
|
284
|
+
# @return [OrderListResponse]
|
285
|
+
def retrieve_orders(opts = {})
|
286
|
+
data, _status_code, _headers = retrieve_orders_with_http_info(opts)
|
287
|
+
data
|
288
|
+
end
|
289
|
+
|
290
|
+
# Retrieves a list of orders
|
291
|
+
# Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
|
292
|
+
# @param [Hash] opts the optional parameters
|
293
|
+
# @option opts [Integer] :page
|
294
|
+
# @return [Array<(OrderListResponse, Integer, Hash)>] OrderListResponse data, response status code and response headers
|
295
|
+
def retrieve_orders_with_http_info(opts = {})
|
296
|
+
if @api_client.config.debugging
|
297
|
+
@api_client.config.logger.debug 'Calling API: OrdersApi.retrieve_orders ...'
|
298
|
+
end
|
299
|
+
# resource path
|
300
|
+
local_var_path = '/v1/orders'
|
301
|
+
|
302
|
+
# query parameters
|
303
|
+
query_params = opts[:query_params] || {}
|
304
|
+
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
|
305
|
+
|
306
|
+
# header parameters
|
307
|
+
header_params = opts[:header_params] || {}
|
308
|
+
# HTTP header 'Accept' (if needed)
|
309
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
310
|
+
|
311
|
+
# form parameters
|
312
|
+
form_params = opts[:form_params] || {}
|
313
|
+
|
314
|
+
# http body (model)
|
315
|
+
post_body = opts[:body]
|
316
|
+
|
317
|
+
# return_type
|
318
|
+
return_type = opts[:return_type] || 'OrderListResponse'
|
319
|
+
|
320
|
+
# auth_names
|
321
|
+
auth_names = opts[:auth_names] || ['bearer_auth']
|
322
|
+
|
323
|
+
new_options = opts.merge(
|
324
|
+
:header_params => header_params,
|
325
|
+
:query_params => query_params,
|
326
|
+
:form_params => form_params,
|
327
|
+
:body => post_body,
|
328
|
+
:auth_names => auth_names,
|
329
|
+
:return_type => return_type
|
330
|
+
)
|
331
|
+
|
332
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
333
|
+
if @api_client.config.debugging
|
334
|
+
@api_client.config.logger.debug "API called: OrdersApi#retrieve_orders\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
335
|
+
end
|
336
|
+
return data, status_code, headers
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|