Переглянути джерело

before crm-cRUD-generalization

master
Patrick Peng Sun 8 роки тому
джерело
коміт
dab7db8edb
7 змінених файлів з 6273 додано та 3 видалено
  1. +24
    -2
      crmLeadStream.go
  2. +10
    -0
      crmLeadStream_test.go
  3. +6
    -0
      crmLead_test.go
  4. +2
    -1
      eventSubscribe.go
  5. +225
    -0
      sample_data/Notifications.json
  6. +50
    -0
      sample_data/crm_stream.json
  7. +5956
    -0
      sample_data/crmhar/sending-email-quote.har

+ 24
- 2
crmLeadStream.go Переглянути файл

@@ -1,5 +1,10 @@
package main

import (
"encoding/json"
"log"
)

// {
// "id": "595072499036b8a52",
// "deleted": false,
@@ -80,6 +85,23 @@ type crmdStream struct {
}

//add note
func add2Stream() {
//url := "https://c.hitxy.org.au/api/v1/Note"
func add2Stream(parentID, parentType, content string, attachmentsIDs []string) (resp string, err error) {
s := crmdStream{}
s.AttachmentsIDs = attachmentsIDs
s.IsInternal = false
s.ParentID = parentID
s.ParentType = parentType
s.Post = content
s.Type = "Post"
url := "https://c.hitxy.org.au/api/v1/Note"

headers := crmPrepareLeadUploadHTTPHeader()

b, err := json.Marshal(s)
if err != nil {
log.Fatal(err)
return
}
resp, err = postRAW(b, url, headers)
return
}

+ 10
- 0
crmLeadStream_test.go Переглянути файл

@@ -4,6 +4,7 @@ import (
"encoding/json"
"log"
"testing"
"time"
)

func TestDecodeStream(t *testing.T) {
@@ -75,3 +76,12 @@ func TestDecodeStream(t *testing.T) {
AssertEqual(t, s.AttachmentsTypes["5950769075cd82e67"], "image/png", "attachment mime type not match")

}

func TestAddNewStream(t *testing.T) {
SetupConfig()

parentid := "595071f8450974b72"
parentType := "Lead"
content := time.Now().Format("2006-Jan-02, 15:04:05")
add2Stream(parentid, parentType, content, []string{})
}

+ 6
- 0
crmLead_test.go Переглянути файл

@@ -397,3 +397,9 @@ func TestFindOpenIDOnline(t *testing.T) {
log.Println(found)
log.Println(err)
}

func TestLeadJsonCompose(t *testing.T) {
info := crmLeadInfo{}
info.FirstName = "中文First"

}

+ 2
- 1
eventSubscribe.go Переглянути файл

@@ -90,7 +90,8 @@ func (in *InWechatMsg) askUserFillupBasicInfo() {
func sendGreeting4ExistingUser(in InWechatMsg, info crmLeadInfo) {

first := "欢迎" + info.Name + "返回澳洲校友会"
url := "http://wechat.hitxy.org.au/profile_newly_register"
//url := "http://wechat.hitxy.org.au/profile_newly_register"
url := "http://192.168.1.39:4200/profile_newly_register"
remark := ""
communityName := "哈工大澳洲校友会"
joinDate := info.getCreatedAt().Format("2006-Jan-02")

+ 225
- 0
sample_data/Notifications.json Переглянути файл

@@ -0,0 +1,225 @@
{
"total": 6,
"list": [
{
"id": "595130adb9e73",
"deleted": false,
"number": 14,
"data": {
"noteId": "595130adb925848fd"
},
"noteData": {
"id": "595130adb925848fd",
"deleted": false,
"post": "2017-Jun-27, 02:05:01",
"data": {},
"type": "Post",
"targetType": null,
"number": 44,
"isGlobal": false,
"createdByGender": "Neutral",
"isInternal": false,
"createdAt": "2017-06-26 16:05:01",
"modifiedAt": "2017-06-26 16:05:01",
"parentId": "595071f8450974b72",
"parentType": "Lead",
"parentName": " \u5218\u5efa\u660e",
"relatedId": null,
"relatedType": null,
"createdById": "58ef420cac3cf6c95",
"createdByName": "wechat robot",
"modifiedById": null,
"modifiedByName": null,
"superParentId": null,
"superParentType": null
},
"type": "Note",
"read": false,
"emailIsProcessed": false,
"createdAt": "2017-06-26 16:05:01",
"message": null,
"userId": "1",
"userName": "Admin",
"relatedId": "595130adb925848fd",
"relatedType": "Note",
"relatedParentId": "595071f8450974b72",
"relatedParentType": "Lead"
},
{
"id": "59513024ede75",
"deleted": false,
"number": 13,
"data": {
"noteId": "59513024ed2d8b39b"
},
"noteData": {
"id": "59513024ed2d8b39b",
"deleted": false,
"post": "2017-Jun-27, 02:02:44",
"data": {},
"type": "Post",
"targetType": null,
"number": 43,
"isGlobal": false,
"createdByGender": "Neutral",
"isInternal": false,
"createdAt": "2017-06-26 16:02:44",
"modifiedAt": "2017-06-26 16:02:44",
"parentId": "595071f8450974b72",
"parentType": "Lead",
"parentName": " \u5218\u5efa\u660e",
"relatedId": null,
"relatedType": null,
"createdById": "58ef420cac3cf6c95",
"createdByName": "wechat robot",
"modifiedById": null,
"modifiedByName": null,
"superParentId": null,
"superParentType": null
},
"type": "Note",
"read": true,
"emailIsProcessed": false,
"createdAt": "2017-06-26 16:02:44",
"message": null,
"userId": "1",
"userName": "Admin",
"relatedId": "59513024ed2d8b39b",
"relatedType": "Note",
"relatedParentId": "595071f8450974b72",
"relatedParentType": "Lead"
},
{
"id": "59512ff247ac3",
"deleted": false,
"number": 12,
"data": {
"noteId": "59512ff246e3dda77"
},
"noteData": {
"id": "59512ff246e3dda77",
"deleted": false,
"post": "2017-Jun-27, 02:01:53",
"data": {},
"type": "Post",
"targetType": null,
"number": 42,
"isGlobal": false,
"createdByGender": "Neutral",
"isInternal": false,
"createdAt": "2017-06-26 16:01:54",
"modifiedAt": "2017-06-26 16:01:54",
"parentId": "595071f8450974b72",
"parentType": "Lead",
"parentName": " \u5218\u5efa\u660e",
"relatedId": null,
"relatedType": null,
"createdById": "58ef420cac3cf6c95",
"createdByName": "wechat robot",
"modifiedById": null,
"modifiedByName": null,
"superParentId": null,
"superParentType": null
},
"type": "Note",
"read": true,
"emailIsProcessed": false,
"createdAt": "2017-06-26 16:01:54",
"message": null,
"userId": "1",
"userName": "Admin",
"relatedId": "59512ff246e3dda77",
"relatedType": "Note",
"relatedParentId": "595071f8450974b72",
"relatedParentType": "Lead"
},
{
"id": "5951279c7dd67",
"deleted": false,
"number": 11,
"data": {
"noteId": "5951279c7d05397a5"
},
"noteData": {
"id": "5951279c7d05397a5",
"deleted": false,
"post": "2017-Jun-27, 01:26:20",
"data": {},
"type": "Post",
"targetType": null,
"number": 41,
"isGlobal": false,
"createdByGender": "Neutral",
"isInternal": false,
"createdAt": "2017-06-26 15:26:20",
"modifiedAt": "2017-06-26 15:26:20",
"parentId": "595071f8450974b72",
"parentType": "Lead",
"parentName": " \u5218\u5efa\u660e",
"relatedId": null,
"relatedType": null,
"createdById": "58ef420cac3cf6c95",
"createdByName": "wechat robot",
"modifiedById": null,
"modifiedByName": null,
"superParentId": null,
"superParentType": null
},
"type": "Note",
"read": true,
"emailIsProcessed": false,
"createdAt": "2017-06-26 15:26:20",
"message": null,
"userId": "1",
"userName": "Admin",
"relatedId": "5951279c7d05397a5",
"relatedType": "Note",
"relatedParentId": "595071f8450974b72",
"relatedParentType": "Lead"
},
{
"id": "5951240d405cf",
"deleted": false,
"number": 8,
"data": {
"noteId": "5951240d3f8dea842"
},
"noteData": {
"id": "5951240d3f8dea842",
"deleted": false,
"post": "2017-Jun-27, 01:11:09",
"data": {},
"type": "Post",
"targetType": null,
"number": 38,
"isGlobal": false,
"createdByGender": "Neutral",
"isInternal": false,
"createdAt": "2017-06-26 15:11:09",
"modifiedAt": "2017-06-26 15:11:09",
"parentId": "595071f8450974b72",
"parentType": "Lead",
"parentName": " \u5218\u5efa\u660e",
"relatedId": null,
"relatedType": null,
"createdById": "58ef420cac3cf6c95",
"createdByName": "wechat robot",
"modifiedById": null,
"modifiedByName": null,
"superParentId": null,
"superParentType": null
},
"type": "Note",
"read": true,
"emailIsProcessed": false,
"createdAt": "2017-06-26 15:11:09",
"message": null,
"userId": "1",
"userName": "Admin",
"relatedId": "5951240d3f8dea842",
"relatedType": "Note",
"relatedParentId": "595071f8450974b72",
"relatedParentType": "Lead"
}
]
}

+ 50
- 0
sample_data/crm_stream.json Переглянути файл

@@ -0,0 +1,50 @@
[
{
"id": "595072499036b8a52",
"deleted": false,
"post": "another stream",
"data": {},
"type": "Post",
"isInternal": false,
"createdAt": "2017-06-26 02:32:41",
"modifiedAt": "2017-06-26 02:32:41",
"parentId": "595071f8450974b72",
"parentType": "Lead",
"attachmentsIds": [],
"createdById": "1"
},
{
"id": "595072499036b8a52",
"deleted": false,
"post": "another stream",
"data": {},
"type": "Post",
"targetType": null,
"number": 34,
"isGlobal": false,
"createdByGender": "",
"isInternal": false,
"createdAt": "2017-06-26 02:32:41",
"modifiedAt": "2017-06-26 02:50:58",
"parentId": "595071f8450974b72",
"parentType": "Lead",
"parentName": " \u5218\u5efa\u660e",
"relatedId": null,
"relatedType": null,
"attachmentsIds": [
"5950769075cd82e67"
],
"attachmentsNames": {
"5950769075cd82e67": "flag_gb.png"
},
"createdById": "1",
"createdByName": "Admin",
"modifiedById": "1",
"modifiedByName": "Admin",
"superParentId": null,
"superParentType": null,
"attachmentsTypes": {
"5950769075cd82e67": "image\/png"
}
}
]

+ 5956
- 0
sample_data/crmhar/sending-email-quote.har
Різницю між файлами не показано, бо вона завелика
Переглянути файл


Завантаження…
Відмінити
Зберегти