amocrm-client
Version:
JS Library for AmoCRM
96 lines (85 loc) • 3.05 kB
text/typescript
import { ICriteria, IEntityAttributes, IResourceCollection, ISelfLinkResponse } from "./api";
import { CustomFieldFilter, Moment, RangeFilter } from "./common";
import { ICustomFieldValue } from "./custom_field";
type CustomerWithString = "catalog_elements" | "contacts" | "companies";
export type CustomerWith = Array<CustomerWithString> | CustomerWithString;
export type CustomerCriteria = Partial<ICriteria<Partial<CustomerFilter>, CustomerWith>>;
export type TransactionCriteria = Partial<Omit<ICriteria<{ id: number }, never>, "with" | "query" | "order">>
export type EmbeddedCustomer = Partial<ICustomerAttributes>;
export type EmbeddedSegment = Partial<ICustomerSegmentAttributes>;
export interface ICustomerAttributes extends IEntityAttributes {
name: string;
next_price: number;
next_date: Date;
responsible_user_id: number;
periodcity: number;
created_by: number;
updated_by: number;
created_at: Date;
updated_at: Date;
closest_task_at: Date;
is_deleted: boolean;
custom_fields_values: ICustomFieldValue[] | null;
ltv: number;
purchases_count: number;
avarage_check: number;
_embedded: ICustomerEmbedded;
}
export interface ITransactionAttributes extends IEntityAttributes {
comment: string;
price: number;
completed_at: EpochTimeStamp;
customer_id: number;
created_by: number;
updated_by: number;
created_at: Date;
updated_at: Date;
is_deleted: boolean;
_embedded: TransactionEmbedded;
}
export interface ICustomerStatusAttributes extends IEntityAttributes {
name: string;
sort: number;
is_default: boolean;
conditions: Array<any>;
color: string;
type: number;
}
export interface ICustomerSegmentAttributes extends IEntityAttributes {
name: string;
color: string;
customers_count: number;
available_products_price_types: number[];
created_at: Date;
updated_at: Date;
}
export interface ICustomerEmbedded {
tags: IResourceCollection<IEntityAttributes>;
segments?: IResourceCollection<IEntityAttributes>;
contacts?: IResourceCollection<IEntityAttributes>;
companies?: IResourceCollection<IEntityAttributes>;
catalog_elements?: IResourceCollection<any>;
}
export interface TransactionEmbedded {
customer: IResourceCollection<IEntityAttributes>;
catalog_elements?: IResourceCollection<IEntityAttributes>;
}
interface IEmbeddedSegment {
id: number;
_links: ISelfLinkResponse;
}
export interface CustomerFilter {
id: number | number[];
name: string | string[];
next_price: number | RangeFilter;
next_date: RangeFilter;
status_id: number | number[];
created_by: number | number[];
updated_by: number | number[];
responsible_user_id: number | number[];
created_at: RangeFilter;
updated_at: RangeFilter;
closed_at: RangeFilter;
closest_task_at: RangeFilter;
custom_fields_values: CustomFieldFilter[];
}