amocrm-client
Version:
JS Library for AmoCRM
38 lines (33 loc) • 1.7 kB
text/typescript
import { TConstructor } from "../../types";
import { IRequestOptions } from "../../interfaces/common";
import { IResourceEntity } from "../../interfaces/api";
import { applyMixins } from "../../util";
import { hasSave } from "./mixins/hasSave";
import { hasFetch } from "./mixins/hasFetch";
import { hasCreate } from "./mixins/hasCreate";
import { hasUpdate } from "./mixins/hasUpdate";
import { hasContacts } from "./mixins/hasContacts";
import { hasResoinsibleUser } from "./mixins/hasResponsibleUser";
import { UserCriteria } from "../../interfaces/user";
import { IUser } from "./User";
import { ContactCriteria } from "../../interfaces/contact";
import { IContact } from "./Contact";
import { CustomerCriteria, ICustomerAttributes } from "../../interfaces/customer";
import { CustomerDTO } from "../../dto/customer.dto";
import { ICustomerFactory } from "../factories/CustomerFactory";
export interface ICustomer extends IResourceEntity<ICustomerFactory>, ICustomerAttributes {
create(options?: IRequestOptions): Promise<ICustomer>;
update(options?: IRequestOptions): Promise<ICustomer>;
save(options?: IRequestOptions): Promise<ICustomer>;
fetch(criteria?: Partial<CustomerCriteria>, options?: IRequestOptions): Promise<ICustomer>;
contacts(criteria?: Pick<ContactCriteria, "with">, options?: IRequestOptions): Promise<IContact | false>;
responsibleUser(criteria?: Pick<UserCriteria, "with">, options?: IRequestOptions): Promise<IUser | false>;
}
export const Customer: TConstructor<ICustomer> = applyMixins(CustomerDTO, [
hasContacts,
hasResoinsibleUser,
hasCreate,
hasUpdate,
hasSave,
hasFetch
]);