2024-04-17 09:30:19 +00:00
package model
2024-06-12 13:26:49 +00:00
import "time"
type AmoAccountUser struct {
ID int64 ` json:"id" ` // ID пользователя
AmoID int32 ` json:"amoID" ` // ID компании в амо, к которой пользователь принадлежит
AmoUserID int32 ` json:"amoUserID" ` // ID пользователя в амо
Name string ` json:"name" ` // Имя
Email string ` json:"email" ` // Email
Role int32 ` json:"role" ` // Роль
Group int32 ` json:"group" ` // Группа
Deleted bool ` json:"deleted" `
CreatedAt time . Time ` json:"createdAt" `
}
type AmoAccount struct {
ID int64 ` json:"id" ` // ID компании
AccountID string ` json:"accountID" ` // ID аккаунта нас
AmoID int32 ` json:"amoID" ` // ID компании в амо
Name string ` json:"name" ` // Название
Deleted bool ` json:"deleted" `
CreatedAt time . Time ` json:"createdAt" `
Subdomain string ` json:"subdomain" ` // поддомен
Country string ` json:"country" ` // Страна
DriveURL string ` json:"driveURL" ` // URL объктного хранилища
2024-06-18 08:58:15 +00:00
Stale bool ` json:"stale" ` // флаг "не свежести" если с токенами все в порядке - false, если просрочились то true
2024-04-17 09:30:19 +00:00
}
type UserGroups struct {
ID int ` json:"id" bson:"id" `
Name string ` json:"name" bson:"name" `
UUID interface { } ` json:"uuid" bson:"uuid" `
}
type Token struct {
AccountID string ` json:"account_id" ` // id в квизе
RefreshToken string ` json:"refresh_token" ` // 80 дней
AccessToken string ` json:"access_token" ` // 20 минут
AuthCode string ` json:"auth_code" `
Expiration int64 ` json:"expiration" ` // таймшамп времени когда кончится AccessToken
CreatedAt int64 ` json:"created_at" ` // таймшамп времени создания, нужен для отслеживания 80 дней
}
type Pipeline struct {
// айдишник в нашей системе Primary Key
2024-04-18 11:00:02 +00:00
ID int64 ` json:"ID" `
2024-04-17 09:30:19 +00:00
/* - айдишник воронки в амо*/
2024-04-18 11:00:02 +00:00
Amoid int32 ` json:"AmoID" `
2024-04-17 09:30:19 +00:00
/* - связь с аккаунтом в интеграции амо id аккаунта в амо*/
2024-04-18 11:00:02 +00:00
AccountID int32 ` json:"AccountID" `
2024-04-17 09:30:19 +00:00
/* - название воронки в амо*/
Name string ` json:"Name" `
/* - флаг архивной воронки в амо*/
Isarchive bool ` json:"IsArchive" `
/* - флаг мягкого удаления*/
Deleted bool ` json:"Deleted" `
/* - таймштамп создания воронки в нашей системе*/
Createdat int64 ` json:"CreatedAt" `
}
type Step struct {
/* - айдишник в нашей системе Primary Key*/
2024-04-18 11:00:02 +00:00
ID int64 ` json:"ID" `
2024-04-17 09:30:19 +00:00
/* - айдишник шага воронки в амо*/
2024-04-18 11:00:02 +00:00
Amoid int32 ` json:"AmoID" `
2024-04-17 09:30:19 +00:00
/* - айдишник воронки в амо*/
2024-04-18 11:00:02 +00:00
Pipelineid int32 ` json:"PipelineID" `
2024-04-17 09:30:19 +00:00
/* - связь с аккаунтом в интеграции амо id в амо*/
2024-04-18 11:00:02 +00:00
Accountid int32 ` json:"AccountID" `
2024-04-17 09:30:19 +00:00
/* - название воронки в амо*/
Name string ` json:"Name" `
/* - цвет шага в амо*/
Color string ` json:"Color" `
/* - флаг мягкого удаления*/
Deleted bool ` json:"Deleted" `
/* - таймштамп создания воронки в нашей системе*/
Createdat int64 ` json:"CreatedAt" `
}
type Tag struct {
/* - айдишник в нашей системе Primary Key*/
2024-04-18 11:00:02 +00:00
ID int64 ` json:"ID" `
2024-04-17 09:30:19 +00:00
/* - айдишник тега в амо*/
2024-04-18 11:00:02 +00:00
Amoid int32 ` json:"AmoID" `
2024-04-17 09:30:19 +00:00
/* - связь с аккаунтом в интеграции амо id аккаунта в амо*/
2024-04-18 11:00:02 +00:00
Accountid int32 ` json:"AccountID" `
2024-04-17 09:30:19 +00:00
/* - сущность, к которой принадлежит этот тег. Наверное, стоит сделать через enum в базе*/
Entity EntityType ` json:"Entity" `
/* - название тега в амо*/
Name string ` json:"Name" `
/* - цвет тега в амо*/
Color * string ` json:"Color" `
/* - флаг мягкого удаления*/
Deleted bool ` json:"Deleted" `
/* - таймштамп создания тега в нашей системе*/
Createdat int64 ` json:"CreatedAt" `
}
type Field struct {
/* - айдишник в нашей системе Primary Key*/
2024-04-18 11:00:02 +00:00
ID int64 ` json:"ID" `
2024-04-17 09:30:19 +00:00
/* - айдишник кастомного поля в амо*/
2024-04-18 11:00:02 +00:00
Amoid int32 ` json:"AmoID" `
2024-04-17 09:30:19 +00:00
/* - кодовое слово в амо*/
Code string ` json:"Code" `
/* - связь с аккаунтом в интеграции амо id аккаунта в амо*/
2024-04-18 11:00:02 +00:00
Accountid int32 ` json:"AccountID" `
2024-04-17 09:30:19 +00:00
/* - название воронки в амо*/
Name string ` json:"Name" `
/* - тип сущности в амо, для которой это кастомное поле*/
Entity EntityType ` json:"Entity" `
/* - тип поля https://www.amocrm.ru/developers/content/crm_platform/custom-fields#%D0%94%D0%BE%D1%81%D1%82%D1%83%D0%BF%D0%BD%D1%8B%D0%B5-%D1%82%D0%B8%D0%BF%D1%8B-%D0%BF%D0%BE%D0%BB%D0%B5%D0%B9*/
2024-04-28 13:03:05 +00:00
Type FieldType ` json:"Type" `
2024-04-17 09:30:19 +00:00
/* - флаг мягкого удаления*/
Deleted bool ` json:"Deleted" `
/* - таймштамп создания воронки в нашей системе*/
Createdat int64 ` json:"CreatedAt" `
}
type EntityType string
const (
2024-04-29 14:03:48 +00:00
LeadsType EntityType = "leads"
ContactsType EntityType = "contacts"
CompaniesType EntityType = "companies"
CustomersType EntityType = "customers"
2024-04-17 09:30:19 +00:00
)
type Rule struct {
/* - айдишник в нашей системе*/
2024-04-23 12:04:24 +00:00
ID int64 ` json:"ID" `
2024-04-17 09:30:19 +00:00
/* - связь с аккаунтом в интеграции амо id в амо*/
2024-04-23 12:04:24 +00:00
Accountid int32 ` json:"AccountID" `
2024-04-17 09:30:19 +00:00
/* - айдишник опроса*/
2024-04-23 12:04:24 +00:00
Quizid int32 ` json:"QuizID" `
2024-04-17 09:30:19 +00:00
/* - айдишник ответственного за сделку*/
2024-04-23 12:04:24 +00:00
Performerid int32 ` json:"PerformerID" `
2024-04-17 09:30:19 +00:00
/* - айдишник воронки*/
2024-04-23 12:04:24 +00:00
Pipelineid int32 ` json:"PipelineID" `
2024-04-17 09:30:19 +00:00
/* - айдишник этапа*/
2024-04-23 12:04:24 +00:00
Stepid int32 ` json:"StepID" `
2024-04-17 09:30:19 +00:00
/* - список UTM для этого опроса*/
2024-05-17 19:03:20 +00:00
//Utms []int32 `json:"UTMs"`
2024-04-17 09:30:19 +00:00
/* - правила заполнения полей сущностей в амо*/
Fieldsrule Fieldsrule ` json:"FieldsRule" `
2024-06-08 12:59:56 +00:00
// теги добавляемые к сделке
TagsToAdd TagsToAdd ` json:"TagsToAdd" `
2024-04-17 09:30:19 +00:00
/* - флаг мягкого удаления*/
Deleted bool ` json:"Deleted" `
/* - таймштамп создания воронки в нашей системе*/
2024-04-17 15:17:07 +00:00
Createdat int64 ` json:"CreatedAt" `
2024-04-17 09:30:19 +00:00
}
2024-06-08 12:59:56 +00:00
type TagsToAdd struct {
Lead [ ] int64 ` json:"Lead" `
Contact [ ] int64 ` json:"Contact" `
Company [ ] int64 ` json:"Company" `
Customer [ ] int64 ` json:"Customer" `
}
2024-04-17 09:30:19 +00:00
type Fieldsrule struct {
2024-06-28 07:18:42 +00:00
Lead FieldRule ` json:"Lead" `
2024-05-07 15:29:04 +00:00
Contact ContactRules ` json:"Contact" `
2024-06-28 07:18:42 +00:00
Company FieldRule ` json:"Company" `
Customer FieldRule ` json:"Customer" `
2024-04-17 09:30:19 +00:00
}
type FieldRule struct {
/* - сопоставление айдишника вопроса полю, которое будет заполняться ответом. соответственно QuestionID это айдишник вопроса. это я так мэпу пытался записать*/
Questionid map [ int ] int ` json:"QuestionID" ` // ключ id вопроса значение id астомного поля
}
2024-05-07 13:37:24 +00:00
type ContactRules struct {
// ключ имя, значение id кастомного поля
ContactRuleMap map [ string ] int
2024-06-28 07:18:42 +00:00
Questionid map [ int ] int ` json:"QuestionID" ` // ключ id вопроса значение id астомного поля
2024-05-07 13:37:24 +00:00
}
2024-05-07 14:08:33 +00:00
type QuizContact struct {
FormContact struct {
Fields struct {
Name ContactField ` json:"name" `
Email ContactField ` json:"email" `
Phone ContactField ` json:"phone" `
Text ContactField ` json:"text" `
Address ContactField ` json:"address" `
} ` json:"fields" `
} ` json:"formContact" `
}
type ContactField struct {
Text string ` json:"text" `
InnerText string ` json:"innerText" `
Key string ` json:"key" `
Required bool ` json:"required" `
Used bool ` json:"used" `
}
2024-05-07 14:29:19 +00:00
type ContactQuizConfig string
const (
TypeContactName ContactQuizConfig = "name"
TypeContactEmail ContactQuizConfig = "email"
TypeContactPhone ContactQuizConfig = "phone"
TypeContactText ContactQuizConfig = "text"
TypeContactAddress ContactQuizConfig = "address"
)
2024-05-17 19:03:20 +00:00
//type UTM struct {
// /* - айдишник в нашей системе Primary Key*/
// ID int64 `json:"ID"`
// /* - айдишник кастомного поля в амо*/
// Amofieldid int32 `json:"AmoFieldID"`
// /* - айдишник квиза*/
// Quizid int32 `json:"QuizID"`
// /* - связь с аккаунтом в интеграции амо id амо*/
// Accountid int32 `json:"AccountID"`
// /* - название тега в амо*/
// Name string `json:"Name"`
// /* - флаг мягкого удаления*/
// Deleted bool `json:"Deleted"`
// /* - таймштамп создания тега в нашей системе*/
// Createdat int64 `json:"CreatedAt"`
//}
2024-04-28 13:03:05 +00:00
type FieldType string
const (
TypeAmoText FieldType = "text" //Текст
TypeAmoNumeric FieldType = "numeric" //Число
TypeAmoCheckbox FieldType = "checkbox" //Флаг
TypeAmoSelect FieldType = "select" //Список
TypeAmoMultiselect FieldType = "multiselect" //Мультисписок
TypeAmoDate FieldType = "date" //Дата
TypeAmoUrl FieldType = "url" // Ссылка
TypeAmoTextarea FieldType = "textarea" // Текстовая область
TypeAmoRadiobutton FieldType = "radiobutton" // Переключатель
TypeAmoStreetAddress FieldType = "streetaddress" // Короткий адрес
TypeAmoSmartAddress FieldType = "smart_address" // Адрес
TypeAmoBirthday FieldType = "birthday" // День рождения
TypeAmoLegalEntity FieldType = "legal_entity" // Юр. лицо
TypeAmoDateTime FieldType = "date_time" // Дата и время
TypeAmoPrice FieldType = "price" //Цена
TypeAmoCategory FieldType = "category" // Категория
TypeAmoItems FieldType = "items" // Предметы
TypeAmoTrackingData FieldType = "tracking_data" // Отслеживаемые данные
TypeAmoLinkedEntity FieldType = "linked_entity" // Связь с другим элементом
TypeAmoChainedList FieldType = "chained_list" // Каталоги и списки (платная опция Супер-поля)
TypeAmoMonetary FieldType = "monetary" // Денежное (платная опция Супер-поля)
TypeAmoFile FieldType = "file" // Файл
TypeAmoPayer FieldType = "payer" // Плательщик (только в списке Счета-покупки)
TypeAmoSupplier FieldType = "supplier" // Поставщик (только в списке Счета-покупки)
2024-04-29 09:36:30 +00:00
TypeAmoMultiText FieldType = "multitext" // что то чего нет в списке полей но она есть в амо))
2024-04-28 13:03:05 +00:00
)
2024-05-02 08:38:26 +00:00
var TypeMapping = map [ string ] FieldType {
2024-05-05 07:47:42 +00:00
"variant" : TypeAmoText , //TypeAmoChainedList,
"images" : TypeAmoText , //TypeAmoFile,
"varimg" : TypeAmoText , //TypeAmoFile,
2024-05-02 08:38:26 +00:00
"file" : TypeAmoFile ,
"text" : TypeAmoText ,
"emoji" : TypeAmoText ,
2024-05-05 07:47:42 +00:00
"select" : TypeAmoText , //TypeAmoSelect,
"date" : TypeAmoText , //TypeAmoDate,
"number" : TypeAmoText , //TypeAmoNumeric,
2024-05-02 08:38:26 +00:00
"page" : TypeAmoText ,
"rating" : TypeAmoText ,
"result" : TypeAmoText ,
}
2024-05-04 11:03:52 +00:00
type AmoUsersTrueResults struct {
2024-05-05 07:47:42 +00:00
QuizID int64
AnswerID int64
Result bool
QuestionID int64
Content string
Session string
AccessToken string
AmoAccountID int32
2024-05-17 19:03:20 +00:00
UTMs UTMSavingMap
2024-05-05 07:47:42 +00:00
FieldsRule Fieldsrule
2024-06-08 13:20:31 +00:00
TagsToAdd TagsToAdd
2024-05-05 07:47:42 +00:00
PerformerID int32
StepID int32
PipelineID int32
PerformerName string
2024-06-05 12:33:24 +00:00
SubDomain string
2024-06-08 14:15:20 +00:00
QuizAccountID string
2024-06-08 14:58:11 +00:00
DriveURL string
2024-05-04 11:03:52 +00:00
}
2024-06-20 15:37:25 +00:00
// возможно стоит добавить enum? тип ContactQuizConfig уже есть
type ContactAmo struct {
ID int64
AccountID int32 // id аккаунта в амо к которому привязан контакт
AmoID int32 // id контакта в амо
Field string // значение поля
}