Skip to content

Commit e9d9a82

Browse files
authored
Merge pull request #4 from patch-technology/bs/prep-1.0.0-release
First Release
2 parents 164ca89 + c4d18ad commit e9d9a82

File tree

2 files changed

+89
-14
lines changed

2 files changed

+89
-14
lines changed

README.md

+88-13
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
The official Ruby gem for the [Patch API](https://www.usepatch.com)
66

77
## 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)
109

1110
## Installation
1211

@@ -30,6 +29,8 @@ gem install patch_ruby
3029

3130
## Usage
3231

32+
### Configuration
33+
3334
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:
3435
```ruby
3536
require 'patch_ruby'
@@ -40,16 +41,90 @@ Patch.configure do |config|
4041
end
4142
```
4243

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.
46+
47+
[API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1orders/get)
48+
49+
#### Examples
4450
```ruby
45-
begin
46-
orders_response = Patch::Order.retrieve_orders
47-
48-
orders_response.data.each do |order|
49-
puts "Order ID: #{order.id}, Order State: #{order.state}"
50-
end
51-
# Rescue from any Patch API errors
52-
rescue Patch::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.
74+
75+
[API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1estimates/get)
76+
77+
#### Examples
78+
```ruby
79+
# Create an estimate
80+
mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
81+
Patch::Estimate.create_mass_estimate(mass_g: mass)
82+
83+
# Retrieve an estimate
84+
estimate_id = 'est_test_1234'
85+
Patch::Estimate.retrieve_estimate(estimate_id)
86+
87+
# Retrieve a list of estimates
88+
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.
94+
95+
[API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1projects/get)
96+
97+
#### Examples
98+
```ruby
99+
# Retrieve a project
100+
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).
110+
111+
[API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1preferences/post)
112+
113+
#### Examples
114+
```ruby
115+
# Create a preference
116+
project_id = 'pro_test_1234' # Pass in the project_id for your preference
117+
Patch::Preference.create_preference(project_id: project_id)
118+
119+
# Retrieve a preference
120+
preference_id = 'pre_test_1234' # Pass in the preferences's id
121+
Patch::Preference.retrieve_preference(preference_id)
122+
123+
# Delete a preference
124+
preference_id = 'pre_test_1234' # Pass in the preferences's id
125+
Patch::Preference.delete_preference(preference_id)
126+
127+
# Retrieve a list of preferences
128+
page = 1 # Pass in which page of preferences you'd like
129+
Patch::Preference.retrieve_preferences(page: page)
55130
```

lib/patch_ruby/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
=end
1212

1313
module Patch
14-
VERSION = '1.0.0.pre'
14+
VERSION = '1.0.0'
1515
end

0 commit comments

Comments
 (0)