base_collection.d.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { Options } from "got";
  2. import { ApiError } from "../models/api_error";
  3. import { PaginatedResult } from "../models/paginated_result";
  4. import { Keyable } from "../interfaces/keyable";
  5. import { ClientData } from "../interfaces/client_data";
  6. import { BulkResult } from "../interfaces/bulk_result";
  7. type RejectHandler = (data: any) => ApiError;
  8. type ResolveHandler = (json: Keyable, headers: Keyable, ...args: any[]) => any;
  9. export declare abstract class BaseCollection {
  10. readonly clientData: ClientData;
  11. protected static rootElementName: string;
  12. protected static rootElementNameSingular: string | null;
  13. protected static endpoint: string | null;
  14. protected static prefixURI: string | null;
  15. protected static elementClass: any;
  16. protected static secondaryElementNameSingular: string | null;
  17. protected static secondaryElementClass: any;
  18. constructor(clientData: ClientData);
  19. protected doList(params: Keyable): Promise<any>;
  20. protected doGet(id: string | number, params?: Keyable): Promise<any>;
  21. protected doDelete(id: string | number, params?: Keyable): Promise<any>;
  22. protected doCreate(body: Keyable | null, params?: Keyable, resolveFn?: (json: Keyable, _headers: Keyable, secondary?: boolean) => any): Promise<any>;
  23. protected doUpdate(id: string | number, body: Keyable | null, req_params: Keyable, resolveFn?: (json: Keyable, headers: Keyable) => any): Promise<any>;
  24. protected populateObjectFromJsonRoot(json: Keyable, headers: Keyable): any;
  25. protected populateSecondaryObjectFromJsonRoot(json: Keyable, headers: Keyable): any;
  26. protected populateObjectFromJson(json: Keyable, _headers: Keyable, secondary?: boolean): any;
  27. protected populateArrayFromJsonBulk(json: Keyable, headers: Keyable): BulkResult | this[];
  28. protected populateArrayFromJson(json: Keyable, headers: Keyable): PaginatedResult | Keyable | this[];
  29. protected populateApiErrorFromJson(json: any): ApiError;
  30. protected returnBareJSON(json: Keyable | Array<Keyable>): Keyable | Array<Keyable>;
  31. protected handleReject(data: any): ApiError;
  32. protected createPromise(method: Options["method"], params: Keyable, resolveFn: ResolveHandler, rejectFn: RejectHandler, body: object | object[] | null, uri?: string | null): Promise<any>;
  33. protected objToArray(raw_body: Keyable | Keyable[]): Array<Keyable>;
  34. }
  35. export {};