Skip to content

Commit

Permalink
Merge pull request #39 from Michael-LiK/main
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa authored Sep 20, 2023
2 parents 4cb5cc3 + ef93500 commit 22539e8
Show file tree
Hide file tree
Showing 38 changed files with 795 additions and 3 deletions.
15 changes: 15 additions & 0 deletions api/native/photo_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package native

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

func PhotoList(clt *core.SDKClient, accessToken string, req *native.PhotoListRequest) (*native.PhotoListResponse, error) {
var resp native.PhotoListResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
15 changes: 15 additions & 0 deletions api/native/upload.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package native

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

func Upload(clt *core.SDKClient, accessToken string, req *native.UploadRequest) (*native.UploadResponse, error) {
var resp native.UploadResponse
err := clt.Upload(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
15 changes: 15 additions & 0 deletions api/native/user_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package native

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

func UserList(clt *core.SDKClient, accessToken string, req *native.UserListRequest) (*native.UserListResponse, error) {
var resp native.UserListResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
16 changes: 16 additions & 0 deletions api/target_v2/template_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package target_v2

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

// TemplateList 查询定向模板接口
func TemplateDetails(clt *core.SDKClient, accessToken string, req *target_v2.TemplateDetailsRequest) (*target_v2.TemplateDetailsResponse, error) {
var resp target_v2.TemplateDetailsResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
16 changes: 16 additions & 0 deletions api/v2.2/appcenter/app/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package app

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/v2.2/appcenter/app"
)

func List(clt *core.SDKClient, accessToken string, req *app.ListRequest) (*app.ListResponse, error) {
var resp app.ListResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}

15 changes: 15 additions & 0 deletions api/v2.2/appcenter/subpkg/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package subpkg

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/v2.2/appcenter/subpkg"
)

func Create(clt *core.SDKClient, accessToken string, req *subpkg.CreateRequest) (*subpkg.CreateResponse, error) {
var resp subpkg.CreateResponse
err := clt.Post(accessToken, req, &resp.Item)
if err != nil {
return &resp, err
}
return &resp, nil
}
15 changes: 15 additions & 0 deletions api/v2.2/appcenter/subpkg/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package subpkg

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/v2.2/appcenter/subpkg"
)

func List(clt *core.SDKClient, accessToken string, req *subpkg.ListRequest) (*subpkg.ListResponse, error) {
var resp subpkg.ListResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
15 changes: 15 additions & 0 deletions api/v2.2/appcenter/subpkg/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package subpkg

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/v2.2/appcenter/subpkg"
)

func Update(clt *core.SDKClient, accessToken string, req *subpkg.UpdateRequest) (*subpkg.UpdateResponse, error) {
var resp subpkg.UpdateResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return &resp, err
}
return &resp, nil
}
15 changes: 15 additions & 0 deletions api/v2.2/unit/bid_updte.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package unit

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

func BidUpdate(clt *core.SDKClient, accessToken string, req *unit.BidUpdateRequest) ([]uint64, error) {
var resp unit.BidUpdateResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return resp.UnitIds, nil
}
16 changes: 16 additions & 0 deletions api/v2.2/unit/budget_update.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/v2.2/unit"
)

// 更新广告组预算
func BudgetUpdate(clt *core.SDKClient, accessToken string, req *unit.BudgetUpdateRequest) ([]uint64,error) {
var resp unit.BudgetUpdateResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return resp.UnitIds, nil
}
17 changes: 17 additions & 0 deletions api/v2.2/unit/status_update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package unit


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

// Create 创建广告组
func StatusUpdate(clt *core.SDKClient, accessToken string, req *unit.StatusUpdateRequest) ([]uint64, error) {
var resp unit.StatusUpdateResponse
err := clt.Post(accessToken, req, &resp)
if err != nil {
return nil, err
}
return resp.UnitIds, nil
}
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/bububa/kwai-marketing-api

go 1.20
go 1.19


13 changes: 12 additions & 1 deletion model/file/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,16 @@ type Video struct {
// Duration 视频时长; 单位毫秒
Duration int64 `json:"duration,omitempty"`
// Source 视频来源; 0:自上传,1:开眼,2:素造,7:聚星视频
Source int `json:"source,omitempty"`
Source int `json:"source,omitempty"`
AdPhotoValuateInfo AdPhotoValuateInfoItem `json:"adPhotoValuateInfo"`
}
type AdPhotoValuateInfoItem struct {
SimLabel string `json:"simLabel"`
QualityLabel string `json:"qualityLabel"`
QuotaMsg string `json:"quotaMsg"`
IsDupPhoto bool `json:"isDupPhoto"`
IsDelayReview interface{} `json:"isDelayReview"`
OptimizationSuggestions string `json:"optimizationSuggestions"`
RunningScore int `json:"runningScore"`
HitTagCombination int `json:"hitTagCombination"`
}
24 changes: 24 additions & 0 deletions model/native/photo_list_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package native

import "encoding/json"

type PhotoListRequest struct {
AuthorID uint64 `json:"author_id"` // 达人用户id
AdvertiserID uint64 `json:"advertiser_id"` // 广告主ID
PCursor string `json:"pcursor"` // 游标,第一次不传,后续滑动获取时根据结果返回的pcursor填取
Count int `json:"count"` // 每次获取的个数,最大不超过50个
KOLUserType int `json:"kol_user_type"` // 原生达人类型,1普通快手号(备注:需要在“普通快手号原生白名单”中才能返回列表),2服务号原生,3聚星达人原生
CampaignType int `json:"campaign_type"` // 计划类型,原生场景下仅支持部分计划类型,2提升应用安装,5收集销售线索,7提升应用活跃,19小程序推广
TabType int `json:"tab_type"` // 0代表profile页非隐藏视频,1代表profile页隐藏视频
}

// Url implement PostRequest interface
func (r PhotoListRequest) Url() string {
return "gw/dsp/v1/native/photo/list"
}

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

type PhotoListResponse struct {
Photos []*KwaiOrdePhotoViewSnake `json:"photos"` // 视频列表
PCursor string `json:"pcursor"` // 下标,如果后面无更多视频则返回 no_more; 如果后续有更多视频需用此返回填到拉取视频接口的入参上
}

type CdnUrlInfo struct {
Cdn string `json:"cdn"` // cdn信息
Url string `json:"url"` // url信息
}

type KwaiOrdePhotoViewSnake struct {
PhotoID string `json:"photo_id"` // 加密后的photoId
Caption string `json:"caption"` // 视频标题
CoverURL []CdnUrlInfo `json:"cover_url"` // 封面url
MovieURL []CdnUrlInfo `json:"movie_url"` // 视频url
Duration int64 `json:"duration"` // 视频时长,单位毫秒
Height int `json:"height"` // 视频高度
Width int `json:"width"` // 视频宽度
CreativeMaterialType int `json:"creative_material_type"` // 视频横竖版: 1竖版,2横版
AdSocialOrderID int `json:"ad_socail_order_id,omitempty"` // 聚星订单id
}
63 changes: 63 additions & 0 deletions model/native/upload_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package native

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

type UploadRequest struct {
AdvertiserId uint64 `json:"advertiser_id"`
Photo *model.UploadField `json:"photo"` // 视频file
ShieldBackwardSwitch bool `json:"shieldBackwardSwitch"` // 上传视频后是否自动同步至快手个人主页,false表示屏蔽,视频不可在个人主页可见,true表示不屏蔽
AuthorID uint64 `json:"authorId"` // 原生上传至达人的快手号
NativePlcSwitch bool `json:"nativePlcSwitch"`
PhotoCaption string `json:"photoCaption"`
}

// Url implement UploadRequest interface
func (r UploadRequest) Url() string {
return "gw/dsp/v1/photo/upload"
}

// Encode implenent UploadRequest interface
func (r UploadRequest) Encode() []model.UploadField {
fileName := r.Photo.Value
if fileName == "" {
fileName = "file"
}
shieldBackwardSwitch := "false"
if r.ShieldBackwardSwitch {
shieldBackwardSwitch = "true"
}
nativePlcSwitch := "false"
if r.NativePlcSwitch {
nativePlcSwitch = "true"
}
return []model.UploadField{
{
Key: "advertiser_id",
Value: strconv.FormatUint(r.AdvertiserId, 10),
},
{
Key: "authorId",
Value: strconv.FormatUint(r.AuthorID, 10),
},
{
Key: "shieldBackwardSwitch",
Value: shieldBackwardSwitch,
},
{
Key: "photo",
Value: fileName,
Reader: r.Photo.Reader,
},
{
Key: "nativePlcSwitch",
Value: nativePlcSwitch,
},
{
Key: "photoCaption",
Value: r.PhotoCaption,
},
}
}
5 changes: 5 additions & 0 deletions model/native/upload_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package native

type UploadResponse struct {
PhotoID uint64 `json:"photo_id"`
}
19 changes: 19 additions & 0 deletions model/native/user_list_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package native

import "encoding/json"

type UserListRequest struct {
AdvertiserID uint64 `json:"advertiser_id"` // 广告主ID
KOLUserType []int `json:"kol_user_type"` // 达人原生类型,1代表普通快手号(备注:需要在“普通快手号原生白名单”中才能返回列表),2服务号原生达人,3聚星原生达人
}

// Url implement PostRequest interface
func (r UserListRequest) Url() string {
return "gw/dsp/v1/native/user/list"
}

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

type UserListResponse struct {
UserList []*UserProfileViewSnake `json:"user_list"` //用户列表
}

type UserProfileViewSnake struct {
UserID int64 `json:"user_id"` // 用户id
UserName string `json:"user_name"` // 用户名称
UserSex string `json:"user_sex"` // 用户性别,男性M,女性F
HeadURL string `json:"head_url"` // 用户头像
KOLUserType int `json:"kol_user_type"` // 达人用户类型,2服务号达人,3聚星达人
}
39 changes: 39 additions & 0 deletions model/target_v2/behavior_interest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package target_v2

// BehaviorInterest 行为兴趣定向
type BehaviorInterest struct {
// Behavior 行为定向
Behavior *Behavior `json:"behavior,omitempty"`
// Interest 兴趣定向
Interest *Interest `json:"interest,omitempty"`
}

// Behavior 行为定向
type Behavior struct {
// Keyword 行为定向关键词
Keyword []Keyword `json:"keyword,omitempty"`
// Label 行为定向,类目词
Label []string `json:"label,omitempty"`
// TimeType 在多少天内发生行为的用户; 0:7天 1:15天 2:30天 3:90天4:180天
TimeType int `json:"time_type,omitempty"`
// StrengthType 行为强度; 0:不限 1:高强度
StrengthType int `json:"strength_type,omitempty"`
// SceneType 行为场景; 1:社区 2:APP 4:推广
SceneType []int `json:"scene_type,omitempty"`
}

// Interest 兴趣定向
type Interest struct {
// Label 兴趣定向类目词; 根据/rest/openapi/v1/tool/label/behavior_interest接口获取。将兴趣类目id从最高层类目id开始,以“-”连接起来,假如有一个类目id为80202,父类目id为802,最高层类目id为8,则此时应该写"8-802-80202";如果想全选最高层类目"8"底下的所有子类目,填"8"
Label []string `json:"label,omitempty"`
// StrengthType 兴趣标签强度; 0:不限 1:高强度
StrengthType int `json:"strength_type,omitempty"`
}

// Keyword 行为定向关键词
type Keyword struct {
// ID 关键词id
ID uint64 `json:"id,omitempty"`
// Name 关键词名称
Name string `json:"name,omitempty"`
}
Loading

0 comments on commit 22539e8

Please sign in to comment.