patch_ruby 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +27 -7
- data/lib/patch_ruby/configuration.rb +2 -2
- data/lib/patch_ruby/version.rb +1 -1
- data/patch_ruby.gemspec +1 -1
- data/spec/configuration_spec.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dad4b825fa4e046cac94a1672e5b89d5fc1edd0ab48e414d35449e71137a1b01
|
4
|
+
data.tar.gz: 8a23b9c1d27d6dd8b32da5f064e7aaef3bd4c2452d3b9e4934c2dd9877d97c6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee4a8a1abc63aea00bff1b795340ab44bad333e539f89d39733d74d8645907796afdbc2a72f0ab93a84bdde82ec2d9dc825c8fe7ebd3715337fc82a606edab12
|
7
|
+
data.tar.gz: 96376448d26040c8ce8be567a9ff9110964f1fb380ab7852029274508ce2b9ab599a809f927918dd0661dc153f2eee6f03315f4486b3ce7d4ebadf76e08cc951
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@ 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.5.0] - 2021-03-01
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Changed base URL from https://api.usepatch.com to https://api.patch.io
|
13
|
+
|
8
14
|
## [1.4.0] - 2021-02-15
|
9
15
|
|
10
16
|
### Added
|
@@ -20,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
20
26
|
|
21
27
|
### Added
|
22
28
|
|
23
|
-
- Adds support for creating carbon emission estimates for flights, shipping, and vehicles. See the [docs](https://docs.
|
29
|
+
- Adds support for creating carbon emission estimates for flights, shipping, and vehicles. See the [docs](https://docs.patch.io/#/?id=estimates) for more information.
|
24
30
|
|
25
31
|
## [1.2.5] - 2020-01-08
|
26
32
|
|
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,11 +101,13 @@ 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
112
|
# Create a mass estimate
|
102
113
|
mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
|
@@ -142,6 +153,7 @@ Patch::Estimate.retrieve_estimates(page: page)
|
|
142
153
|
```
|
143
154
|
|
144
155
|
### Projects
|
156
|
+
|
145
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.
|
146
158
|
|
147
159
|
When fetching Projects, you can add filters to the query to narrow the result. Currently supported filters are:
|
@@ -150,9 +162,10 @@ When fetching Projects, you can add filters to the query to narrow the result. C
|
|
150
162
|
- `type`
|
151
163
|
- `minimum_available_mass`
|
152
164
|
|
153
|
-
[API Reference](https://docs.
|
165
|
+
[API Reference](https://docs.patch.io/#/?id=projects)
|
154
166
|
|
155
167
|
#### Examples
|
168
|
+
|
156
169
|
```ruby
|
157
170
|
# Retrieve a project
|
158
171
|
project_id = 'pro_test_1234' # Pass in the project's ID
|
@@ -176,11 +189,13 @@ Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
|
|
176
189
|
```
|
177
190
|
|
178
191
|
### Preferences
|
179
|
-
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).
|
180
192
|
|
181
|
-
|
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)
|
182
196
|
|
183
197
|
#### Examples
|
198
|
+
|
184
199
|
```ruby
|
185
200
|
# Create a preference
|
186
201
|
project_id = 'pro_test_1234' # Pass in the project_id for your preference
|
@@ -202,26 +217,31 @@ Patch::Preference.retrieve_preferences(page: page)
|
|
202
217
|
## Development
|
203
218
|
|
204
219
|
To build the gem locally, run:
|
220
|
+
|
205
221
|
```
|
206
222
|
$ gem build patch_ruby.gemspec
|
207
223
|
```
|
208
224
|
|
209
225
|
This will create a .gem file. To install the local gem:
|
226
|
+
|
210
227
|
```
|
211
228
|
$ gem install patch_ruby-1.x.x.gem
|
212
229
|
```
|
213
230
|
|
214
231
|
Install dependencies:
|
232
|
+
|
215
233
|
```
|
216
234
|
$ bundle install
|
217
235
|
```
|
218
236
|
|
219
237
|
Set up required environment variables:
|
238
|
+
|
220
239
|
```
|
221
240
|
$ export SANDBOX_API_KEY=<SANDBOX API KEY>
|
222
241
|
```
|
223
242
|
|
224
243
|
Run tests:
|
244
|
+
|
225
245
|
```
|
226
246
|
$ bundle exec rspec
|
227
247
|
```
|
@@ -127,7 +127,7 @@ module Patch
|
|
127
127
|
|
128
128
|
def initialize
|
129
129
|
@scheme = 'https'
|
130
|
-
@host = 'api.
|
130
|
+
@host = 'api.patch.io'
|
131
131
|
@base_path = ''
|
132
132
|
@api_key = {}
|
133
133
|
@api_key_prefix = {}
|
@@ -212,7 +212,7 @@ module Patch
|
|
212
212
|
variables: {
|
213
213
|
defaultHost: {
|
214
214
|
description: "No description provided",
|
215
|
-
default_value: "api.
|
215
|
+
default_value: "api.patch.io",
|
216
216
|
}
|
217
217
|
}
|
218
218
|
}
|
data/lib/patch_ruby/version.rb
CHANGED
data/patch_ruby.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.platform = Gem::Platform::RUBY
|
22
22
|
s.authors = ["Patch Technology"]
|
23
23
|
s.email = ["developers@usepatch.com"]
|
24
|
-
s.homepage = "https://www.
|
24
|
+
s.homepage = "https://www.patch.io"
|
25
25
|
s.summary = "Ruby wrapper for the Patch API"
|
26
26
|
s.description = "Ruby wrapper for the Patch API"
|
27
27
|
s.license = 'MIT'
|
data/spec/configuration_spec.rb
CHANGED
@@ -18,7 +18,7 @@ describe Patch::Configuration do
|
|
18
18
|
before(:each) do
|
19
19
|
# uncomment below to setup host and base_path
|
20
20
|
# require 'URI'
|
21
|
-
# uri = URI.parse("https://api.
|
21
|
+
# uri = URI.parse("https://api.patch.io")
|
22
22
|
# Patch.configure do |c|
|
23
23
|
# c.host = uri.host
|
24
24
|
# c.base_path = uri.path
|
@@ -28,14 +28,14 @@ describe Patch::Configuration do
|
|
28
28
|
describe '#base_url' do
|
29
29
|
it 'should have the default value' do
|
30
30
|
# uncomment below to test default value of the base path
|
31
|
-
# expect(config.base_url).to eq("https://api.
|
31
|
+
# expect(config.base_url).to eq("https://api.patch.io")
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should remove trailing slashes' do
|
35
35
|
[nil, '', '/', '//'].each do |base_path|
|
36
36
|
config.base_path = base_path
|
37
37
|
# uncomment below to test trailing slashes
|
38
|
-
# expect(config.base_url).to eq("https://api.
|
38
|
+
# expect(config.base_url).to eq("https://api.patch.io")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patch_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patch Technology
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -163,7 +163,7 @@ files:
|
|
163
163
|
- spec/models/project_spec.rb
|
164
164
|
- spec/spec_helper.rb
|
165
165
|
- spec/support/shared/generated_classes.rb
|
166
|
-
homepage: https://www.
|
166
|
+
homepage: https://www.patch.io
|
167
167
|
licenses:
|
168
168
|
- MIT
|
169
169
|
metadata: {}
|