@@ -102,27 +102,33 @@ Estimates allow API users to get a quote for the cost of compensating a certain
102
102
103
103
``` javascript
104
104
// Create a mass estimate
105
- const mass = 1000000 ; // Pass in the mass in grams (i.e. 1 metric tonne)
106
- patch .estimates .createMassEstimate ({ mass_g: mass });
105
+ const mass_g = 1000000 ; // Pass in the mass in grams (i.e. 1 metric tonne)
106
+ patch .estimates .createMassEstimate ({ mass_g });
107
107
108
108
// Create a flight estimate
109
109
const distance_m = 9000000 ; // Pass in the distance traveled in meters
110
- patch .estimates .createFlightEstimate ({ distance_m: distance_m });
110
+ patch .estimates .createFlightEstimate ({ distance_m });
111
111
112
112
// Create a shipping estimate
113
113
const distance_m = 9000000 ;
114
114
// Pass in the shipping distance in meters, the transportation method, and the package mass
115
115
patch .estimates .createShippingEstimate ({
116
- distance_m: distance_m ,
116
+ distance_m,
117
117
transportation_method: ' air' ,
118
118
package_mass_g: 1000
119
119
});
120
120
121
+ // Create a bitcoin estimate
122
+ const transaction_value_btc_sats = 1000 ; // [Optional] Pass in the transaction value in satoshis
123
+ patch .estimates .createBitcoinEstimate ({
124
+ transaction_value_btc_sats
125
+ });
126
+
121
127
// Create a vehicle estimate
122
128
const distance_m = 9000000 ;
123
129
// Pass in the shipping distance in meters and the model/make/year of the vehicle
124
130
patch .estimates .createVehicleEstimate ({
125
- distance_m: distance_m ,
131
+ distance_m,
126
132
make: ' Toyota' ,
127
133
model: ' Corolla' ,
128
134
year: 1995
@@ -184,7 +190,7 @@ Preferences are how you route your orders in Patch. If you don't have a preferen
184
190
``` javascript
185
191
// Create a preference
186
192
const projectId = ' pro_test_1234' ; // Pass in the project_id for your preference
187
- patch .preferences .createPreference (( project_id: projectId) );
193
+ patch .preferences .createPreference ({ project_id: projectId } );
188
194
189
195
// Retrieve a preference
190
196
const preferenceId = ' pre_test_1234' ; // Pass in the preferences's id
@@ -234,9 +240,13 @@ $ npm link @patch-technology/patch
234
240
This will create a ` node_modules ` directory in your test repository which will symlink to your locally built package. To test out the package, open a node REPL and import the package and run some queries.
235
241
236
242
``` sh
237
- $ node
238
- > const Patch = require(' @patch-technology/patch' )
239
- > Patch.default(process.env.SANDBOX_API_KEY).projects.retrieveProjects ().then(( response) => console.log(response))
243
+ SANDBOX_API_KEY=xxx node
244
+ ```
245
+
246
+ ``` node
247
+ const Patch = require (' @patch-technology/patch' );
248
+ const patch = Patch .default (process .env .SANDBOX_API_KEY );
249
+ patch .projects .retrieveProjects ().then ((response ) => console .log (response));
240
250
```
241
251
242
252
### Run the specs
0 commit comments