-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomer_journey.go
67 lines (51 loc) · 1.94 KB
/
customer_journey.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
57
58
59
60
61
62
63
64
65
66
67
package relay42
import (
"fmt"
"net/http"
)
// CustomerJourneyService holds the R42 service
type CustomerJourneyService service
// GetCurrentJourneyStep returns a profile journey step by journeyID and profileID
func (service *ContentService) GetCurrentJourneyStep(journeyID, profileID string) (*JourneyStep, error) {
method := http.MethodGet
path := fmt.Sprintf("/v1/site-%d/customer/journey/%s/%s", service.r.siteID, journeyID, profileID)
req, err := service.r.newRequest(method, path, nil, nil)
if err != nil {
return &JourneyStep{}, err
}
var journeyStep *JourneyStep
err = service.r.do(req, &journeyStep)
return journeyStep, err
}
// GetJourneySteps returns profile journey steps by profileID
func (service *ContentService) GetJourneySteps(profileID string) ([]*JourneyStep, error) {
method := http.MethodGet
path := fmt.Sprintf("/v1/site-%d/customer/journey/%s", service.r.siteID, profileID)
req, err := service.r.newRequest(method, path, nil, nil)
if err != nil {
return []*JourneyStep{}, err
}
var journeySteps []*JourneyStep
err = service.r.do(req, &journeySteps)
return journeySteps, err
}
// RemoveProfileFromJourney removes a profile from a journey step by journeyID and profileID
func (service *CustomerJourneyService) RemoveProfileFromJourney(journeyID, profileID string) error {
method := http.MethodDelete
path := fmt.Sprintf("/v1/site-%d/customer/journey/%s/%s", service.r.siteID, journeyID, profileID)
req, err := service.r.newRequest(method, path, nil, nil)
if err != nil {
return err
}
return service.r.do(req, nil)
}
// RemoveProfileFromJourneys removes a profile from all journeys by profileID
func (service *CustomerJourneyService) RemoveProfileFromJourneys(profileID string) error {
method := http.MethodDelete
path := fmt.Sprintf("/v1/site-%d/customer/journey/%s", service.r.siteID, profileID)
req, err := service.r.newRequest(method, path, nil, nil)
if err != nil {
return err
}
return service.r.do(req, nil)
}