Documentation for the ParityDeals JavaScript SDK
@paritydeals/js-sdk
is a lightweight, plain TypeScript library designed for interacting with the ParityDeals entitlement service. It allows you to:
Option | Type | Description | |
---|---|---|---|
customerId | string | Unique identifier for the customer | |
accessToken | string | - | Authentication token for API requests |
environment | sandbox|production | ’production’ | The environment to use. If you want to use the sandbox, you must provide this. |
initializeAndFetch | boolean | true | Automatically fetch entitlements on initialization |
onError | (error: Error) => void | - | Error callback function |
hasAccess(featureId: string): boolean
getEntitlement<T>(featureId: string, type: T['type']): T | null
getAllEntitlements(): EntitlementMap | null
fetchAllEntitlements(forceRefresh?: boolean): Promise<EntitlementMap>
isLoading(): boolean
getLastError(): Error | null
clearCache(): void
Option | Type | Description |
---|---|---|
apiUrl | string | Base URL for the API |
entitlementsPath | string | Path for fetching entitlements |
apiConfig.maxRetries | number | Maximum number of retries for API requests |
apiConfig.timeout | number | Timeout for API requests in milliseconds |
apiConfig.backoffBaseDelay | number | Base delay for exponential backoff strategy |
environment
option to sandbox
in the init
function.