@salad-labs/loopz-typescript
Version:
The Official Loopz TypeScript SDK
70 lines • 3.74 kB
TypeScript
import { Maybe } from "./types/base";
import { IProposal, ListProposalsFilters, ListProposalsOrder, ListProposalsResponse } from "./interfaces/proposal";
import { CreateProposal, ProposalStatus, ProposalType } from "./types/proposal";
/**
* Represents a class for interacting with proposals through HTTP requests.
* @class Proposal
* @extends Client
*/
export declare class Proposal {
private static _config;
private static _instance;
private static _client;
/**
* Get the PROPOSAL_STATUS constant object.
* @returns {ProposalStatus} The constant object PROPOSAL_STATUS.
*/
static get PROPOSAL_STATUS(): ProposalStatus;
/**
* Returns a copy of the PROPOSAL_STATUS object as a constant ProposalType.
* @returns {ProposalType} A copy of the PROPOSAL_STATUS object.
*/
static get PROPOSAL_TYPE(): ProposalType;
/** static methods */
static config(config: {
devMode: boolean;
}): void;
static getInstance(): Proposal;
private constructor();
/**
* Creates a new proposal object and inserts it into the backend.
* @param {CreateProposal} proposal - The proposal object to be inserted, which must be a CreateProposal.
* @returns A Promise that resolves to a string or null.
* @throws {Error} If signedMessage is required but not provided.
*/
private _createProposal;
/** public instance methods */
/**
* Retrieves a proposal instance with the given ID and optional creator address.
* @param {string} id - The ID of the proposal instance to retrieve.
* @param {string} [did] - The creator address associated with the proposal instance. If provided, the API checks if the creatorAddress is the creator of the proposal.
* @returns {Promise<Maybe<IProposal>>} A promise that resolves to the retrieved proposal instance, or null if not found.
* @throws {Error} If the "id" parameter is invalid or if an error occurs during the retrieval process.
*/
get(id: string, did?: string): Promise<Maybe<IProposal>>;
/**
* Retrieves a list of proposals based on the provided filters, order options, skip, take, and creator address.
* @param {ListProposalsFilters} filtersOptions - The filters to apply to the list of proposals.
* @param {ListProposalsOrder} orderOptions - The order in which the proposals should be listed.
* @param {number} skip - The number of proposals to skip.
* @param {number} take - The number of proposals to retrieve.
* @param {string} creatorAddress - The address of the proposal creator.
* @returns {Promise<ListProposalsResponse>} A promise that resolves to a ListProposalsResponse object containing the list of proposals and total count.
*/
list(filtersOptions?: ListProposalsFilters, orderOptions?: ListProposalsOrder, skip?: number, take?: number, did?: string): Promise<Maybe<ListProposalsResponse>>;
/**
* Creates a new proposal using the provided proposal object and signed message.
* @param {CreateProposal} proposal - The proposal object containing the proposal data.
* @returns A new proposal created using the provided data.
*/
create(proposal: CreateProposal, signedMessage: string): Promise<boolean>;
/**
* Deletes a proposal with the given ID.
* @param {string} id - The ID of the proposal to delete.
* @param {string} creatorAddress - The address of the creator of the proposal.
* @returns {Promise<void>} A promise that resolves when the proposal is successfully deleted.
* @throws {Error} If the signedMessage is required but not provided.
*/
delete(id: string, creatorAddress: string): Promise<void>;
}
//# sourceMappingURL=proposal.d.ts.map