PageProof
Constructor Summary
Public Constructor | ||
public |
constructor(options: {}) |
Member Summary
Public Members | ||
public |
The Accounts API. |
|
public |
The repository of registered adapters. |
|
public |
The Comments API. |
|
public |
The Dashboard API. |
|
public |
The Files API. |
|
public |
The Proofs API. |
|
public |
The current session. |
|
public |
The Users API. |
|
public |
The Workflows API. |
Method Summary
Public Methods | ||
public |
Returns the Admin API (experimental). |
|
public |
Registers an event handler. |
|
public |
Sets the current session. |
Public Constructors
public constructor(options: {}) source
Params:
Name | Type | Attribute | Description |
options | {} |
|
Public Members
public adapters: AdapterRepository source
The repository of registered adapters.
The AdapterRepository helps provide the functionality of the SDK to the APIs (API).
Public Methods
public admin(): Promise<Admin> source
Returns the Admin API (experimental).
Please use this API with caution. This functionality is primarily used within the app, so these APIs are updated
regularly. Please ensure you have registered a error.deprecated
event to be notified when these APIs become
incompatible with the version of the SDK you're running.
We also advise you to let us know when you incorporate this API into your app, as we will try our best to notify you of major breaking changes. Email us at hello@pageproof.com.
This feature is only for team/enterprise administrators. If you call this method while authenticated with a non-admin account, the promise will reject. Only the first call to this method is potentially async, as it verifies the account is actually an administrator.
Example:
const client = new PageProof(...);
const admin = await client.admin();
const users = await admin.team.users.active(); // retrieve a list of all the active users in your team
console.log(users); // [User, User, User]
public on(event: string, handler: function): void source
Registers an event handler.
The SDK exposes some events/hooks, which you can use to make it easier for yourself to use it seamlessly. For example, we have an event ("error.unauthorized") which is emitted when an endpoint responds with a 401 (Unauthorized). If you return a Promise, it will automatically retry the request.
All event handlers are invoked at the same time. Returning a Promise in one, will not defer the others.
Here is a list of currently supported events.
error.unauthorized
error.deprecated
error.throttled
error.response
Return:
void |
Example:
const client = new PageProof({ <omitted> });
client.on('error.unauthorized', () => {
// If the "error.unauthorized" event handler returns a promise, the SDK
// will automatically retry the request if it notices the session has changed.
return client.accounts.login('user@example.com', '<password>');
});
const client = new PageProof({ <omitted> });
client.on('error.deprecated', (event) => {
// Some custom code which notifies you (the developer) that it's probably time
// to update the SDK. We will never deprecate APIs without an update to the
// SDK with a replacement.
});