@@ -36,11 +36,11 @@ After installing the package, you'll have to configure it with your API key whic
3636
3737``` javascript
3838// ES6+
39- import Patch from ' @patch-technology/patch' ;
40- const patch = Patch (' key_test_1234' );
39+ import Patch from ' @patch-technology/patch'
40+ const patch = Patch (' key_test_1234' )
4141
4242// ES5
43- var patch = require (' @patch-technology/patch' ).default (' key_test_1234' );
43+ var patch = require (' @patch-technology/patch' ).default (' key_test_1234' )
4444```
4545
4646### Orders
@@ -56,8 +56,16 @@ In Patch, orders represent a purchase of carbon offsets or negative emissions by
5656const mass = 1000000 // Pass in the mass in grams (i.e. 1 metric tonne)
5757patch .orders .createOrder ({ mass_g: mass })
5858
59+ // You can also specify a project-id field (optional) to be used instead of the preferred one
60+ const projectId = ' pro_test_1234' // Pass in the project's ID
61+ patch .orders .createOrder ({ mass_g: mass, project_id: projectId })
62+
63+ // Orders also accept a metadata field (optional)
64+ const metadata = { user: ' john doe' }
65+ patch .orders .createOrder ({ mass_g: mass, metadata: metadata })
66+
5967// Retrieve an order
60- orderId = ' ord_test_1234' // Pass in the order's id
68+ const orderId = ' ord_test_1234' // Pass in the order's id
6169patch .orders .retrieveOrder (orderId)
6270
6371// Place an order
@@ -83,16 +91,20 @@ Estimates allow API users to get a quote for the cost of compensating a certain
8391
8492``` javascript
8593// Create an estimate
86- const mass = 1000000 ; // Pass in the mass in grams (i.e. 1 metric tonne)
87- patch .estimates .createMassEstimate ({ mass_g: mass });
94+ const mass = 1000000 // Pass in the mass in grams (i.e. 1 metric tonne)
95+ patch .estimates .createMassEstimate ({ mass_g: mass })
96+
97+ // You can also specify a project-id field (optional) to be used instead of the preferred one
98+ const projectId = ' pro_test_1234' // Pass in the project's ID
99+ patch .estimates .createMassEstimate ({ mass_g: mass, project_id: projectId })
88100
89101// Retrieve an estimate
90- const estimateId = ' est_test_1234' ;
91- patch .estimates .retrieveEstimate (estimate_id);
102+ const estimateId = ' est_test_1234'
103+ patch .estimates .retrieveEstimate (estimate_id)
92104
93105// Retrieve a list of estimates
94- const page = 1 ; // Pass in which page of estimates you'd like
95- patch .estimates .retrieveEstimates ({ page });
106+ const page = 1 // Pass in which page of estimates you'd like
107+ patch .estimates .retrieveEstimates ({ page })
96108```
97109
98110### Projects
@@ -105,12 +117,12 @@ Projects are the ways Patch takes CO2 out of the air. They can represent refores
105117
106118``` javascript
107119// Retrieve a project
108- const projectId = ' pro_test_1234' ; // Pass in the project's ID
109- patch .projects .retrieveProject (projectId);
120+ const projectId = ' pro_test_1234' // Pass in the project's ID
121+ patch .projects .retrieveProject (projectId)
110122
111123// Retrieve a list of projects
112- const page = 1 ; // Pass in which page of projects you'd like
113- patch .projects .retrieveProjects ({ page });
124+ const page = 1 // Pass in which page of projects you'd like
125+ patch .projects .retrieveProjects ({ page })
114126```
115127
116128### Preferences
@@ -123,18 +135,44 @@ Preferences are how you route your orders in Patch. If you don't have a preferen
123135
124136``` javascript
125137// Create a preference
126- const projectId = ' pro_test_1234' ; // Pass in the project_id for your preference
127- patch .preferences .createPreference (( project_id: projectId));
138+ const projectId = ' pro_test_1234' // Pass in the project_id for your preference
139+ patch .preferences .createPreference ({ project_id: projectId })
128140
129141// Retrieve a preference
130- const preferenceId = ' pre_test_1234' ; // Pass in the preferences's id
131- patch .preferences .retrievePreference (preferenceId);
142+ const preferenceId = ' pre_test_1234' // Pass in the preferences's id
143+ patch .preferences .retrievePreference (preferenceId)
132144
133145// Delete a preference
134- const preferenceId = ' pre_test_1234' ; // Pass in the preferences's id
135- patch .preferences .deletePreference (preferenceId);
146+ const preferenceId = ' pre_test_1234' // Pass in the preferences's id
147+ patch .preferences .deletePreference (preferenceId)
136148
137149// Retrieve a list of preferences
138- const page = 1 ; // Pass in which page of preferences you'd like
139- patch .preferences .retrievePreferences ({ page });
150+ const page = 1 // Pass in which page of preferences you'd like
151+ patch .preferences .retrievePreferences ({ page })
152+ ```
153+
154+ ## Development
155+
156+ Install node modules
157+
158+ ```
159+ $ npm install
160+ ```
161+
162+ Set required environment variables:
163+
164+ ```
165+ $ export SANDBOX_API_KEY=<SANDBOX API KEY>
166+ ```
167+
168+ Build:
169+
170+ ```
171+ $ npm run build
172+ ```
173+
174+ Run tests:
175+
176+ ```
177+ $ npm test
140178```
0 commit comments