-
Notifications
You must be signed in to change notification settings - Fork 1
/
quote-get.ts
36 lines (30 loc) · 1.02 KB
/
quote-get.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import dotenv from "dotenv";
import { join } from "path";
import { fileURLToPath } from "url";
dotenv.config({
path: fileURLToPath(join(import.meta.url, "..", "..", ".env")),
});
const KEY_ID = process.env.KEY_ID;
const WALLET_ADDRESS = process.env.WALLET_ADDRESS;
const QUOTE_URL = process.env.QUOTE_URL;
const QUOTE_ACCESS_TOKEN = process.env.QUOTE_ACCESS_TOKEN;
const PRIVATE_KEY_PATH = process.env.PRIVATE_KEY_PATH;
//@! start chunk 1 | title=Import dependencies
import { createAuthenticatedClient } from "@interledger/open-payments";
//@! end chunk 1
//@! start chunk 2 | title=Initialize Open Payments client
const client = await createAuthenticatedClient({
walletAddressUrl: WALLET_ADDRESS,
privateKey: PRIVATE_KEY_PATH,
keyId: KEY_ID,
});
//@! end chunk 2
//@! start chunk 3 | title=Get quote
const quote = await client.quote.get({
url: QUOTE_URL,
accessToken: QUOTE_ACCESS_TOKEN,
});
//@! end chunk 3
//@! start chunk 4 | title=Output
console.log("QUOTE:", JSON.stringify(quote, null, 2));
//@! end chunk 4