This repository has been archived by the owner on Feb 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathad.go
119 lines (99 loc) · 2.02 KB
/
ad.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package fbintegration
import (
"fmt"
"strings"
facebookLib "github.com/huandu/facebook"
)
type (
// Ad comment pending
Ad struct {
ID string
AdsetID string
Creative *Creative
Post *Post
}
)
// NewAd comment pending
func NewAd(result *facebookLib.Result) Ad {
var id string
var creativeID string
var adsetID string
result.DecodeField("id", &id)
result.DecodeField("creative.id", &creativeID)
result.DecodeField("adset.id", &adsetID)
return Ad{
ID: id,
AdsetID: adsetID,
Creative: &Creative{ID: creativeID},
Post: &Post{},
}
}
// CreateBatchParams comment pending
func (a *Ad) CreateBatchParams() BatchParams {
fields := []string{
"effective_object_story_id",
"object_id",
"object_type",
}
uri := fmt.Sprintf(
"%s?fields=%s",
a.Creative.ID,
strings.Join(fields, ","),
)
return NewBatchParams(uri)
}
// CreateInsightParams comment pending
func (a *Ad) CreateInsightParams() BatchParams {
fields := []string{
"objective",
"estimated_ad_recallers",
"inline_link_clicks",
"inline_post_engagement",
"actions",
"ctr",
"clicks",
"impressions",
"inline_link_click_ctr",
"reach",
"spend",
"total_actions",
"total_unique_actions",
"unique_actions",
"video_p95_watched_actions",
}
uri := fmt.Sprintf(
"%s/insights?fields=%s&date_preset=lifetime",
a.ID,
strings.Join(fields, ","),
)
return NewBatchParams(uri)
}
// CreateBreakdownInsightParams comment pending
func (a *Ad) CreateBreakdownInsightParams() BatchParams {
fields := []string{
"reach",
}
breakdowns := []string{
"age",
"gender",
}
uri := fmt.Sprintf(
"%s/insights?fields=%s&date_preset=lifetime&breakdowns=%s",
a.ID,
strings.Join(fields, ","),
strings.Join(breakdowns, ","),
)
return NewBatchParams(uri)
}
// CreateTargetingParams comment pending
func (a *Ad) CreateTargetingParams() BatchParams {
fields := []string{
"targeting",
}
uri := fmt.Sprintf(
"%s?fields=%s&date_preset=lifetime",
a.AdsetID,
strings.Join(fields, ","),
)
return NewBatchParams(uri)
}