Skip to content

Commit

Permalink
feat(dsp/dpa): 完善商品库API
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Aug 2, 2024
1 parent 3185946 commit 7574a03
Show file tree
Hide file tree
Showing 25 changed files with 1,009 additions and 123 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,17 @@
- 修改应用分包备注 [ subpkg.Description(clt *core.SDKClient, accessToken string, req *subpkg.DescriptionRequest) error ]
- 获取分包管理/回收站列表 [ subpkg.List(clt *core.SDKClient, accessToken string, req *subpkg.ListRequest) (*subpkg.ListResponse, error) ]
- 分包失败重新构建 [ app.RetryBuildSubPackage(clt *core.SDKClient, accessToken string, req *app.RetryBuildSubPackageRequest) (int, error) ]
- 商品库 (api/dsp/dpa)
- 查询 DPA 模板信息 [ TemplateList(clt *core.SDKClient, accessToken string, req *dpa.TemplateListRequest) (*dpa.TemplateListResponse, error) ]
- 获取商品库类目树 [ CategoryList(clt *core.SDKClient, accessToken string, req *dpa.CategoryListRequest) (*dpa.CategoryListResponse, error) ]
- 获取商品库列表 [ LibraryList(clt *core.SDKClient, accessToken string, req *dpa.LibraryListRequest) (*dpa.LibraryListResponse, error) ]
- 创建商品 [ ProductBatchCreate(clt *core.SDKClient, accessToken string, req *dpa.ProductBatchCreateRequest) ([]dpa.ProductUpdateResult, error) ]
- 更新商品 [ ProductBatchUpdate(clt *core.SDKClient, accessToken string, req *dpa.ProductBatchUpdateRequest) ([]dpa.ProductUpdateResult, error) ]
- 获取商品列表 [ ProductBatchQuery(clt *core.SDKClient, accessToken string, req *dpa.ProductBatchQueryRequest) (*dpa.ProductBatchQueryResponse, error) ]
- 获取商品列表(游标) [ ProductCursorQuery(clt *core.SDKClient, accessToken string, req *dpa.ProductCursorQueryRequest) (*dpa.ProductCursorQueryResponse, error) ]
- 获取SDPA创意视频模板 [ CreativeTemplateList(clt *core.SDKClient, accessToken string, req *dpa.CreativeTemplateListRequest) (*dpa.CreativeTemplateListResponse, error) ]
- 批量模板合成SDPA创意视频 [ CreativeVideoGenerate(clt *core.SDKClient, accessToken string, req *dpa.CreativeVideoGenerateRequest) ([]dpa.GenerateVideoResult, error) ]
- CID服务商投放SDPA接口 [ SecretCidLink(clt *core.SDKClient, accessToken string, req *dpa.SecretCidLinkRequest) error ]
- 数据上报管理 (api/track)
- 转化回传 [ Activate(req *track.ActivateRequest) error ]
- 点击检测链接 [ Click(baseUrl string, fields []string) string ]
Expand Down
15 changes: 15 additions & 0 deletions api/dsp/dpa/category_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dpa

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

// CategoryList 获取商品库类目树
func CategoryList(clt *core.SDKClient, accessToken string, req *dpa.CategoryListRequest) (*dpa.CategoryListResponse, error) {
var resp dpa.CategoryListResponse
if err := clt.Post(accessToken, req, &resp); err != nil {
return nil, err
}
return &resp, nil
}
15 changes: 15 additions & 0 deletions api/dsp/dpa/creative_template_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dpa

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

// CreativeTemplateList 获取SDPA创意视频模板
func CreativeTemplateList(clt *core.SDKClient, accessToken string, req *dpa.CreativeTemplateListRequest) (*dpa.CreativeTemplateListResponse, error) {
var resp dpa.CreativeTemplateListResponse
if err := clt.Post(accessToken, req, &resp); err != nil {
return nil, err
}
return &resp, nil
}
15 changes: 15 additions & 0 deletions api/dsp/dpa/creative_video_generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dpa

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

// CreativeVideoGenerate 批量模板合成SDPA创意视频
func CreativeVideoGenerate(clt *core.SDKClient, accessToken string, req *dpa.CreativeVideoGenerateRequest) ([]dpa.GenerateVideoResult, error) {
var resp dpa.CreativeVideoGenerateResponse
if err := clt.Post(accessToken, req, &resp); err != nil {
return nil, err
}
return resp.VideoInfos, nil
}
15 changes: 15 additions & 0 deletions api/dsp/dpa/product_batch_create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dpa

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

// ProductBatchCreate 创建商品
func ProductBatchCreate(clt *core.SDKClient, accessToken string, req *dpa.ProductBatchCreateRequest) ([]dpa.ProductUpdateResult, error) {
var resp dpa.ProductBatchUpdateResponse
if err := clt.Post(accessToken, req, &resp); err != nil {
return nil, err
}
return resp.ProductEditResponses, nil
}
15 changes: 15 additions & 0 deletions api/dsp/dpa/product_batch_update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dpa

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

// ProductBatchUpdate 更新商品
func ProductBatchUpdate(clt *core.SDKClient, accessToken string, req *dpa.ProductBatchUpdateRequest) ([]dpa.ProductUpdateResult, error) {
var resp dpa.ProductBatchUpdateResponse
if err := clt.Post(accessToken, req, &resp); err != nil {
return nil, err
}
return resp.ProductEditResponses, nil
}
15 changes: 15 additions & 0 deletions api/dsp/dpa/product_cursor_query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dpa

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

// ProductCursorQuery 获取商品列表(游标)
func ProductCursorQuery(clt *core.SDKClient, accessToken string, req *dpa.ProductCursorQueryRequest) (*dpa.ProductCursorQueryResponse, error) {
var resp dpa.ProductCursorQueryResponse
if err := clt.Post(accessToken, req, &resp); err != nil {
return nil, err
}
return &resp, nil
}
11 changes: 11 additions & 0 deletions api/dsp/dpa/secret_cid_link.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dpa

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

// SecretCidLink CID服务商投放SDPA接口
func SecretCidLink(clt *core.SDKClient, accessToken string, req *dpa.SecretCidLinkRequest) error {
return clt.Post(accessToken, req, nil)
}
15 changes: 15 additions & 0 deletions api/dsp/dpa/template_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dpa

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

// TemplateList 查询 DPA 模板信息
func TemplateList(clt *core.SDKClient, accessToken string, req *dpa.TemplateListRequest) (*dpa.TemplateListResponse, error) {
var resp dpa.TemplateListResponse
if err := clt.Post(accessToken, req, &resp); err != nil {
return nil, err
}
return &resp, nil
}
37 changes: 37 additions & 0 deletions model/dsp/dpa/category_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package dpa

import "github.com/bububa/kwai-marketing-api/model"

// CategoryListRequest 获取商品库类目树 API Request
type CategoryListRequest struct {
// AdvertiserID 广告主账号ID
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// LibraryID 商品库ID
LibraryID uint64 `json:"library_id,omitempty"`
}

// Url implements PostRequest interface
func (r CategoryListRequest) Url() string {
return "gw/dsp/v1/dpa/category/list"
}

// Encode implements PostRequest interface
func (r CategoryListRequest) Encode() []byte {
return model.JSONMarshal(r)
}

// CategoryListResponse 获取商品库类目树 API Response
type CategoryListResponse struct {
// Details 类目信息列表
Details []Category `json:"details,omitempty"`
}

// Category 类目信息
type Category struct {
// Label 类目名称
Label string `json:"label,omitempty"`
// Children 子类目
Children []Category `json:"children,omitempty"`
// Value 类目ID
Value uint64 `json:"value,omitempty"`
}
54 changes: 54 additions & 0 deletions model/dsp/dpa/creative_template_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package dpa

import "github.com/bububa/kwai-marketing-api/model"

// CreativeTemplateListRequest 获取SDPA创意视频模板 API Request
type CreativeTemplateListRequest struct {
// PageInfo 分页信息
PageInfo *model.PageInfo `json:"page_info,omitempty"`
// OuterID 商品外部ID
// 填写则返回"canSelect"
OuterID string `json:"outer_id,omitempty"`
// AdvertiserID 广告主账号ID
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// LibraryID 商品库ID
LibraryID uint64 `json:"library_id,omitempty"`
// ProductID 商品ID
// 填写则返回"canSelect",优先于"outer_id"生效
ProductID uint64 `json:"product_id,omitempty"`
}

// Url implements PostRequest interface
func (r CreativeTemplateListRequest) Url() string {
return "gw/dsp/v1/dpa/creative/template/list"
}

// Encode implements PostRequest interface
func (r CreativeTemplateListRequest) Encode() []byte {
return model.JSONMarshal(r)
}

// CreativeTemplateListResponse 获取SDPA创意视频模板 API Response
type CreativeTemplateListResponse struct {
// PageInfo 分页信息
PageInfo *model.PageInfo `json:"page_info,omitempty"`
// TemplateList 创意模板列表
TemplateList []CreativeTemplate `json:"template_list,omitempty"`
}

// CreativeTemplate 创意模板
type CreativeTemplate struct {
// Image 封面图URL
Image string `json:"image,omitempty"`
// DemoURL 样例视频URL
DemoURL string `json:"demo_url,omitempty"`
// TemplateID 模板ID
TemplateID uint64 `json:"template_id,omitempty"`
// PackageID 配置包ID
PackageID uint64 `json:"package_id,omitempty"`
// TemplateType 模板类型
// 1-图片模板, 2-视频模板, 3-图片视频模板
TemplateType int `json:"template_type,omitempty"`
// CanSelect 是否可选
CanSelect bool `json:"can_select,omitempty"`
}
68 changes: 68 additions & 0 deletions model/dsp/dpa/creative_video_generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package dpa

import (
"fmt"

"github.com/bububa/kwai-marketing-api/model"
)

// CreativeVideoGenerateRequest 批量模板合成SDPA创意视频 API Request
type CreativeVideoGenerateRequest struct {
// OuterID 商品外部ID
OuterID string `json:"outer_id,omitempty"`
// Templates 视频模板信息
Templates []CreativeTemplate `json:"templates,omitempty"`
// AdvertiserID 广告主账号ID
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// LibraryID 商品库ID
LibraryID uint64 `json:"library_id,omitempty"`
// ProductID 商品ID
// 优先于"outer_id"生效
ProductID uint64 `json:"product_id,omitempty"`
}

// Url implements PostRequest interface
func (r CreativeVideoGenerateRequest) Url() string {
return "gw/dsp/v1/dpa/creative/video/generate"
}

// Encode implements PostRequest interface
func (r CreativeVideoGenerateRequest) Encode() []byte {
return model.JSONMarshal(r)
}

// CreativeVideoGenerateResponse 批量模板合成SDPA创意视频 API Response
type CreativeVideoGenerateResponse struct {
// VideoInfos 视频信息列表
VideoInfos []GenerateVideoResult `json:"video_infos,omitempty"`
}

// GenerateVideoResult 合成视频信息
type GenerateVideoResult struct {
// OuterID 商品第三方ID
OuterID string `json:"outer_id,omitempty"`
// ProductName 商品名称
ProductName string `json:"product_name,omitempty"`
// VideoURL 视频URL
VideoURL string `json:"video_url,omitempty"`
// Code 失败状态码
Code string `json:"code,omitempty"`
// Message 失败信息
Message string `json:"message,omitempty"`
// PhotoID Photo ID
PhotoID uint64 `json:"photo_id,omitempty"`
// TemplateID 模板ID
TemplateID uint64 `json:"template_id,omitempty"`
// ProductID 商品ID
ProductID uint64 `json:"product_id,omitempty"`
}

// IsError check generated video is failed
func (r GenerateVideoResult) IsError() bool {
return r.Code != ""
}

// Error implements error interface
func (r GenerateVideoResult) Error() string {
return fmt.Sprintf("code:%s, msg:%s", r.Code, r.Message)
}
27 changes: 10 additions & 17 deletions model/dsp/dpa/library_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import "github.com/bububa/kwai-marketing-api/model"

// LibraryListRequest 获取商品库列表 API Request
type LibraryListRequest struct {
// PageInfo 分页信息
PageInfo *model.PageInfo `json:"page_info,omitempty"`
// Name 商品库名称
Name string `json:"name,omitempty"`
// BizID 商品库业务类型 1-主站, 2-联盟, 3-通用
BizID []int `json:"biz_id,omitempty"`
// AdvertiserID 广告主ID
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// LibraryID 商品库ID
LibraryID uint64 `json:"library_id,omitempty"`
// Name 商品库名称
Name string `json:"name,omitempty"`
// Status 商品库状态 1-审核中, 2-使用中, 3-审核失败, 4-暂停使用, 5-XML初始化中, 6-XML初始化失败
Status int `json:"status,omitempty"`
// QueryType 商品库权限类型 1-使用权限, 2-编辑权限(含使用权限)
QueryType int `json:"query_type,omitempty"`
// BizID 商品库业务类型 1-主站, 2-联盟, 3-通用
BizID []int `json:"biz_id,omitempty"`
// PageInfo 分页信息
PageInfo *PageInfoSneak `json:"page_info,omitempty"`
}

// Url implement PostRequest interface
Expand All @@ -33,25 +33,18 @@ func (r LibraryListRequest) Encode() []byte {
// LibraryListResponse 获取商品库列表 API Response
type LibraryListResponse struct {
// PageInfo 列表页参数
PageInfo struct {
// CurrentPage 当前页码, 第一页是1
CurrentPage int `json:"current_page,omitempty"`
// PageSize 分页大小
PageSize int `json:"page_size,omitempty"`
// TotalCount 数据总数
TotalCount int `json:"total_count,omitempty"`
} `json:"page_info,omitempty"`
Data []AdDpaLibraryViewSneak `json:"data,omitempty"`
PageInfo *model.PageInfo `json:"page_info,omitempty"`
Data []AdDpaLibraryViewSneak `json:"data,omitempty"`
}

// AdDpaLibraryViewSneak 商品库信息
type AdDpaLibraryViewSneak struct {
// LibraryID 商品库ID
LibraryID uint64 `json:"library_id,omitempty"`
// Name 商品库名称
Name string `json:"name,omitempty"`
// LibraryDesc 商品库描述
LibraryDesc string `json:"library_desc,omitempty"`
// LibraryID 商品库ID
LibraryID uint64 `json:"library_id,omitempty"`
// Status 商品库状态 1-审核中, 2-使用中, 3-审核失败, 4-暂停使用, 5-XML初始化中, 6-XML初始化失败
Status int `json:"status,omitempty"`
// CreateTime 商品库创建时间 毫秒时间戳
Expand Down
9 changes: 0 additions & 9 deletions model/dsp/dpa/page_info_sneak.go

This file was deleted.

Loading

0 comments on commit 7574a03

Please sign in to comment.