forked from TencentAd/marketing-api-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetProductCatalogsReports.go
73 lines (65 loc) · 2.07 KB
/
GetProductCatalogsReports.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
/*
* Marketing API
*
* Marketing API
*
* API version: 1.3
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package main
import (
"encoding/json"
"fmt"
"net/http"
"github.com/antihax/optional"
"github.com/tencentad/marketing-api-go-sdk/pkg/ads"
"github.com/tencentad/marketing-api-go-sdk/pkg/api"
"github.com/tencentad/marketing-api-go-sdk/pkg/config"
"github.com/tencentad/marketing-api-go-sdk/pkg/errors"
"github.com/tencentad/marketing-api-go-sdk/pkg/model"
)
type ProductCatalogsReportsGetExample struct {
TAds *ads.SDKClient
AccessToken string
AccountId int64
ProductCatalogId int64
DateRange model.ReportDateRange
ProductCatalogsReportsGetOpts *api.ProductCatalogsReportsGetOpts
}
func (e *ProductCatalogsReportsGetExample) Init() {
e.AccessToken = "YOUR ACCESS TOKEN"
e.TAds = ads.Init(&config.SDKConfig{
AccessToken: e.AccessToken,
IsDebug: true,
})
e.AccountId = int64(0)
e.ProductCatalogId = int64(0)
e.DateRange = model.ReportDateRange{
StartDate: "REPORT START DATE",
EndDate: "REPORT END DATE",
}
e.ProductCatalogsReportsGetOpts = &api.ProductCatalogsReportsGetOpts{
Fields: optional.NewInterface([]string{"date", "product_catalog_id", "product_outer_id", "view_count", "valid_click_count", "ctr", "cpc", "cost"}),
}
}
func (e *ProductCatalogsReportsGetExample) RunExample() (model.ProductCatalogsReportsGetResponseData, http.Header, error) {
tads := e.TAds
// change ctx as needed
ctx := *tads.Ctx
return tads.ProductCatalogsReports().Get(ctx, e.AccountId, e.ProductCatalogId, e.DateRange, e.ProductCatalogsReportsGetOpts)
}
func main() {
e := &ProductCatalogsReportsGetExample{}
e.Init()
response, headers, err := e.RunExample()
if err != nil {
if resErr, ok := err.(errors.ResponseError); ok {
errStr, _ := json.Marshal(resErr)
fmt.Println("Response error:", string(errStr))
} else {
fmt.Println("Error:", err)
}
}
fmt.Println("Response data:", response)
fmt.Println("Headers:", headers)
}