Class: PrivateClient
Ties the three seams together: build a request, send it, update the session.
Constructors
Constructor
new PrivateClient(options?): PrivateClient;Parameters
| Parameter | Type |
|---|---|
options? | PrivateClientOptions |
Returns
PrivateClient
Accessors
session
Get Signature
get session(): SessionData;Returns
Methods
patchAuth()
patchAuth(auth): void;Merges fields into the session auth (e.g. the user id after login).
Parameters
| Parameter | Type |
|---|---|
auth | Partial<AuthState> |
Returns
void
patchSession()
patchSession(patch): void;Merges top-level fields into the session (e.g. the USDID identity).
Parameters
| Parameter | Type |
|---|---|
patch | Partial<SessionData> |
Returns
void
persist()
persist(): Promise<void>;Saves the current session to the store, when there is one.
Returns
Promise<void>
request()
request(input): Promise<PrivateResponseJson>;Sends a request and parses it, throwing a typed error on failure. If the session expired and an onSessionExpired hook is set, it re-authenticates and repeats the request once. A login_required rejection means the request was not applied, so repeating a mutation is safe.
Parameters
| Parameter | Type |
|---|---|
input | PrivateRequestOptions |
Returns
Promise<PrivateResponseJson>
send()
send(input): Promise<HttpResponse>;Sends a request and returns the raw response. Updates and persists the session.
Parameters
| Parameter | Type |
|---|---|
input | PrivateRequestOptions |
Returns
Promise<HttpResponse>
fromStore()
static fromStore(store, options?): Promise<PrivateClient>;A client started from the session a store holds, or from a fresh one.
Parameters
| Parameter | Type |
|---|---|
store | SessionStore |
options? | { transport?: HttpTransport; } |
options.transport? | HttpTransport |
Returns
Promise<PrivateClient>