Skip to content

Commit

Permalink
fix(eventmanager): 获取账户下资产列表(新), issue: #70
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Aug 23, 2024
1 parent 328b87c commit 156ef20
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 61 deletions.
2 changes: 1 addition & 1 deletion marketing-api/api/eventmanager/all_assets_detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ func AllAssetsDetail(clt *core.SDKClient, accessToken string, req *eventmanager.
if err := clt.GetAPI("2/tools/event/all_assets/detail/", req, &resp, accessToken); err != nil {
return nil, err
}
return resp.Data.List, nil
return resp.Data.AssetList, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// EventConvertOptimizedGoalGet 获取优化目标
// 查询事件管理下资产的优化目标
func EventConvertOptimizedGoalGet(clt *core.SDKClient, accessToken string, req *eventmanager.EventConvertOptimizedGoalGetRequest) (*eventmanager.EventConvertOptimizedGoalGetResponseData, error) {
func EventConvertOptimizedGoalGet(clt *core.SDKClient, accessToken string, req *eventmanager.EventConvertOptimizedGoalGetRequest) (*eventmanager.EventConvertOptimizedGoalGetResult, error) {
var resp eventmanager.EventConvertOptimizedGoalGetResponse
if err := clt.Get("2/tools/event_convert/optimized_goal/get/", req, &resp, accessToken); err != nil {
return nil, err
Expand Down
5 changes: 3 additions & 2 deletions marketing-api/api/eventmanager/v3/optimized_goal_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package v3

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/eventmanager"
v3 "github.com/bububa/oceanengine/marketing-api/model/eventmanager/v3"
)

// OptimizedGoalGet 获取优化目标
// 查询事件管理下资产的优化目标
func OptimizedGoalGet(clt *core.SDKClient, accessToken string, req *v3.OptimizedGoalGetRequest) (*v3.OptimizedGoalGetResponseData, error) {
var resp v3.OptimizedGoalGetResponse
func OptimizedGoalGet(clt *core.SDKClient, accessToken string, req *v3.OptimizedGoalGetRequest) (*eventmanager.EventConvertOptimizedGoalGetResult, error) {
var resp eventmanager.EventConvertOptimizedGoalGetResponse
if err := clt.GetAPI("v3.0/event_manager/optimized_goal/get_v2/", req, &resp, accessToken); err != nil {
return nil, err
}
Expand Down
2 changes: 2 additions & 0 deletions marketing-api/enum/dpa_adtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ type DpaAdType string
const (
// DpaAdType_DPA_LINK 落地页
DpaAdType_DPA_LINK DpaAdType = "DPA_LINK"
// DpaAdType_DPA_APP 应用下载
DpaAdType_DPA_APP DpaAdType = "DPA_APP"
)
15 changes: 15 additions & 0 deletions marketing-api/enum/event_convert_optimized_goal_value_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package enum

// EventConvertOptimizedGoalValueType 设置差异价值
type EventConvertOptimizedGoalValueType = string

const (
// EventConvertOptimizedGoalValueType_DISABLED 未设置
EventConvertOptimizedGoalValueType_DISABLED EventConvertOptimizedGoalValueType = "DISABLED"
// EventConvertOptimizedGoalValueType_DISCRIMINATEBYGROUP 人群差异价值
EventConvertOptimizedGoalValueType_DISCRIMINATEBYGROUP EventConvertOptimizedGoalValueType = "DISCRIMINATEBYGROUP"
// EventConvertOptimizedGoalValueType_DYNAMICVALUE 动态价值
EventConvertOptimizedGoalValueType_DYNAMICVALUE EventConvertOptimizedGoalValueType = "DYNAMICVALUE"
// EventConvertOptimizedGoalValueType_FIXED 固定价值
EventConvertOptimizedGoalValueType_FIXED EventConvertOptimizedGoalValueType = "FIXED"
)
8 changes: 4 additions & 4 deletions marketing-api/model/eventmanager/all_assets_detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

// AllAssetsDetailRequest 获取已创建资产详情(新) API Request
type AllAssetsDetailRequest struct {
// AdvertiserID 广告主 id
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// AssetIDs 资产id列表,list长度最长50
// 当账户下不存在该资产id时不会返回详情信息;当资产共享失效时,不会返回详情信息。
AssetIDs []uint64 `json:"asset_ids,omitempty"`
// AdvertiserID 广告主 id
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
}

// Encode implements GetRequest interface
Expand All @@ -30,7 +30,7 @@ func (r AllAssetsDetailRequest) Encode() string {
type AllAssetsDetailResponse struct {
model.BaseResponse
Data struct {
// List 资产列表
List []AssetDetail `json:"list,omitempty"`
// AssetList 资产列表
AssetList []AssetDetail `json:"asset_list,omitempty"`
} `json:"data,omitempty"`
}
2 changes: 1 addition & 1 deletion marketing-api/model/eventmanager/all_assets_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ type AllAssetsListResult struct {
// PageInfo 分页信息
PageInfo *model.PageInfo `json:"page_info,omitempty"`
// List 资产列表
List []AssetBaseInfo `json:"list,omitempty"`
AssetList []AssetBaseInfo `json:"asset_list,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type EventConvertOptimizedGoal struct {
// TwentyFourHourBack 24 小时历史有无回传, true 表示有,false 表示无
TwentyFourHourBack bool `json:"twenty_four_hour_back,omitempty"`
// ValueType 价值类型,Disabled 不展示、DiscriminateByGroup 人群差异价值、DynamicValue 动态回传价值、Fixed 固定价值
ValueType string `json:"value_type,omitempty"`
ValueType enum.EventConvertOptimizedGoalValueType `json:"value_type,omitempty"`
// AssetTypes 资产类型,:THIRD_EXTERNAL:三方落地页、TETRIS_EXTERNAL:建站、APP 应用、QUICK_APP 快应用、MINI_PROGRAME字节小程序
AssetTypes []enum.AssetType `json:"asset_types,omitempty"`
// DeepGoals 深度优化目标列表
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ func (r EventConvertOptimizedGoalGetRequest) Encode() string {
type EventConvertOptimizedGoalGetResponse struct {
model.BaseResponse
// Data json返回值
Data *EventConvertOptimizedGoalGetResponseData `json:"data,omitempty"`
Data *EventConvertOptimizedGoalGetResult `json:"data,omitempty"`
}

// EventConvertOptimizedGoalGetResponseData json返回值
type EventConvertOptimizedGoalGetResponseData struct {
// EventConvertOptimizedGoalGetResult json返回值
type EventConvertOptimizedGoalGetResult struct {
// AssetIDs 资产 id
AssetIDs []uint64 `json:"asset_ids,omitempty"`
// Goals 优化目标数据列表
Expand Down
111 changes: 63 additions & 48 deletions marketing-api/model/eventmanager/v3/optimized_goal_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,82 @@ import (
"strconv"

"github.com/bububa/oceanengine/marketing-api/enum"
"github.com/bububa/oceanengine/marketing-api/model"
"github.com/bububa/oceanengine/marketing-api/model/eventmanager"
"github.com/bububa/oceanengine/marketing-api/util"
)

// OptimizedGoalGetRequest 获取优化目标 API Request
// OptimizedGoalGetRequest 获取优化目标(巨量广告升级版) API Request
type OptimizedGoalGetRequest struct {
// AdvertiserID 广告主id
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// DeliveryMode 投放模式,允许值:MANUAL手动投放(默认值)、PROCEDURAL自动投放
DeliveryMode enum.DeliveryMode `json:"delivery_mode,omitempty"`
// LandingType 广告组推广目的,允许值:LINK 销售线索收集
LandingType enum.LandingType `json:"landing_type,omitempty"`
// MarketingGoal 营销场景,允许值:VIDEO_AND_IMAGE 短视频/图片,LIVE直播
MarketingGoal enum.MarketingGoal `json:"marketing_goal,omitempty"`
// AdType 广告类型,允许值: ALL
// AdType 广告类型,允许值:ALL 可选值:
// ALL 信息流
// SEARCH 搜索
AdType enum.CampaignType `json:"ad_type,omitempty"`
// DeliveryType 投放类型,允许值
// NORMAL 常规投放
// DURATION 周期稳投
// 当前仅支持搜索广告,即ad_type = SEARCH下传入该枚举值有效,否则报错
DeliveryType enum.DeliveryType `json:"delivery_type,omitempty"`
// AssetType 资产类型,允许值:THIRD_EXTERNAL 三方落地页、TETRIS_EXTERNAL 建站、APP 应用、QUICK_APP 快应用、MINI_PROGRAME字节小程序
AssetType enum.AssetType `json:"asset_type,omitempty"`
// MiniProgoramID 字节小程序资产id,当asset_type=MINI_PROGRAME时需传入
MiniProgramID string `json:"mini_program_id,omitempty"`
// QuickAppID 快应用id,当 landing_type = QUICK_APP 时该字段必填
QuickAppID string `json:"quick_app_id,omitempty"`
// SiteID 建站site_id,当asset_type为TETRIS_EXTERNAL时必填,site_id可以通过【获取橙子建站站点列表】接口获得
SiteID uint64 `json:"site_id,omitempty"`
// AssetID 三方的资产id,当asset_type为THIRD_EXTERNAL时必填
AssetID uint64 `json:"asset_id,omitempty"`
// QuickAppID 快应用id
QuickAppID uint64 `json:"quick_app_id,omitempty"`
// MiniProgramID 字节小程序资产id
MiniProgramID string `json:"mini_program_id,omitempty"`
// PackageName 应用包名称
PackageName string `json:"package_name,omitempty"`
// AppType 应用类型,当asset_type为应用APP时必填
// 可选值:ANDROID 、IOS
AppType string `json:"app_type,omitempty"`
// AppPromotionType 子目标,当 landing_type = APP 时该字段必填,允许值: DOWNLOAD 应用下载、LAUNCH 应用调用、RESERVE 预约下载
// AppPromotionType 子目标,可选值:
// DOWNLOAD 应用下载
// LAUNCH 应用调起
// RESERVE 预约下载
AppPromotionType enum.AppPromotionType `json:"app_promotion_type,omitempty"`
// MarketingGoal 营销场景, 可选值:
// LIVE
// VIDEO_AND_IMAGE
MarketingGoal enum.MarketingGoal `json:"marketing_goal,omitempty"`
// DeliveryMode 投放模式 可选值:
// MANUAL 手动投放模式
// PROCEDURAL 自动投放模式
DeliveryMode enum.DeliveryMode `json:"delivery_mode,omitempty"`
// DpaAdType dpa广告类型,可选值:
// DPA_APP 应用下载
// DPA_LINK 落地页
DpaAdType enum.DpaAdType `json:"dpa_adtype,omitempty"`
// MicroPromotionType 小程序类型,landing_type = MICRO_GAME 时有效且必填
// 可选值:
// BYTE_APP 节小程序
// BYTE_GAME 字节小游戏
// WECHAT_APP 微信小程序
// WECHAT_GAME 微信小游戏
MicroPromotionType enum.MicroPromotionType `json:"micro_promotion_type,omitempty"`
// MicroAppInstanceID 小程序资产id
MicroAppInstanceID string `json:"micro_app_instance_id,omitempty"`
// DeliveryType 可选值:
// DURATION 周期稳投
// NORMAL 常规投放
DeliveryType enum.DeliveryType `json:"delivery_type,omitempty"`
}

// Encode implement GetRequest interface
func (r OptimizedGoalGetRequest) Encode() string {
values := util.GetUrlValues()
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
if r.DeliveryMode != "" {
values.Set("delivery_mode", string(r.DeliveryMode))
}
values.Set("landing_type", string(r.LandingType))
if r.MarketingGoal != "" {
values.Set("marketing_goal", string(r.MarketingGoal))
}
if r.AppType != "" {
values.Set("app_type", r.AppType)
}
values.Set("asset_type", string(r.AssetType))
values.Set("ad_type", string(r.AdType))
if r.MiniProgramID != "" {
values.Set("mini_program_id", r.MiniProgramID)
}
if r.QuickAppID != "" {
values.Set("quick_app_id", r.QuickAppID)
values.Set("asset_type", string(r.AssetType))
if r.SiteID > 0 {
values.Set("site_id", strconv.FormatUint(r.SiteID, 10))
}
if r.AssetID > 0 {
values.Set("asset_id", strconv.FormatUint(r.AssetID, 10))
}
if r.MiniProgramID != "" {
values.Set("mini_program_id", r.MiniProgramID)
}
if r.PackageName != "" {
values.Set("package_name", r.PackageName)
}
Expand All @@ -77,22 +89,25 @@ func (r OptimizedGoalGetRequest) Encode() string {
if r.AppPromotionType != "" {
values.Set("app_promotion_type", string(r.AppPromotionType))
}
if r.MarketingGoal != "" {
values.Set("marketing_goal", string(r.MarketingGoal))
}
if r.DeliveryMode != "" {
values.Set("delivery_mode", string(r.DeliveryMode))
}
if r.DpaAdType != "" {
values.Set("dpa_adtype", string(r.DpaAdType))
}
if r.MicroPromotionType != "" {
values.Set("micro_promotion_type", string(r.MicroPromotionType))
}
if r.MicroAppInstanceID != "" {
values.Set("micro_app_instance_id", r.MicroAppInstanceID)
}
if r.DeliveryType != "" {
values.Set("delivery_type", string(r.DeliveryType))
}
ret := values.Encode()
util.PutUrlValues(values)
return ret
}

// OptimizedGoalGetResponse 获取优化目标 API Response
type OptimizedGoalGetResponse struct {
model.BaseResponse
// Data json返回值
Data *OptimizedGoalGetResponseData `json:"data,omitempty"`
}

// OptimizedGoalGetResponseData json返回值
type OptimizedGoalGetResponseData struct {
// AssetIDs 资产 id
AssetIDs []uint64 `json:"asset_ids,omitempty"`
// Goals 优化目标数据列表
Goals []eventmanager.EventConvertOptimizedGoal `json:"goals,omitempty"`
}

0 comments on commit 156ef20

Please sign in to comment.