-
Notifications
You must be signed in to change notification settings - Fork 0
/
Thread.go
56 lines (46 loc) · 1.37 KB
/
Thread.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package skylead
import (
"fmt"
"net/http"
errortools "github.com/leapforce-libraries/go_errortools"
go_http "github.com/leapforce-libraries/go_http"
)
type Lead struct {
Id int64 `json:"id"`
IsDeclined int64 `json:"isDeclined"`
BackToCampaignTimestamp int64 `json:"backToCampaignTimestamp"`
NextStepId int64 `json:"nextStepId"`
}
type Thread struct {
Account int64 `json:"account"`
Thread string `json:"thread"`
Dashboard int64 `json:"dashboard"`
CampaignId int64 `json:"threadId"`
Lead Lead `json:"lead"`
LinkedInUser LinkedInUser `json:"linkedinUser"`
}
type GetThreadsConfig struct {
UserId int64
AccountId int64
CampaignId int64
}
func (service *Service) GetThreads(config *GetThreadsConfig) (*[]Thread, *errortools.Error) {
if config == nil {
return nil, errortools.ErrorMessage("config is nil")
}
result := struct {
Result struct {
Items []Thread `json:"items"`
} `json:"result"`
}{}
requestConfig := go_http.RequestConfig{
Method: http.MethodGet,
Url: service.url(fmt.Sprintf("users/%v/accounts/%v/campaigns/%v/messages", config.UserId, config.AccountId, config.CampaignId)),
ResponseModel: &result,
}
_, _, e := service.httpRequest(&requestConfig)
if e != nil {
return nil, e
}
return &result.Result.Items, nil
}