Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

108 linhas
3.4KB

  1. package main
  2. import (
  3. "encoding/json"
  4. "log"
  5. )
  6. // {
  7. // "id": "595072499036b8a52",
  8. // "deleted": false,
  9. // "post": "another stream",
  10. // "data": {},
  11. // "type": "Post",
  12. // "isInternal": false,
  13. // "createdAt": "2017-06-26 02:32:41",
  14. // "modifiedAt": "2017-06-26 02:32:41",
  15. // "parentId": "595071f8450974b72",
  16. // "parentType": "Lead",
  17. // "attachmentsIds": [],
  18. // "createdById": "1"
  19. // }
  20. // {
  21. // "id": "595072499036b8a52",
  22. // "deleted": false,
  23. // "post": "another stream",
  24. // "data": {},
  25. // "type": "Post",
  26. // "targetType": null,
  27. // "number": 34,
  28. // "isGlobal": false,
  29. // "createdByGender": "",
  30. // "isInternal": false,
  31. // "createdAt": "2017-06-26 02:32:41",
  32. // "modifiedAt": "2017-06-26 02:50:58",
  33. // "parentId": "595071f8450974b72",
  34. // "parentType": "Lead",
  35. // "parentName": " \u5218\u5efa\u660e",
  36. // "relatedId": null,
  37. // "relatedType": null,
  38. // "attachmentsIds": [
  39. // "5950769075cd82e67"
  40. // ],
  41. // "attachmentsNames": {
  42. // "5950769075cd82e67": "flag_gb.png"
  43. // },
  44. // "createdById": "1",
  45. // "createdByName": "Admin",
  46. // "modifiedById": "1",
  47. // "modifiedByName": "Admin",
  48. // "superParentId": null,
  49. // "superParentType": null,
  50. // "attachmentsTypes": {
  51. // "5950769075cd82e67": "image\/png"
  52. // }
  53. // }
  54. type crmdStream struct {
  55. ID string `json:"id"`
  56. Deleted bool `json:"deleted"`
  57. Post string `json:"post"`
  58. //Data passed
  59. Type string `json:"type"`
  60. //targetType unknown, why null
  61. Number int `json:"number,omitempty"`
  62. IsGlobal bool `json:"isGlobal,omitempty"`
  63. CreatedByGender string `json:"createdByGender,omitempty"`
  64. IsInternal bool `json:"isInternal"`
  65. CreateAt string `json:"createdAt"`
  66. ModifiedAt string `json:"modifiedAt"`
  67. ParentID string `json:"parentId"`
  68. ParentType string `json:"parentType"`
  69. ParentName string `json:"parentName,omitempty"`
  70. RelatedID string `json:"relatedId,omitempty"`
  71. RelatedType string `json:"relatedType,omitempty"`
  72. AttachmentsIDs []string `json:"attachmentsIds"`
  73. AttachmentsNames map[string]string `json:"attachmentsNames,omitempty"`
  74. AttachmentsTypes map[string]string `json:"attachmentsTypes,omitempty"`
  75. CreatedByID string `json:"createdById"`
  76. CreatedByName string `json:"createdByName,omitempty"`
  77. ModifiedByID string `json:"modifiedById,omitempty"`
  78. ModifiedByName string `json:"modifiedByName,omitempty"`
  79. SuperParentID string `json:"superParentId,omitempty"`
  80. SuperParentType string `json:"superParentType,omitempty"`
  81. }
  82. //add note
  83. func add2Stream(parentID, parentType, content string, attachmentsIDs []string) (resp string, err error) {
  84. s := crmdStream{}
  85. s.AttachmentsIDs = attachmentsIDs
  86. s.IsInternal = false
  87. s.ParentID = parentID
  88. s.ParentType = parentType
  89. s.Post = content
  90. s.Type = "Post"
  91. url := "https://c.hitxy.org.au/api/v1/Note"
  92. headers := crmPrepareLeadUploadHTTPHeader()
  93. b, err := json.Marshal(s)
  94. if err != nil {
  95. log.Fatal(err)
  96. return
  97. }
  98. resp, err = postRAW(b, url, headers)
  99. return
  100. }