feat: leads: added GetMain().

This commit is contained in:
Andrey Parhomenko 2024-05-31 16:06:01 +05:00
parent df24215dcb
commit 7583137585

View file

@ -64,16 +64,27 @@ type Companies struct {
Links Links `json:"_links"`
}
type Contacts struct {
type Contact struct {
ID int `json:"id"`
IsMain bool `json:"is_main"`
Links Links `json:"_links"`
}
type Contacts []Contact
func (cs Contacts) GetMain() (Contact, bool) {
for _, contact := range cs {
if contact.IsMain {
return contact, true
}
}
return Contact{}, false
}
type Embedded struct {
Tags []*Tags `json:"tags"`
CatalogElements []*CatalogElements `json:"catalog_elements"`
LossReason []*LossReason `json:"loss_reason"`
Companies []*Companies `json:"companies"`
Contacts []*Contacts `json:"contacts"`
Contacts Contacts `json:"contacts"`
}