Skip to content

Commit

Permalink
feat(qianchuan/material): 增加获取账户下素材列表
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Oct 14, 2024
1 parent de48611 commit 4dae3df
Show file tree
Hide file tree
Showing 13 changed files with 333 additions and 153 deletions.
11 changes: 6 additions & 5 deletions marketing-api/QIANCHUAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- 账户关系获取
- 获取千川账户下已授权抖音号 [ aweme.AuthorizedGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *aweme.AuthorizedGetRequest) (*aweme.AuthorizedGetResponseData, error) ]
- 获取千川账户下抖音号授权列表 [ advertiser.AwemeAuthListGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *advertiser.AwemeAuthListGetRequest) (*advertiser.AwemeAuthListGetResult, error) ]
- 获取已授权的账户(店铺/代理商)[ oauth.AdvertiserGet(ctx context.Context, clt *core.SDKClient, accessToken string) ([]oauth.Advertiser, error) ]
- 获取已授权的账户(店铺/代理商)[ oauth.AdvertiserGet(ctx context.Context, clt \*core.SDKClient, accessToken string) ([]oauth.Advertiser, error) ]
- 获取店铺账户关联的广告账户列表 [ shop.AdvertiserList(ctx context.Context, clt *core.SDKClient, accessToken string, req *shop.AdvertiserListRequest) (*shop.AdvertiserListResponseData, error) ]
- 获取代理商账户关联的广告账户列表 [ advertiser.AdvertiserSelect(ctx context.Context, clt *core.SDKClient, accessToken string, req *agent.AdvertiserSelectRequest) (*agent.AdvertiserSelectResponseData, error) ]
- 广告主添加抖音号 [ tools.AwemeAuth(ctx context.Context, clt *core.SDKClient, accessToken string, req *tools.AwemeAuthRequest) (bool, error) ]
Expand Down Expand Up @@ -62,9 +62,10 @@
- 批量更新广告创意状态 [ UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.UpdateStatusRequest) (*creative.UpdateResponseData, error) ]
- 获取账户下创意列表 [ Get(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.GetRequest) (*creative.GetResponseData, error) ]
- 获取计划审核建议 [ RejectReason(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.RejectReasonRequest) ([]creative.RejectReasonList, error) ]
- 广告素材管理 (api/ad)
- 获取计划下素材列表 [ MaterialGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *ad.MaterialGetRequest) (*ad.MaterialGetResult, error) ]
- 删除广告计划下素材 [ MaterialDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *ad.MaterialDeleteRequest) error ]
- 广告素材管理 (api/material)
- 获取账户下素材列表 [ 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 ]
- 商品/直播间管理
- 获取可投商品列表 [ 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) ]
Expand Down Expand Up @@ -120,7 +121,7 @@
- 获取随心推订单列表 [ OrderGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *aweme.OrderGetRequest) (*aweme.OrderGetResult, error) ]
- 获取随心推订单详情 [ OrderDetailGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *aweme.OrderDetailGetRequest) (*aweme.Order, error) ]
- 获取随心推订单数据 [ api/qianchuan/report.OrderGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.GetRequest) (*report.GetResponseData, error) ]
- 获取随心推兴趣标签 [ InterestActionInterestKeyword(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID uint64) ([]aweme.InterestKeyword, error) ]
- 获取随心推兴趣标签 [ InterestActionInterestKeyword(ctx context.Context, clt \*core.SDKClient, accessToken string, advertiserID uint64) ([]aweme.InterestKeyword, error) ]
- 获取随心推可投视频列表 [ VideoGet(clt *core.SDKClient, accessToken string, req *aweme.VideoGetRequest) (*aweme.VideoGetResult, error) ]
- 获取随心推投放效果预估 [ EstimateProfit(clt *core.SDKClient, accessToken string, req *aweme.EstimateProfitRequest) (*aweme.EstimateProfit, error) ]
- 获取随心推短视频建议出价 [ SuggestBid(clt *core.SDKClient, accessToken string, req *aweme.SuggestBidRequest) (float64, error) ]
Expand Down
13 changes: 0 additions & 13 deletions marketing-api/api/qianchuan/ad/material_delete.go

This file was deleted.

18 changes: 0 additions & 18 deletions marketing-api/api/qianchuan/ad/material_get.go

This file was deleted.

13 changes: 13 additions & 0 deletions marketing-api/api/qianchuan/material/ad_material_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package material

import (
"context"

"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/qianchuan/material"
)

// AdMaterialDelete 删除广告创意
func AdMaterialDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *material.AdMaterialDeleteRequest) error {
return clt.Post(ctx, "v1.0/qianchuan/ad/material/delete/", req, nil, accessToken)
}
18 changes: 18 additions & 0 deletions marketing-api/api/qianchuan/material/ad_material_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package material

import (
"context"

"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/qianchuan/material"
)

// AdMaterialGet 获取计划下素材列表
// 获取计划下的素材信息,包括素材的元信息,审核状态,关联创意ID,派生信息,是否删除等。
func AdMaterialGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *material.AdMaterialGetRequest) (*material.AdMaterialGetResult, error) {
var resp material.AdMaterialGetResponse
if err := clt.GetAPI(ctx, "v1.0/qianchuan/ad/material/get/", req, resp, accessToken); err != nil {
return nil, err
}
return resp.Data, nil
}
2 changes: 2 additions & 0 deletions marketing-api/api/qianchuan/material/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package material 广告素材管理
package material
17 changes: 17 additions & 0 deletions marketing-api/api/qianchuan/material/get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package material

import (
"context"

"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/qianchuan/material"
)

// Get 获取账户下素材列表
func Get(ctx context.Context, clt *core.SDKClient, accessToken string, req *material.GetRequest) (*material.GetResult, error) {
var resp material.GetResponse
if err := clt.GetAPI(ctx, "v1.0/qianchuan/material/get/", req, resp, accessToken); err != nil {
return nil, err
}
return resp.Data, nil
}
4 changes: 4 additions & 0 deletions marketing-api/enum/material_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ const (
MaterialSource_JI_CHUANG MaterialSource = "JI_CHUANG"
// MaterialSource_AWEME 抖音主页视频
MaterialSource_AWEME MaterialSource = "AWEME"
// MaterialSource_JIANYING 剪映共享素材
MaterialSource_JIANYING MaterialSource = "JIANYING"
// MaterialSource_QUNFENG 群峰共享素材
MaterialSource_QUNFENG MaterialSource = "QUNFENG"
// MaterialSource_OTHERS 其他来源
MaterialSource_OTHERS MaterialSource = "OTHERS"
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package ad
package material

import "github.com/bububa/oceanengine/marketing-api/util"

// MaterialDeleteRequest 删除广告计划下素材 API Request
type MaterialDeleteRequest struct {
// AdMaterialDeleteRequest 删除广告计划下素材 API Request
type AdMaterialDeleteRequest struct {
// MaterialIDs 待删除素材ID
// 注意:最大支持100个素材
MaterialIDs []uint64 `json:"material_ids,omitempty"`
Expand All @@ -14,6 +14,6 @@ type MaterialDeleteRequest struct {
}

// Encode implement PostRequest interface
func (r MaterialDeleteRequest) Encode() []byte {
func (r AdMaterialDeleteRequest) Encode() []byte {
return util.JSONMarshal(r)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ad
package material

import (
"strconv"
Expand All @@ -8,9 +8,6 @@ import (
"github.com/bububa/oceanengine/marketing-api/util"
)

// MaterialType 素材类型
type MaterialType string

const (
// MaterialType_IMAGE 图片,图文
MaterialType_IMAGE MaterialType = "IMAGE"
Expand All @@ -22,10 +19,10 @@ const (
MaterialType_VIDEO MaterialType = "VIDEO"
)

// MaterialGetRequest 获取计划下素材列表 API Request
type MaterialGetRequest struct {
// AdMaterialGetRequest 获取计划下素材列表 API Request
type AdMaterialGetRequest struct {
// Filtering 过滤条件
Filtering *MaterialGetFiltering `json:"filtering,omitempty"`
Filtering *AdMaterialGetFiltering `json:"filtering,omitempty"`
// OrderType 排序方式 可选值:
// ASC 升序
// DESC 降序 默认
Expand All @@ -42,8 +39,8 @@ type MaterialGetRequest struct {
PageSize int `json:"page_size,omitempty"`
}

// MaterialGetFiltering 过滤条件
type MaterialGetFiltering struct {
// AdMaterialGetFiltering 过滤条件
type AdMaterialGetFiltering struct {
// MaterialType 素材类型 可选值:
// IMAGE 图片,图文
// TITLE 标题
Expand Down Expand Up @@ -98,7 +95,7 @@ type MaterialGetFiltering struct {
}

// Encode implements GetRequest interface
func (r MaterialGetRequest) Encode() string {
func (r AdMaterialGetRequest) Encode() string {
values := util.GetUrlValues()
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
values.Set("ad_id", strconv.FormatUint(r.AdID, 10))
Expand All @@ -122,114 +119,15 @@ func (r MaterialGetRequest) Encode() string {
return ret
}

// MaterialGetResponse 获取计划下素材列表 API Response
type MaterialGetResponse struct {
Data *MaterialGetResult `json:"data,omitempty"`
// AdMaterialGetResponse 获取计划下素材列表 API Response
type AdMaterialGetResponse struct {
Data *AdMaterialGetResult `json:"data,omitempty"`
model.BaseResponse
}

type MaterialGetResult struct {
type AdMaterialGetResult struct {
// PageInfo 分页结果
PageInfo *model.PageInfo `json:"page_info,omitempty"`
// AdMaterialInfos 返回的素材信息列表
AdMaterialInfos []AdMaterialInfo `json:"ad_material_infos,omitempty"`
}

// AdMaterialInfo 素材信息
type AdMaterialInfo struct {
// MaterialDeliveryType 素材投放状态
MaterialDeliveryType string `json:"material_delivery_type,omitempty"`
// AuditStatus 审核状态 可选值:
// PASS 审核通过
// REJECT 审核拒绝
// IN_PROGRESS 审核中
AuditStatus string `json:"audit_status,omitempty"`
// CreativeIDs 关联的创意id
CreativeIDs []uint64 `json:"creative_ids,omitempty"`
// IsDel 是否删除
IsDel bool `json:"is_del,omitempty"`
// IsAutoGenerate 是否派生
IsAutoGenerate bool `json:"is_auto_generate,omitempty"`
}

// MaterialInfo 素材信息
type MaterialInfo struct {
// VideoMaterial 视频素材
VideoMaterial *VideoMaterial `json:"video_material,omitempty"`
// ImageMaterial 图片素材
ImageMaterial *ImageMaterial `json:"image_material,omitempty"`
// TitleMaterial 标题素材
TitleMaterial *TitleMaterial `json:"title_material,omitempty"`
// RoomMaterial 直播间画面用户信息
RoomMaterial *RoomMaterial `json:"room_material,omitempty"`
// MaterialType 素材类型
MaterialType MaterialType `json:"material_type,omitempty"`
}

// VideoMaterial 视频素材
type VideoMaterial struct {
// CoverImage 视频封面图片
CoverImage *MaterialImage `json:"cover_image,omitempty"`
// VideoID 视频 id
VideoID string `json:"video_id,omitempty"`
// Title 视频标题
Title string `json:"title,omitempty"`
// Source 视频来源
Source enum.MaterialSource `json:"source,omitempty"`
// ImageMode 素材样式
ImageMode enum.MaterialMode `json:"image_mode,omitempty"`
// MaterialID 素材id
MaterialID uint64 `json:"material_id,omitempty"`
// VideoDuration 视频时长
VideoDuration float64 `json:"video_duration,omitempty"`
}

// ImageMaterial 图片素材
type ImageMaterial struct {
// Title 标题
Title string `json:"title,omitempty"`
// MusicURL 图文音乐播放链接
MusicURL string `json:"music_url,omitempty"`
// Description 图文描述
Description string `json:"description,omitempty"`
// ImageMode 素材样式
ImageMode enum.MaterialMode `json:"image_mode,omitempty"`
// Source 来源
Source enum.MaterialSource `json:"source,omitempty"`
// Images 图片
Images []MaterialImage `json:"images,omitempty"`
// MaterialID 素材id
MaterialID uint64 `json:"material_id,omitempty"`
}

// TitleMaterial 标题素材
type TitleMaterial struct {
// Title 标题
Title string `json:"title,omitempty"`
// MaterialID 素材id
MaterialID uint64 `json:"material_id,omitempty"`
}

// RoomMaterial 直播间画面用户信息
type RoomMaterial struct {
// Name 直播间名称
Name string `json:"name,omitempty"`
// AwemeAvatar 头像
AwemeAvatar string `json:"aweme_avatar,omitempty"`
// ID 直播间id
ID uint64 `json:"id,omitempty"`
}

// MaterialImage 图片信息
type MaterialImage struct {
// WebURL 图片url
WebURL string `json:"web_url,omitempty"`
// ImageURL 图片url
ImageURL string `json:"image_url,omitempty"`
// ID 图片id
ID string `json:"id,omitempty"`
// Height 图片高度
Height int `json:"height,omitempty"`
// Width 图片宽度
Width int `json:"width,omitempty"`
}
2 changes: 2 additions & 0 deletions marketing-api/model/qianchuan/material/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package material 广告素材管理
package material
Loading

0 comments on commit 4dae3df

Please sign in to comment.