From 3fdc47a4219fc4a7f4a332cb676380afd50dfd6d Mon Sep 17 00:00:00 2001 From: Syd Xu Date: Thu, 5 Dec 2024 11:59:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(qianchuan/material):=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=AE=A1=E5=88=92=E7=BB=B4=E5=BA=A6=E7=B4=A0=E6=9D=90?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- marketing-api/QIANCHUAN.md | 2 + .../api/qianchuan/material/ad_get.go | 17 ++++ .../api/qianchuan/material/suggestion.go | 17 ++++ .../model/qianchuan/material/ad_get.go | 94 +++++++++++++++++++ .../qianchuan/material/ad_material_get.go | 11 --- .../model/qianchuan/material/material.go | 11 +++ .../model/qianchuan/material/suggestion.go | 72 ++++++++++++++ 7 files changed, 213 insertions(+), 11 deletions(-) create mode 100644 marketing-api/api/qianchuan/material/ad_get.go create mode 100644 marketing-api/api/qianchuan/material/suggestion.go create mode 100644 marketing-api/model/qianchuan/material/ad_get.go create mode 100644 marketing-api/model/qianchuan/material/suggestion.go diff --git a/marketing-api/QIANCHUAN.md b/marketing-api/QIANCHUAN.md index bf03559..8003803 100644 --- a/marketing-api/QIANCHUAN.md +++ b/marketing-api/QIANCHUAN.md @@ -66,6 +66,8 @@ - 获取账户下素材列表 [ Get(ctx context.Context, clt *core.SDKClient, accessToken string, req *material.GetRequest) (*material.GetResult, error) ] - 获取计划下素材列表 [ AdMaterialGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *material.AdMaterialGetRequest) (*material.AdMaterialGetResult, error) ] - 删除广告计划下素材 [ AdMaterialDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *material.AdMaterialDeleteRequest) error ] + - 计划下素材审核建议 [ Suggestion(ctx context.Context, clt *core.SDKClient, accessToken string, req *material.SuggestionRequest) (*material.SuggestionResult, error) ] + - 获取素材关联计划 [ AdGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *material.AdGetRequest) (*material.AdGetResult, error) ] - 商品/直播间管理 - 获取可投商品列表 [ AvailableGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *product.AvailableGetRequest) (*product.AvailableGetResponseData, error) ] - 获取千川账户下已授权抖音号 [ AuthorizedGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *aweme.AuthorizedGetRequest) (*aweme.AuthorizedGetResponseData, error) ] diff --git a/marketing-api/api/qianchuan/material/ad_get.go b/marketing-api/api/qianchuan/material/ad_get.go new file mode 100644 index 0000000..d5459e9 --- /dev/null +++ b/marketing-api/api/qianchuan/material/ad_get.go @@ -0,0 +1,17 @@ +package material + +import ( + "context" + + "github.com/bububa/oceanengine/marketing-api/core" + "github.com/bububa/oceanengine/marketing-api/model/qianchuan/material" +) + +// AdGet 获取素材关联计划 +func AdGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *material.AdGetRequest) (*material.AdGetResult, error) { + var resp material.AdGetResponse + if err := clt.GetAPI(ctx, "v1.0/qianchuan/material/ad/get/", req, resp, accessToken); err != nil { + return nil, err + } + return resp.Data, nil +} diff --git a/marketing-api/api/qianchuan/material/suggestion.go b/marketing-api/api/qianchuan/material/suggestion.go new file mode 100644 index 0000000..57f4f7e --- /dev/null +++ b/marketing-api/api/qianchuan/material/suggestion.go @@ -0,0 +1,17 @@ +package material + +import ( + "context" + + "github.com/bububa/oceanengine/marketing-api/core" + "github.com/bububa/oceanengine/marketing-api/model/qianchuan/material" +) + +// Suggestion 计划下素材审核建议 +func Suggestion(ctx context.Context, clt *core.SDKClient, accessToken string, req *material.SuggestionRequest) (*material.SuggestionResult, error) { + var resp material.SuggestionResponse + if err := clt.GetAPI(ctx, "v1.0/qianchuan/ad/material/suggestion/", req, resp, accessToken); err != nil { + return nil, err + } + return resp.Data, nil +} diff --git a/marketing-api/model/qianchuan/material/ad_get.go b/marketing-api/model/qianchuan/material/ad_get.go new file mode 100644 index 0000000..289dca2 --- /dev/null +++ b/marketing-api/model/qianchuan/material/ad_get.go @@ -0,0 +1,94 @@ +package material + +import ( + "strconv" + + "github.com/bububa/oceanengine/marketing-api/enum" + "github.com/bububa/oceanengine/marketing-api/enum/qianchuan" + "github.com/bububa/oceanengine/marketing-api/model" + "github.com/bububa/oceanengine/marketing-api/model/qianchuan/report" + "github.com/bububa/oceanengine/marketing-api/util" +) + +// AdGetRequest 获取素材关联计划 API Request +type AdGetRequest struct { + // AdvertiserID 广告主id + AdvertiserID uint64 `json:"advertiser_id,omitempty"` + // MaterialID 素材id + MaterialID uint64 `json:"material_id,omitempty"` + // MaterialType 素材类型,可选值: + // IMAGE 图片,图文 + // LIVE_ROOM 直播间画面 + // TITLE 标题 + // VIDEO 视频 + MaterialType MaterialType `json:"material_type,omitempty"` + // MarketingScene 广告类型,可选值: + // FEED 通投 + // SEARCH 搜索 + // SHOPPING_MALL 商城广告 + MarketingScene qianchuan.MarketingScene `json:"marketing_scene,omitempty"` + // MarketingGoal 营销场景,可选值: + // VIDEO_PROM_GOODS:推商品 + // LIVE_PROM_GOODS:推直播间 + MarketingGoal enum.MarketingGoal `json:"marketing_goal,omitempty"` + // StartTime 计划数据开始时间,格式“YYYY-MM-DD” + // 注意:最早开始时间不大于“当前时间-180天” + StartTime string `json:"start_time,omitempty"` + // EndTime 计划数据结束时间,格式“YYYY-MM-DD” + EndTime string `json:"end_time,omitempty"` + // Fields 需要查询的消耗指标,取值见返回值中metric相关指标 + Fields []string `json:"fields,omitempty"` + // OrderField 排序字段 + OrderField string `json:"order_field,omitempty"` + // OrderType 排序方式 可选值: + // ASC 升序 + // DESC 降序 + OrderType enum.OrderType `json:"order_type,omitempty"` +} + +// Encode implements GetRequest interface +func (r AdGetRequest) Encode() string { + values := util.GetUrlValues() + values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10)) + values.Set("material_id", strconv.FormatUint(r.MaterialID, 10)) + values.Set("material_type", string(r.MaterialType)) + values.Set("marketing_scene", string(r.MarketingScene)) + values.Set("marketing_goal", string(r.MarketingGoal)) + values.Set("start_time", r.StartTime) + values.Set("end_time", r.EndTime) + if len(r.Fields) > 0 { + values.Set("fields", string(util.JSONMarshal(r.Fields))) + } + if r.OrderField != "" { + values.Set("order_field", r.OrderField) + } + if r.OrderType != "" { + values.Set("order_type", string(r.OrderType)) + } + ret := values.Encode() + util.PutUrlValues(values) + return ret +} + +// AdGetResponse 获取素材关联计划 API Response +type AdGetResponse struct { + Data *AdGetResult `json:"data,omitempty"` + model.BaseResponse +} + +type AdGetResult struct { + // PageInfo 分页信息 + PageInfo *model.PageInfo `json:"page_info,omitempty"` + // AdList 计划列表 + AdList []MaterialAd `json:"ad_list,omitempty"` +} + +// MaterialAd 素材关联计划 +type MaterialAd struct { + // AdID 计划id + AdID uint64 `json:"ad_id,omitempty"` + // AdName 计划名称 + AdName string `json:"ad_name,omitempty"` + // Metrics 指标 + Metrics *report.Metrics `json:"metrics,omitempty"` +} diff --git a/marketing-api/model/qianchuan/material/ad_material_get.go b/marketing-api/model/qianchuan/material/ad_material_get.go index 9826630..b949c35 100644 --- a/marketing-api/model/qianchuan/material/ad_material_get.go +++ b/marketing-api/model/qianchuan/material/ad_material_get.go @@ -8,17 +8,6 @@ import ( "github.com/bububa/oceanengine/marketing-api/util" ) -const ( - // MaterialType_IMAGE 图片,图文 - MaterialType_IMAGE MaterialType = "IMAGE" - // MaterialType_TITLE 标题 - MaterialType_TITLE MaterialType = "TITLE" - // MaterialType_LIVE_ROOM 直播间画面 - MaterialType_LIVE_ROOM MaterialType = "LIVE_ROOM" - // MaterialType_VIDEO 视频 - MaterialType_VIDEO MaterialType = "VIDEO" -) - // AdMaterialGetRequest 获取计划下素材列表 API Request type AdMaterialGetRequest struct { // Filtering 过滤条件 diff --git a/marketing-api/model/qianchuan/material/material.go b/marketing-api/model/qianchuan/material/material.go index 0deae44..22dfc66 100644 --- a/marketing-api/model/qianchuan/material/material.go +++ b/marketing-api/model/qianchuan/material/material.go @@ -8,6 +8,17 @@ import ( // MaterialType 素材类型 type MaterialType string +const ( + // MaterialType_IMAGE 图片,图文 + MaterialType_IMAGE MaterialType = "IMAGE" + // MaterialType_TITLE 标题 + MaterialType_TITLE MaterialType = "TITLE" + // MaterialType_LIVE_ROOM 直播间画面 + MaterialType_LIVE_ROOM MaterialType = "LIVE_ROOM" + // MaterialType_VIDEO 视频 + MaterialType_VIDEO MaterialType = "VIDEO" +) + // AdMaterialInfo 素材信息 type AdMaterialInfo struct { // MaterialInfo 素材信息 diff --git a/marketing-api/model/qianchuan/material/suggestion.go b/marketing-api/model/qianchuan/material/suggestion.go new file mode 100644 index 0000000..a4b2e43 --- /dev/null +++ b/marketing-api/model/qianchuan/material/suggestion.go @@ -0,0 +1,72 @@ +package material + +import ( + "strconv" + + "github.com/bububa/oceanengine/marketing-api/model" + "github.com/bububa/oceanengine/marketing-api/util" +) + +// SuggestionRequest 计划下素材审核建议 API Request +type SuggestionRequest struct { + // MaterialIDs 素材id列表 + MaterialIDs []uint64 `json:"material_ids,omitempty"` + // AdvertiserID 广告主id + AdvertiserID uint64 `json:"advertiser_id,omitempty"` + // AdID 计划id + AdID uint64 `json:"ad_id,omitempty"` +} + +// Encode implements GetRequest interface +func (r SuggestionRequest) Encode() string { + values := util.GetUrlValues() + values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10)) + values.Set("ad_id", strconv.FormatUint(r.AdID, 10)) + values.Set("material_ids", string(util.JSONMarshal(r.MaterialIDs))) + ret := values.Encode() + util.PutUrlValues(values) + return ret +} + +// SuggestionResponse 计划下素材审核建议 API Response +type SuggestionResponse struct { + Data *SuggestionResult `json:"data,omitempty"` + model.BaseResponse +} + +type SuggestionResult struct { + List []Suggestion `json:"list,omitempty"` +} + +// Suggestion 素材审核建议 +type Suggestion struct { + // AuditRecords 审核列表 + AuditRecords []AuditRecord `json:"audit_records,omitempty"` + // MaterialID 素材id + MaterialID uint64 `json:"material_id,omitempty"` +} + +// AuditPlatform 审核平台 +type AuditPlatform string + +const ( + // AuditPlatform_UNKNOWN 未知 + AuditPlatform_UNKNOWN AuditPlatform = "UNKNOWN" + // AuditPlatform_AD 广告审核 + AuditPlatform_AD AuditPlatform = "AD" + // AuditPlatform_CONTENT 内容审核 + AuditPlatform_CONTENT AuditPlatform = "CONTENT" +) + +// AuditRecord 审核列表 +type AuditRecord struct { + // AuditPlatform 审核平台:可选值: + // UNKNOWN:未知 + // AD:广告审核 + // CONTENT:内容审核 + AuditPlatform AuditPlatform `json:"audit_platform,omitempty"` + // RejectReason 拒绝原因 + RejectReason []string `json:"reject_reason,omitempty"` + // Suggestions 建议 + Suggestions []string `json:"suggestions,omitempty"` +} From bb52c5a6e0a882bcd6eda14a3fde5c038a251fee Mon Sep 17 00:00:00 2001 From: Syd Xu Date: Thu, 5 Dec 2024 12:05:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(qianchuan):=20=E5=AE=9A=E5=90=91?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=94=AF=E6=8C=81=E8=A1=8C=E6=94=BF=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- marketing-api/model/qianchuan/ad/audience.go | 2 ++ marketing-api/model/qianchuan/ad/region_update.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/marketing-api/model/qianchuan/ad/audience.go b/marketing-api/model/qianchuan/ad/audience.go index ea8e3ea..5bea24e 100644 --- a/marketing-api/model/qianchuan/ad/audience.go +++ b/marketing-api/model/qianchuan/ad/audience.go @@ -24,6 +24,8 @@ type Audience struct { // 1:支持电子围栏定向 // 2:支持电子围栏定向 ElectricFenceRegion int `json:"electric_fence_region,omitempty"` + // RegionVersion 行政区域版本号,可选值:2.3.2 新版本 + RegionVersion string `json:"region_version,omitempty"` // City 具体定向的城市列表,当 district 为COUNTY,city 为必填,枚举值详见【附件-city.json】;省市传法:city: [12],district: CITY;区县的传法:city: [130102],district: COUNTY City []uint64 `json:"city,omitempty"` // LocationType 地域定向的用户状态类型,当 district 为COUNTY,CITY为必填,允许值:CURRENT:正在该地区的用户,HOME:居住在该地区的用户,TRAVEL;到该地区旅行的用户,ALL:该地区内的所有用户 diff --git a/marketing-api/model/qianchuan/ad/region_update.go b/marketing-api/model/qianchuan/ad/region_update.go index a0d3593..e01629d 100644 --- a/marketing-api/model/qianchuan/ad/region_update.go +++ b/marketing-api/model/qianchuan/ad/region_update.go @@ -32,6 +32,12 @@ type RegionUpdateRequest struct { // 注意: // 1、当地域定向类型为“不限”/地域定向的用户状态类型为“正在该地区的用户”才支持 ExcludeLimitedRegion int `json:"exclude_limited_region,omitempty"` + // ElectricFenceRegion 电子围栏定向,可选值: + // 1 不支持电子围栏地区 + // 2 支持电子围栏地区 + ElectricFenceRegion int `json:"electric_fence_region,omitempty"` + // RegionVersion 行政区域版本号,可选值: 2.3.3 新版本 + RegionVersion string `json:"region_version,omitempty"` } // Encode implement PostRequest interface