@dynamic-labs/sdk-api 0.0.250 → 0.0.252
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# sdk-api
|
|
2
|
+
|
|
3
|
+
This library contains a generated TypeScript client using [openapi](https://spec.openapis.org/oas/v3.0.1). It can be used with any Javascript/Typescript project.
|
|
4
|
+
|
|
5
|
+
Documentation on the current set of REST APIs can be found at: https://docs.dynamic.xyz/api-reference/overview
|
|
6
|
+
|
|
7
|
+
# APIs
|
|
8
|
+
|
|
9
|
+
- SdkApi
|
|
10
|
+
- These are endpoints used exclusively by the [Dynamic React SDK](https://www.npmjs.com/package/@dynamic-labs/sdk-react). Several endpoints in these APIs require a [JWT](https://docs.dynamic.xyz/react-sdk/references/user-payload#-the-jwt-update) created by the `verify` or `signin` endpoints, and are specific to a user in the SDK's environment. These APIs are typically used on a client site or frontend to enhance their customers' experience.
|
|
11
|
+
- Dashboard APIs
|
|
12
|
+
- These endpoints are used by admins of an organization to update site settings and manage users of the environment. These APIs require an [API token](https://docs.dynamic.xyz/api-reference/overview#authentication) scoped for a specific environment. These APIs are typically used on a client backend, to manage all their users' data and make corresponding settings changes that affect all users of a site.
|
|
13
|
+
- The most commonly used API among the dashbaord APIs is `UsersApi`
|
|
14
|
+
|
|
15
|
+
# Examples
|
|
16
|
+
|
|
17
|
+
This section provides an example of how to use `SDKApi`. This would be similar to using the other available generated APIs, like `UsesrApi` or `ExportsApi`, etc.
|
|
18
|
+
|
|
19
|
+
### SdkApi
|
|
20
|
+
|
|
21
|
+
Initialize a new instance of the `SDKApi` class:
|
|
22
|
+
```typescript
|
|
23
|
+
import { Configuration, SDKApi } from '@dynamic-labs/sdk-api';
|
|
24
|
+
|
|
25
|
+
const sdkApi = (jwt: string) => {
|
|
26
|
+
const settings = {
|
|
27
|
+
basePath: ApiEndpoint.getBaseUrl(),
|
|
28
|
+
headers: {
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
settings.headers.Authorization = `Bearer ${jwt}`;
|
|
33
|
+
return new SDKApi(new Configuration(settings));
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Then you would be able to use it like this:
|
|
38
|
+
```typescript
|
|
39
|
+
const response = await sdkApi(jwt).updateSelf({
|
|
40
|
+
environmentId,
|
|
41
|
+
userFields: fields, // { alias, firstName, lastName, username, ... }
|
|
42
|
+
});
|
|
43
|
+
// do something with the response
|
|
44
|
+
```
|