You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+88-13
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,7 @@
5
5
The official Ruby gem for the [Patch API](https://www.usepatch.com)
6
6
7
7
## Documentation
8
-
9
-
For detailed documentation and examples, see the [Patch API docs](https://docs.usepatch.com).
8
+
For a complete API reference, check out [Patch's API Reference.](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml)
10
9
11
10
## Installation
12
11
@@ -30,6 +29,8 @@ gem install patch_ruby
30
29
31
30
## Usage
32
31
32
+
### Configuration
33
+
33
34
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:
34
35
```ruby
35
36
require'patch_ruby'
@@ -40,16 +41,90 @@ Patch.configure do |config|
40
41
end
41
42
```
42
43
43
-
Once configured, you can test it out:
44
+
### Orders
45
+
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.
puts"Order ID: #{order.id}, Order State: #{order.state}"
50
-
end
51
-
# Rescue from any Patch API errors
52
-
rescuePatch::ApiError => e
53
-
puts"Failed to retrieve Orders with status code #{e.code}: #{e.message}"
54
-
end
51
+
# Create an order
52
+
mass =1_000_000# Pass in the mass in grams (i.e. 1 metric tonne)
53
+
Patch::Order.create_order(mass_g: mass)
54
+
55
+
# Retrieve an order
56
+
order_id ='ord_test_1234'# Pass in the order's id
57
+
Patch::Order.retrieve_order(order_id)
58
+
59
+
# Place an order
60
+
order_id ='ord_test_1234'# Pass in the order's id
61
+
Patch::Order.place_order(order_id)
62
+
63
+
# Cancel an order
64
+
order_id ='ord_test_1234'# Pass in the order's id
65
+
Patch::Order.cancel_order(order_id)
66
+
67
+
# Retrieve a list of orders
68
+
page =1# Pass in which page of orders you'd like
69
+
Patch::Order.retrieve_orders(page: page)
70
+
```
71
+
72
+
### Estimates
73
+
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.
page =1# Pass in which page of estimates you'd like
89
+
Patch::Estimate.retrieve_estimates(page: page)
90
+
```
91
+
92
+
### Projects
93
+
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.
project_id ='pro_test_1234'# Pass in the project's ID
101
+
Patch::Project.retrieve_project(project_id)
102
+
103
+
# Retrieve a list of projects
104
+
page =1# Pass in which page of projects you'd like
105
+
Patch::Project.retrieve_projects(page: page)
106
+
```
107
+
108
+
### Preferences
109
+
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](dashboard.usepatch.com/projects).
0 commit comments