Skip to content

Commit

Permalink
feat(qianchuan): 支持获取计划学习期/成本保障状态
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Oct 16, 2023
1 parent d885229 commit b84ccff
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 0 deletions.
2 changes: 2 additions & 0 deletions marketing-api/QIANCHUAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
- 获取非ROI目标建议出价 [ SuggestBid(clt *core.SDKClient, accessToken string, req *ad.SuggestBidRequest) (*ad.SuggestBidResult, error) ]
- 获取建议预算接口 [ SuggestBudget(clt *core.SDKClient, accessToken string, req *ad.SuggestBudgetRequest) (*ad.SuggestBudgetResult, error) ]
- 获取预估效果接口 [ EstimateEffect(clt *core.SDKClient, accessToken string, req *ad.EstimateEffectRequest) (*ad.EstimateEffectResult, error) ]
- 获取计划成本保障状态 [ CompensateStatusGet(clt *core.SDKClient, accessToken string, req *ad.CompensateStatusGetRequest) ([]ad.CompensateStatus, error) ]
- 获取计划学习期状态 [ LearningStatusGet(clt *core.SDKClient, accessToken string, req *ad.LearningStatusGetRequest) ([]ad.LearningStatus, error) ]
- 广告创意管理 (api/qianchuan/creative)
- 批量更新广告创意状态 [ UpdateStatus(clt *core.SDKClient, accessToken string, req *creative.UpdateStatusRequest) (*creative.UpdateResponseData, error) ]
- 获取账户下创意列表 [ Get(clt *core.SDKClient, accessToken string, req *creative.GetRequest) (*creative.GetResponseData, error) ]
Expand Down
16 changes: 16 additions & 0 deletions marketing-api/api/qianchuan/ad/compensate_status_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ad

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/qianchuan/ad"
)

// CompensateStatusGet 获取计划成本保障状态
func CompensateStatusGet(clt *core.SDKClient, accessToken string, req *ad.CompensateStatusGetRequest) ([]ad.CompensateStatus, error) {
var resp ad.CompensateStatusGetResponse
err := clt.Get("v1.0/qianchuan/ad/compensate_status/get/", req, &resp, accessToken)
if err != nil {
return nil, err
}
return resp.Data.List, nil
}
16 changes: 16 additions & 0 deletions marketing-api/api/qianchuan/ad/learning_status_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ad

import (
"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/model/qianchuan/ad"
)

// LearningStatusGet 获取计划学习期状态
func LearningStatusGet(clt *core.SDKClient, accessToken string, req *ad.LearningStatusGetRequest) ([]ad.LearningStatus, error) {
var resp ad.LearningStatusGetResponse
err := clt.Get("v1.0/qianchuan/ad/learning_status/get/", req, &resp, accessToken)
if err != nil {
return nil, err
}
return resp.Data.List, nil
}
29 changes: 29 additions & 0 deletions marketing-api/enum/qianchuan/compensate_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package qianchuan

// CompensateRequestStatus 当前请求是否成功
type CompensateRequestStatus string

const (
// CompensateRequestStatus_SUCCESS 查询成功
CompensateRequestStatus_SUCCESS CompensateRequestStatus = "SUCCESS"
// CompensateRequestStatus_FAILED 查询失败,请重试
CompensateRequestStatus_FAILED CompensateRequestStatus = "FAILED"
)

// CompensateStatus 计划成本保障状态
type CompensateStatus string

const (
// CompensateStatus_IN_EFFECT 成本保障生效中
CompensateStatus_IN_EFFECT CompensateStatus = "IN_EFFECT"
// CompensateStatus_INVALID 成本保障已失效
CompensateStatus_INVALID CompensateStatus = "INVALID"
// CompensateStatus_CONFIRMING 成本保障确认中
CompensateStatus_CONFIRMING CompensateStatus = "CONFIRMING"
// CompensateStatus_PAID 成本保障已到账
CompensateStatus_PAID CompensateStatus = "PAID"
// CompensateStatus_ENDED 成本保障已结束
CompensateStatus_ENDED CompensateStatus = "ENDED"
// CompensateStatus_DEFAULT 无成本保障状态
CompensateStatus_DEFAULT CompensateStatus = "DEFAULT"
)
15 changes: 15 additions & 0 deletions marketing-api/enum/qianchuan/learing_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package qianchuan

// LearningStatus 学习期状态
type LearningStatus string

const (
// LearningStatus_LEARNING 学习期
LearningStatus_LEARNING LearningStatus = "LEARNING"
// LearningStatus_LEARNED 学习期结束
LearningStatus_LEARNED LearningStatus = "LEARNING"
// LearningStatus_LEARN_FAILED 学习期失败
LearningStatus_LEARN_FAILED LearningStatus = "LEARN_FAILED"
// LearningStatus_DEFAULT 无学习期状态
LearningStatus_DEFAULT LearningStatus = "DEFAULT"
)
56 changes: 56 additions & 0 deletions marketing-api/model/qianchuan/ad/compensate_status_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package ad

import (
"strconv"

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

// CompensateStatusGetRequest 获取计划成本保障状态 API Request
type CompensateStatusGetRequest struct {
// AdvertiserID 广告主id
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// AdIDs 计划id列表,每次最多传入50个
AdIDs []uint64 `json:"ad_ids,omitempty"`
}

func (r CompensateStatusGetRequest) Encode() string {
values := util.GetUrlValues()
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
values.Set("ad_ids", string(util.JSONMarshal(r.AdIDs)))
ret := values.Encode()
util.PutUrlValues(values)
return ret
}

// CompensateStatusGetResponse 获取计划成本保障状态 API Response
type CompensateStatusGetResponse struct {
model.BaseResponse
Data struct {
List []CompensateStatus `json:"list,omitempty"`
} `json:"data,omitempty"`
}

// CompensateStatus 计划成本保障状态
type CompensateStatus struct {
// AdID 计划id
AdID uint64 `json:"ad_id,omitempty"`
// Status 当前请求是否成功, 枚举值:
// SUCCESS: 查询成功
// FAILED: 查询失败,请重试
Status qianchuan.CompensateRequestStatus `json:"status,omitempty"`
// CompensateStatus 计划成本保障状态,允许值
// IN_EFFECT: 成本保障生效中
// INVALID: 成本保障已失效
// CONFIRMING: 成本保障确认中
// PAID: 成本保障已到账
// ENDED: 成本保障已结束
// DEFAULT:无成本保障状态
CompensateStatus qianchuan.CompensateStatus `json:"compensate_status,omitempty"`
// Reason 成本保障失效/结束原因
Reason string `json:"reason,omitempty"`
// URL 赔付规则链接
URL string `json:"url,omitempty"`
}
48 changes: 48 additions & 0 deletions marketing-api/model/qianchuan/ad/learning_status_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ad

import (
"strconv"

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

// LearningStatusGetRequest 获取计划学习期状态 API Request
type LearningStatusGetRequest struct {
// AdvertiserID 广告主id
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// AdIDs 计划id列表,每次最多传入50个
AdIDs []uint64 `json:"ad_ids,omitempty"`
}

func (r LearningStatusGetRequest) Encode() string {
values := util.GetUrlValues()
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
values.Set("ad_ids", string(util.JSONMarshal(r.AdIDs)))
ret := values.Encode()
util.PutUrlValues(values)
return ret
}

// LearningStatusGetResponse 获取计划学习期状态 API Response
type LearningStatusGetResponse struct {
model.BaseResponse
Data struct {
// List 计划列表
List []LearningStatus `json:"list,omitempty"`
} `json:"data,omitempty"`
}

// LearingStatus 计划学习期状态
type LearningStatus struct {
// AdID 计划id
AdID uint64 `json:"ad_id,omitempty"`
// Status 学习期状态,允许值:
// LEARNING(学习期)
// LEARNED(学习期结束)
// LEARN_FAILED(学习期失败)
// DEFAULT:无学习期状态
// 具体可以参考此文档的说明:关于学习期
Status qianchuan.LearningStatus `json:"status,omitempty"`
}

0 comments on commit b84ccff

Please sign in to comment.