1
1
# Openledger TypeScript Library
2
2
3
3
[ ![ fern shield] ( https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen )] ( https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fopenledger%2Fopenledger-typescript-sdk )
4
- [ ![ npm shield] ( https://img.shields.io/npm/v/@ openledger/typescript-sdk )] ( https://www.npmjs.com/package/@ openledger/typescript-sdk )
4
+ [ ![ npm shield] ( https://img.shields.io/npm/v/openledger )] ( https://www.npmjs.com/package/openledger )
5
5
6
6
The Openledger TypeScript library provides convenient access to the Openledger API from TypeScript.
7
7
8
8
## Installation
9
9
10
10
``` sh
11
- npm i -s @ openledger/typescript-sdk
11
+ npm i -s openledger
12
12
```
13
13
14
14
## Reference
@@ -20,12 +20,13 @@ A full reference for this library is available [here](./reference.md).
20
20
Instantiate and use the client with the following:
21
21
22
22
``` typescript
23
- import { OpenLedgerClientClient } from " @ openledger/typescript-sdk " ;
23
+ import { OpenLedgerClientClient } from " openledger" ;
24
24
25
25
const client = new OpenLedgerClientClient ({ token: " YOUR_TOKEN" });
26
- await client .authentication .generateToken ({
27
- clientId: " client_id" ,
28
- clientSecret: " client_secret" ,
26
+ await client .categories .createANewCategory ({
27
+ entityId: " entityId" ,
28
+ name: " name" ,
29
+ type: " ASSET" ,
29
30
});
30
31
```
31
32
@@ -35,9 +36,9 @@ The SDK exports all request and response types as TypeScript interfaces. Simply
35
36
following namespace:
36
37
37
38
``` typescript
38
- import { OpenLedgerClient } from " @ openledger/typescript-sdk " ;
39
+ import { OpenLedgerClient } from " openledger" ;
39
40
40
- const request: OpenLedgerClient .TokenRequest = {
41
+ const request: OpenLedgerClient .GetV1BanksCreateLinkRequest = {
41
42
...
42
43
};
43
44
```
@@ -48,10 +49,10 @@ When the API returns a non-success status code (4xx or 5xx response), a subclass
48
49
will be thrown.
49
50
50
51
``` typescript
51
- import { OpenLedgerClientError } from " @ openledger/typescript-sdk " ;
52
+ import { OpenLedgerClientError } from " openledger" ;
52
53
53
54
try {
54
- await client .authentication . generateToken (... );
55
+ await client .categories . createANewCategory (... );
55
56
} catch (err ) {
56
57
if (err instanceof OpenLedgerClientError ) {
57
58
console .log (err .statusCode );
69
70
If you would like to send additional headers as part of the request, use the ` headers ` request option.
70
71
71
72
``` typescript
72
- const response = await client .authentication . generateToken (... , {
73
+ const response = await client .categories . createANewCategory (... , {
73
74
headers: {
74
75
' X-Custom-Header' : ' custom value'
75
76
}
@@ -91,7 +92,7 @@ A request is deemed retryable when any of the following HTTP status codes is ret
91
92
Use the ` maxRetries ` request option to configure this behavior.
92
93
93
94
``` typescript
94
- const response = await client .authentication . generateToken (... , {
95
+ const response = await client .categories . createANewCategory (... , {
95
96
maxRetries: 0 // override maxRetries at the request level
96
97
});
97
98
```
@@ -101,7 +102,7 @@ const response = await client.authentication.generateToken(..., {
101
102
The SDK defaults to a 60 second timeout. Use the ` timeoutInSeconds ` option to configure this behavior.
102
103
103
104
``` typescript
104
- const response = await client .authentication . generateToken (... , {
105
+ const response = await client .categories . createANewCategory (... , {
105
106
timeoutInSeconds: 30 // override timeout to 30s
106
107
});
107
108
```
@@ -112,7 +113,7 @@ The SDK allows users to abort requests at any point by passing in an abort signa
112
113
113
114
``` typescript
114
115
const controller = new AbortController ();
115
- const response = await client .authentication . generateToken (... , {
116
+ const response = await client .categories . createANewCategory (... , {
116
117
abortSignal: controller .signal
117
118
});
118
119
controller .abort (); // aborts the request
@@ -124,7 +125,7 @@ The SDK provides access to raw response data, including headers, through the `.w
124
125
The ` .withRawResponse() ` method returns a promise that results to an object with a ` data ` and a ` rawResponse ` property.
125
126
126
127
``` typescript
127
- const { data, rawResponse } = await client .authentication . generateToken (... ).withRawResponse ();
128
+ const { data, rawResponse } = await client .categories . createANewCategory (... ).withRawResponse ();
128
129
129
130
console .log (data );
130
131
console .log (rawResponse .headers [' X-My-Header' ]);
@@ -148,7 +149,7 @@ The SDK provides a way for you to customize the underlying HTTP client / Fetch f
148
149
unsupported environment, this provides a way for you to break glass and ensure the SDK works.
149
150
150
151
``` typescript
151
- import { OpenLedgerClientClient } from " @ openledger/typescript-sdk " ;
152
+ import { OpenLedgerClientClient } from " openledger" ;
152
153
153
154
const client = new OpenLedgerClientClient ({
154
155
...
0 commit comments