Skip to content

Commit

Permalink
feat: 增加广告投放-获取各层级信息相关API
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Jul 30, 2021
1 parent 91e6dec commit 65e13e1
Show file tree
Hide file tree
Showing 49 changed files with 982 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
- 获取广告账户余额信息 [ FundGet(clt *core.SDKClient, accessToken string, advertiserID int64) (float64, error) ]
- 获取广告主账户流水信息 [ FundDailyFlows(clt *core.SDK, accessToken string, req *advertiser.FundDailyFlowsRequest) (*advertiser.FundDailyFlowsResponse, error) ]
- 广告投放
- 获取各层级信息
- 获取广告计划信息 [ campaign.List(clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) ]
- 获取广告组信息 [ unit.List(clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) ]
- 获取广告创意信息 [ creative.List(clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) ]
- 获取程序化创意2.0信息 [ creative.AdvancedProgramList(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramListRequest) (*creative.AdvancedProgramListResponse, error) ]
- 获取程序化创意2.0审核信息 [ creative.AdvancedProgramReviewDetail(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramReviewDetailRequest) (*creative.AdvancedProgramReviewDetail, error) ]
- 账户操作记录信息查询 [ tool.OperationRecordList(clt *core.SDKClient, accessToken string, req *tool.OperationRecordListRequest) (*tool.OperationRecordListResponse, error) ]
- 定向人群预估查询 [ tool.AudiencePredict(clt *core.SDKClient, accessToken string, req *tool.AudiencePredictRequest) (int64, error) ]
- 账户层级
- 账户日预算查询 [ advertiser.BudgetGet(clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.Budget, error) ]
- 修改账户预算 [ advertiser.UpdateBudget(clt *core.SDKClient, accessToken string, req *advertiser.UpdateBudgetRequest) error ]
Expand Down
2 changes: 2 additions & 0 deletions api/campaign/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package campaign 广告计划相关API
package campaign
16 changes: 16 additions & 0 deletions api/campaign/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package campaign

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/campaign"
)

// List 获取广告计划信息
func List(clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) {
var resp campaign.ListResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
16 changes: 16 additions & 0 deletions api/creative/advanced_program_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package creative

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/creative"
)

// AdvancedProgramList 获取程序化创意2.0信息
func AdvancedProgramList(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramListRequest) (*creative.AdvancedProgramListResponse, error) {
var resp creative.AdvancedProgramListResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
16 changes: 16 additions & 0 deletions api/creative/advanced_program_review_detail.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package creative

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/creative"
)

// AdvancedProgramReviewDetail 获取程序化创意2.0审核信息
func AdvancedProgramReviewDetail(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramReviewDetailRequest) (*creative.AdvancedProgramReviewDetail, error) {
var resp creative.AdvancedProgramReviewDetail
err := clt.Get(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
2 changes: 2 additions & 0 deletions api/creative/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package creative 广告创意相关API
package creative
16 changes: 16 additions & 0 deletions api/creative/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package creative

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/creative"
)

// List 获取广告创意信息
func List(clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) {
var resp creative.ListResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
16 changes: 16 additions & 0 deletions api/tool/audience_predict.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package tool

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/tool"
)

// AudiencePredict 定向人群预估查询
func AudiencePredict(clt *core.SDKClient, accessToken string, req *tool.AudiencePredictRequest) (int64, error) {
var resp tool.AudiencePredictResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return 0, err
}
return resp.AudiencePredictNum, nil
}
2 changes: 2 additions & 0 deletions api/tool/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package tool 工具类API
package tool
16 changes: 16 additions & 0 deletions api/tool/operation_record_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package tool

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/tool"
)

// OperationRecordList 账户操作记录信息查询
func OperationRecordList(clt *core.SDKClient, accessToken string, req *tool.OperationRecordListRequest) (*tool.OperationRecordListResponse, error) {
var resp tool.OperationRecordListResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
2 changes: 2 additions & 0 deletions api/unit/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package unit 广告组相关API
package unit
16 changes: 16 additions & 0 deletions api/unit/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package unit

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/unit"
)

// List 获取广告组信息
func List(clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) {
var resp unit.ListResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
2 changes: 2 additions & 0 deletions model/campaign/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package campaign 广告计划相关API
package campaign
40 changes: 40 additions & 0 deletions model/campaign/list_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package campaign

import "encoding/json"

// ListRequest 获取广告计划信息 API Request
type ListRequest struct {
// AdvertiserID 广告主ID
AdvertiserID int64 `json:"advertiser_id,omitempty"`
// CampaignID 广告计划ID; 过滤筛选条件,若不传或传空则视为无限制条件
CampaignID int64 `json:"campaign_id,omitempty"`
// UnitID 广告组ID; 过滤筛选条件,若不传或传空则视为无限制条件
UnitID int64 `json:"unit_id,omitempty"`
// UnitName 广告组名称
UnitName string `json:"unit_name,omitempty"`
// UnitIDs 广告组ID集
UnitIDs []int64 `json:"unit_ids,omitempty"`
// Status 广告组状态;过滤筛选条件;-2:所有包含已删除 10:只包含已删除 不传:所有不包含已删除 其他值无效
Status int `json:"status,omitempty"`
// StartDate 开始时间;与end_date同时传或同时不传;过滤筛选条件,格式为"yyyy-MM-dd",参数值对应update_time信息
StartDate string `json:"start_date,omitempty"`
// EndDate 结束时间; 与start_date同时传或同时不传;过滤筛选条件,格式为"yyyy-MM-dd",参数值对应update_time信息
EndDate string `json:"end_date,omitempty"`
// TimeFilterType 按创建时间,还是更新时间进行筛选; 1.如传入此字段时不传"start_date",与"end_date"字段,则不根据时间筛选。2.传入"start_date",与"end_date"字段,且此字段为1时,按照创建时间进行筛选。3.传入"start_date",与"end_date"字段,此字段不传,或传值为0时,则按照更新时间进行筛选
TimeFilterType int `json:"time_filter_type,omitempty"`
// Page 请求的页码数 默认为1
Page int `json:"page,omitempty"`
// PageSize 请求的每页行数; 默认为20
PageSize int `json:"page_size,omitempty"`
}

// Url implement PostRequest interface
func (r ListRequest) Url() string {
return "v1/campaign/list"
}

// Encode implement PostRequest interface
func (r ListRequest) Encode() []byte {
ret, _ := json.Marshal(r)
return ret
}
7 changes: 7 additions & 0 deletions model/campaign/list_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package campaign

// ListResponse 获取广告计划信息 API Response
type ListResponse struct {
// CampaignSubType 计划子类型; 4:DPA,5:SDPA
CampaignSubType int `json:"campaign_sub_type,omitempty"`
}
41 changes: 41 additions & 0 deletions model/creative/advanced_program_creative.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package creative

// AdvancedProgramCreative 获取程序化创意2.0信息
type AdvancedProgramCreative struct {
// UnitID 广告组ID
Unit int64 `json:"unit_id,omitempty"`
// PackageName 程序化创意包名称,1-100 字符,
PackageName string `json:"package_name,omitempty"`
// HorizontalPhotoIDs 横版视频 id list; 横版视频和竖版视频加起来只能 1-5 个
HorizontalPhotoIDs []string `json:"horizontal_photo_ids,omitempty"`
// VerticalPhotoIDs 竖版视频 id list
VerticalPhotoIDs []string `json:"vertical_photo_ids,omitempty"`
// CoverImageTokens 封面 image_token;只能是 1-4 个
CoverImageTokens []string `json:"cover_image_tokens,omitempty"`
// CoverImageUrls 封面链接地址
CoverImageUrls []string `json:"cover_image_urls,omitempty"`
// SiteID 建站 id
SiteID int64 `json:"site_id,omitempty"`
// StickerStyles 封面贴纸
StickerStyles []int `json:"sticker_styles,omitempty"`
// CoverSlogans 封面广告语
CoverSlogans []string `json:"cover_slogans,omitempty"`
// ActionBar 行动号召按钮
ActionBar string `json:"action_bar,omitempty"`
// Captions 作品广告语; 只能是 1-3 个
Captions []string `json:"captions,omitempty"`
// ClickUrl 第三方点击检测链接
ClickUrl string `json:"click_url,omitempty"`
// ActionbarClickUrl 第三方ActionBar点击监控链接
ActionbarClickUrl string `json:"actionbar_click_url,omitempty"`
// PutStatus 程序化创意操作状态,1:投放,2:暂停,3:删除
PutStatus int `json:"put_status,omitempty"`
// ViewStatus 程序化创意状态; -1:不限,1:计划已暂停,3:计划超预算,6:余额不足,11:组审核中,12:组审核未通过,14:已结束,15:组已暂停,17:组超预算,19:未达投放时间,40:创意已删除,41:审核中,42:审核未通过,46:已暂停,52:投放中,53:作品异常,55:部分素材审核通过
ViewStatus int `json:"view_status,omitempty"`
// ViewStatusReason 程序化创意状态描述
ViewStatusReason string `json:"view_status_reason,omitempty"`
// CreateTime 创建时间
CreateTime string `json:"create_time,omitempty"`
// UpdateTime 最后修改时间
UpdateTime string `json:"update_time,omitempty"`
}
36 changes: 36 additions & 0 deletions model/creative/advanced_program_list_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package creative

import "encoding/json"

// AdvancedProgramListRequest 获取程序化创意2.0信息 API Request
type AdvancedProgramListRequest struct {
// AdvertiserID 广告主ID
AdvertiserID int64 `json:"advertiser_id,omitempty"`
// UnitIDs 广告组ID;不超过一百个,当unit_ids参数不为空时,返回值total_count为0
UnitIDs []int64 `json:"unit_ids,omitempty"`
// PackageName 程序化创意包名称; 非空,0到100字符
PackageName string `json:"package_name,omitempty"`
// Status 程序化创意状态; -2:所有(包含已删除)、40:只包含已删除 不传:所有(不包含已删除)
Status int `json:"status,omitempty"`
// StartDate 开始时间;与end_date同时传或同时不传;过滤筛选条件,格式为"yyyy-MM-dd",参数值对应update_time信息
StartDate string `json:"start_date,omitempty"`
// EndDate 结束时间; 与start_date同时传或同时不传;过滤筛选条件,格式为"yyyy-MM-dd",参数值对应update_time信息
EndDate string `json:"end_date,omitempty"`
// TimeFilterType 按创建时间,还是更新时间进行筛选; 1.如传入此字段时不传"start_date",与"end_date"字段,则不根据时间筛选。2.传入"start_date",与"end_date"字段,且此字段为1时,按照创建时间进行筛选。3.传入"start_date",与"end_date"字段,此字段不传,或传值为0时,则按照更新时间进行筛选
TimeFilterType int `json:"time_filter_type,omitempty"`
// Page 请求的页码数 默认为1
Page int `json:"page,omitempty"`
// PageSize 请求的每页行数; 默认为20
PageSize int `json:"page_size,omitempty"`
}

// Url implement PostRequest interface
func (r AdvancedProgramListRequest) Url() string {
return "v2/creative/advanced/program/list"
}

// Encode implement PostRequest interface
func (r AdvancedProgramListRequest) Encode() []byte {
ret, _ := json.Marshal(r)
return ret
}
9 changes: 9 additions & 0 deletions model/creative/advanced_program_list_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package creative

// AdvancedProgramListResponse 获取程序化创意2.0信息 API Response
type AdvancedProgramListResponse struct {
// TotalCount 数据总数
TotalCount int `json:"total_count,omitempty"`
// Details 返回值详情
Details []AdvancedProgramCreative `json:"details,omitempty"`
}
11 changes: 11 additions & 0 deletions model/creative/advanced_program_review_detail.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package creative

// AdvancedProgramReviewDetail 获取程序化创意2.0审核信息
type AdvancedProgramReviewDetail struct {
// UnitID 当前的程序化创意的广告组id
UnitID int64 `json:"unit_id,omitempty"`
// Slogans 审核不通过的封面广告语
Slogans []string `json:"slogans,omitempty"`
// CombineDetailViews 审核不通过和正在审核的创意组合
CombineDetailViews []CombineDetailView `json:"combine_detail_views,omitempty"`
}
29 changes: 29 additions & 0 deletions model/creative/advanced_program_review_detail_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package creative

import (
"encoding/json"
"net/url"
"strconv"
)

// AdvancedProgramReviewDetailRequest 获取程序化创意2.0审核信息
type AdvancedProgramReviewDetailRequest struct {
// AdvertiserID 广告主ID
AdvertiserID int64 `json:"advertiser_id,omitempty"`
// UnitIDs 广告组ID;数量小于等于20个
UnitIDs []int64 `json:"unit_ids,omitempty"`
}

// Url implement GetRequest interface
func (r AdvancedProgramReviewDetailRequest) Url() string {
return "v2/creative/advanced/program/review_detail"
}

// Encode implement GetRequest interface
func (r AdvancedProgramReviewDetailRequest) Encode() string {
values := &url.Values{}
values.Set("advertiser_id", strconv.FormatInt(r.AdvertiserID, 10))
unitIds, _ := json.Marshal(r.UnitIDs)
values.Set("unit_ids", string(unitIds))
return values.Encode()
}
19 changes: 19 additions & 0 deletions model/creative/combine_detail_reviews.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package creative

// CombineDetailView 审核不通过和正在审核的创意组合
type CombineDetailView struct {
// ID 创意id
ID int64 `json:"id,omitempty"`
// PhotoID 视频id; 已加密
PhotoID int64 `json:"photo_id,omitempty"`
// CoverUrl 封面url
CoverUrl string `json:"cover_url,omitempty"`
// Caption 作品广告语
Caption string `json:"caption,omitempty"`
// ReviewStatus 审核状态;1:审核中2:审核通过3:不通过
ReviewStatus int `json:"review_status,omitempty"`
// ReviewDetail 审核信息;里面是一个String类型数据,是审核信息
ReviewDetail []string `json:"review_detail,omitempty"`
// PutStatus 程序化创意审核状态; 程序化创意操作状态,1:投放,2:暂停,3:删除
PutStatus int `json:"put_status,omitempty"`
}
Loading

0 comments on commit 65e13e1

Please sign in to comment.