-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: ignore tsconfig in npm * docs: `README`, functions.md * docs: mark JSDoc internal and private * docs(README): absolute link for functions.md
- Loading branch information
Showing
9 changed files
with
1,917 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,52 @@ | ||
# web-api-client | ||
# @cryptlex/web-api-client | ||
|
||
[![latest-npm-version](https://badge.fury.io/js/@cryptlex%2Fweb-api-client.svg)](https://www.npmjs.com/package/@cryptlex/web-api-client) ![build](https://github.com/cryptlex/web-api-client-js/actions/workflows/release.yml/badge.svg) | ||
|
||
The Cryptlex Web API Client library provides access to the Cryptlex Web API from applications written in JavaScript. The library maintains types for supporting TypeScript(=>3.5). | ||
|
||
# Requirements | ||
|
||
Node 14 or higher | ||
|
||
# Installation | ||
|
||
``` | ||
npm install @cryptlex/web-api-client | ||
``` | ||
|
||
# Usage | ||
|
||
The library needs to be configured with the a valid access token. This is done in the `CryptlexWebApiClientOptions` instantiation. | ||
|
||
```ts | ||
import { | ||
CryptlexWebApiClient, | ||
CryptlexWebApiClientOptions, | ||
} from "@cryptlex/web-api-client"; | ||
|
||
const ACCESS_TOKEN = "**ACCESS_TOKEN**"; | ||
const PRODUCT_ID = "**PRODUCT_ID**"; | ||
|
||
const cryptlexWebApiClientOptions = new CryptlexWebApiClientOptions( | ||
ACCESS_TOKEN | ||
); | ||
const cryptlexWebApiClient = new CryptlexWebApiClient( | ||
cryptlexWebApiClientOptions | ||
); | ||
|
||
try { | ||
// Create a license in the product defined by PRODUCT_ID | ||
const licenseResponse = await cryptlexWebApiClient.createLicense({ | ||
productId: PRODUCT_ID, | ||
}); | ||
console.log( | ||
"\nSuccessfully created license: " + JSON.stringify(licenseResponse.data) | ||
); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
``` | ||
|
||
# Functions | ||
|
||
The extent of this library can be seen in the [complete list of functions](https://github.com/cryptlex/web-api-client-js/blob/main/docs/functions.md) available. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
## Functions | ||
|
||
<dl> | ||
<dt><a href="#createLicense">createLicense(license)</a> ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code></dt> | ||
<dd><p>Create a license.</p> | ||
</dd> | ||
<dt><a href="#updateLicense">updateLicense(id, license)</a> ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code></dt> | ||
<dd><p>Updates the specified license by setting the values of the existing license to the properties passed. | ||
Any properties not provided will be left unchanged.</p> | ||
</dd> | ||
<dt><a href="#deleteLicense">deleteLicense(id)</a> ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code></dt> | ||
<dd><p>Permanently deletes a license. WRANING: This cannot be undone.</p> | ||
</dd> | ||
<dt><a href="#getLicenses">getLicenses(page, limit, parameters)</a> ⇒ <code>Promise.<ApiResponse.<Array.<LicenseResponse>>></code></dt> | ||
<dd><p>Returns a list of licenses. The licenses are returned sorted by creation date in ascending order.</p> | ||
</dd> | ||
<dt><a href="#getLicense">getLicense(id)</a> ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code></dt> | ||
<dd><p>Retrieves the details of an existing license.</p> | ||
</dd> | ||
<dt><a href="#renewLicense">renewLicense(id)</a> ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code></dt> | ||
<dd><p>Extends the license expiry by it's validity.</p> | ||
</dd> | ||
<dt><a href="#extendLicense">extendLicense(id, extensionLength)</a> ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code></dt> | ||
<dd><p>Extends the license expiry by extension length.</p> | ||
</dd> | ||
<dt><a href="#createUser">createUser(user)</a> ⇒ <code>Promise.<ApiResponse.<UserResponse>></code></dt> | ||
<dd><p>Creates a new user.</p> | ||
</dd> | ||
<dt><a href="#deleteUser">deleteUser(id)</a> ⇒ <code>Promise.<ApiResponse.<any>></code></dt> | ||
<dd><p>Permanently deletes an user. It cannot be undone.</p> | ||
</dd> | ||
<dt><a href="#getUser">getUser(id)</a> ⇒ <code>Promise.<ApiResponse.<UserResponse>></code></dt> | ||
<dd><p>Retrieves the details of an existing user.</p> | ||
</dd> | ||
<dt><a href="#getUsers">getUsers(page, limit, parameters)</a> ⇒ <code>Promise.<ApiResponse.<Array.<UserResponse>>></code></dt> | ||
<dd><p>Returns a list of users. The users are returned sorted by creation date in ascending order.</p> | ||
</dd> | ||
<dt><a href="#updateUser">updateUser(id, user)</a> ⇒ <code>Promise.<ApiResponse.<UserResponse>></code></dt> | ||
<dd><p>Updates the specified user by setting the values of the parameters passed. Any parameters not provided will be left unchanged.</p> | ||
</dd> | ||
<dt><a href="#generateResetPasswordToken">generateResetPasswordToken(id)</a> ⇒ <code>Promise.<ApiResponse.<any>></code></dt> | ||
<dd><p>Generates the reset password token (url encoded) for users with 'user' role. | ||
It should only be used for custom portals to implement password reset.</p> | ||
</dd> | ||
</dl> | ||
|
||
<a name="createLicense"></a> | ||
|
||
## createLicense(license) ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code> | ||
|
||
Create a license. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<LicenseResponse>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ------- | --------------------------------- | ------------------------ | | ||
| license | <code>LicenseCreateRequest</code> | License object to create | | ||
|
||
<a name="updateLicense"></a> | ||
|
||
## updateLicense(id, license) ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code> | ||
|
||
Updates the specified license by setting the values of the existing license to the properties passed. | ||
Any properties not provided will be left unchanged. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<LicenseResponse>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ------- | --------------------------------- | ---------------------------------------------- | | ||
| id | <code>string</code> | Unique identifier for the license. | | ||
| license | <code>LicenseUpdateRequest</code> | License object containing properties to update | | ||
|
||
<a name="deleteLicense"></a> | ||
|
||
## deleteLicense(id) ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code> | ||
|
||
Permanently deletes a license. WRANING: This cannot be undone. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<LicenseResponse>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ----- | ------------------- | ---------------------------------- | | ||
| id | <code>string</code> | Unique identifier for the license. | | ||
|
||
<a name="getLicenses"></a> | ||
|
||
## getLicenses(page, limit, parameters) ⇒ <code>Promise.<ApiResponse.<Array.<LicenseResponse>>></code> | ||
|
||
Returns a list of licenses. The licenses are returned sorted by creation date in ascending order. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<Array.<LicenseResponse>>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ---------- | --------------------------------------- | ------------------------------------------------------------------------------- | | ||
| page | <code>number</code> | Page number. Starts with 1 | | ||
| limit | <code>number</code> | The number of licenses to fetch or 'Page size'. Value can be between 1 and 100. | | ||
| parameters | <code>LicenseListQueryParameters</code> | Parameters to filter the result of the list | | ||
|
||
<a name="getLicense"></a> | ||
|
||
## getLicense(id) ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code> | ||
|
||
Retrieves the details of an existing license. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<LicenseResponse>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ----- | ------------------- | ---------------------------------- | | ||
| id | <code>string</code> | Unique identifier for the license. | | ||
|
||
<a name="renewLicense"></a> | ||
|
||
## renewLicense(id) ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code> | ||
|
||
Extends the license expiry by it's validity. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<LicenseResponse>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ----- | ------------------- | ---------------------------------- | | ||
| id | <code>string</code> | Unique identifier for the license. | | ||
|
||
<a name="extendLicense"></a> | ||
|
||
## extendLicense(id, extensionLength) ⇒ <code>Promise.<ApiResponse.<LicenseResponse>></code> | ||
|
||
Extends the license expiry by extension length. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<LicenseResponse>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| --------------- | ------------------- | --------------------------------------------------------------------- | | ||
| id | <code>string</code> | Unique identifier for the license. | | ||
| extensionLength | <code>number</code> | License extension duration (in seconds) to extend the license expiry. | | ||
|
||
<a name="createUser"></a> | ||
|
||
## createUser(user) ⇒ <code>Promise.<ApiResponse.<UserResponse>></code> | ||
|
||
Creates a new user. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<UserResponse>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ----- | ------------------------------ | -------------------------- | | ||
| user | <code>UserCreateRequest</code> | User creation request body | | ||
|
||
<a name="deleteUser"></a> | ||
|
||
## deleteUser(id) ⇒ <code>Promise.<ApiResponse.<any>></code> | ||
|
||
Permanently deletes an user. It cannot be undone. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<any>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ----- | ------------------- | ------------------------------- | | ||
| id | <code>string</code> | Unique identifier for the user. | | ||
|
||
<a name="getUser"></a> | ||
|
||
## getUser(id) ⇒ <code>Promise.<ApiResponse.<UserResponse>></code> | ||
|
||
Retrieves the details of an existing user. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<UserResponse>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ----- | ------------------- | ------------------------------- | | ||
| id | <code>string</code> | Unique identifier for the user. | | ||
|
||
<a name="getUsers"></a> | ||
|
||
## getUsers(page, limit, parameters) ⇒ <code>Promise.<ApiResponse.<Array.<UserResponse>>></code> | ||
|
||
Returns a list of users. The users are returned sorted by creation date in ascending order. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<Array.<UserResponse>>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ---------- | ------------------------------------ | ------------------------------------------------------------------- | | ||
| page | <code>number</code> | The page number. | | ||
| limit | <code>number</code> | The number of records per page. Must be a number between 1 and 100. | | ||
| parameters | <code>UserListQueryParameters</code> | Parameters to filter the result of the list | | ||
|
||
<a name="updateUser"></a> | ||
|
||
## updateUser(id, user) ⇒ <code>Promise.<ApiResponse.<UserResponse>></code> | ||
|
||
Updates the specified user by setting the values of the parameters passed. Any parameters not provided will be left unchanged. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<UserResponse>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ----- | ------------------------------ | ------------------------------ | | ||
| id | <code>string</code> | Unique identifier for the user | | ||
| user | <code>UserUpdateRequest</code> | User update request object | | ||
|
||
<a name="generateResetPasswordToken"></a> | ||
|
||
## generateResetPasswordToken(id) ⇒ <code>Promise.<ApiResponse.<any>></code> | ||
|
||
Generates the reset password token (url encoded) for users with 'user' role. | ||
It should only be used for custom portals to implement password reset. | ||
|
||
**Kind**: global function | ||
**Returns**: <code>Promise.<ApiResponse.<any>></code> - Promise that resolves to the Web API response | ||
|
||
| Param | Type | Description | | ||
| ----- | ------------------- | ------------------------------ | | ||
| id | <code>string</code> | Unique identifier for the user | |
Oops, something went wrong.