leads.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package leads
  2. import "surdeus.su/core/amo/common"
  3. type Lead struct {
  4. ID int `json:"id"`
  5. Name string `json:"name,omitempty"`
  6. Price int `json:"price,omitempty"`
  7. ResponsibleUserID int `json:"responsible_user_id,omitempty"`
  8. GroupID int `json:"group_id,omitempty"`
  9. StatusID int `json:"status_id,omitempty"`
  10. PipelineID int `json:"pipeline_id,omitempty"`
  11. LossReasonID int `json:"loss_reason_id,omitempty"`
  12. SourceID interface{} `json:"source_id,omitempty"`
  13. CreatedBy int `json:"created_by,omitempty"`
  14. UpdatedBy int `json:"updated_by,omitempty"`
  15. CreatedAt int `json:"created_at,omitempty"`
  16. UpdatedAt int `json:"updated_at,omitempty"`
  17. ClosedAt int `json:"closed_at,omitempty"`
  18. ClosestTaskAt interface{} `json:"closest_task_at,omitempty"`
  19. IsDeleted bool `json:"is_deleted,omitempty"`
  20. CustomFieldsValues common.CustomFieldsValues `json:"custom_fields_values,omitempty"`
  21. Score interface{} `json:"score,omitempty"`
  22. AccountID int `json:"account_id,omitempty"`
  23. IsPriceModifiedByRobot bool `json:"is_price_modified_by_robot,omitempty"`
  24. Links Links `json:"_links,omitempty"`
  25. Embedded Embedded `json:"_embedded,omitempty"`
  26. }
  27. type Self struct {
  28. Href string `json:"href"`
  29. }
  30. type Links struct {
  31. Self Self `json:"self"`
  32. }
  33. type Tags struct {
  34. ID int `json:"id"`
  35. Name string `json:"name"`
  36. }
  37. type Metadata struct {
  38. Quantity int `json:"quantity"`
  39. CatalogID int `json:"catalog_id"`
  40. }
  41. type CatalogElements struct {
  42. ID int `json:"id"`
  43. Metadata Metadata `json:"metadata"`
  44. }
  45. type LossReason struct {
  46. ID int `json:"id"`
  47. Name string `json:"name"`
  48. Sort int `json:"sort"`
  49. CreatedAt int `json:"created_at"`
  50. UpdatedAt int `json:"updated_at"`
  51. Links Links `json:"_links"`
  52. }
  53. type Companies struct {
  54. ID int `json:"id"`
  55. Links Links `json:"_links"`
  56. }
  57. type Contact struct {
  58. ID int `json:"id"`
  59. IsMain bool `json:"is_main"`
  60. Links Links `json:"_links"`
  61. }
  62. type Contacts []Contact
  63. func (cs Contacts) GetMain() (Contact, bool) {
  64. for _, contact := range cs {
  65. if contact.IsMain {
  66. return contact, true
  67. }
  68. }
  69. return Contact{}, false
  70. }
  71. type Embedded struct {
  72. Tags []*Tags `json:"tags"`
  73. CatalogElements []*CatalogElements `json:"catalog_elements"`
  74. LossReason []*LossReason `json:"loss_reason"`
  75. Companies []*Companies `json:"companies"`
  76. Contacts Contacts `json:"contacts"`
  77. }