amocrm-client
Version:
JS Library for AmoCRM
71 lines (61 loc) • 2.19 kB
text/typescript
import { ICriteria, IEntityAttributes, IResourceCollection } from "./api";
type UserWithString = "role" | "group" | "uuid" | "amojo_id";
type UserRoleWithString = "users";
export type UserWith = Array<UserWithString> | UserWithString;
export type UserRoleWith = Array<UserRoleWithString> | UserRoleWithString;
export type UserCriteria = Pick<ICriteria<never, UserWith>, "with" | "page" | "limit">;
export type UserRoleCriteria = Pick<ICriteria<never, UserWith>, "with" | "page" | "limit">;
export type UserCreateCriteria = Omit<IUserAttributes, "id" | "account_id" | "_links"> & { password: string }
export type UserRoleCreateCriteria = Omit<IUserAttributes, "id" | "account_id" | "_links">
export type UserRoleUpdateCriteria = Omit<IUserAttributes, "account_id" | "_links">
export interface IUserAttributes extends IEntityAttributes {
name: string;
email: string;
lang: string;
rights: IUserRightAttributes;
uuid?: null | string;
amojo_id?: null | string;
}
export interface IUserRoleAttributes extends IEntityAttributes {
name: string;
rights: IRightAttributes
}
export interface IUserRightAttributes extends IRightAttributes {
is_admin: boolean;
is_free: boolean;
is_active: boolean;
group_id: number | null;
role_id: number | null;
}
export interface IRightAttributes {
leads: IRights,
contacts: IRights;
companies: IRights,
tasks: Pick<IRights, "edit" | "delete">;
status_rights: IStatusRights[];
catalog_rights: ICatalogRights[];
mail_access: boolean;
catalog_access: boolean;
}
interface IRights {
view: RightActionValue;
edit: RightActionValue;
add: RightActionValue;
delete: RightActionValue;
export: RightActionValue;
}
interface IStatusRights {
entity_type: string;
pipeline_id: number;
status_id: number;
rights: IRights;
}
interface ICatalogRights {
catalog_id: number;
rights: IRights;
}
type RightActionValue = "A" | "G" | "M" | "D";
export interface UserEmbedded {
roles?: IResourceCollection<IEntityAttributes>;
groups?: { id: number; name: string }[];
}