Skip to content

Commit 3b1a258

Browse files
committed
Inital commit
0 parents  commit 3b1a258

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+8137
-0
lines changed

.babelrc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env"
4+
],
5+
"plugins": [
6+
"@babel/plugin-syntax-dynamic-import",
7+
"@babel/plugin-syntax-import-meta",
8+
"@babel/plugin-proposal-class-properties",
9+
"@babel/plugin-proposal-json-strings",
10+
[
11+
"@babel/plugin-proposal-decorators",
12+
{
13+
"legacy": true
14+
}
15+
],
16+
"@babel/plugin-proposal-function-sent",
17+
"@babel/plugin-proposal-export-namespace-from",
18+
"@babel/plugin-proposal-numeric-separator",
19+
"@babel/plugin-proposal-throw-expressions",
20+
"@babel/plugin-proposal-export-default-from",
21+
"@babel/plugin-proposal-logical-assignment-operators",
22+
"@babel/plugin-proposal-optional-chaining",
23+
[
24+
"@babel/plugin-proposal-pipeline-operator",
25+
{
26+
"proposal": "minimal"
27+
}
28+
],
29+
"@babel/plugin-proposal-nullish-coalescing-operator",
30+
"@babel/plugin-proposal-do-expressions",
31+
"@babel/plugin-proposal-function-bind"
32+
]
33+
}

.openapi-generator-ignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

.openapi-generator/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.3.1

README.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Patch Node SDK
2+
![Test](https://github.com/patch-technology/patch-node/workflows/Test/badge.svg)
3+
[![Discord](https://img.shields.io/discord/733029448558837792)](https://discord.gg/AU8543D)
4+
5+
The official Node package for the [Patch API](https://www.usepatch.com)
6+
7+
## Documentation
8+
For a complete API reference, check out [Patch's API Reference.](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml)
9+
10+
## Installation
11+
12+
Add the gem to your `package.json` with `npm`:
13+
```shell
14+
npm install patch-node --save
15+
```
16+
17+
Or `yarn`:
18+
```shell
19+
yarn add patch-node
20+
```
21+
22+
## Usage
23+
24+
### Configuration
25+
26+
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:
27+
```javascript
28+
patch = require('patch-node')('key_test_123')
29+
```
30+
31+
### Orders
32+
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.
33+
34+
[API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1orders/get)
35+
36+
#### Examples
37+
```ruby
38+
# Create an order
39+
mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
40+
Patch::Order.create_order(mass_g: mass)
41+
42+
# Retrieve an order
43+
order_id = 'ord_test_1234' # Pass in the order's id
44+
Patch::Order.retrieve_order(order_id)
45+
46+
# Place an order
47+
order_id = 'ord_test_1234' # Pass in the order's id
48+
Patch::Order.place_order(order_id)
49+
50+
# Cancel an order
51+
order_id = 'ord_test_1234' # Pass in the order's id
52+
Patch::Order.cancel_order(order_id)
53+
54+
# Retrieve a list of orders
55+
page = 1 # Pass in which page of orders you'd like
56+
Patch::Order.retrieve_orders(page: page)
57+
```
58+
59+
### Estimates
60+
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.
61+
62+
[API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1estimates/get)
63+
64+
#### Examples
65+
```ruby
66+
# Create an estimate
67+
mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
68+
Patch::Estimate.create_mass_estimate(mass_g: mass)
69+
70+
# Retrieve an estimate
71+
estimate_id = 'est_test_1234'
72+
Patch::Estimate.retrieve_estimate(estimate_id)
73+
74+
# Retrieve a list of estimates
75+
page = 1 # Pass in which page of estimates you'd like
76+
Patch::Estimate.retrieve_estimates(page: page)
77+
```
78+
79+
### Projects
80+
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.
81+
82+
[API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1projects/get)
83+
84+
#### Examples
85+
```ruby
86+
# Retrieve a project
87+
project_id = 'pro_test_1234' # Pass in the project's ID
88+
Patch::Project.retrieve_project(project_id)
89+
90+
# Retrieve a list of projects
91+
page = 1 # Pass in which page of projects you'd like
92+
Patch::Project.retrieve_projects(page: page)
93+
```
94+
95+
### Preferences
96+
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).
97+
98+
[API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1preferences/post)
99+
100+
#### Examples
101+
```ruby
102+
# Create a preference
103+
project_id = 'pro_test_1234' # Pass in the project_id for your preference
104+
Patch::Preference.create_preference(project_id: project_id)
105+
106+
# Retrieve a preference
107+
preference_id = 'pre_test_1234' # Pass in the preferences's id
108+
Patch::Preference.retrieve_preference(preference_id)
109+
110+
# Delete a preference
111+
preference_id = 'pre_test_1234' # Pass in the preferences's id
112+
Patch::Preference.delete_preference(preference_id)
113+
114+
# Retrieve a list of preferences
115+
page = 1 # Pass in which page of preferences you'd like
116+
Patch::Preference.retrieve_preferences(page: page)
117+
```

0 commit comments

Comments
 (0)