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"` Links Links `json:"_links"`
} }
type Contacts struct {
type Contact struct {
ID int `json:"id"` ID int `json:"id"`
IsMain bool `json:"is_main"` IsMain bool `json:"is_main"`
Links Links `json:"_links"` 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 { type Embedded struct {
Tags []*Tags `json:"tags"` Tags []*Tags `json:"tags"`
CatalogElements []*CatalogElements `json:"catalog_elements"` CatalogElements []*CatalogElements `json:"catalog_elements"`
LossReason []*LossReason `json:"loss_reason"` LossReason []*LossReason `json:"loss_reason"`
Companies []*Companies `json:"companies"` Companies []*Companies `json:"companies"`
Contacts []*Contacts `json:"contacts"` Contacts Contacts `json:"contacts"`
} }