@or-sdk/accounts
v2.5.3
Published
OneReach SDK client for Accounts
Readme
@or-sdk/accounts
OneReach SDK client for Accounts.
When to use
- Use this package when integrating with the Accounts capability on the OneReach platform.
- Use its typed client and exported models instead of hand-writing requests to that service.
When not to use
- Do not use it for a different platform capability; choose the dedicated
@or-sdk/*package instead. - Do not use it for generic third-party HTTP calls.
Installation
$ npm i @or-sdk/accountsUsage
import { Accounts } from '@or-sdk/accounts'
// with direct api url
const accounts = new Accounts({
token: 'my-account-token-string',
sdkUrl: 'http://example.sdk-api/endpoint'
});
// with service discovery(slower)
const accounts = new Accounts({
token: 'my-account-token-string',
discoveryUrl: 'http://example.discovery/endpoint'
});Configuration
- Prefer
sdkUrlwhen the service URL is known; it avoids a discovery request. - Use
discoveryUrlonly when the service URL is not available. - Provide
tokenas a bearer-token string or getter where supported.
Common pitfalls
- Keep the client token current when it can expire; a token getter is preferable where the constructor accepts one.
- Treat the generated TypeScript types as the authoritative contract for optional parameters and response shapes.
Common workflows
const account = await accounts.getAccount('account-id');
await accounts.updateAccountData(account.id, { ...account, name: 'Updated name' });
await accounts.createKey({
accountId: account.id,
key: 'webhook-signing-secret',
secret: 'secret-value',
});
const key = await accounts.getKey({ accountId: account.id, key: 'webhook-signing-secret' });getAccountIdByName and getAccountByName require a SUPER_ADMIN token. Use
scrollSecrets rather than loading all secrets when an account can have many keys.
Complete API reference
All public methods below are taken from the package source. Parameter and return types use the exported TypeScript names; import the corresponding types from this package when constructing requests.
| Method | Returns | Purpose |
|---|---|---|
| listAccounts() | Promise<List<Account>> | List accounts |
| getAccount(accountId: string) | Promise<Account> | Get account by id |
| getAccountIdByName(accountName: string, options?: RequestOptions) | Promise<string \| undefined> | Get account by name |
| getAccountByName({ accountName, }: GetAccountByNameParams, options?: RequestOptions) | Promise<Account \| undefined> | Get account by name |
| getAccountData(accountId: string) | Promise<AccountData> | Get account data by id |
| createAccount(data: AccountData) | Promise<Account> | Create account |
| disableAccount(accountId: string) | Promise<void> | Disable account |
| enableAccount(accountId: string) | Promise<void> | Enable account |
| suspendAccount(accountId: string) | Promise<Account> | Suspend account |
| resumeAccount(accountId: string) | Promise<void> | Resume account |
| updateAccountData(accountId: string, data: AccountData) | Promise<Account> | Update account |
| scrollSecrets({ accountId = 'current', limit = 10, next, } = {} as ListSecretsParams) | Promise<ListSecretsResponse> | List account secrets |
| getKey({ accountId = 'current', key }: GetSecretParams) | Promise<GetSecretResponse> | Get account key |
| createKey({ accountId = 'current', key, secret, type, expireTime, meta }: CreateSecretParams) | Promise<void> | Create account key |
| updateKey({ accountId = 'current', key, expireTime, meta }: UpdateKeyParams) | Promise<void> | Update account key |
| updateKeySecret({ accountId = 'current', key, secret }: UpdateKeySecretParams) | Promise<void> | Update account key secret |
| deleteKey({ accountId = 'current', key }: DeleteSecretParams) | Promise<void> | Delete account key |
More detail
Full signatures and exported types are available in src/ and dist/types/.
