citeright-sdk-js
Version:
An SDK to connect to the CiteRight API.
207 lines (206 loc) • 7.88 kB
TypeScript
import CallerContext from './CallerContext';
import { APIResponse } from './models/APIResponse';
import { CompanyDTO } from './models/CompanyDTO';
import { ItemDTO } from './models/ItemDTO';
import { PasswordChangeDTO } from './models/PasswordChangeDTO';
import { PasswordValidationModel } from './models/PasswordValidationModel';
import { RegistrationRequestDTO } from './models/RegistrationRequestDTO';
import { RegistrationResponseDTO } from './models/RegistrationResponseDTO';
import { UserAvailableModel } from './models/UserAvailableModel';
import { UserDTO } from './models/UserDTO';
import { UserNotification } from './models/UserNotification';
/**
* This is the main class that a developer would instantiate when they intend to execute calls against our API. The
* requirements are an API server URL, a client identifier, and a client password. If any user specific functions are
* to be used (like user and company), then the "login" method must be run and satisfied first.
*/
export declare class CiteRightSDK {
private apiServerUrl;
private apiGatewayUrl;
private clientIdentifier;
private clientIdentifierPassword;
private user;
private apiAgent;
constructor(apiServerUrl: string, apiGatewayUrl: string, clientIdentifier: string, clientIdentifierPassword: string, callerContext?: CallerContext | null);
/**
* Any time after firing the login() method on this SDK, you should be able to inspect this.isLoggedIn() to verify
* that login was successful.
*
* @returns {boolean}
*/
isLoggedIn(): boolean;
/**
* Use this function to have our API send a user an email asking them to reset their password. Most commonly, this
* will be triggered by an end user that is trying to recover a lost password.
*
* @param {string} email
* @returns {Promise<boolean>}
*/
forgotPassword(email: string): Promise<APIResponse>;
resetForgottenPassword(passwordResetToken: string, newPassword: string, confirmPassword: string): Promise<APIResponse>;
/**
* This will invalidate the user's auth
*/
logout(): Promise<void>;
/**
* Get an oAuth token for the user
* @param {string} email
* @param {string} password
*/
login(email: string, password: string): Promise<UserDTO>;
/**
* This is used to extract a stringified version of the login token that can later be used in reloadFromLoginToken.
* This is used when a user's login needs to survive a reload of the environment it is loaded in (like a browser).
* @returns {string}
*/
getLoginToken(): string;
/**
* Use this function to reconstitute a user's logged in session.
*
* @param {string} oauthToken
*/
reloadFromLoginToken(oauthToken: string): UserDTO;
/**
* This will retrieve the abilities available to the connected user as a serialized object that can be used
* with the ACL class.
*
* @returns {Promise<void>}
*/
getAbilities(): Promise<string>;
/**
* This will get a list of Companies that the connected user has permission to manage.
*
* @returns {Promise<CompanyDTO[]>}
*/
getCompanies(): Promise<CompanyDTO[]>;
/**
* This will retrieve a single company by it's id.
*
* @param {string} companyId
* @returns {Promise<CompanyDTO>}
*/
getCompany(companyId: string): Promise<CompanyDTO>;
/**
* This will create a new company.
*
* @param {CompanyDTO} company
* @returns {Promise<CompanyDTO>}
*/
createCompany(company: CompanyDTO): Promise<CompanyDTO>;
/**
* This will save changes to an existing company.
*
* @param {CompanyDTO} company
* @returns {Promise<CompanyDTO>}
*/
updateCompany(company: CompanyDTO): Promise<CompanyDTO>;
/**
* This will save changes to an existing company subscription.
*
* @param {CompanyDTO} company
* @returns {Promise<CompanyDTO>}
*/
updateCompanySubscription(company: CompanyDTO): Promise<CompanyDTO>;
/**
* This will delete an existing company.
*
* @param {CompanyDTO} company
* @returns {Promise<CompanyDTO>}
*/
deleteCompany(company: CompanyDTO): Promise<APIResponse>;
/**
* This will retrieve a list of users for a company by the company id.
* @param {string} companyId
* @returns {Promise<UserDTO[]>}
*/
getUsersForCompany(companyId: string): Promise<UserDTO[]>;
/**
* This will delete a user as long as the connected user is a manager of the users company.
*
* @param {UserDTO} user
* @returns {Promise<APIResponse>}
*/
deleteUser(user: UserDTO): Promise<APIResponse>;
/**
* This will create a user
*
* @param {UserDTO} user
* @returns {Promise<UserDTO>}
*/
createUser(user: UserDTO): Promise<UserDTO>;
/**
* Retrieve a user by their ID.
*
* @param {string} userId
* @returns {Promise<UserDTO>}
*/
getUser(userId: string): Promise<UserDTO>;
/**
* This will update a user
*
* @param {UserDTO} user
* @returns {Promise<UserDTO>}
*/
updateUser(user: UserDTO): Promise<UserDTO>;
/**
* This will attempt to change a password for the connected user. If they don't know their current password, then
* use the forgotPassword function instead.
*
* @param {PasswordChangeDTO} passwordChangeDTO
* @returns {Promise<PasswordValidationModel>}
*/
changeUserPassword(passwordChangeDTO: PasswordChangeDTO): Promise<PasswordValidationModel>;
/**
* This will check to see if a user is available for use. Note that we do not normalize the email in this
* response, since that will happen upon actually creating the company.
*
* @param {string} email
* @returns {Promise<UserAvailableModel>}
*/
checkUserAvailability(email: string): Promise<UserAvailableModel>;
/**
* This will register a new "off the street" user into our system and send them a welcome email.
*
* @param {RegistrationRequestDTO} registrationRequestDTO
* @returns {Promise<RegistrationResponseDTO>}
*/
registerNewCompany(registrationRequestDTO: RegistrationRequestDTO): Promise<RegistrationResponseDTO>;
/**
* This will save an item to the user's library. It is assumed that the metadata has already been saved using
* "parseMetadata" before running this.
*
* @param item
* @param rawHtml
* @param parsedHtml
*/
saveItem(item: ItemDTO, rawHtml: string, parsedHtml: string): Promise<ItemDTO>;
/**
* Send any error data to be logged
*
* @param error
*/
logException(error: any): Promise<void>;
/**
* This will return a list of items that the user has in their company library.
*/
getCompanyLibrary(companyId: string): Promise<ItemDTO[]>;
/**
* This will retrieve an item by the item's vendorDocumentIdentifier for a company.
* @param itemId
*/
getItemByVendorId(companyId: string, vendorDocumentIdentifier: string): Promise<ItemDTO>;
/**
* This will retrieve an item's data by the item's id.
* @param itemId
*/
getItemData(itemId: string): Promise<string>;
/**
* This will retrieve an item's data by the item's id.
* @param itemId
*/
expireContent(itemId: string): Promise<string>;
/**
* This will retrieve an event notification from our document-collaboration-serverless project for a specific user
*/
getNotificationsForUser(): Promise<UserNotification[]>;
}