-
Notifications
You must be signed in to change notification settings - Fork 0
/
segmentation_manual_reql.go
77 lines (67 loc) · 2.21 KB
/
segmentation_manual_reql.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
68
69
70
71
72
73
74
75
76
77
package recombee
import (
"fmt"
"net/http"
)
// CreateManualReQLSegmentation segments the items using multiple ReQL filters.
//
// Use the Add Manual ReQL Items Segment endpoint to create the individual segments.
func CreateManualReQLSegmentation(segmentationId, sourceType string, opts ...RequestOption) Request {
params := make(map[string]interface{})
params["sourceType"] = sourceType
for _, o := range opts {
o(params)
}
return Request{
Path: fmt.Sprintf("/segmentations/manual-reql/%s", segmentationId),
Method: http.MethodPut,
Params: params,
}
}
// UpdateManualReQLSegmentation updates an existing Segmentation.
func UpdateManualReQLSegmentation(segmentationId string, opts ...RequestOption) Request {
params := make(map[string]interface{})
for _, o := range opts {
o(params)
}
return Request{
Path: fmt.Sprintf("/segmentations/manual-reql/%s", segmentationId),
Method: http.MethodPost,
Params: params,
}
}
// AddManualReQLSegment adds a new Segment into a Manual ReQL Segmentation.
//
// The new Segment is defined by a ReQL filter that returns true for an item in case that this item belongs to the segment.
func AddManualReQLSegment(segmentationId, segmentId, filter string, opts ...RequestOption) Request {
params := make(map[string]interface{})
params["filter"] = filter
for _, o := range opts {
o(params)
}
return Request{
Path: fmt.Sprintf("/segmentations/manual-reql/%s/segments/%s", segmentationId, segmentId),
Method: http.MethodPut,
Params: params,
}
}
// UpdateManualReQLSegment update definition of the Segment.
func UpdateManualReQLSegment(segmentationId, segmentId, filter string, opts ...RequestOption) Request {
params := make(map[string]interface{})
params["filter"] = filter
for _, o := range opts {
o(params)
}
return Request{
Path: fmt.Sprintf("/segmentations/manual-reql/%s/segments/%s", segmentationId, segmentId),
Method: http.MethodPost,
Params: params,
}
}
// DeleteManualReQLSegment deletes a Segment from a Manual ReQL Segmentation.
func DeleteManualReQLSegment(segmentationId, segmentId string) Request {
return Request{
Path: fmt.Sprintf("/segmentations/manual-reql/%s/segments/%s", segmentationId, segmentId),
Method: http.MethodDelete,
}
}