diff --git a/leads/leads.go b/leads/leads.go index 236cffc..8969850 100644 --- a/leads/leads.go +++ b/leads/leads.go @@ -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"` }