@basetime/a2w-api-ts
Version:
Client library that communicates with the addtowallet API.
88 lines (87 loc) • 3.16 kB
TypeScript
import { Requester } from '../http/Requester';
import { ApiKey } from '../types/ApiKey';
import { Organization } from '../types/Organization';
import { ScannerDeviceInfo } from '../types/ScannerDeviceInfo';
import { ScannerInvite } from '../types/ScannerInvite';
import OrganizationDataStoresEndpoint from './organizations/DataStoresEndpoint';
import OrganizationExportersEndpoint from './organizations/ExportersEndpoint';
import OrganizationWebhooksEndpoint from './organizations/WebhooksEndpoint';
import Endpoint from './Endpoint';
/**
* Communicate with the organizations endpoints.
*
* Top-level methods cover the org itself, scanner-invite handshake, and API keys. Resource
* sub-endpoints (webhooks, dataStores, exporters) are exposed as `public readonly` props,
* mirroring the composition pattern of {@link ../Client | Client}.
*/
export default class OrganizationsEndpoint extends Endpoint {
/**
* Webhook management (`/organization/webhooks*`).
*
* CRUD on webhooks plus access to the per-organization delivery log.
*/
readonly webhooks: OrganizationWebhooksEndpoint;
/**
* Data store management (`/organization/dataStores*`).
*
* CRUD on key/value and external-source data stores that workflows can read from.
*/
readonly dataStores: OrganizationDataStoresEndpoint;
/**
* Exporter management (`/organization/exporters*`).
*
* CRUD on scheduled exporters plus the ability to run an exporter on demand and tail
* its execution logs.
*/
readonly exporters: OrganizationExportersEndpoint;
/**
* Constructor.
*
* @param req The object to use to make requests.
*/
constructor(req: Requester);
/**
* Fetches the details of the authenticated organization.
*
* @returns The organization.
*/
getMine: () => Promise<Organization>;
/**
* Returns a scanner invite by code.
*
* @param code The invite code.
*/
getScannerInvite: (code: string) => Promise<ScannerInvite | null>;
/**
* Begins the scanner exchange.
*
* @param code The invite code.
*/
startScannerExchange: (code: string) => Promise<ScannerInvite | null>;
/**
* Accepts an scanner app invite code and returns api keys.
*
* @param code The invite code.
* @param pushToken The push token.
* @param scannerDeviceInfo The scanner device info.
*/
finishScannerExchange: (code: string, pushToken: string, scannerDeviceInfo: ScannerDeviceInfo) => Promise<ApiKey>;
/**
* Returns the API keys for the authenticated organization.
*/
getApiKeys: () => Promise<ApiKey[]>;
/**
* Returns an API key by ID.
*
* @param id The ID of the API key.
* @param scanner Optional scanner context — typed as `unknown` because the backend
* accepts any JSON-serializable value; defaults to the empty string.
*/
getApiKey: (id: string, scanner?: unknown) => Promise<ApiKey | null>;
/**
* Deletes an API key.
*
* @param id The ID of the API key.
*/
deleteApiKey: (id: string) => Promise<void>;
}