From 0287e071abd0372f1383c98098b50e3566bdf651 Mon Sep 17 00:00:00 2001 From: Syd Xu Date: Wed, 28 Aug 2024 16:35:59 +0800 Subject: [PATCH] feat(otel): add tracing context --- .github/workflows/go.yml | 47 ++- .github/workflows/goreleaser.yml | 10 +- .goreleaser.yml | 10 +- README.md | 354 +++++++++--------- api/adcompass/advertisers.go | 6 +- api/adcompass/quota_tending.go | 6 +- api/advertiser/budget_get.go | 6 +- api/advertiser/fund_daily_flows.go | 6 +- api/advertiser/fund_get.go | 6 +- api/advertiser/info.go | 6 +- api/advertiser/update_budget.go | 6 +- api/advertiser/white_list.go | 6 +- api/appcenter/app/create_android.go | 6 +- api/appcenter/app/create_ios.go | 6 +- api/appcenter/app/detail.go | 6 +- api/appcenter/app/ios_update.go | 5 +- api/appcenter/app/list.go | 6 +- api/appcenter/app/offline.go | 5 +- api/appcenter/app/offline_appstores.go | 5 +- api/appcenter/app/online.go | 5 +- api/appcenter/app/release.go | 6 +- api/appcenter/app/release_list.go | 6 +- api/appcenter/app/retry_build_sub_package.go | 6 +- api/appcenter/app/update_android.go | 6 +- api/appcenter/app/update_ios.go | 6 +- api/appcenter/subpkg/add.go | 6 +- api/appcenter/subpkg/description.go | 5 +- api/appcenter/subpkg/list.go | 6 +- api/appcenter/subpkg/mod.go | 5 +- api/appcenter/subpkg/release_list.go | 6 +- api/appcenter/upload/apk.go | 6 +- api/appcenter/upload/pic.go | 6 +- api/asset/adv_card_create.go | 6 +- api/asset/adv_card_list.go | 6 +- api/asset/adv_card_remove.go | 6 +- api/campaign/create.go | 6 +- api/campaign/list.go | 6 +- api/campaign/update.go | 6 +- api/campaign/update_budget.go | 6 +- api/campaign/update_status.go | 6 +- api/comment/cancel_top.go | 6 +- api/comment/list.go | 6 +- api/comment/reply.go | 6 +- api/comment/set_top.go | 6 +- api/comment/shield.go | 6 +- api/comment/shield_info_create.go | 6 +- api/comment/shield_info_delete.go | 6 +- api/comment/shield_info_list.go | 6 +- api/comment/tree.go | 6 +- api/creative/action_bar_text_list.go | 6 +- api/creative/advanced_program_create.go | 6 +- api/creative/advanced_program_list.go | 6 +- .../advanced_program_review_detail.go | 6 +- api/creative/advanced_program_update.go | 6 +- api/creative/batch_update.go | 6 +- api/creative/create.go | 6 +- api/creative/create_advanced.go | 6 +- api/creative/creative_tag_advise.go | 6 +- api/creative/list.go | 6 +- api/creative/preview.go | 6 +- api/creative/update.go | 8 +- api/creative/update_status.go | 6 +- api/dmp/population_accounts_push.go | 6 +- api/dmp/population_delete.go | 6 +- api/dmp/population_list.go | 6 +- api/dmp/population_push.go | 6 +- api/dmp/population_update.go | 6 +- api/dmp/population_update_v2.go | 6 +- api/dmp/population_upload.go | 6 +- api/dmp/population_upload_file_v2.go | 6 +- api/dmp/population_upload_v2.go | 6 +- api/dsp/campaign/create.go | 6 +- api/dsp/campaign/list.go | 6 +- api/dsp/campaign/update.go | 6 +- api/dsp/campaign/update_status.go | 6 +- api/dsp/creative/advanced_creative_create.go | 6 +- api/dsp/creative/advanced_creative_list.go | 6 +- api/dsp/creative/advanced_creative_update.go | 6 +- api/dsp/creative/batch_update.go | 6 +- api/dsp/creative/create.go | 6 +- api/dsp/creative/list.go | 6 +- api/dsp/creative/preview.go | 6 +- api/dsp/creative/update.go | 6 +- api/dsp/creative/update_status.go | 6 +- api/dsp/dpa/category_list.go | 6 +- api/dsp/dpa/creative_template_list.go | 6 +- api/dsp/dpa/creative_video_generate.go | 6 +- api/dsp/dpa/library_list.go | 6 +- api/dsp/dpa/product_batch_create.go | 6 +- api/dsp/dpa/product_batch_query.go | 6 +- api/dsp/dpa/product_batch_update.go | 6 +- api/dsp/dpa/product_cursor_query.go | 6 +- api/dsp/dpa/secret_cid_link.go | 6 +- api/dsp/dpa/template_list.go | 6 +- api/dsp/jingbell/share.go | 6 +- api/dsp/native/open_account_native.go | 6 +- api/dsp/target/option_distance_list.go | 6 +- api/dsp/target/template_create.go | 6 +- api/dsp/target/template_delete.go | 6 +- api/dsp/target/template_details.go | 6 +- api/dsp/target/template_related_unit_list.go | 6 +- api/dsp/target/template_sync_history.go | 6 +- api/dsp/target/template_unit_sync.go | 6 +- api/dsp/target/template_update.go | 6 +- api/dsp/target/template_upgrade.go | 6 +- api/dsp/target/template_upgrade_list.go | 6 +- api/dsp/unit/batch_update_monitor_urls.go | 6 +- api/dsp/unit/create.go | 6 +- api/dsp/unit/get_monitor_urls.go | 6 +- api/dsp/unit/list.go | 6 +- api/dsp/unit/update.go | 6 +- api/dsp/unit/update_bid.go | 6 +- api/dsp/unit/update_day_budget.go | 6 +- api/dsp/unit/update_status.go | 6 +- api/dsp/video/query_auto_share_switch.go | 6 +- api/file/ad_app_create.go | 6 +- api/file/ad_app_create_test.go | 10 +- api/file/ad_app_list.go | 6 +- api/file/ad_app_list_test.go | 6 +- api/file/ad_app_update.go | 6 +- api/file/ad_image_get.go | 6 +- api/file/ad_image_list.go | 6 +- api/file/ad_image_upload_v1.go | 6 +- api/file/ad_image_upload_v2.go | 6 +- api/file/ad_video_delete.go | 6 +- api/file/ad_video_get.go | 6 +- api/file/ad_video_list.go | 6 +- api/file/ad_video_relate_creatives.go | 6 +- api/file/ad_video_share.go | 6 +- api/file/ad_video_share_new.go | 6 +- api/file/ad_video_tag_delete.go | 6 +- api/file/ad_video_update.go | 6 +- api/file/ad_video_upload_v1.go | 6 +- api/file/ad_video_upload_v2.go | 6 +- api/file/pic_share.go | 6 +- api/file/upload_atlas_photo.go | 6 +- api/file/video_list_by_cursor.go | 7 +- api/live/list_jingle_bell.go | 6 +- api/live/list_live_user.go | 6 +- api/live/report/live_component_report.go | 6 +- api/live/report/live_user_report.go | 6 +- api/lp/consult_list.go | 6 +- api/native/photo_list.go | 6 +- api/native/upload.go | 6 +- api/native/user_list.go | 6 +- api/oauth/access_token.go | 6 +- api/oauth/approval_list.go | 6 +- api/oauth/refresh_token.go | 6 +- api/oauth/url.go | 3 +- api/page/batch_give.go | 6 +- api/page/cid_info_update.go | 6 +- api/page/list.go | 6 +- api/region/district_list.go | 6 +- api/region/list.go | 6 +- api/report/account_report.go | 6 +- api/report/agent_report.go | 6 +- api/report/asynctask/create.go | 6 +- api/report/asynctask/download.go | 6 +- api/report/asynctask/list.go | 6 +- api/report/audience_report.go | 6 +- api/report/campaign_report.go | 6 +- api/report/creative_report.go | 6 +- api/report/material_report.go | 6 +- api/report/merchant_detail_report.go | 6 +- api/report/program_creative_report.go | 6 +- api/report/query_word_report.go | 6 +- api/report/unit_report.go | 6 +- api/report/word_info_report.go | 7 +- api/search/word_info_list.go | 6 +- api/target/template_create.go | 6 +- api/target/template_delete.go | 6 +- api/target/template_list.go | 6 +- api/target/template_update.go | 6 +- api/target_v2/template_list.go | 6 +- api/tool/app_search.go | 6 +- api/tool/audience_predict.go | 6 +- api/tool/convert_list.go | 6 +- api/tool/creative_word_list.go | 6 +- api/tool/creative_word_styles.go | 6 +- api/tool/key_frame.go | 6 +- api/tool/operation_record_list.go | 6 +- api/tool/preput/predication_task_create.go | 6 +- api/tool/preput/predication_task_details.go | 6 +- api/tool/preput/predication_task_list.go | 6 +- .../preput/predication_task_management.go | 6 +- api/tool/quota_info.go | 6 +- api/tool/targeting_tags_list.go | 6 +- api/tool/unit/bid_predict.go | 6 +- api/tool/unit/bid_trend_predict_detail.go | 6 +- api/tool/unit/suggest_bid_detail.go | 6 +- api/unit/create.go | 6 +- api/unit/create_union.go | 6 +- api/unit/list.go | 6 +- api/unit/ocpc_conversion_infos.go | 6 +- api/unit/update.go | 6 +- api/unit/update_bid.go | 6 +- api/unit/update_day_budget.go | 6 +- api/unit/update_status.go | 6 +- api/unit/update_union.go | 6 +- api/v2.2/campaign/create.go | 6 +- api/v2.2/campaign/list.go | 6 +- api/v2.2/campaign/status_update.go | 7 +- api/v2.2/campaign/update.go | 6 +- api/v2.2/creative/create.go | 6 +- api/v2.2/creative/list.go | 6 +- api/v2.2/creative/list_advanced_creative.go | 6 +- api/v2.2/unit/bid_updte.go | 6 +- api/v2.2/unit/budget_update.go | 6 +- api/v2.2/unit/create.go | 6 +- api/v2.2/unit/list.go | 6 +- api/v2.2/unit/status_update.go | 7 +- api/wordinfo/create.go | 6 +- api/wordinfo/list.go | 6 +- api/wordinfo/update_match_type.go | 6 +- api/wordinfo/update_status.go | 6 +- core/client.go | 134 ++++--- core/otel.go | 102 +++++ go.mod | 13 +- go.sum | 21 ++ model/dsp/unit/target.go | 2 +- 220 files changed, 1261 insertions(+), 699 deletions(-) create mode 100644 core/otel.go create mode 100644 go.sum diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6d20379..e40fb6d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -2,12 +2,11 @@ name: Go on: push: - branches: [ master, main ] + branches: [master, main] pull_request: - branches: [ master, main ] + branches: [master, main] jobs: - build: runs-on: ubuntu-latest env: @@ -17,28 +16,28 @@ jobs: run: working-directory: ${{ env.GOPATH }}/${{ env.package }} steps: - - uses: actions/checkout@v3 - with: - path: ${{ env.GOPATH }}/${{ env.package }} + - uses: actions/checkout@v4 + with: + path: ${{ env.GOPATH }}/${{ env.package }} - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.20' - cache-dependency-path: | - ${{ env.GOPATH }}/${{ env.package }}/go.mod - ${{ env.GOPATH }}/${{ env.package }}/go.sum + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ">=1.21.0" + cache-dependency-path: | + ${{ env.GOPATH }}/${{ env.package }}/go.mod + ${{ env.GOPATH }}/${{ env.package }}/go.sum - - name: Dependencies - run: go mod download + - name: Dependencies + run: go mod download - - name: Build - working-directory: ${{ env.GOPATH }}/${{ env.package }} - run: | - go build -v ./... + - name: Build + working-directory: ${{ env.GOPATH }}/${{ env.package }} + run: | + go build -v ./... - - name: Test - env: - APPKEY: ${{ secrets.APPKEY }} - SECRET: ${{ secrets.APP_SECRET }} - run: go test -v ./... + - name: Test + env: + APPKEY: ${{ secrets.APPKEY }} + SECRET: ${{ secrets.APP_SECRET }} + run: go test -v ./... diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index d810040..61f5bb5 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -3,7 +3,7 @@ name: goreleaser on: push: tags: - - '*' + - "*" jobs: goreleaser: @@ -12,16 +12,16 @@ jobs: cache: ${{ github.workspace }}/go.sum steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: ">=1.21.0" cache-dependency-path: ${{ env.cache }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v6 with: # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser diff --git a/.goreleaser.yml b/.goreleaser.yml index e056f06..b6a9815 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -10,7 +10,7 @@ before: builds: - skip: true archives: - - id: "kwai-marketing-api" + - id: "kwai-marketing-api" name_template: >- {{ .ProjectName }}_ {{- title .Os }}_ @@ -18,12 +18,12 @@ archives: {{- else if eq .Arch "386" }}i386 {{- else }}{{ .Arch }}{{ end }} checksum: - name_template: 'checksums.txt' + name_template: "checksums.txt" snapshot: - name_template: "{{ .Tag }}-next" + version_template: "{{ .Tag }}-next" changelog: sort: asc filters: exclude: - - '^docs:' - - '^test:' + - "^docs:" + - "^test:" diff --git a/README.md b/README.md index 295b12c..d35444f 100644 --- a/README.md +++ b/README.md @@ -9,226 +9,226 @@ [![GitHub release](https://img.shields.io/github/release/bububa/kwai-marketing-api.svg)](https://GitHub.com/bububa/kwai-marketing-api/releases/) - Oauth2 授权 (api/oauth) - - 生成授权链接 [ Url(clt *core.SDKClient, req *oauth.UrlRequest) string ] - - 获取AccessToken [ AccessToken(clt *core.SDKClient, authCode String) (*oauth.AccessTokenResponse, error) ] - - 刷新Token [ RefreshToken(clt *core.SDKClient, refreshToken string) (*oauth.AccessTokenResponse, error)] - - 拉取token下授权广告账户接口 [ ApprovalList(clt \*core.SDKClient, accessToken string, pageNo int, pageSize int) ([]uint64, error) ] + - 生成授权链接 [ Url(ctx context.Context, clt *core.SDKClient, req *oauth.UrlRequest) string ] + - 获取AccessToken [ AccessToken(ctx context.Context, clt *core.SDKClient, authCode String) (*oauth.AccessTokenResponse, error) ] + - 刷新Token [ RefreshToken(ctx context.Context, clt *core.SDKClient, refreshToken string) (*oauth.AccessTokenResponse, error)] + - 拉取token下授权广告账户接口 [ ApprovalList(ctx context.Context, clt \*core.SDKClient, accessToken string, pageNo int, pageSize int) ([]uint64, error) ] - 账号服务 - 广告主 (api/advertiser) - - 获取广告主信息 [ Info(clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.Info, error) ] - - 获取广告账户余额信息 [ FundGet(clt *core.SDKClient, accessToken string, advertiserID int64) (float64, error) ] - - 获取广告主账户流水信息 [ FundDailyFlows(clt *core.SDK, accessToken string, req *advertiser.FundDailyFlowsRequest) (*advertiser.FundDailyFlowsResponse, error) ] + - 获取广告主信息 [ Info(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.Info, error) ] + - 获取广告账户余额信息 [ FundGet(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID int64) (float64, error) ] + - 获取广告主账户流水信息 [ FundDailyFlows(ctx context.Context, clt *core.SDK, accessToken string, req *advertiser.FundDailyFlowsRequest) (*advertiser.FundDailyFlowsResponse, error) ] - 账户罗盘(api/adcompass) - - 获取罗盘绑定广告主列 [ Advertisers(clt \*core.SDKClient, accessToken string, advertiserID uint64) ([]adcompass.Advertiser, error) ] - - 磁力罗盘对外 quota 腾挪接口 [ QuotaTending(clt *core.SDKClient, accessToken string, req *adcompass.QuotaTendingRequest) (string, error) ] + - 获取罗盘绑定广告主列 [ Advertisers(ctx context.Context, clt \*core.SDKClient, accessToken string, advertiserID uint64) ([]adcompass.Advertiser, error) ] + - 磁力罗盘对外 quota 腾挪接口 [ QuotaTending(ctx context.Context, clt *core.SDKClient, accessToken string, req *adcompass.QuotaTendingRequest) (string, error) ] - 广告投放 - 智能创编 (api/dsp) - 广告计划 (api/dsp/campaign) - - 创建广告计划 [ Create(clt *core.SDKClient, accessToken string, req *campaign.CreateRequest) (uint64, error) ] - - 修改广告计划 [ Update(clt *core.SDKClient, accessToken string, req *campaign.UpdateRequest) (uint64, error) ] - - 获取广告计划信息 [ List(clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) ] - - 修改广告计划状态 [ UpdateStatus(clt *core.SDKClient, accessToken string, req *campaign.UpdateStatusRequest) ([]uint64, error) ] + - 创建广告计划 [ Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.CreateRequest) (uint64, error) ] + - 修改广告计划 [ Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.UpdateRequest) (uint64, error) ] + - 获取广告计划信息 [ List(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) ] + - 修改广告计划状态 [ UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.UpdateStatusRequest) ([]uint64, error) ] - 广告组 (api/dsp/unit) - - 创建广告组 [ Create(clt *core.SDKClient, accessToken string, req *unit.CreateRequest) (uint64, error) ] - - 修改广告组 [ Update(clt *core.SDKClient, accessToken string, req *unit.UpdateRequest) (uint64, error) ] - - 查询广告组 [ List(clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) ] - - 修改广告组预算 [ UpdateDayBudget(clt *core.SDKClient, accessToken string, req *unit.UpdateDayBudgetRequest) error ] - - 修改广告组状态 [ UpdateStatus(clt *core.SDKClient, accessToken string, req *unit.UpdateStatusRequest) ([]int64, error) ] - - 修改广告组出价 [ UpdateBid(clt *core.SDKClient, accessToken string, req *unit.UpdateBidRequest) error ] - - 批量获取监测链接接口 [ GetMonitorURLs(clt *core.SDKClient, accessToken string, req *unit.GetMonitorURLsRequest) ([]unit.UnitMonitorURL, error) ] - - 监测链接批量更新接口 [ BatchUpdateMonitorURLs(clt *core.SDKClient, accessToken string, req *unit.BatchUpdateMonitorURLsRequest) ([]unit.UnitMonitorURL, error) ] + - 创建广告组 [ Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.CreateRequest) (uint64, error) ] + - 修改广告组 [ Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateRequest) (uint64, error) ] + - 查询广告组 [ List(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) ] + - 修改广告组预算 [ UpdateDayBudget(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateDayBudgetRequest) error ] + - 修改广告组状态 [ UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateStatusRequest) ([]int64, error) ] + - 修改广告组出价 [ UpdateBid(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateBidRequest) error ] + - 批量获取监测链接接口 [ GetMonitorURLs(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.GetMonitorURLsRequest) ([]unit.UnitMonitorURL, error) ] + - 监测链接批量更新接口 [ BatchUpdateMonitorURLs(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.BatchUpdateMonitorURLsRequest) ([]unit.UnitMonitorURL, error) ] - 广告创意 (api/dsp/creative) - - 创建自定义创意 [ Create(clt *core.SDKClient, accessToken string, req *creative.CreateRequest) (uint64, error) ] - - 创建程序化创意 [ AdvancedCreativeCreate(clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeCreateRequest) (uint64, error) ] - - 修改自定义创意 [ Update(clt *core.SDKClient, accessToken string, req *creative.UpdateRequest) (uint64, error) ] - - 修改程序化创意 [ AdvancedCreativeUpdate(clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeUpdateRequest) (uint64, error) ] - - 批量修改自定义创意 [ BatchUpdate(clt *core.SDKClient, accessToken string, req *creative.BatchUpdateRequest) (*creative.BatchUpdateResponse, error) ] - - 查询自定义创意 [ List(clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) ] - - 查询程序化创意 [ AdvancedCreativeList(clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeListRequest) (*creative.AdvancedCreativeListResponse, error) ] - - 修改创意状态 [ UpdateStatus(clt *core.SDKClient, accessToken string, req *creative.UpdateStatusRequest) ([]uint64, error) ] - - 创意体验 [ Preview(clt *core.SDKClient, accessToken string, req *creative.PreviewRequest) error ] + - 创建自定义创意 [ Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.CreateRequest) (uint64, error) ] + - 创建程序化创意 [ AdvancedCreativeCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeCreateRequest) (uint64, error) ] + - 修改自定义创意 [ Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.UpdateRequest) (uint64, error) ] + - 修改程序化创意 [ AdvancedCreativeUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeUpdateRequest) (uint64, error) ] + - 批量修改自定义创意 [ BatchUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.BatchUpdateRequest) (*creative.BatchUpdateResponse, error) ] + - 查询自定义创意 [ List(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) ] + - 查询程序化创意 [ AdvancedCreativeList(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeListRequest) (*creative.AdvancedCreativeListResponse, error) ] + - 修改创意状态 [ UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.UpdateStatusRequest) ([]uint64, error) ] + - 创意体验 [ Preview(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.PreviewRequest) error ] - 获取各层级信息 - - 获取广告计划信息 [ campaign.List(clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) ] - - 获取广告组信息 [ unit.List(clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) ] - - 获取广告创意信息 [ creative.List(clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) ] - - 获取程序化创意2.0信息 [ creative.AdvancedProgramList(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramListRequest) (*creative.AdvancedProgramListResponse, error) ] - - 获取程序化创意2.0审核信息 [ creative.AdvancedProgramReviewDetail(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramReviewDetailRequest) (*creative.AdvancedProgramReviewDetail, error) ] - - 账户操作记录信息查询 [ tool.OperationRecordList(clt *core.SDKClient, accessToken string, req *tool.OperationRecordListRequest) (*tool.OperationRecordListResponse, error) ] - - 定向人群预估查询 [ tool.AudiencePredict(clt *core.SDKClient, accessToken string, req *tool.AudiencePredictRequest) (int64, error) ] + - 获取广告计划信息 [ campaign.List(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) ] + - 获取广告组信息 [ unit.List(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) ] + - 获取广告创意信息 [ creative.List(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) ] + - 获取程序化创意2.0信息 [ creative.AdvancedProgramList(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramListRequest) (*creative.AdvancedProgramListResponse, error) ] + - 获取程序化创意2.0审核信息 [ creative.AdvancedProgramReviewDetail(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramReviewDetailRequest) (*creative.AdvancedProgramReviewDetail, error) ] + - 账户操作记录信息查询 [ tool.OperationRecordList(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.OperationRecordListRequest) (*tool.OperationRecordListResponse, error) ] + - 定向人群预估查询 [ tool.AudiencePredict(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.AudiencePredictRequest) (int64, error) ] - 账户层级 - - 账户日预算查询 [ advertiser.BudgetGet(clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.Budget, error) ] - - 修改账户预算 [ advertiser.UpdateBudget(clt *core.SDKClient, accessToken string, req *advertiser.UpdateBudgetRequest) error ] + - 账户日预算查询 [ advertiser.BudgetGet(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.Budget, error) ] + - 修改账户预算 [ advertiser.UpdateBudget(ctx context.Context, clt *core.SDKClient, accessToken string, req *advertiser.UpdateBudgetRequest) error ] - 广告计划(api/campaign) - - 创建广告计划 [ Create(clt *core.SDKClient, accessToken string, req *campaign.CreateRequest) (int64, error) ] - - 修改广告计划 [ Update(clt *core.SDKClient, accessToken string, req *campaign.UpdateRequest) (int64, error) ] - - 修改广告计划预算 [ UpdateBudget(clt *core.SDKClient, accessToken string, req *campaign.UpdateBudgetRequest) error ] - - 修改广告计划状态 [ UpdateStatus(clt *core.SDKClient, accessToken string, req *campaign.UpdateStatusRequest) ([]int64, error) ] + - 创建广告计划 [ Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.CreateRequest) (int64, error) ] + - 修改广告计划 [ Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.UpdateRequest) (int64, error) ] + - 修改广告计划预算 [ UpdateBudget(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.UpdateBudgetRequest) error ] + - 修改广告计划状态 [ UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.UpdateStatusRequest) ([]int64, error) ] - 广告组(api/unit) - - 创建广告组 [ Create(clt *core.SDKClient, accessToken string, req *unit.CreateRequest) (int64, error) ] - - 创建创建联盟定投广告组 [ CreateUnion(clt *core.SDKClient, accessToken string, req *unit.CreateUnionRequest) (int64, error) ] - - 修改广告组 [ Update(clt *core.SDKClient, accessToken string, req *unit.UpdateRequest) (int64, error) ] - - 修改联盟定投广告组 [ UpdateUnion(clt *core.SDKClient, accessToken string, req *unit.UpdateUnionRequest) (int64, error) ] - - 修改广告组预算 [ UpdateDayBudget(clt *core.SDKClient, accessToken string, req *unit.UpdateDayBudgetRequest) error ] - - 修改广告组状态 [ UpdateStatus(clt *core.SDKClient, accessToken string, req *unit.UpdateStatusRequest) ([]int64, error) ] - - 修改广告组出价 [ UpdateBid(clt *core.SDKClient, accessToken string, req *unit.UpdateBidRequest) error ] + - 创建广告组 [ Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.CreateRequest) (int64, error) ] + - 创建创建联盟定投广告组 [ CreateUnion(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.CreateUnionRequest) (int64, error) ] + - 修改广告组 [ Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateRequest) (int64, error) ] + - 修改联盟定投广告组 [ UpdateUnion(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateUnionRequest) (int64, error) ] + - 修改广告组预算 [ UpdateDayBudget(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateDayBudgetRequest) error ] + - 修改广告组状态 [ UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateStatusRequest) ([]int64, error) ] + - 修改广告组出价 [ UpdateBid(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateBidRequest) error ] - 广告创意(api/creative) - - 创建创意 [ Create(clt *core.SDKClient, accessToken string, req *creative.CreateRequest) (int64, error) ] - - 创建程序化2.0创意 [ AdvancedProgramCreate(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramCreateRequest) (int64, error) ] - - 批量创建&修改创意 [ BatchUpdate(clt *core.SDKClient, accessToken string, req *creative.BatchUpdateRequest) (*creative.BatchUpdateResponse, error) ] - - 修改创意 [ Update(clt *core.SDKClient, accessToken string, req *creative.UpdateRequest) (int64, error) ] - - 修改程序化2.0创意 [ AdvancedProgramUpdate(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramUpdateRequest) error ] - - 修改创意状态 [ UpdateStatus(clt *core.SDKClient, accessToken string, req *creative.UpdateStatusRequest) ([]int64, error) ] - - 创意体验 [ Preview(clt *core.SDKClient, accessToken string, req *creative.PreviewRequest) error ] - - 创意标签填写建议 [ CreativeTagAdvise(clt *core.SDKClient, accessToken string, req *creative.CreativeTagAdviseRequest) (*creative.CreativeTagAdviseResponse, error) ] + - 创建创意 [ Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.CreateRequest) (int64, error) ] + - 创建程序化2.0创意 [ AdvancedProgramCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramCreateRequest) (int64, error) ] + - 批量创建&修改创意 [ BatchUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.BatchUpdateRequest) (*creative.BatchUpdateResponse, error) ] + - 修改创意 [ Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.UpdateRequest) (int64, error) ] + - 修改程序化2.0创意 [ AdvancedProgramUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramUpdateRequest) error ] + - 修改创意状态 [ UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.UpdateStatusRequest) ([]int64, error) ] + - 创意体验 [ Preview(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.PreviewRequest) error ] + - 创意标签填写建议 [ CreativeTagAdvise(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.CreativeTagAdviseRequest) (*creative.CreativeTagAdviseResponse, error) ] - 高级创意(api/asset) - - 获取高级创意列表 [ AdvCardList(clt *core.SDKClient, accessToken string, req *asset.AdvCardListRequest) (*asset.AdvCardListResponse, error) ] - - 创建高级创意接口 [ AdvCardCreate(clt *core.SDKClient, accessToken string, req *asset.AdvCardCreateRequest) ([]int64, error) ] - - 删除高级创意接口 [ AdvCardRemove(clt *core.SDKClient, accessToken string, req *asset.AdvCardRemoveRequest) ([]int64, error) ] + - 获取高级创意列表 [ AdvCardList(ctx context.Context, clt *core.SDKClient, accessToken string, req *asset.AdvCardListRequest) (*asset.AdvCardListResponse, error) ] + - 创建高级创意接口 [ AdvCardCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *asset.AdvCardCreateRequest) ([]int64, error) ] + - 删除高级创意接口 [ AdvCardRemove(ctx context.Context, clt *core.SDKClient, accessToken string, req *asset.AdvCardRemoveRequest) ([]int64, error) ] - 搜索广告工具 - 关键词管理 (api/wordinfo) - - 获取关键词列表 [ List(clt *core.SDKClient, accessToken string, req *wordinfo.ListRequest) (*wordinfo.ListResponse, error) ] - - 创建关键词 [ Create(clt *core.SDKClient, accessToken string, req *wordinfo.CreateRequest) (*wordinfo.CreateResponse, error) ] - - 修改关键词匹配方式 [ UpdateMatchType(clt *core.SDKClient, accessToken string, req *wordinfo.UpdateMatchTypeRequest) ([]uint64, error) ] - - 修改关键词投放状态 [ UpdateStatus(clt *core.SDKClient, accessToken string, req *wordinfo.UpdateStatusRequest) ([]uint64, error) ] + - 获取关键词列表 [ List(ctx context.Context, clt *core.SDKClient, accessToken string, req *wordinfo.ListRequest) (*wordinfo.ListResponse, error) ] + - 创建关键词 [ Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *wordinfo.CreateRequest) (*wordinfo.CreateResponse, error) ] + - 修改关键词匹配方式 [ UpdateMatchType(ctx context.Context, clt *core.SDKClient, accessToken string, req *wordinfo.UpdateMatchTypeRequest) ([]uint64, error) ] + - 修改关键词投放状态 [ UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *wordinfo.UpdateStatusRequest) ([]uint64, error) ] - 数据报表 - 广告数据报表 (api/report) - - 代理商数据 [ AgentReport(clt *core.SDKClient, accessToken string, req *report.AgentReportRequest) (*report.AgentReportResponse, error) ] - - 广告主数据 [ AccountReport(clt *core.SDKClient, accessToken string, req *report.AccountReportRequest) (*report.ReportResponse, error) ] - - 广告计划数据 [ CampaignReport(clt *core.SDKClient, accessToken string, req *report.CampaignReportRequest) (*report.ReportResponse, error) ] - - 广告单元数据 [ UnitReport(clt *core.SDKClient, accessToken string, req *report.UnitReportRequest) (*report.ReportResponse, error) ] - - 广告创意数据 [ CreativeReport(clt *core.SDKClient, accessToken string, req *report.CreativeReportRequest) (*report.ReportResponse, error) ] - - 程序化创意数据 [ ProgramCreativeReport(clt *core.SDKClient, accessToken string, req *report.ProgramCreativeReportRequest) (*report.ReportResponse, error) ] - - 广告素材数据 [ CreativeReport(clt *core.SDKClient, accessToken string, req *report.MaterialReportRequest) (*report.ReportResponse, error) ] - - 人群分析数据 [ AudienceReport(clt *core.SDKClient, accessToken string, req *report.AudienceReportRequest) (*report.ReportResponse, error) ] - - 小店通转化数据 [ MerchantDeatailReport(clt *core.SDKClient, accessToken string, req *report.MerchantDetailReportRequest) (*report.MerchantDetailReportResponse, error) ] - - 关键词报表 [ WordInfoReport(clt *core.SDKClient, accessToken string, req *report.WordInfoReportRequest) (*report.ReportResponse, error) ] - - 搜索词报表 [ QueryWordReport(clt *core.SDKClient, accessToken string, req *report.QueryWordReportRequest) (*report.ReportResponse, error) ] + - 代理商数据 [ AgentReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.AgentReportRequest) (*report.AgentReportResponse, error) ] + - 广告主数据 [ AccountReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.AccountReportRequest) (*report.ReportResponse, error) ] + - 广告计划数据 [ CampaignReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.CampaignReportRequest) (*report.ReportResponse, error) ] + - 广告单元数据 [ UnitReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.UnitReportRequest) (*report.ReportResponse, error) ] + - 广告创意数据 [ CreativeReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.CreativeReportRequest) (*report.ReportResponse, error) ] + - 程序化创意数据 [ ProgramCreativeReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.ProgramCreativeReportRequest) (*report.ReportResponse, error) ] + - 广告素材数据 [ CreativeReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.MaterialReportRequest) (*report.ReportResponse, error) ] + - 人群分析数据 [ AudienceReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.AudienceReportRequest) (*report.ReportResponse, error) ] + - 小店通转化数据 [ MerchantDeatailReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.MerchantDetailReportRequest) (*report.MerchantDetailReportResponse, error) ] + - 关键词报表 [ WordInfoReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.WordInfoReportRequest) (*report.ReportResponse, error) ] + - 搜索词报表 [ QueryWordReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.QueryWordReportRequest) (*report.ReportResponse, error) ] - 素材管理(api/file) - 图片素材 - - 上传图片v1接口 [ AdImageUploadV1(clt *core.SDKClient, accessToken string, req *file.AdImageUploadRequestV1) (*file.Image, error) ] - - 上传图片v2接口 [ AdImageUploadV2(clt *core.SDKClient, accessToken string, req *file.AdImageUploadRequestV2) (*file.Image, error) ] - - 查询图片信息get接口 [ AdImageGet(clt *core.SDKClient, accessToken string, req *file.AdImageGetRequest) (*file.Image, error) ] - - 查询图片信息list接口 [ AdImageList(clt *core.SDKClient, accessToken string, req *file.AdImageListRequest) (*file.AdImageListResponse, error) ] + - 上传图片v1接口 [ AdImageUploadV1(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdImageUploadRequestV1) (*file.Image, error) ] + - 上传图片v2接口 [ AdImageUploadV2(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdImageUploadRequestV2) (*file.Image, error) ] + - 查询图片信息get接口 [ AdImageGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdImageGetRequest) (*file.Image, error) ] + - 查询图片信息list接口 [ AdImageList(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdImageListRequest) (*file.AdImageListResponse, error) ] - 视频素材 - - 上传视频接口v1 [ AdVideoUploadV1(clt *core.SDKClient, accessToken string, req *file.AdVideoUploadRequestV1) (string, error) ] - - 上传视频接口v2 [ AdVideoUploadV2(clt *core.SDKClient, accessToken string, req *file.AdVideoUploadRequestV2) (*file.Video, error) ] - - 获取视频信息get接口 [ AdVideoGet(clt *core.SDKClient, accessToken string, req *file.AdVideoGetRequest) ([]file.Video, error) ] - - 查询视频信息list接口 [ AdVideoList(clt *core.SDKClient, accessToken string, req *file.AdVideoListRequest) (*file.AdVideoListResponse, error) ] + - 上传视频接口v1 [ AdVideoUploadV1(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoUploadRequestV1) (string, error) ] + - 上传视频接口v2 [ AdVideoUploadV2(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoUploadRequestV2) (*file.Video, error) ] + - 获取视频信息get接口 [ AdVideoGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoGetRequest) ([]file.Video, error) ] + - 查询视频信息list接口 [ AdVideoList(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoListRequest) (*file.AdVideoListResponse, error) ] - 视频库 - - 视频库-推送视频 [ AdVideoShare(clt *core.SDKClient, accessToken string, req *file.AdVideoShareRequest) ([]file.AdVideoShareDetail, error) ] - - 视频库-批量更新视频功能 [ AdVideoUpdate(clt *core.SDKClient, accessToken string, req *file.AdVideoUpdateRequest) error ] - - 视频库-删除视频标签 [ AdVideoTagDelete(clt *core.SDKClient, accessToken string, req *file.AdVideoTagDeleteRequest) error ] - - 视频关联创意数查询 [ AdVideoRelateCreatives(clt *core.SDKClient, accessToken string, req *file.AdVideoRelateCreativesRequest) ([]file.AdVideoRelatedCreatives, error) ] - - 查询账户共享视频库按钮是否开启 [ dsp.video.QueryAutoShareSwitch(clt *core.SDKClient, accessToken string, req *video.QueryAutoShareSwitchRequest) (*video.QueryAutoShareSwitchResponse, error) ] + - 视频库-推送视频 [ AdVideoShare(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoShareRequest) ([]file.AdVideoShareDetail, error) ] + - 视频库-批量更新视频功能 [ AdVideoUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoUpdateRequest) error ] + - 视频库-删除视频标签 [ AdVideoTagDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoTagDeleteRequest) error ] + - 视频关联创意数查询 [ AdVideoRelateCreatives(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoRelateCreativesRequest) ([]file.AdVideoRelatedCreatives, error) ] + - 查询账户共享视频库按钮是否开启 [ dsp.video.QueryAutoShareSwitch(ctx context.Context, clt *core.SDKClient, accessToken string, req *video.QueryAutoShareSwitchRequest) (*video.QueryAutoShareSwitchResponse, error) ] - 建站管理(api/page) - - 获取魔力建站落地页组信息列表 [ List(clt *core.SDKClient, accessToken string, req *page.ListRequest) (*page.ListResponse, error) ] - - 批量转赠 [ BatchGive(clt *core.SDKClient, accessToken string, req *page.BatchGiveRequest) error ] - - 魔力建站落地页更新CID信息 [ CidInfoUpdate(clt *core.SDKClient, accessToken string, req *page.CidInfoUpdateRequest) (uint64, error) ] + - 获取魔力建站落地页组信息列表 [ List(ctx context.Context, clt *core.SDKClient, accessToken string, req *page.ListRequest) (*page.ListResponse, error) ] + - 批量转赠 [ BatchGive(ctx context.Context, clt *core.SDKClient, accessToken string, req *page.BatchGiveRequest) error ] + - 魔力建站落地页更新CID信息 [ CidInfoUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *page.CidInfoUpdateRequest) (uint64, error) ] - 工具 - 查询工具 - - 获取可选的深度转化目标 [ unit.OcpcConversionInfos(clt *core.SDKClient, accessToken string, req *unit.OcpcConversionInfosRequest) (*unit.OcpcConversionInfosResponse, error) ] - - 获取可选的定向标签 [ tool.TargetingTagsList(clt *core.SDKClient, accessToken string, req *tool.TargetingTagsListRequest) (*tool.TargetingTag, error) ] - - 获取可选的应用定向 [ tool.AppSearch(clt *core.SDKClient, accessToken string, req *tool.AppSearchRequest) (*tool.TargetingApp, error) ] - - 获取可选的推荐封面 [ tool.KeyFrame(clt *core.SDKClient, accessToken string, req *tool.KeyFrameRequest) ([]string, error) ] - - 获取可选的动态词包 [ tool.CreativeWordList(clt \*core.SDKClient, accessToken string, advertiserID int64) ([]tool.CreativeWord, error) ] - - 获取行动号召按钮 [ creative.ActionBarTextList(clt *core.SDKClient, accessToken string, req *creative.ActionBarTextListRequest) ([]string, error) ] - - 获取可选的封面贴纸样式 [ tool.CreativeWordStyles(clt \*core.SDKClient, accessToken string, advertiserID int64) ([]tool.CreativeWordStyle, error) ] - - 获取可用的转化目标 [ tool.ConvertList(clt *core.SDKClient, accessToken string, req *tool.ConvertListRequest) (*tool.ConvertListResponse, error) ] - - 获取可选白名单接口 [ advertiser.WhiteList(clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.WhiteListResponse, error) ] - - 获取地域定向 [ region.List(clt \*core.SDKClient, accessToken string) (map[string]region.Region, error) ] - - 获取商圈地域定向 [ region.DistrictList(clt \*core.SDKClient, accessToken string, advertiserID int64) (map[string]region.District, error) ] - - 获取可用咨询组件列表 [ lp.ConsultList(clt *core.SDKClient, accessToken string, req *lp.ConsultListRequest) (*lp.ConsultListResponse, error) ] + - 获取可选的深度转化目标 [ unit.OcpcConversionInfos(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.OcpcConversionInfosRequest) (*unit.OcpcConversionInfosResponse, error) ] + - 获取可选的定向标签 [ tool.TargetingTagsList(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.TargetingTagsListRequest) (*tool.TargetingTag, error) ] + - 获取可选的应用定向 [ tool.AppSearch(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.AppSearchRequest) (*tool.TargetingApp, error) ] + - 获取可选的推荐封面 [ tool.KeyFrame(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.KeyFrameRequest) ([]string, error) ] + - 获取可选的动态词包 [ tool.CreativeWordList(ctx context.Context, clt \*core.SDKClient, accessToken string, advertiserID int64) ([]tool.CreativeWord, error) ] + - 获取行动号召按钮 [ creative.ActionBarTextList(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.ActionBarTextListRequest) ([]string, error) ] + - 获取可选的封面贴纸样式 [ tool.CreativeWordStyles(ctx context.Context, clt \*core.SDKClient, accessToken string, advertiserID int64) ([]tool.CreativeWordStyle, error) ] + - 获取可用的转化目标 [ tool.ConvertList(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.ConvertListRequest) (*tool.ConvertListResponse, error) ] + - 获取可选白名单接口 [ advertiser.WhiteList(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.WhiteListResponse, error) ] + - 获取地域定向 [ region.List(ctx context.Context, clt \*core.SDKClient, accessToken string) (map[string]region.Region, error) ] + - 获取商圈地域定向 [ region.DistrictList(ctx context.Context, clt \*core.SDKClient, accessToken string, advertiserID int64) (map[string]region.District, error) ] + - 获取可用咨询组件列表 [ lp.ConsultList(ctx context.Context, clt *core.SDKClient, accessToken string, req *lp.ConsultListRequest) (*lp.ConsultListResponse, error) ] - 出价建议 - - 获取广告组出价建议 [ tool.unit.SuggestBidDetail(clt *core.SDKClient, accessToken string, req *unit.SuggestBidDetailRequest) ([]unit.SuggestBidUnit, error) ] - - 获取广告组曝光、转化预估 [ tool.unit.BidPredict(clt *core.SDKClient, accessToken string, req *unit.BidPredictRequest) (*unit.BidPredict, error) ] - - 获取广告组投放预估曲线 [ tool.unit.BidTrendPredictDetail(clt *core.SDKClient, accessToken string, req *unit.BidTrendPredictDetailRequest) (*unit.BidTrendPredict, error) ] + - 获取广告组出价建议 [ tool.unit.SuggestBidDetail(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.SuggestBidDetailRequest) ([]unit.SuggestBidUnit, error) ] + - 获取广告组曝光、转化预估 [ tool.unit.BidPredict(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.BidPredictRequest) (*unit.BidPredict, error) ] + - 获取广告组投放预估曲线 [ tool.unit.BidTrendPredictDetail(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.BidTrendPredictDetailRequest) (*unit.BidTrendPredict, error) ] - 投前预估 - - 投前预估列表页接口 [ tools.preunit.PredicationTaskList(clt *core.SDKClient, accessToken string, req *preput.PredicationTaskListRequest) (*preput.PredicationTaskListResponse, error) ] - - 投前预估详情 [ tools.preput.PredicationTaskDetails(clt *core.SDKClient, accessToken string, req *preput.PredicationTaskCreateRequest) (*preput.AdPredicationTaskDetail, error) ] - - 投前预估任务管理接口 [ tool.preput.PredicationTaskManagement(clt *core.SDKClient, accessToken string, req *preput.PredicationTaskManagementRequest) (*preput.RealTaskResult, error) ] - - 创建投前预估任务 [ tool.preput.PredicationTaskCreate(clt *core.SDKClient, accessToken string, req *preput.PredicationTaskCreateRequest) (*preput.RealTaskResult, error) ] + - 投前预估列表页接口 [ tools.preunit.PredicationTaskList(ctx context.Context, clt *core.SDKClient, accessToken string, req *preput.PredicationTaskListRequest) (*preput.PredicationTaskListResponse, error) ] + - 投前预估详情 [ tools.preput.PredicationTaskDetails(ctx context.Context, clt *core.SDKClient, accessToken string, req *preput.PredicationTaskCreateRequest) (*preput.AdPredicationTaskDetail, error) ] + - 投前预估任务管理接口 [ tool.preput.PredicationTaskManagement(ctx context.Context, clt *core.SDKClient, accessToken string, req *preput.PredicationTaskManagementRequest) (*preput.RealTaskResult, error) ] + - 创建投前预估任务 [ tool.preput.PredicationTaskCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *preput.PredicationTaskCreateRequest) (*preput.RealTaskResult, error) ] - 功能名单 - - 获取创意分类标签白名单客户 [ advertiser.WhiteList(clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.WhiteListResponse, error) ] - - 获取联盟投放白名单 [ advertiser.WhiteList(clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.WhiteListResponse, error) ] + - 获取创意分类标签白名单客户 [ advertiser.WhiteList(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.WhiteListResponse, error) ] + - 获取联盟投放白名单 [ advertiser.WhiteList(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.WhiteListResponse, error) ] - 应用列表 - - 创建应用 [ file.AdAppCreate(clt *core.SDKClient, accessToken string, req *file.AdAppCreateRequest) (*file.App, error) ] - - 修改应用 [ file.AdAppUpdate(clt *core.SDKClient, accessToken string, req *file.AdAppUpdateRequest) (*file.App, error) ] - - 获取应用列表 [ file.AdAppList(clt *core.SDKClient, accessToken string, req *file.AdAppListRequest) (*file.AdAppListResponse, error) ] + - 创建应用 [ file.AdAppCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdAppCreateRequest) (*file.App, error) ] + - 修改应用 [ file.AdAppUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdAppUpdateRequest) (*file.App, error) ] + - 获取应用列表 [ file.AdAppList(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdAppListRequest) (*file.AdAppListResponse, error) ] - 定向模版(新) (api/dsp/target) - - 查询定向模板 [ TemplateDetails(clt *core.SDKClient, accessToken string, req *target.TemplateDetailsRequest) (*target.TemplateDetailsResponse, error) ] - - 创建定向模板 [ TemplateCreate(clt *core.SDKClient, accessToken string, req *target.TemplateCreateRequest) (uint64, error) ] - - 更新定向模板 [ TemplateUpdate(clt *core.SDKClient, accessToken string, req *target.TemplateUpdateRequest) (uint64, error) ] - - 删除定向模板 [ TemplateDelete(clt *core.SDKClient, accessToken string, req *target.TemplateDeleteRequest) (uint64, error) ] - - 根据店铺名称查询商圈信息 [ OptionDistanceList(clt *core.SDKClient, accessToken string, req *target.OptionDistanceListRequest) (*target.OptionDistanceListResponse, error) ] - - 定向模板同步 [ TemplateUnitSync(clt *core.SDKClient, accessToken string, req *target.TemplateUnitSyncRequest) (*target.TemplateUnitSyncResponse, error) ] - - 模板同步失败查询 [ TemplateSyncHistory(clt *core.SDKClient, accessToken string, req *target.TemplateSyncHistoryRequest) (*target.TemplateSyncHistoryResponse, error) ] - - 查询模板关联的广告列表接口 [ TemplateRelatedUnitList(clt *core.SDKClient, accessToken string, req *target.TemplateRelatedUnitListRequest) (*target.TemplateRelatedUnitListResponse, error) ] - - 查询待升级模板列表 [ TemplateUpgradeList(clt *core.SDKClient, accessToken string, req *target.TemplateUpgradeListRequest) ([]target.TemplateUpgradeItem, error) ] - - 模板升级 [ TemplateUpgrade(clt *core.SDKClient, accessToken string, req *target.TemplateUpgradeRequest) (int64, error) ] + - 查询定向模板 [ TemplateDetails(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateDetailsRequest) (*target.TemplateDetailsResponse, error) ] + - 创建定向模板 [ TemplateCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateCreateRequest) (uint64, error) ] + - 更新定向模板 [ TemplateUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateUpdateRequest) (uint64, error) ] + - 删除定向模板 [ TemplateDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateDeleteRequest) (uint64, error) ] + - 根据店铺名称查询商圈信息 [ OptionDistanceList(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.OptionDistanceListRequest) (*target.OptionDistanceListResponse, error) ] + - 定向模板同步 [ TemplateUnitSync(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateUnitSyncRequest) (*target.TemplateUnitSyncResponse, error) ] + - 模板同步失败查询 [ TemplateSyncHistory(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateSyncHistoryRequest) (*target.TemplateSyncHistoryResponse, error) ] + - 查询模板关联的广告列表接口 [ TemplateRelatedUnitList(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateRelatedUnitListRequest) (*target.TemplateRelatedUnitListResponse, error) ] + - 查询待升级模板列表 [ TemplateUpgradeList(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateUpgradeListRequest) ([]target.TemplateUpgradeItem, error) ] + - 模板升级 [ TemplateUpgrade(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateUpgradeRequest) (int64, error) ] - 定向模版 - - 创建定向模板 [ target.TemplateCreate(clt *core.SDKClient, accessToken string, req *target.TemplateCreateRequest) (*target.Template, error) ] - - 查询定向模板接口 [ target.TemplateList(clt *core.SDKClient, accessToken string, req *target.TemplateListRequest) (*target.TemplateListResponse, error) ] - - 修改定向模板 [ target.TemplateUpdate(clt *core.SDKClient, accessToken string, req *target.TemplateUpdateRequest) (*target.Template, error) ] - - 删除定向模板 [ target.TemplateDelete(clt *core.SDKClient, accessToken string, req *target.TemplateDeleteRequest) error ] + - 创建定向模板 [ target.TemplateCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateCreateRequest) (*target.Template, error) ] + - 查询定向模板接口 [ target.TemplateList(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateListRequest) (*target.TemplateListResponse, error) ] + - 修改定向模板 [ target.TemplateUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateUpdateRequest) (*target.Template, error) ] + - 删除定向模板 [ target.TemplateDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateDeleteRequest) error ] - 直播推广 (api/dsp/jingbell) - - 小铃铛推送 [ jingbel.Share(clt *core.SDKClient, accessToken string, req *jingbell.ShareRequest) error ] + - 小铃铛推送 [ jingbel.Share(ctx context.Context, clt *core.SDKClient, accessToken string, req *jingbell.ShareRequest) error ] - 原生广告投放工具 (api/dsp/native) - - 开启原生扩量开关接口 [ OpenAccountNative(clt *core.SDKClient, accessToken string, req *native.OpenAccountNativeRequest) error ] + - 开启原生扩量开关接口 [ OpenAccountNative(ctx context.Context, clt *core.SDKClient, accessToken string, req *native.OpenAccountNativeRequest) error ] - 评论管理 (api/comment) - - 评论列表数据查询 [ List(clt *core.SDKClient, accessToken string, req *comment.ListRequest) (*comment.ListResponse, error) ] - - 回复评论 [ Reply(clt *core.SDKClient, accessToken string, req *comment.ReplyRequest) ([]comment.ReplyResult, error) ] - - 评论树查询 [ Tree(clt *core.SDKClient, accessToken string, req *comment.TreeRequest) (*comment.TreeResponse, error) ] - - 屏蔽评论 [ Shield(clt *core.SDKClient, accessToken string, req *comment.ShieldRequest) error ] - - 增加屏蔽评论信息 [ ShieldInfoCreate(clt *core.SDKClient, accessToken string, req *comment.ShieldInfoCreateRequest) ([]uint64, error) ] - - 删除屏蔽评论信息 [ ShieldInfoDelete(clt *core.SDKClient, accessToken string, req *comment.ShieldInfoDeleteRequest) error ] - - 获取屏蔽评论信息列表 [ ShieldInfoList(clt *core.SDKClient, accessToken string, req *comment.ShieldInfoListRequest) (*comment.ShieldInfoListResponse, error) ] - - 评论置顶 [ SetTop(clt *core.SDKClient, accessToken string, req *comment.SetTopRequest) (uint64, error) ] - - 取消评论置顶 [ CancelTop(clt *core.SDKClient, accessToken string, req *comment.CancelTopRequest) (uint64, error) ] + - 评论列表数据查询 [ List(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ListRequest) (*comment.ListResponse, error) ] + - 回复评论 [ Reply(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ReplyRequest) ([]comment.ReplyResult, error) ] + - 评论树查询 [ Tree(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.TreeRequest) (*comment.TreeResponse, error) ] + - 屏蔽评论 [ Shield(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ShieldRequest) error ] + - 增加屏蔽评论信息 [ ShieldInfoCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ShieldInfoCreateRequest) ([]uint64, error) ] + - 删除屏蔽评论信息 [ ShieldInfoDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ShieldInfoDeleteRequest) error ] + - 获取屏蔽评论信息列表 [ ShieldInfoList(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ShieldInfoListRequest) (*comment.ShieldInfoListResponse, error) ] + - 评论置顶 [ SetTop(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.SetTopRequest) (uint64, error) ] + - 取消评论置顶 [ CancelTop(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.CancelTopRequest) (uint64, error) ] - DMP人群管理(api/dmp) - - 人群包上传接口 [ PopulationUpload(clt *core.SDKClient, accessToken string, req *dmp.PopulationUploadRequest) (*dmp.Population, error) ] - - 人群包更新接口 [ PopulationUpdate(clt *core.SDKClient, accessToken string, req *dmp.PopulationUpdateRequest) (*dmp.Population, error) ] - - 人群列表查询接口 [ PopulationList(clt *core.SDKClient, accessToken string, req *dmp.PopulationListRequest) ([]dmp.Population, error) ] - - 人群包删除接口 [ PopulationDelete(clt *core.SDKClient, accessToken string, req *dmp.PopulationDeleteRequest) error ] - - 人群包跨账户推送 [ PopulationAccountsPush(clt *core.SDKClient, accessToken string, req *dmp.PopulationAccountsPushRequest) (*dmp.PopulationAccountsPushResponse, error) ] - - 人群包上线接口 [ PopulationPush(clt *core.SDKClient, accessToken string, req *dmp.PopulationPushRequest) error ] + - 人群包上传接口 [ PopulationUpload(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationUploadRequest) (*dmp.Population, error) ] + - 人群包更新接口 [ PopulationUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationUpdateRequest) (*dmp.Population, error) ] + - 人群列表查询接口 [ PopulationList(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationListRequest) ([]dmp.Population, error) ] + - 人群包删除接口 [ PopulationDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationDeleteRequest) error ] + - 人群包跨账户推送 [ PopulationAccountsPush(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationAccountsPushRequest) (*dmp.PopulationAccountsPushResponse, error) ] + - 人群包上线接口 [ PopulationPush(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationPushRequest) error ] - 应用管理 (api/appcenter) - 文件上传 (api/appcenter/upload) - - 上传 APK 文件 [ Apk(clt *core.SDKClient, accessToken string, req *upload.ApkRequest) (string, error) ] - - 上传图片 [ Pic(clt *core.SDKClient, accessToken string, req *upload.PicRequest) (string, error) ] + - 上传 APK 文件 [ Apk(ctx context.Context, clt *core.SDKClient, accessToken string, req *upload.ApkRequest) (string, error) ] + - 上传图片 [ Pic(ctx context.Context, clt *core.SDKClient, accessToken string, req *upload.PicRequest) (string, error) ] - 应用创编 - - 创建 Android 应用 [ CreateAndroid(clt *core.SDKClient, accessToken string, req *app.CreateAndroidRequest) (*app.App, error) ] - - 创建 iOS 应用 [ CreateIos(clt *core.SDKClient, accessToken string, req *app.CreateIosRequest) (*app.App, error) ] - - 编辑 Android 应用 [ UpdateAndroid(clt *core.SDKClient, accessToken string, req *app.UpdateAndroidRequest) (*app.App, error) ] - - 更新 iOS 应用 [ UpdateIos(clt *core.SDKClient, accessToken string, req *app.UpdateIosRequest) (*app.App, error) ] + - 创建 Android 应用 [ CreateAndroid(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.CreateAndroidRequest) (*app.App, error) ] + - 创建 iOS 应用 [ CreateIos(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.CreateIosRequest) (*app.App, error) ] + - 编辑 Android 应用 [ UpdateAndroid(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.UpdateAndroidRequest) (*app.App, error) ] + - 更新 iOS 应用 [ UpdateIos(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.UpdateIosRequest) (*app.App, error) ] - 应用查询For单元投放 - - 获取新版应用发布列表【单元创编】[ app.ReleaseList(clt *core.SDKClient, accessToken string, req *app.ReleaseListRequest) (*app.ListResponse, error) ] - - 获取新版分包发布列表【单元创编】 [ subpkg.ReleaseList(clt *core.SDKClient, accessToken string, req *subpkg.ReleaseListRequest) (*subpkg.ListResponse, error) ] + - 获取新版应用发布列表【单元创编】[ app.ReleaseList(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.ReleaseListRequest) (*app.ListResponse, error) ] + - 获取新版分包发布列表【单元创编】 [ subpkg.ReleaseList(ctx context.Context, clt *core.SDKClient, accessToken string, req *subpkg.ReleaseListRequest) (*subpkg.ListResponse, error) ] - 应用查询For应用中心 - - 获取应用列表 [ app.List(clt *core.SDKClient, accessToken string, req *app.ListRequest) (*app.ListResponse, error) ] - - 获取应用详情 [ app.Detail(clt *core.SDKClient, accessToken string, req *app.DetailRequest) (*app.App, error) ] + - 获取应用列表 [ app.List(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.ListRequest) (*app.ListResponse, error) ] + - 获取应用详情 [ app.Detail(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.DetailRequest) (*app.App, error) ] - 应用操作 - - iOS 应用上报更新 [ app.IosUpdate(clt *core.SDKClient, accessToken string, req *app.IosUpdateRequest) error ] - - 发布应用 [ app.Release(clt *core.SDKClient, accessToken string, req *app.ReleaseRequest) (*app.App, error) ] - - 应用上架 [ app.Online(clt *core.SDKClient, accessToken string, req *app.OnlineRequest) error ] - - 应用下架 [ app.Offline(clt *core.SDKClient, accessToken string, req *app.OfflineRequest) error ] - - 应用商店上下架 [ app.OfflineAppStores(clt *core.SDKClient, accessToken string, req *app.OfflineAppStoresRequest) error ] + - iOS 应用上报更新 [ app.IosUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.IosUpdateRequest) error ] + - 发布应用 [ app.Release(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.ReleaseRequest) (*app.App, error) ] + - 应用上架 [ app.Online(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.OnlineRequest) error ] + - 应用下架 [ app.Offline(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.OfflineRequest) error ] + - 应用商店上下架 [ app.OfflineAppStores(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.OfflineAppStoresRequest) error ] - 应用分包 - - 新建应用分包 [ subpkg.Add(clt *core.SDKClient, accessToken string, req *subpkg.AddRequest) ([]subpkg.SubPackage, error) ] - - 更新/恢复/删除应用分包 [ subpkg.Mod(clt *core.SDKClient, accessToken string, req *subpkg.ModRequest) error ] - - 修改应用分包备注 [ 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) ] + - 新建应用分包 [ subpkg.Add(ctx context.Context, clt *core.SDKClient, accessToken string, req *subpkg.AddRequest) ([]subpkg.SubPackage, error) ] + - 更新/恢复/删除应用分包 [ subpkg.Mod(ctx context.Context, clt *core.SDKClient, accessToken string, req *subpkg.ModRequest) error ] + - 修改应用分包备注 [ subpkg.Description(ctx context.Context, clt *core.SDKClient, accessToken string, req *subpkg.DescriptionRequest) error ] + - 获取分包管理/回收站列表 [ subpkg.List(ctx context.Context, clt *core.SDKClient, accessToken string, req *subpkg.ListRequest) (*subpkg.ListResponse, error) ] + - 分包失败重新构建 [ app.RetryBuildSubPackage(ctx context.Context, 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 ] + - 查询 DPA 模板信息 [ TemplateList(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.TemplateListRequest) (*dpa.TemplateListResponse, error) ] + - 获取商品库类目树 [ CategoryList(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.CategoryListRequest) (*dpa.CategoryListResponse, error) ] + - 获取商品库列表 [ LibraryList(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.LibraryListRequest) (*dpa.LibraryListResponse, error) ] + - 创建商品 [ ProductBatchCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.ProductBatchCreateRequest) ([]dpa.ProductUpdateResult, error) ] + - 更新商品 [ ProductBatchUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.ProductBatchUpdateRequest) ([]dpa.ProductUpdateResult, error) ] + - 获取商品列表 [ ProductBatchQuery(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.ProductBatchQueryRequest) (*dpa.ProductBatchQueryResponse, error) ] + - 获取商品列表(游标) [ ProductCursorQuery(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.ProductCursorQueryRequest) (*dpa.ProductCursorQueryResponse, error) ] + - 获取SDPA创意视频模板 [ CreativeTemplateList(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.CreativeTemplateListRequest) (*dpa.CreativeTemplateListResponse, error) ] + - 批量模板合成SDPA创意视频 [ CreativeVideoGenerate(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.CreativeVideoGenerateRequest) ([]dpa.GenerateVideoResult, error) ] + - CID服务商投放SDPA接口 [ SecretCidLink(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.SecretCidLinkRequest) error ] - 数据上报管理 (api/track) - 转化回传 [ Activate(req *track.ActivateRequest) error ] - 点击检测链接 [ Click(baseUrl string, fields []string) string ] diff --git a/api/adcompass/advertisers.go b/api/adcompass/advertisers.go index 86ee751..f968788 100644 --- a/api/adcompass/advertisers.go +++ b/api/adcompass/advertisers.go @@ -1,17 +1,19 @@ package adcompass import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/adcompass" ) // Advertisers 获取罗盘绑定广告主列 -func Advertisers(clt *core.SDKClient, accessToken string, advertiserID uint64) ([]adcompass.Advertiser, error) { +func Advertisers(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID uint64) ([]adcompass.Advertiser, error) { req := &adcompass.AdvertisersRequest{ AdvertiserID: advertiserID, } var resp adcompass.AdvertisersResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/adcompass/quota_tending.go b/api/adcompass/quota_tending.go index 60d9c7d..c9f8949 100644 --- a/api/adcompass/quota_tending.go +++ b/api/adcompass/quota_tending.go @@ -1,14 +1,16 @@ package adcompass import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/adcompass" ) // QuotaTending 磁力罗盘对外 quota 腾挪接口 -func QuotaTending(clt *core.SDKClient, accessToken string, req *adcompass.QuotaTendingRequest) (string, error) { +func QuotaTending(ctx context.Context, clt *core.SDKClient, accessToken string, req *adcompass.QuotaTendingRequest) (string, error) { var resp adcompass.QuotaTendingResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return "", err } return resp.Describe, nil diff --git a/api/advertiser/budget_get.go b/api/advertiser/budget_get.go index d476c7c..83858fd 100644 --- a/api/advertiser/budget_get.go +++ b/api/advertiser/budget_get.go @@ -1,17 +1,19 @@ package advertiser import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/advertiser" ) // BudgetGet 账户日预算查询 -func BudgetGet(clt *core.SDKClient, accessToken string, advertiserID uint64) (*advertiser.Budget, error) { +func BudgetGet(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID uint64) (*advertiser.Budget, error) { req := &advertiser.BudgetGetRequest{ AdvertiserID: advertiserID, } var resp advertiser.Budget - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/advertiser/fund_daily_flows.go b/api/advertiser/fund_daily_flows.go index c2b7c81..49d6617 100644 --- a/api/advertiser/fund_daily_flows.go +++ b/api/advertiser/fund_daily_flows.go @@ -1,14 +1,16 @@ package advertiser import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/advertiser" ) // FundDailyFlows 获取广告账户流水信息 -func FundDailyFlows(clt *core.SDKClient, accessToken string, req *advertiser.FundDailyFlowsRequest) (*advertiser.FundDailyFlowsResponse, error) { +func FundDailyFlows(ctx context.Context, clt *core.SDKClient, accessToken string, req *advertiser.FundDailyFlowsRequest) (*advertiser.FundDailyFlowsResponse, error) { var resp advertiser.FundDailyFlowsResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/advertiser/fund_get.go b/api/advertiser/fund_get.go index 7bc55f6..2e4cc63 100644 --- a/api/advertiser/fund_get.go +++ b/api/advertiser/fund_get.go @@ -1,17 +1,19 @@ package advertiser import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/advertiser" ) // FundGet 获取广告账户余额信息 -func FundGet(clt *core.SDKClient, accessToken string, advertiserID uint64) (float64, error) { +func FundGet(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID uint64) (float64, error) { req := &advertiser.FundGetRequest{ AdvertiserID: advertiserID, } var resp advertiser.FundGetResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/advertiser/info.go b/api/advertiser/info.go index 392ba79..6bafbd5 100644 --- a/api/advertiser/info.go +++ b/api/advertiser/info.go @@ -1,17 +1,19 @@ package advertiser import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/advertiser" ) // Info 获取广告账户信息 -func Info(clt *core.SDKClient, accessToken string, advertiserID uint64) (*advertiser.Info, error) { +func Info(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID uint64) (*advertiser.Info, error) { req := &advertiser.InfoRequest{ AdvertiserID: advertiserID, } var resp advertiser.Info - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/advertiser/update_budget.go b/api/advertiser/update_budget.go index 3353abb..337d557 100644 --- a/api/advertiser/update_budget.go +++ b/api/advertiser/update_budget.go @@ -1,11 +1,13 @@ package advertiser import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/advertiser" ) // UpdateBudget 修改账户预算 -func UpdateBudget(clt *core.SDKClient, accessToken string, req *advertiser.UpdateBudgetRequest) error { - return clt.Post(accessToken, req, nil) +func UpdateBudget(ctx context.Context, clt *core.SDKClient, accessToken string, req *advertiser.UpdateBudgetRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/advertiser/white_list.go b/api/advertiser/white_list.go index 3ba8eca..dc8ffe5 100644 --- a/api/advertiser/white_list.go +++ b/api/advertiser/white_list.go @@ -1,17 +1,19 @@ package advertiser import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/advertiser" ) // WhiteList 获取可选白名单接口 -func WhiteList(clt *core.SDKClient, accessToken string, advertiserID uint64) (*advertiser.WhiteListResponse, error) { +func WhiteList(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID uint64) (*advertiser.WhiteListResponse, error) { req := &advertiser.WhiteListRequest{ AdvertiserID: advertiserID, } var resp advertiser.WhiteListResponse - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/appcenter/app/create_android.go b/api/appcenter/app/create_android.go index 77713b5..659ef43 100644 --- a/api/appcenter/app/create_android.go +++ b/api/appcenter/app/create_android.go @@ -1,14 +1,16 @@ package app import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/app" ) // CreateAndroid 创建Android应用 -func CreateAndroid(clt *core.SDKClient, accessToken string, req *app.CreateAndroidRequest) (*app.App, error) { +func CreateAndroid(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.CreateAndroidRequest) (*app.App, error) { var resp app.App - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/appcenter/app/create_ios.go b/api/appcenter/app/create_ios.go index 837985b..2d6f29d 100644 --- a/api/appcenter/app/create_ios.go +++ b/api/appcenter/app/create_ios.go @@ -1,14 +1,16 @@ package app import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/app" ) // CreateIos 创建iOS应用 -func CreateIos(clt *core.SDKClient, accessToken string, req *app.CreateIosRequest) (*app.App, error) { +func CreateIos(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.CreateIosRequest) (*app.App, error) { var resp app.App - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/appcenter/app/detail.go b/api/appcenter/app/detail.go index a7a9444..b4dd323 100644 --- a/api/appcenter/app/detail.go +++ b/api/appcenter/app/detail.go @@ -1,14 +1,16 @@ package app import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/app" ) // Detail 【应用中心】获取应用详情 -func Detail(clt *core.SDKClient, accessToken string, req *app.DetailRequest) (*app.App, error) { +func Detail(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.DetailRequest) (*app.App, error) { var resp app.App - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/appcenter/app/ios_update.go b/api/appcenter/app/ios_update.go index d1fdeca..99c5394 100644 --- a/api/appcenter/app/ios_update.go +++ b/api/appcenter/app/ios_update.go @@ -1,6 +1,7 @@ package app import ( + "context" "errors" "github.com/bububa/kwai-marketing-api/core" @@ -8,9 +9,9 @@ import ( ) // IosUpdate iOS 应用上报更新 -func IosUpdate(clt *core.SDKClient, accessToken string, req *app.IosUpdateRequest) error { +func IosUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.IosUpdateRequest) error { var resp app.IosUpdateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return err } if !resp.Result { diff --git a/api/appcenter/app/list.go b/api/appcenter/app/list.go index b86b091..a194f86 100644 --- a/api/appcenter/app/list.go +++ b/api/appcenter/app/list.go @@ -1,14 +1,16 @@ package app import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/app" ) // List 【应用中心】获取应用列表 -func List(clt *core.SDKClient, accessToken string, req *app.ListRequest) (*app.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.ListRequest) (*app.ListResponse, error) { var resp app.ListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/appcenter/app/offline.go b/api/appcenter/app/offline.go index b206b5a..0ee2826 100644 --- a/api/appcenter/app/offline.go +++ b/api/appcenter/app/offline.go @@ -1,6 +1,7 @@ package app import ( + "context" "errors" "github.com/bububa/kwai-marketing-api/core" @@ -8,9 +9,9 @@ import ( ) // Offline 【应用中心】应用下架 -func Offline(clt *core.SDKClient, accessToken string, req *app.OfflineRequest) error { +func Offline(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.OfflineRequest) error { var resp app.OnlineOfflineResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return err } if !resp.Result { diff --git a/api/appcenter/app/offline_appstores.go b/api/appcenter/app/offline_appstores.go index 884d49b..5aad445 100644 --- a/api/appcenter/app/offline_appstores.go +++ b/api/appcenter/app/offline_appstores.go @@ -1,6 +1,7 @@ package app import ( + "context" "errors" "github.com/bububa/kwai-marketing-api/core" @@ -8,9 +9,9 @@ import ( ) // OfflineAppStores 【应用中心】应用商店上下架 -func OfflineAppStores(clt *core.SDKClient, accessToken string, req *app.OfflineAppStoresRequest) error { +func OfflineAppStores(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.OfflineAppStoresRequest) error { var resp app.OnlineOfflineResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return err } if !resp.Result { diff --git a/api/appcenter/app/online.go b/api/appcenter/app/online.go index cdb6ef2..003c763 100644 --- a/api/appcenter/app/online.go +++ b/api/appcenter/app/online.go @@ -1,6 +1,7 @@ package app import ( + "context" "errors" "github.com/bububa/kwai-marketing-api/core" @@ -8,9 +9,9 @@ import ( ) // Online 【应用中心】应用上架 -func Online(clt *core.SDKClient, accessToken string, req *app.OnlineRequest) error { +func Online(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.OnlineRequest) error { var resp app.OnlineOfflineResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return err } if !resp.Result { diff --git a/api/appcenter/app/release.go b/api/appcenter/app/release.go index 5dbd762..baa18d6 100644 --- a/api/appcenter/app/release.go +++ b/api/appcenter/app/release.go @@ -1,14 +1,16 @@ package app import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/app" ) // Release 【应用中心】发布应用 -func Release(clt *core.SDKClient, accessToken string, req *app.ReleaseRequest) (*app.App, error) { +func Release(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.ReleaseRequest) (*app.App, error) { var resp app.App - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/appcenter/app/release_list.go b/api/appcenter/app/release_list.go index 6aa7945..27874c2 100644 --- a/api/appcenter/app/release_list.go +++ b/api/appcenter/app/release_list.go @@ -1,14 +1,16 @@ package app import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/app" ) // ReleaseList 获取新版应用发布列表【单元创编】 -func ReleaseList(clt *core.SDKClient, accessToken string, req *app.ReleaseListRequest) (*app.ListResponse, error) { +func ReleaseList(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.ReleaseListRequest) (*app.ListResponse, error) { var resp app.ListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/appcenter/app/retry_build_sub_package.go b/api/appcenter/app/retry_build_sub_package.go index d7dd750..60e5d16 100644 --- a/api/appcenter/app/retry_build_sub_package.go +++ b/api/appcenter/app/retry_build_sub_package.go @@ -1,14 +1,16 @@ package app import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/app" ) // RetryBuildSubPackage 【应用中心】分包失败,重新构建 -func RetryBuildSubPackage(clt *core.SDKClient, accessToken string, req *app.RetryBuildSubPackageRequest) (int, error) { +func RetryBuildSubPackage(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.RetryBuildSubPackageRequest) (int, error) { var resp app.RetryBuildSubPackageResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.RetryCnt, nil diff --git a/api/appcenter/app/update_android.go b/api/appcenter/app/update_android.go index be29802..2a448c1 100644 --- a/api/appcenter/app/update_android.go +++ b/api/appcenter/app/update_android.go @@ -1,14 +1,16 @@ package app import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/app" ) // UpdateAndroid 更新Android应用 -func UpdateAndroid(clt *core.SDKClient, accessToken string, req *app.UpdateAndroidRequest) (*app.App, error) { +func UpdateAndroid(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.UpdateAndroidRequest) (*app.App, error) { var resp app.App - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/appcenter/app/update_ios.go b/api/appcenter/app/update_ios.go index 3b8f165..fd00295 100644 --- a/api/appcenter/app/update_ios.go +++ b/api/appcenter/app/update_ios.go @@ -1,14 +1,16 @@ package app import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/app" ) // UpdateIos 更新iOS应用 -func UpdateIos(clt *core.SDKClient, accessToken string, req *app.UpdateIosRequest) (*app.App, error) { +func UpdateIos(ctx context.Context, clt *core.SDKClient, accessToken string, req *app.UpdateIosRequest) (*app.App, error) { var resp app.App - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/appcenter/subpkg/add.go b/api/appcenter/subpkg/add.go index bc528a0..e8f05eb 100644 --- a/api/appcenter/subpkg/add.go +++ b/api/appcenter/subpkg/add.go @@ -1,14 +1,16 @@ package subpkg import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/subpkg" ) // Add 【应用中心】新建应用分包 -func Add(clt *core.SDKClient, accessToken string, req *subpkg.AddRequest) ([]subpkg.SubPackage, error) { +func Add(ctx context.Context, clt *core.SDKClient, accessToken string, req *subpkg.AddRequest) ([]subpkg.SubPackage, error) { var resp []subpkg.SubPackage - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return resp, err } return resp, nil diff --git a/api/appcenter/subpkg/description.go b/api/appcenter/subpkg/description.go index 95c3c88..4ec2e78 100644 --- a/api/appcenter/subpkg/description.go +++ b/api/appcenter/subpkg/description.go @@ -1,6 +1,7 @@ package subpkg import ( + "context" "errors" "github.com/bububa/kwai-marketing-api/core" @@ -8,9 +9,9 @@ import ( ) // Description 【应用中心】修改应用分包备注 -func Description(clt *core.SDKClient, accessToken string, req *subpkg.DescriptionRequest) error { +func Description(ctx context.Context, clt *core.SDKClient, accessToken string, req *subpkg.DescriptionRequest) error { var resp subpkg.ModResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return err } if !resp.Result { diff --git a/api/appcenter/subpkg/list.go b/api/appcenter/subpkg/list.go index 9b0ac65..009b2e5 100644 --- a/api/appcenter/subpkg/list.go +++ b/api/appcenter/subpkg/list.go @@ -1,14 +1,16 @@ package subpkg import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/subpkg" ) // List 【应用中心】获取分包管理/回收站列表 -func List(clt *core.SDKClient, accessToken string, req *subpkg.ListRequest) (*subpkg.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *subpkg.ListRequest) (*subpkg.ListResponse, error) { var resp subpkg.ListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/appcenter/subpkg/mod.go b/api/appcenter/subpkg/mod.go index 46aeff5..10cbd4f 100644 --- a/api/appcenter/subpkg/mod.go +++ b/api/appcenter/subpkg/mod.go @@ -1,6 +1,7 @@ package subpkg import ( + "context" "errors" "github.com/bububa/kwai-marketing-api/core" @@ -8,9 +9,9 @@ import ( ) // Mod 【应用中心】更新/恢复/删除应用分包 -func Mod(clt *core.SDKClient, accessToken string, req *subpkg.ModRequest) error { +func Mod(ctx context.Context, clt *core.SDKClient, accessToken string, req *subpkg.ModRequest) error { var resp subpkg.ModResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return err } if !resp.Result { diff --git a/api/appcenter/subpkg/release_list.go b/api/appcenter/subpkg/release_list.go index 2e31495..9837a46 100644 --- a/api/appcenter/subpkg/release_list.go +++ b/api/appcenter/subpkg/release_list.go @@ -1,14 +1,16 @@ package subpkg import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/subpkg" ) // ReleaseList 获取新版分包发布列表【单元创编】 -func ReleaseList(clt *core.SDKClient, accessToken string, req *subpkg.ReleaseListRequest) (*subpkg.ListResponse, error) { +func ReleaseList(ctx context.Context, clt *core.SDKClient, accessToken string, req *subpkg.ReleaseListRequest) (*subpkg.ListResponse, error) { var resp subpkg.ListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/appcenter/upload/apk.go b/api/appcenter/upload/apk.go index d40d560..d651308 100644 --- a/api/appcenter/upload/apk.go +++ b/api/appcenter/upload/apk.go @@ -1,14 +1,16 @@ package upload import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/upload" ) // Apk 上传 APK 文件 -func Apk(clt *core.SDKClient, accessToken string, req *upload.ApkRequest) (string, error) { +func Apk(ctx context.Context, clt *core.SDKClient, accessToken string, req *upload.ApkRequest) (string, error) { var resp upload.ApkResponse - if err := clt.Upload(accessToken, req, &resp); err != nil { + if err := clt.Upload(ctx, accessToken, req, &resp); err != nil { return "", err } return resp.BlobStoreKey, nil diff --git a/api/appcenter/upload/pic.go b/api/appcenter/upload/pic.go index 6d64ca0..22a188e 100644 --- a/api/appcenter/upload/pic.go +++ b/api/appcenter/upload/pic.go @@ -1,14 +1,16 @@ package upload import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/appcenter/upload" ) // Pic 上传图片 -func Pic(clt *core.SDKClient, accessToken string, req *upload.PicRequest) (string, error) { +func Pic(ctx context.Context, clt *core.SDKClient, accessToken string, req *upload.PicRequest) (string, error) { var resp upload.PicResponse - if err := clt.Upload(accessToken, req, &resp); err != nil { + if err := clt.Upload(ctx, accessToken, req, &resp); err != nil { return "", err } return resp.URL, nil diff --git a/api/asset/adv_card_create.go b/api/asset/adv_card_create.go index 90d5970..d68e277 100644 --- a/api/asset/adv_card_create.go +++ b/api/asset/adv_card_create.go @@ -1,14 +1,16 @@ package asset import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/asset" ) // AdvCardCreate 创建高级创意接口 -func AdvCardCreate(clt *core.SDKClient, accessToken string, req *asset.AdvCardCreateRequest) ([]uint64, error) { +func AdvCardCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *asset.AdvCardCreateRequest) ([]uint64, error) { var resp asset.AdvCardCreateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/asset/adv_card_list.go b/api/asset/adv_card_list.go index 3b4c9b3..877041c 100644 --- a/api/asset/adv_card_list.go +++ b/api/asset/adv_card_list.go @@ -1,14 +1,16 @@ package asset import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/asset" ) // AdvCardList 获取高级创意列表 -func AdvCardList(clt *core.SDKClient, accessToken string, req *asset.AdvCardListRequest) (*asset.AdvCardListResponse, error) { +func AdvCardList(ctx context.Context, clt *core.SDKClient, accessToken string, req *asset.AdvCardListRequest) (*asset.AdvCardListResponse, error) { var resp asset.AdvCardListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/asset/adv_card_remove.go b/api/asset/adv_card_remove.go index e432f44..b8f20b7 100644 --- a/api/asset/adv_card_remove.go +++ b/api/asset/adv_card_remove.go @@ -1,14 +1,16 @@ package asset import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/asset" ) // AdvCardRemove 删除高级创意接口 -func AdvCardRemove(clt *core.SDKClient, accessToken string, req *asset.AdvCardRemoveRequest) ([]uint64, error) { +func AdvCardRemove(ctx context.Context, clt *core.SDKClient, accessToken string, req *asset.AdvCardRemoveRequest) ([]uint64, error) { var resp asset.AdvCardRemoveResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/campaign/create.go b/api/campaign/create.go index eb770a6..3e4fe10 100644 --- a/api/campaign/create.go +++ b/api/campaign/create.go @@ -1,14 +1,16 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/campaign" ) // Create 创建广告计划 -func Create(clt *core.SDKClient, accessToken string, req *campaign.CreateRequest) (uint64, error) { +func Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.CreateRequest) (uint64, error) { var resp campaign.CreateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/campaign/list.go b/api/campaign/list.go index 75e5e31..ff2c572 100644 --- a/api/campaign/list.go +++ b/api/campaign/list.go @@ -1,14 +1,16 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/campaign" ) // List 获取广告计划信息 -func List(clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) { var resp campaign.ListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/campaign/update.go b/api/campaign/update.go index 73e92d8..d6c5c6b 100644 --- a/api/campaign/update.go +++ b/api/campaign/update.go @@ -1,14 +1,16 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/campaign" ) // Update 修改广告计划 -func Update(clt *core.SDKClient, accessToken string, req *campaign.UpdateRequest) (uint64, error) { +func Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.UpdateRequest) (uint64, error) { var resp campaign.UpdateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/campaign/update_budget.go b/api/campaign/update_budget.go index 49c0b41..668cb58 100644 --- a/api/campaign/update_budget.go +++ b/api/campaign/update_budget.go @@ -1,11 +1,13 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/campaign" ) // UpdateBudget 修改广告计划预算 -func UpdateBudget(clt *core.SDKClient, accessToken string, req *campaign.UpdateBudgetRequest) error { - return clt.Post(accessToken, req, nil) +func UpdateBudget(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.UpdateBudgetRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/campaign/update_status.go b/api/campaign/update_status.go index 1dc164c..9d70bc3 100644 --- a/api/campaign/update_status.go +++ b/api/campaign/update_status.go @@ -1,14 +1,16 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/campaign" ) // UpdateStatus 修改广告计划状态 -func UpdateStatus(clt *core.SDKClient, accessToken string, req *campaign.UpdateStatusRequest) ([]uint64, error) { +func UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.UpdateStatusRequest) ([]uint64, error) { var resp campaign.UpdateStatusResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/comment/cancel_top.go b/api/comment/cancel_top.go index d6fdd5b..6033260 100644 --- a/api/comment/cancel_top.go +++ b/api/comment/cancel_top.go @@ -1,14 +1,16 @@ package comment import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/comment" ) // CancelTop 取消置顶 -func CancelTop(clt *core.SDKClient, accessToken string, req *comment.CancelTopRequest) (uint64, error) { +func CancelTop(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.CancelTopRequest) (uint64, error) { var resp comment.CancelTopResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.CommentID, nil diff --git a/api/comment/list.go b/api/comment/list.go index 406995e..1a901d0 100644 --- a/api/comment/list.go +++ b/api/comment/list.go @@ -1,14 +1,16 @@ package comment import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/comment" ) // List 评论列表数据查询 -func List(clt *core.SDKClient, accessToken string, req *comment.ListRequest) (*comment.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ListRequest) (*comment.ListResponse, error) { var resp comment.ListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/comment/reply.go b/api/comment/reply.go index 245dcde..9273449 100644 --- a/api/comment/reply.go +++ b/api/comment/reply.go @@ -1,14 +1,16 @@ package comment import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/comment" ) // Reply 回复评论 -func Reply(clt *core.SDKClient, accessToken string, req *comment.ReplyRequest) ([]comment.ReplyResult, error) { +func Reply(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ReplyRequest) ([]comment.ReplyResult, error) { var resp comment.ReplyResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/comment/set_top.go b/api/comment/set_top.go index d954929..7932dc6 100644 --- a/api/comment/set_top.go +++ b/api/comment/set_top.go @@ -1,14 +1,16 @@ package comment import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/comment" ) // SetTop 评论置顶 -func SetTop(clt *core.SDKClient, accessToken string, req *comment.SetTopRequest) (uint64, error) { +func SetTop(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.SetTopRequest) (uint64, error) { var resp comment.SetTopResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.CommentID, nil diff --git a/api/comment/shield.go b/api/comment/shield.go index a2dda1e..4db7384 100644 --- a/api/comment/shield.go +++ b/api/comment/shield.go @@ -1,11 +1,13 @@ package comment import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/comment" ) // Shield 屏蔽评论 -func Shield(clt *core.SDKClient, accessToken string, req *comment.ShieldRequest) error { - return clt.Post(accessToken, req, nil) +func Shield(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ShieldRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/comment/shield_info_create.go b/api/comment/shield_info_create.go index 60416eb..22d2f7e 100644 --- a/api/comment/shield_info_create.go +++ b/api/comment/shield_info_create.go @@ -1,14 +1,16 @@ package comment import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/comment" ) // ShieldInfoCreate 增加屏蔽评论信息 -func ShieldInfoCreate(clt *core.SDKClient, accessToken string, req *comment.ShieldInfoCreateRequest) ([]uint64, error) { +func ShieldInfoCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ShieldInfoCreateRequest) ([]uint64, error) { var resp comment.ShieldInfoCreateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp.ShieldInfoIDList, nil diff --git a/api/comment/shield_info_delete.go b/api/comment/shield_info_delete.go index 193032b..2839c5b 100644 --- a/api/comment/shield_info_delete.go +++ b/api/comment/shield_info_delete.go @@ -1,11 +1,13 @@ package comment import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/comment" ) // ShieldInfoDelete 删除屏蔽评论信息 -func ShieldInfoDelete(clt *core.SDKClient, accessToken string, req *comment.ShieldInfoDeleteRequest) error { - return clt.Post(accessToken, req, nil) +func ShieldInfoDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ShieldInfoDeleteRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/comment/shield_info_list.go b/api/comment/shield_info_list.go index 727440f..63a2af4 100644 --- a/api/comment/shield_info_list.go +++ b/api/comment/shield_info_list.go @@ -1,14 +1,16 @@ package comment import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/comment" ) // ShieldInfoList 获取屏蔽评论信息列表 -func ShieldInfoList(clt *core.SDKClient, accessToken string, req *comment.ShieldInfoListRequest) (*comment.ShieldInfoListResponse, error) { +func ShieldInfoList(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.ShieldInfoListRequest) (*comment.ShieldInfoListResponse, error) { var resp comment.ShieldInfoListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/comment/tree.go b/api/comment/tree.go index a2ca036..e3a14ee 100644 --- a/api/comment/tree.go +++ b/api/comment/tree.go @@ -1,14 +1,16 @@ package comment import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/comment" ) // Tree 评论树查询 -func Tree(clt *core.SDKClient, accessToken string, req *comment.TreeRequest) (*comment.TreeResponse, error) { +func Tree(ctx context.Context, clt *core.SDKClient, accessToken string, req *comment.TreeRequest) (*comment.TreeResponse, error) { var resp comment.TreeResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/creative/action_bar_text_list.go b/api/creative/action_bar_text_list.go index bf6fc9d..620e022 100644 --- a/api/creative/action_bar_text_list.go +++ b/api/creative/action_bar_text_list.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // ActionBarTextList 获取行动号召按钮 -func ActionBarTextList(clt *core.SDKClient, accessToken string, req *creative.ActionBarTextListRequest) ([]string, error) { +func ActionBarTextList(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.ActionBarTextListRequest) ([]string, error) { var resp creative.ActionBarTextListResponse - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/creative/advanced_program_create.go b/api/creative/advanced_program_create.go index 03e7a2e..b726561 100644 --- a/api/creative/advanced_program_create.go +++ b/api/creative/advanced_program_create.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // AdvancedProgramCreate 创建程序化2.0创意 -func AdvancedProgramCreate(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramCreateRequest) (uint64, error) { +func AdvancedProgramCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramCreateRequest) (uint64, error) { var resp creative.AdvancedProgramCreateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/creative/advanced_program_list.go b/api/creative/advanced_program_list.go index 90471bf..d30761f 100644 --- a/api/creative/advanced_program_list.go +++ b/api/creative/advanced_program_list.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // AdvancedProgramList 获取程序化创意2.0信息 -func AdvancedProgramList(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramListRequest) (*creative.AdvancedProgramListResponse, error) { +func AdvancedProgramList(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramListRequest) (*creative.AdvancedProgramListResponse, error) { var resp creative.AdvancedProgramListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/creative/advanced_program_review_detail.go b/api/creative/advanced_program_review_detail.go index fea444d..0083865 100644 --- a/api/creative/advanced_program_review_detail.go +++ b/api/creative/advanced_program_review_detail.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // AdvancedProgramReviewDetail 获取程序化创意2.0审核信息 -func AdvancedProgramReviewDetail(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramReviewDetailRequest) (*creative.AdvancedProgramReviewDetail, error) { +func AdvancedProgramReviewDetail(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramReviewDetailRequest) (*creative.AdvancedProgramReviewDetail, error) { var resp creative.AdvancedProgramReviewDetail - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/creative/advanced_program_update.go b/api/creative/advanced_program_update.go index d8b685e..69a32a6 100644 --- a/api/creative/advanced_program_update.go +++ b/api/creative/advanced_program_update.go @@ -1,11 +1,13 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // AdvancedProgramUpdate 修改程序化2.0创意 -func AdvancedProgramUpdate(clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramUpdateRequest) error { - return clt.Post(accessToken, req, nil) +func AdvancedProgramUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedProgramUpdateRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/creative/batch_update.go b/api/creative/batch_update.go index 8c4849f..6835655 100644 --- a/api/creative/batch_update.go +++ b/api/creative/batch_update.go @@ -1,15 +1,17 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // BatchUpdate 批量创建&修改创意 // 注:该接口可实现创意的批量创建&更新,上传creative_id为更新,不上传creative_id则为创建。 -func BatchUpdate(clt *core.SDKClient, accessToken string, req *creative.BatchUpdateRequest) (*creative.BatchUpdateResponse, error) { +func BatchUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.BatchUpdateRequest) (*creative.BatchUpdateResponse, error) { var resp creative.BatchUpdateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/creative/create.go b/api/creative/create.go index 8a59d5f..dc4ad38 100644 --- a/api/creative/create.go +++ b/api/creative/create.go @@ -1,15 +1,17 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // Create 创建创意 // 【注】联盟广告不支持便利贴图片素材,只有联盟广告支持横版竖版图片素材。 -func Create(clt *core.SDKClient, accessToken string, req *creative.CreateRequest) (uint64, error) { +func Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.CreateRequest) (uint64, error) { var resp creative.CreateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/creative/create_advanced.go b/api/creative/create_advanced.go index 73279d0..fe0fbc2 100644 --- a/api/creative/create_advanced.go +++ b/api/creative/create_advanced.go @@ -1,15 +1,17 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // Create 创建创意 // 【注】联盟广告不支持便利贴图片素材,只有联盟广告支持横版竖版图片素材。 -func CreateAdvanced(clt *core.SDKClient, accessToken string, req *creative.CreateAdvancedRequest) (uint64, error) { +func CreateAdvanced(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.CreateAdvancedRequest) (uint64, error) { var resp creative.CreateAdvancedResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/creative/creative_tag_advise.go b/api/creative/creative_tag_advise.go index 7cc25fb..7234866 100644 --- a/api/creative/creative_tag_advise.go +++ b/api/creative/creative_tag_advise.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // CreativeTagAdvise 创意标签填写建议 -func CreativeTagAdvise(clt *core.SDKClient, accessToken string, req *creative.CreativeTagAdviseRequest) (*creative.CreativeTagAdviseResponse, error) { +func CreativeTagAdvise(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.CreativeTagAdviseRequest) (*creative.CreativeTagAdviseResponse, error) { var resp creative.CreativeTagAdviseResponse - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/creative/list.go b/api/creative/list.go index 66cc96d..fbc1fef 100644 --- a/api/creative/list.go +++ b/api/creative/list.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // List 获取广告创意信息 -func List(clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) { var resp creative.ListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/creative/preview.go b/api/creative/preview.go index 84991de..49aaead 100644 --- a/api/creative/preview.go +++ b/api/creative/preview.go @@ -1,11 +1,13 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // Preview 创意体验 -func Preview(clt *core.SDKClient, accessToken string, req *creative.PreviewRequest) error { - return clt.Post(accessToken, req, nil) +func Preview(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.PreviewRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/creative/update.go b/api/creative/update.go index 9b9e10b..6f47056 100644 --- a/api/creative/update.go +++ b/api/creative/update.go @@ -1,15 +1,17 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // Update 修改创意 -//【注】联盟广告不支持便利贴图片素材。 -func Update(clt *core.SDKClient, accessToken string, req *creative.UpdateRequest) (uint64, error) { +// 【注】联盟广告不支持便利贴图片素材。 +func Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.UpdateRequest) (uint64, error) { var resp creative.UpdateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/creative/update_status.go b/api/creative/update_status.go index 361d756..e77676e 100644 --- a/api/creative/update_status.go +++ b/api/creative/update_status.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/creative" ) // UpdateStatus 修改创意状态 -func UpdateStatus(clt *core.SDKClient, accessToken string, req *creative.UpdateStatusRequest) ([]uint64, error) { +func UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.UpdateStatusRequest) ([]uint64, error) { var resp creative.UpdateStatusResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/dmp/population_accounts_push.go b/api/dmp/population_accounts_push.go index 4cdfdb5..7b41a5b 100644 --- a/api/dmp/population_accounts_push.go +++ b/api/dmp/population_accounts_push.go @@ -1,14 +1,16 @@ package dmp import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dmp" ) // PopulationAccountsPush 人群包跨账户推送 -func PopulationAccountsPush(clt *core.SDKClient, accessToken string, req *dmp.PopulationAccountsPushRequest) (*dmp.PopulationAccountsPushResponse, error) { +func PopulationAccountsPush(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationAccountsPushRequest) (*dmp.PopulationAccountsPushResponse, error) { var resp dmp.PopulationAccountsPushResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/dmp/population_delete.go b/api/dmp/population_delete.go index 5c9120e..266941e 100644 --- a/api/dmp/population_delete.go +++ b/api/dmp/population_delete.go @@ -1,11 +1,13 @@ package dmp import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dmp" ) // PopulationDelete 人群包删除接口 -func PopulationDelete(clt *core.SDKClient, accessToken string, req *dmp.PopulationDeleteRequest) error { - return clt.Post(accessToken, req, nil) +func PopulationDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationDeleteRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/dmp/population_list.go b/api/dmp/population_list.go index 17a5a5a..dbbee04 100644 --- a/api/dmp/population_list.go +++ b/api/dmp/population_list.go @@ -1,14 +1,16 @@ package dmp import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dmp" ) // PopulationList 人群列表查询接口 -func PopulationList(clt *core.SDKClient, accessToken string, req *dmp.PopulationListRequest) (*dmp.PopulationListResponse, error) { +func PopulationList(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationListRequest) (*dmp.PopulationListResponse, error) { var resp *dmp.PopulationListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/dmp/population_push.go b/api/dmp/population_push.go index 6cf0824..3c4a066 100644 --- a/api/dmp/population_push.go +++ b/api/dmp/population_push.go @@ -1,11 +1,13 @@ package dmp import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dmp" ) // PopulationPush 人群包上线接口 -func PopulationPush(clt *core.SDKClient, accessToken string, req *dmp.PopulationPushRequest) error { - return clt.Post(accessToken, req, nil) +func PopulationPush(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationPushRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/dmp/population_update.go b/api/dmp/population_update.go index 3215235..07be59c 100644 --- a/api/dmp/population_update.go +++ b/api/dmp/population_update.go @@ -1,14 +1,16 @@ package dmp import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dmp" ) // PopulationUpdate 人群包更新接口 -func PopulationUpdate(clt *core.SDKClient, accessToken string, req *dmp.PopulationUpdateRequest) (*dmp.Population, error) { +func PopulationUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationUpdateRequest) (*dmp.Population, error) { var resp dmp.Population - err := clt.Upload(accessToken, req, &resp) + err := clt.Upload(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/dmp/population_update_v2.go b/api/dmp/population_update_v2.go index 130e22c..796c04a 100644 --- a/api/dmp/population_update_v2.go +++ b/api/dmp/population_update_v2.go @@ -1,14 +1,16 @@ package dmp import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dmp" ) // PopulationUpdateV2 人群包更新接口 -func PopulationUpdateV2(clt *core.SDKClient, accessToken string, req *dmp.PopulationUpdateRequestv2) (*dmp.PopulationV2, error) { +func PopulationUpdateV2(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationUpdateRequestv2) (*dmp.PopulationV2, error) { var resp dmp.PopulationV2 - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/dmp/population_upload.go b/api/dmp/population_upload.go index 40246da..bf82859 100644 --- a/api/dmp/population_upload.go +++ b/api/dmp/population_upload.go @@ -1,14 +1,16 @@ package dmp import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dmp" ) // PopulationUpload 人群包上传接口 -func PopulationUpload(clt *core.SDKClient, accessToken string, req *dmp.PopulationUploadRequest) (*dmp.Population, error) { +func PopulationUpload(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationUploadRequest) (*dmp.Population, error) { var resp dmp.Population - err := clt.Upload(accessToken, req, &resp) + err := clt.Upload(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/dmp/population_upload_file_v2.go b/api/dmp/population_upload_file_v2.go index 5d08197..47b90f8 100644 --- a/api/dmp/population_upload_file_v2.go +++ b/api/dmp/population_upload_file_v2.go @@ -1,14 +1,16 @@ package dmp import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dmp" ) // PopulationUpload 人群包上传接口 -func PopulationUploadFileV2(clt *core.SDKClient, accessToken string, req *dmp.PopulationUploadFileRequest) (*dmp.FileV2, error) { +func PopulationUploadFileV2(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationUploadFileRequest) (*dmp.FileV2, error) { var resp dmp.FileV2 - err := clt.Upload(accessToken, req, &resp) + err := clt.Upload(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/dmp/population_upload_v2.go b/api/dmp/population_upload_v2.go index 4af9626..ebe2d54 100644 --- a/api/dmp/population_upload_v2.go +++ b/api/dmp/population_upload_v2.go @@ -1,14 +1,16 @@ package dmp import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dmp" ) // PopulationUpload 人群包上传接口 -func PopulationUploadV2(clt *core.SDKClient, accessToken string, req *dmp.PopulationUploadRequestV2) (*dmp.PopulationV2, error) { +func PopulationUploadV2(ctx context.Context, clt *core.SDKClient, accessToken string, req *dmp.PopulationUploadRequestV2) (*dmp.PopulationV2, error) { var resp dmp.PopulationV2 - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/dsp/campaign/create.go b/api/dsp/campaign/create.go index f1cbcb9..2211ecb 100644 --- a/api/dsp/campaign/create.go +++ b/api/dsp/campaign/create.go @@ -1,15 +1,17 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/campaign" ) // Create 创建广告计划 // 【注】创建搜索广告计划。每个广告主账号下最多可允许创建500个计划 -func Create(clt *core.SDKClient, accessToken string, req *campaign.CreateRequest) (uint64, error) { +func Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.CreateRequest) (uint64, error) { var resp campaign.CreateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.CampaignID, nil diff --git a/api/dsp/campaign/list.go b/api/dsp/campaign/list.go index 2753fa2..3ec1b56 100644 --- a/api/dsp/campaign/list.go +++ b/api/dsp/campaign/list.go @@ -1,14 +1,16 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/campaign" ) // List 获取广告计划信息 -func List(clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) { var resp campaign.ListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/campaign/update.go b/api/dsp/campaign/update.go index b2522fe..f49797d 100644 --- a/api/dsp/campaign/update.go +++ b/api/dsp/campaign/update.go @@ -1,14 +1,16 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/campaign" ) // Update 修改广告计划 -func Update(clt *core.SDKClient, accessToken string, req *campaign.UpdateRequest) (uint64, error) { +func Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.UpdateRequest) (uint64, error) { var resp campaign.UpdateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.CampaignID, nil diff --git a/api/dsp/campaign/update_status.go b/api/dsp/campaign/update_status.go index b09ac78..7f29012 100644 --- a/api/dsp/campaign/update_status.go +++ b/api/dsp/campaign/update_status.go @@ -1,14 +1,16 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/campaign" ) // UpdateStatus 修改广告计划状态 -func UpdateStatus(clt *core.SDKClient, accessToken string, req *campaign.UpdateStatusRequest) ([]uint64, error) { +func UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.UpdateStatusRequest) ([]uint64, error) { var resp campaign.UpdateStatusResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp.CampaignIDs, nil diff --git a/api/dsp/creative/advanced_creative_create.go b/api/dsp/creative/advanced_creative_create.go index 339bcfd..a98b2d6 100644 --- a/api/dsp/creative/advanced_creative_create.go +++ b/api/dsp/creative/advanced_creative_create.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/creative" ) // AdvancedCreativeCreate 创建程序化创意 -func AdvancedCreativeCreate(clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeCreateRequest) (uint64, error) { +func AdvancedCreativeCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeCreateRequest) (uint64, error) { var resp creative.AdvancedCreativeCreateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.UnitID, nil diff --git a/api/dsp/creative/advanced_creative_list.go b/api/dsp/creative/advanced_creative_list.go index 9cdbb0b..3192662 100644 --- a/api/dsp/creative/advanced_creative_list.go +++ b/api/dsp/creative/advanced_creative_list.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/creative" ) // AdvancedCreativeList 查询程序化创意 -func AdvancedCreativeList(clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeListRequest) (*creative.AdvancedCreativeListResponse, error) { +func AdvancedCreativeList(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeListRequest) (*creative.AdvancedCreativeListResponse, error) { var resp creative.AdvancedCreativeListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/creative/advanced_creative_update.go b/api/dsp/creative/advanced_creative_update.go index 1da0d07..ab28b34 100644 --- a/api/dsp/creative/advanced_creative_update.go +++ b/api/dsp/creative/advanced_creative_update.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/creative" ) // AdvancedCreativeUpdate 修改程序化创意 -func AdvancedCreativeUpdate(clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeUpdateRequest) (uint64, error) { +func AdvancedCreativeUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeUpdateRequest) (uint64, error) { var resp creative.AdvancedCreativeUpdateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.UnitID, nil diff --git a/api/dsp/creative/batch_update.go b/api/dsp/creative/batch_update.go index 63a4e05..111b6cd 100644 --- a/api/dsp/creative/batch_update.go +++ b/api/dsp/creative/batch_update.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/creative" ) // BatchUpdate 批量修改自定义创意 -func BatchUpdate(clt *core.SDKClient, accessToken string, req *creative.BatchUpdateRequest) (*creative.BatchUpdateResponse, error) { +func BatchUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.BatchUpdateRequest) (*creative.BatchUpdateResponse, error) { var resp creative.BatchUpdateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/creative/create.go b/api/dsp/creative/create.go index 796a6ac..3a4a7c7 100644 --- a/api/dsp/creative/create.go +++ b/api/dsp/creative/create.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/creative" ) // Create 创建自定义创意 -func Create(clt *core.SDKClient, accessToken string, req *creative.CreateRequest) (uint64, error) { +func Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.CreateRequest) (uint64, error) { var resp creative.CreateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.CreativeID, nil diff --git a/api/dsp/creative/list.go b/api/dsp/creative/list.go index ed070d9..43de9e7 100644 --- a/api/dsp/creative/list.go +++ b/api/dsp/creative/list.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/creative" ) // List 查询自定义创意 -func List(clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) { var resp creative.ListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/creative/preview.go b/api/dsp/creative/preview.go index 1b17eba..606cbd2 100644 --- a/api/dsp/creative/preview.go +++ b/api/dsp/creative/preview.go @@ -1,11 +1,13 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/creative" ) // Preview 创意体验 -func Preview(clt *core.SDKClient, accessToken string, req *creative.PreviewRequest) error { - return clt.Post(accessToken, req, nil) +func Preview(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.PreviewRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/dsp/creative/update.go b/api/dsp/creative/update.go index fa466f9..53adc26 100644 --- a/api/dsp/creative/update.go +++ b/api/dsp/creative/update.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/creative" ) // Update 修改自定义创意 -func Update(clt *core.SDKClient, accessToken string, req *creative.UpdateRequest) (uint64, error) { +func Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.UpdateRequest) (uint64, error) { var resp creative.UpdateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.CreativeID, nil diff --git a/api/dsp/creative/update_status.go b/api/dsp/creative/update_status.go index ba3909f..12bfc19 100644 --- a/api/dsp/creative/update_status.go +++ b/api/dsp/creative/update_status.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/creative" ) // UpdateStatus 修改创意状态 -func UpdateStatus(clt *core.SDKClient, accessToken string, req *creative.UpdateStatusRequest) ([]uint64, error) { +func UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.UpdateStatusRequest) ([]uint64, error) { var resp creative.UpdateStatusResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp.CreativeIDs, nil diff --git a/api/dsp/dpa/category_list.go b/api/dsp/dpa/category_list.go index 75f6249..dd18b45 100644 --- a/api/dsp/dpa/category_list.go +++ b/api/dsp/dpa/category_list.go @@ -1,14 +1,16 @@ package dpa import ( + "context" + "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) { +func CategoryList(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.CategoryListRequest) (*dpa.CategoryListResponse, error) { var resp dpa.CategoryListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/dpa/creative_template_list.go b/api/dsp/dpa/creative_template_list.go index ee3653a..a9766f5 100644 --- a/api/dsp/dpa/creative_template_list.go +++ b/api/dsp/dpa/creative_template_list.go @@ -1,14 +1,16 @@ package dpa import ( + "context" + "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) { +func CreativeTemplateList(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.CreativeTemplateListRequest) (*dpa.CreativeTemplateListResponse, error) { var resp dpa.CreativeTemplateListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/dpa/creative_video_generate.go b/api/dsp/dpa/creative_video_generate.go index 034fa32..7f63f57 100644 --- a/api/dsp/dpa/creative_video_generate.go +++ b/api/dsp/dpa/creative_video_generate.go @@ -1,14 +1,16 @@ package dpa import ( + "context" + "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) { +func CreativeVideoGenerate(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.CreativeVideoGenerateRequest) ([]dpa.GenerateVideoResult, error) { var resp dpa.CreativeVideoGenerateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp.VideoInfos, nil diff --git a/api/dsp/dpa/library_list.go b/api/dsp/dpa/library_list.go index 3d22f85..13c9d68 100644 --- a/api/dsp/dpa/library_list.go +++ b/api/dsp/dpa/library_list.go @@ -1,14 +1,16 @@ package dpa import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/dpa" ) // LibraryList 获取商品列表 -func LibraryList(clt *core.SDKClient, accessToken string, req *dpa.LibraryListRequest) (*dpa.LibraryListResponse, error) { +func LibraryList(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.LibraryListRequest) (*dpa.LibraryListResponse, error) { var resp dpa.LibraryListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/dpa/product_batch_create.go b/api/dsp/dpa/product_batch_create.go index 5061ca7..4cbd371 100644 --- a/api/dsp/dpa/product_batch_create.go +++ b/api/dsp/dpa/product_batch_create.go @@ -1,14 +1,16 @@ package dpa import ( + "context" + "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) { +func ProductBatchCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.ProductBatchCreateRequest) ([]dpa.ProductUpdateResult, error) { var resp dpa.ProductBatchUpdateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp.ProductEditResponses, nil diff --git a/api/dsp/dpa/product_batch_query.go b/api/dsp/dpa/product_batch_query.go index f7b0fdf..35379ef 100644 --- a/api/dsp/dpa/product_batch_query.go +++ b/api/dsp/dpa/product_batch_query.go @@ -1,14 +1,16 @@ package dpa import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/dpa" ) // ProductBatchQuery 获取商品列表 -func ProductBatchQuery(clt *core.SDKClient, accessToken string, req *dpa.ProductBatchQueryRequest) (*dpa.ProductBatchQueryResponse, error) { +func ProductBatchQuery(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.ProductBatchQueryRequest) (*dpa.ProductBatchQueryResponse, error) { var resp dpa.ProductBatchQueryResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/dpa/product_batch_update.go b/api/dsp/dpa/product_batch_update.go index c53818b..9697587 100644 --- a/api/dsp/dpa/product_batch_update.go +++ b/api/dsp/dpa/product_batch_update.go @@ -1,14 +1,16 @@ package dpa import ( + "context" + "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) { +func ProductBatchUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.ProductBatchUpdateRequest) ([]dpa.ProductUpdateResult, error) { var resp dpa.ProductBatchUpdateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp.ProductEditResponses, nil diff --git a/api/dsp/dpa/product_cursor_query.go b/api/dsp/dpa/product_cursor_query.go index 84150db..7f1b4ab 100644 --- a/api/dsp/dpa/product_cursor_query.go +++ b/api/dsp/dpa/product_cursor_query.go @@ -1,14 +1,16 @@ package dpa import ( + "context" + "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) { +func ProductCursorQuery(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.ProductCursorQueryRequest) (*dpa.ProductCursorQueryResponse, error) { var resp dpa.ProductCursorQueryResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/dpa/secret_cid_link.go b/api/dsp/dpa/secret_cid_link.go index 50a1993..fe6fbfc 100644 --- a/api/dsp/dpa/secret_cid_link.go +++ b/api/dsp/dpa/secret_cid_link.go @@ -1,11 +1,13 @@ package dpa import ( + "context" + "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) +func SecretCidLink(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.SecretCidLinkRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/dsp/dpa/template_list.go b/api/dsp/dpa/template_list.go index 2697cdd..6e61080 100644 --- a/api/dsp/dpa/template_list.go +++ b/api/dsp/dpa/template_list.go @@ -1,14 +1,16 @@ package dpa import ( + "context" + "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) { +func TemplateList(ctx context.Context, clt *core.SDKClient, accessToken string, req *dpa.TemplateListRequest) (*dpa.TemplateListResponse, error) { var resp dpa.TemplateListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/jingbell/share.go b/api/dsp/jingbell/share.go index f3a26a5..7d20051 100644 --- a/api/dsp/jingbell/share.go +++ b/api/dsp/jingbell/share.go @@ -1,15 +1,17 @@ package jingbell import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model" "github.com/bububa/kwai-marketing-api/model/dsp/jingbell" ) // Share 小铃铛推送 -func Share(clt *core.SDKClient, accessToken string, req *jingbell.ShareRequest) error { +func Share(ctx context.Context, clt *core.SDKClient, accessToken string, req *jingbell.ShareRequest) error { var resp jingbell.ShareResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return err } if resp.Result != 1 { diff --git a/api/dsp/native/open_account_native.go b/api/dsp/native/open_account_native.go index de423b0..822640b 100644 --- a/api/dsp/native/open_account_native.go +++ b/api/dsp/native/open_account_native.go @@ -1,12 +1,14 @@ package native import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/native" ) // OpenAccountNative 开启原生扩量开关接口 -func OpenAccountNative(clt *core.SDKClient, accessToken string, req *native.OpenAccountNativeRequest) error { +func OpenAccountNative(ctx context.Context, clt *core.SDKClient, accessToken string, req *native.OpenAccountNativeRequest) error { var resp native.OpenAccountNativeResponse - return clt.Post(accessToken, req, &resp) + return clt.Post(ctx, accessToken, req, &resp) } diff --git a/api/dsp/target/option_distance_list.go b/api/dsp/target/option_distance_list.go index 96b3e58..03c01e7 100644 --- a/api/dsp/target/option_distance_list.go +++ b/api/dsp/target/option_distance_list.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/target" ) // OptionDistanceList 根据店铺名称查询商圈信息 -func OptionDistanceList(clt *core.SDKClient, accessToken string, req *target.OptionDistanceListRequest) (*target.OptionDistanceListResponse, error) { +func OptionDistanceList(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.OptionDistanceListRequest) (*target.OptionDistanceListResponse, error) { var resp target.OptionDistanceListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/target/template_create.go b/api/dsp/target/template_create.go index 1901283..3168699 100644 --- a/api/dsp/target/template_create.go +++ b/api/dsp/target/template_create.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/target" ) // TemplateCreate 创建定向模板 -func TemplateCreate(clt *core.SDKClient, accessToken string, req *target.TemplateCreateRequest) (uint64, error) { +func TemplateCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateCreateRequest) (uint64, error) { var resp target.TemplateCreateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.TemplateID, nil diff --git a/api/dsp/target/template_delete.go b/api/dsp/target/template_delete.go index cf1d85f..c7ebf24 100644 --- a/api/dsp/target/template_delete.go +++ b/api/dsp/target/template_delete.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/target" ) // TemplateDelete 删除定向模板 -func TemplateDelete(clt *core.SDKClient, accessToken string, req *target.TemplateDeleteRequest) (uint64, error) { +func TemplateDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateDeleteRequest) (uint64, error) { var resp target.TemplateDeleteResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.TemplateID, nil diff --git a/api/dsp/target/template_details.go b/api/dsp/target/template_details.go index 949e3e8..3ee8b2e 100644 --- a/api/dsp/target/template_details.go +++ b/api/dsp/target/template_details.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/target" ) // TemplateDetails 查询定向模板 -func TemplateDetails(clt *core.SDKClient, accessToken string, req *target.TemplateDetailsRequest) (*target.TemplateDetailsResponse, error) { +func TemplateDetails(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateDetailsRequest) (*target.TemplateDetailsResponse, error) { var resp target.TemplateDetailsResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/target/template_related_unit_list.go b/api/dsp/target/template_related_unit_list.go index 6c1f330..1eabf4b 100644 --- a/api/dsp/target/template_related_unit_list.go +++ b/api/dsp/target/template_related_unit_list.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/target" ) // TemplateRelatedUnitList 查询模板关联的广告列表接口 -func TemplateRelatedUnitList(clt *core.SDKClient, accessToken string, req *target.TemplateRelatedUnitListRequest) (*target.TemplateRelatedUnitListResponse, error) { +func TemplateRelatedUnitList(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateRelatedUnitListRequest) (*target.TemplateRelatedUnitListResponse, error) { var resp target.TemplateRelatedUnitListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/target/template_sync_history.go b/api/dsp/target/template_sync_history.go index 05157ad..b84a7a5 100644 --- a/api/dsp/target/template_sync_history.go +++ b/api/dsp/target/template_sync_history.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/target" ) // TemplateSyncHistory 模板同步失败查询 -func TemplateSyncHistory(clt *core.SDKClient, accessToken string, req *target.TemplateSyncHistoryRequest) (*target.TemplateSyncHistoryResponse, error) { +func TemplateSyncHistory(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateSyncHistoryRequest) (*target.TemplateSyncHistoryResponse, error) { var resp target.TemplateSyncHistoryResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/target/template_unit_sync.go b/api/dsp/target/template_unit_sync.go index ba4085f..a095a9a 100644 --- a/api/dsp/target/template_unit_sync.go +++ b/api/dsp/target/template_unit_sync.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/target" ) // TemplateUnitSync 定向模板同步 -func TemplateUnitSync(clt *core.SDKClient, accessToken string, req *target.TemplateUnitSyncRequest) (*target.TemplateUnitSyncResponse, error) { +func TemplateUnitSync(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateUnitSyncRequest) (*target.TemplateUnitSyncResponse, error) { var resp target.TemplateUnitSyncResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/target/template_update.go b/api/dsp/target/template_update.go index 9380e90..b66d8a7 100644 --- a/api/dsp/target/template_update.go +++ b/api/dsp/target/template_update.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/target" ) // TemplateUpdate 更新定向模板 -func TemplateUpdate(clt *core.SDKClient, accessToken string, req *target.TemplateUpdateRequest) (uint64, error) { +func TemplateUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateUpdateRequest) (uint64, error) { var resp target.TemplateUpdateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.TemplateID, nil diff --git a/api/dsp/target/template_upgrade.go b/api/dsp/target/template_upgrade.go index 11c2fe5..b18bc8d 100644 --- a/api/dsp/target/template_upgrade.go +++ b/api/dsp/target/template_upgrade.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/target" ) // TemplateUpgrade 模板升级 -func TemplateUpgrade(clt *core.SDKClient, accessToken string, req *target.TemplateUpgradeRequest) (int64, error) { +func TemplateUpgrade(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateUpgradeRequest) (int64, error) { var resp target.TemplateUpgradeResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.TemplateCount, nil diff --git a/api/dsp/target/template_upgrade_list.go b/api/dsp/target/template_upgrade_list.go index c31b6f8..b258769 100644 --- a/api/dsp/target/template_upgrade_list.go +++ b/api/dsp/target/template_upgrade_list.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/target" ) // TemplateUpgradeList 查询待升级模板列表 -func TemplateUpgradeList(clt *core.SDKClient, accessToken string, req *target.TemplateUpgradeListRequest) ([]target.TemplateUpgradeItem, error) { +func TemplateUpgradeList(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateUpgradeListRequest) ([]target.TemplateUpgradeItem, error) { var resp []target.TemplateUpgradeItem - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp, nil diff --git a/api/dsp/unit/batch_update_monitor_urls.go b/api/dsp/unit/batch_update_monitor_urls.go index c189ea8..040ea45 100644 --- a/api/dsp/unit/batch_update_monitor_urls.go +++ b/api/dsp/unit/batch_update_monitor_urls.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/unit" ) // BatchUpdateMonitorURLs 监测链接批量更新接口 -func BatchUpdateMonitorURLs(clt *core.SDKClient, accessToken string, req *unit.BatchUpdateMonitorURLsRequest) ([]unit.UnitMonitorURL, error) { +func BatchUpdateMonitorURLs(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.BatchUpdateMonitorURLsRequest) ([]unit.UnitMonitorURL, error) { var resp unit.GetMonitorURLsResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp.UnitMonitorURLs, nil diff --git a/api/dsp/unit/create.go b/api/dsp/unit/create.go index 560dd76..2ba0fa2 100644 --- a/api/dsp/unit/create.go +++ b/api/dsp/unit/create.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/unit" ) // Create 创建广告组 -func Create(clt *core.SDKClient, accessToken string, req *unit.CreateRequest) (uint64, error) { +func Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.CreateRequest) (uint64, error) { var resp unit.CreateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.UnitID, nil diff --git a/api/dsp/unit/get_monitor_urls.go b/api/dsp/unit/get_monitor_urls.go index f6ef0ae..c60ed5c 100644 --- a/api/dsp/unit/get_monitor_urls.go +++ b/api/dsp/unit/get_monitor_urls.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/unit" ) // GetMonitorURLs 批量获取监测链接接口 -func GetMonitorURLs(clt *core.SDKClient, accessToken string, req *unit.GetMonitorURLsRequest) ([]unit.UnitMonitorURL, error) { +func GetMonitorURLs(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.GetMonitorURLsRequest) ([]unit.UnitMonitorURL, error) { var resp unit.GetMonitorURLsResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp.UnitMonitorURLs, nil diff --git a/api/dsp/unit/list.go b/api/dsp/unit/list.go index aede01e..a0ee6e5 100644 --- a/api/dsp/unit/list.go +++ b/api/dsp/unit/list.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/unit" ) // List 获取广告组信息 -func List(clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) { var resp unit.ListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/dsp/unit/update.go b/api/dsp/unit/update.go index aff1d49..c12d647 100644 --- a/api/dsp/unit/update.go +++ b/api/dsp/unit/update.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/unit" ) // Update 修改广告组 -func Update(clt *core.SDKClient, accessToken string, req *unit.UpdateRequest) (uint64, error) { +func Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateRequest) (uint64, error) { var resp unit.UpdateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.UnitID, nil diff --git a/api/dsp/unit/update_bid.go b/api/dsp/unit/update_bid.go index 67e5ae2..baa1028 100644 --- a/api/dsp/unit/update_bid.go +++ b/api/dsp/unit/update_bid.go @@ -1,11 +1,13 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/unit" ) // UpdateBid 修改广告组出价 -func UpdateBid(clt *core.SDKClient, accessToken string, req *unit.UpdateBidRequest) error { - return clt.Post(accessToken, req, nil) +func UpdateBid(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateBidRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/dsp/unit/update_day_budget.go b/api/dsp/unit/update_day_budget.go index 3d6b3a3..1a87699 100644 --- a/api/dsp/unit/update_day_budget.go +++ b/api/dsp/unit/update_day_budget.go @@ -1,11 +1,13 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/unit" ) // UpdateDayBudget 修改广告组预算 -func UpdateDayBudget(clt *core.SDKClient, accessToken string, req *unit.UpdateDayBudgetRequest) error { - return clt.Post(accessToken, req, nil) +func UpdateDayBudget(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateDayBudgetRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/dsp/unit/update_status.go b/api/dsp/unit/update_status.go index b3dd6c3..881a8ec 100644 --- a/api/dsp/unit/update_status.go +++ b/api/dsp/unit/update_status.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/unit" ) // UpdateStatus 修改广告组状态 -func UpdateStatus(clt *core.SDKClient, accessToken string, req *unit.UpdateStatusRequest) ([]uint64, error) { +func UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateStatusRequest) ([]uint64, error) { var resp unit.UpdateStatusResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/dsp/video/query_auto_share_switch.go b/api/dsp/video/query_auto_share_switch.go index 0c27c7e..c05390a 100644 --- a/api/dsp/video/query_auto_share_switch.go +++ b/api/dsp/video/query_auto_share_switch.go @@ -1,14 +1,16 @@ package video import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/dsp/video" ) // QueryAutoShareSwitch 查询账户共享视频库按钮是否开启 -func QueryAutoShareSwitch(clt *core.SDKClient, accessToken string, req *video.QueryAutoShareSwitchRequest) (*video.QueryAutoShareSwitchResponse, error) { +func QueryAutoShareSwitch(ctx context.Context, clt *core.SDKClient, accessToken string, req *video.QueryAutoShareSwitchRequest) (*video.QueryAutoShareSwitchResponse, error) { var resp video.QueryAutoShareSwitchResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/file/ad_app_create.go b/api/file/ad_app_create.go index f9aa803..261970f 100644 --- a/api/file/ad_app_create.go +++ b/api/file/ad_app_create.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdAppCreate 创建应用 -func AdAppCreate(clt *core.SDKClient, accessToken string, req *file.AdAppCreateRequest) (*file.App, error) { +func AdAppCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdAppCreateRequest) (*file.App, error) { var resp file.App - err := clt.Upload(accessToken, req, &resp) + err := clt.Upload(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/ad_app_create_test.go b/api/file/ad_app_create_test.go index f207a40..7a9341f 100644 --- a/api/file/ad_app_create_test.go +++ b/api/file/ad_app_create_test.go @@ -1,13 +1,15 @@ package file import ( + "context" "fmt" + "testing" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" - "testing" ) -func CreatKuaishouApp() (app *file.App, err error) { +func CreatKuaishouApp(ctx context.Context) (app *file.App, err error) { sdk := core.NewSDKClient(0, "xxxxx") req := &file.AdAppCreateRequest{ AdvertiserID: 11044594, @@ -20,12 +22,12 @@ func CreatKuaishouApp() (app *file.App, err error) { ImageToken: "c11a7c41163041e4b1f3e3fbf48f8a91.png", AppDetailImageToken: "38146cb2bb334d6f99f30f1ca096b86c.jpg", } - app, err = AdAppCreate(sdk, "36f7b5519e1f4437e382c6a34ed3aec3", req) + app, err = AdAppCreate(ctx, sdk, "36f7b5519e1f4437e382c6a34ed3aec3", req) fmt.Println(err) return } func TestData(t *testing.T) { - app, _ := CreatKuaishouApp() + app, _ := CreatKuaishouApp(context.Background()) fmt.Println(app) } diff --git a/api/file/ad_app_list.go b/api/file/ad_app_list.go index 3686048..e9f35d1 100644 --- a/api/file/ad_app_list.go +++ b/api/file/ad_app_list.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdAppList 获取应用列表 -func AdAppList(clt *core.SDKClient, accessToken string, req *file.AdAppListRequest) (*file.AdAppListResponse, error) { +func AdAppList(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdAppListRequest) (*file.AdAppListResponse, error) { var resp file.AdAppListResponse - err := clt.GetOnBody(accessToken, req, &resp) + err := clt.GetOnBody(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/ad_app_list_test.go b/api/file/ad_app_list_test.go index 96acb66..6541352 100644 --- a/api/file/ad_app_list_test.go +++ b/api/file/ad_app_list_test.go @@ -1,10 +1,12 @@ package file import ( + "context" "fmt" + "testing" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" - "testing" ) func TestAdAppList(t *testing.T) { @@ -16,7 +18,7 @@ func TestAdAppList(t *testing.T) { list *file.AdAppListResponse ) - list, err := AdAppList(sdk, "36f7b5519e1f4437e382c6a34ed3aec3", req) + list, err := AdAppList(context.Background(), sdk, "36f7b5519e1f4437e382c6a34ed3aec3", req) fmt.Println(err) fmt.Println(list) } diff --git a/api/file/ad_app_update.go b/api/file/ad_app_update.go index 1fbe15b..2d90266 100644 --- a/api/file/ad_app_update.go +++ b/api/file/ad_app_update.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdAppUpdate 修改应用 -func AdAppUpdate(clt *core.SDKClient, accessToken string, req *file.AdAppUpdateRequest) (*file.App, error) { +func AdAppUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdAppUpdateRequest) (*file.App, error) { var resp file.App - err := clt.Upload(accessToken, req, &resp) + err := clt.Upload(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/ad_image_get.go b/api/file/ad_image_get.go index b1f16e1..2242f8d 100644 --- a/api/file/ad_image_get.go +++ b/api/file/ad_image_get.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdImageGet 查询图片信息get接口 -func AdImageGet(clt *core.SDKClient, accessToken string, req *file.AdImageGetRequest) (*file.Image, error) { +func AdImageGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdImageGetRequest) (*file.Image, error) { var resp file.Image - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/ad_image_list.go b/api/file/ad_image_list.go index 5076ed8..21529e9 100644 --- a/api/file/ad_image_list.go +++ b/api/file/ad_image_list.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdImageList 查询图片信息list接口 -func AdImageList(clt *core.SDKClient, accessToken string, req *file.AdImageListRequest) (*file.AdImageListResponse, error) { +func AdImageList(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdImageListRequest) (*file.AdImageListResponse, error) { var resp file.AdImageListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/ad_image_upload_v1.go b/api/file/ad_image_upload_v1.go index 74d4222..74d0632 100644 --- a/api/file/ad_image_upload_v1.go +++ b/api/file/ad_image_upload_v1.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdImageUploadV1 上传图片v1接口 -func AdImageUploadV1(clt *core.SDKClient, accessToken string, req *file.AdImageUploadRequestV1) (*file.Image, error) { +func AdImageUploadV1(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdImageUploadRequestV1) (*file.Image, error) { var resp file.Image - err := clt.Upload(accessToken, req, &resp) + err := clt.Upload(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/ad_image_upload_v2.go b/api/file/ad_image_upload_v2.go index 435bb7c..d4c4dd2 100644 --- a/api/file/ad_image_upload_v2.go +++ b/api/file/ad_image_upload_v2.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdImageUploadV2 上传图片v2接口 -func AdImageUploadV2(clt *core.SDKClient, accessToken string, req *file.AdImageUploadRequestV2) (*file.Image, error) { +func AdImageUploadV2(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdImageUploadRequestV2) (*file.Image, error) { var resp file.Image - err := clt.Upload(accessToken, req, &resp) + err := clt.Upload(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/ad_video_delete.go b/api/file/ad_video_delete.go index eac826c..746a8d3 100644 --- a/api/file/ad_video_delete.go +++ b/api/file/ad_video_delete.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdVideoDelete 批量删除视频 -func AdVideoDelete(clt *core.SDKClient, accessToken string, req *file.AdVideoDeleteRequest) ([]string, error) { +func AdVideoDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoDeleteRequest) ([]string, error) { var ret file.AdVideoDeleteResponse - if err := clt.Post(accessToken, req, &ret); err != nil { + if err := clt.Post(ctx, accessToken, req, &ret); err != nil { return nil, err } return ret.PhotoIDs, nil diff --git a/api/file/ad_video_get.go b/api/file/ad_video_get.go index 7a1ca35..db796d2 100644 --- a/api/file/ad_video_get.go +++ b/api/file/ad_video_get.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdVideoGet 查询视频信息get接口 -func AdVideoGet(clt *core.SDKClient, accessToken string, req *file.AdVideoGetRequest) ([]file.Video, error) { +func AdVideoGet(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoGetRequest) ([]file.Video, error) { var resp []file.Video - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/ad_video_list.go b/api/file/ad_video_list.go index 9e64bdf..88631b7 100644 --- a/api/file/ad_video_list.go +++ b/api/file/ad_video_list.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdVideoList 查询视频信息list接口 -func AdVideoList(clt *core.SDKClient, accessToken string, req *file.AdVideoListRequest) (*file.AdVideoListResponse, error) { +func AdVideoList(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoListRequest) (*file.AdVideoListResponse, error) { var resp file.AdVideoListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/ad_video_relate_creatives.go b/api/file/ad_video_relate_creatives.go index e2c96d2..4e57bb0 100644 --- a/api/file/ad_video_relate_creatives.go +++ b/api/file/ad_video_relate_creatives.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdVideoRelateCreatives 视频关联创意数查询 -func AdVideoRelateCreatives(clt *core.SDKClient, accessToken string, req *file.AdVideoRelateCreativesRequest) ([]file.AdVideoRelatedCreatives, error) { +func AdVideoRelateCreatives(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoRelateCreativesRequest) ([]file.AdVideoRelatedCreatives, error) { var resp file.AdVideoRelateCreativesResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/ad_video_share.go b/api/file/ad_video_share.go index 7cb6fa8..5bb08e6 100644 --- a/api/file/ad_video_share.go +++ b/api/file/ad_video_share.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdVideoShare 视频库-推送视频 -func AdVideoShare(clt *core.SDKClient, accessToken string, req *file.AdVideoShareRequest) ([]file.AdVideoShareDetail, error) { +func AdVideoShare(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoShareRequest) ([]file.AdVideoShareDetail, error) { var resp file.AdVideoShareResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/ad_video_share_new.go b/api/file/ad_video_share_new.go index 28f03ed..ab7df0a 100644 --- a/api/file/ad_video_share_new.go +++ b/api/file/ad_video_share_new.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdVideoShareNew 视频库-推送视频(新版) -func AdVideoShareNew(clt *core.SDKClient, accessToken string, req *file.AdVideoShareNewRequest) (*file.AdVideoShareNewResponse, error) { +func AdVideoShareNew(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoShareNewRequest) (*file.AdVideoShareNewResponse, error) { var resp file.AdVideoShareNewResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/file/ad_video_tag_delete.go b/api/file/ad_video_tag_delete.go index 10434e3..45df67d 100644 --- a/api/file/ad_video_tag_delete.go +++ b/api/file/ad_video_tag_delete.go @@ -1,11 +1,13 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdVideoTagDelete 视频库-删除视频标签 -func AdVideoTagDelete(clt *core.SDKClient, accessToken string, req *file.AdVideoTagDeleteRequest) error { - return clt.Post(accessToken, req, nil) +func AdVideoTagDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoTagDeleteRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/file/ad_video_update.go b/api/file/ad_video_update.go index 0ed4ab1..e6a8b9d 100644 --- a/api/file/ad_video_update.go +++ b/api/file/ad_video_update.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdVideoUpdate 视频库-批量更新视频功能 -func AdVideoUpdate(clt *core.SDKClient, accessToken string, req *file.AdVideoUpdateRequest) ([]string, error) { +func AdVideoUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoUpdateRequest) ([]string, error) { var ret file.AdVideoUpdateResponse - if err := clt.Post(accessToken, req, &ret); err != nil { + if err := clt.Post(ctx, accessToken, req, &ret); err != nil { return nil, err } return ret.PhotoIDs, nil diff --git a/api/file/ad_video_upload_v1.go b/api/file/ad_video_upload_v1.go index 041e06e..c41e28a 100644 --- a/api/file/ad_video_upload_v1.go +++ b/api/file/ad_video_upload_v1.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdVideoUploadV1 上传视频v1接口 -func AdVideoUploadV1(clt *core.SDKClient, accessToken string, req *file.AdVideoUploadRequestV1) (string, error) { +func AdVideoUploadV1(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoUploadRequestV1) (string, error) { var resp file.Video - err := clt.Upload(accessToken, req, &resp) + err := clt.Upload(ctx, accessToken, req, &resp) if err != nil { return "", err } diff --git a/api/file/ad_video_upload_v2.go b/api/file/ad_video_upload_v2.go index b321e02..4fd24c1 100644 --- a/api/file/ad_video_upload_v2.go +++ b/api/file/ad_video_upload_v2.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdVideoUploadV2 上传视频v2接口 -func AdVideoUploadV2(clt *core.SDKClient, accessToken string, req *file.AdVideoUploadRequestV2) (*file.Video, error) { +func AdVideoUploadV2(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.AdVideoUploadRequestV2) (*file.Video, error) { var resp file.Video - err := clt.Upload(accessToken, req, &resp) + err := clt.Upload(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/file/pic_share.go b/api/file/pic_share.go index 2511724..4461f59 100644 --- a/api/file/pic_share.go +++ b/api/file/pic_share.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // PicShare 图片库推送 -func PicShare(clt *core.SDKClient, accessToken string, req *file.PicShareRequest) ([]file.PicShareResult, error) { +func PicShare(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.PicShareRequest) ([]file.PicShareResult, error) { var resp file.PicShareResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp.Details, nil diff --git a/api/file/upload_atlas_photo.go b/api/file/upload_atlas_photo.go index d1d713f..164b35e 100644 --- a/api/file/upload_atlas_photo.go +++ b/api/file/upload_atlas_photo.go @@ -1,14 +1,16 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // UploadAtlasPhoto 上传图文视频 -func UploadAtlasPhoto(clt *core.SDKClient, accessToken string, req *file.UploadAtlasPhotoRequest) (string, error) { +func UploadAtlasPhoto(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.UploadAtlasPhotoRequest) (string, error) { var ret file.UploadAtlasPhotoResponse - if err := clt.Post(accessToken, req, &ret); err != nil { + if err := clt.Post(ctx, accessToken, req, &ret); err != nil { return "", err } return ret.PhotoID, nil diff --git a/api/file/video_list_by_cursor.go b/api/file/video_list_by_cursor.go index 25b76c6..370d6fd 100644 --- a/api/file/video_list_by_cursor.go +++ b/api/file/video_list_by_cursor.go @@ -1,17 +1,18 @@ package file import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/file" ) // AdVideoList 查询视频信息list接口 -func VideoListByCursor(clt *core.SDKClient, accessToken string, req *file.VideoListByCursorRequest) (*file.VideoListByCursorResponse, error) { +func VideoListByCursor(ctx context.Context, clt *core.SDKClient, accessToken string, req *file.VideoListByCursorRequest) (*file.VideoListByCursorResponse, error) { var resp file.VideoListByCursorResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } return &resp, nil } - diff --git a/api/live/list_jingle_bell.go b/api/live/list_jingle_bell.go index 56fb809..3a018d4 100644 --- a/api/live/list_jingle_bell.go +++ b/api/live/list_jingle_bell.go @@ -1,14 +1,16 @@ package live import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/live" ) // ListJingleBell 获取直播间小铃铛列表 -func ListJingleBell(clt *core.SDKClient, accessToken string, req *live.ListJingleBellRequest) (*live.ListJingleBellResponse, error) { +func ListJingleBell(ctx context.Context, clt *core.SDKClient, accessToken string, req *live.ListJingleBellRequest) (*live.ListJingleBellResponse, error) { var resp live.ListJingleBellResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/live/list_live_user.go b/api/live/list_live_user.go index fcf43a6..e8ce36b 100644 --- a/api/live/list_live_user.go +++ b/api/live/list_live_user.go @@ -1,14 +1,16 @@ package live import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/live" ) // ListLiveUser 获取主播列表 -func ListLiveUser(clt *core.SDKClient, accessToken string, req *live.ListLiveUserRequest) (*live.ListLiveUserResponse, error) { +func ListLiveUser(ctx context.Context, clt *core.SDKClient, accessToken string, req *live.ListLiveUserRequest) (*live.ListLiveUserResponse, error) { var resp live.ListLiveUserResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/live/report/live_component_report.go b/api/live/report/live_component_report.go index ae4798d..b5344d9 100644 --- a/api/live/report/live_component_report.go +++ b/api/live/report/live_component_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/live/report" ) // ListLiveComponentReport 直播间组件报表 -func ListLiveComponentReport(clt *core.SDKClient, accessToken string, req *report.ListLiveComponentReportRequest) (*report.ListLiveComponentReportResponse, error) { +func ListLiveComponentReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.ListLiveComponentReportRequest) (*report.ListLiveComponentReportResponse, error) { var resp report.ListLiveComponentReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/live/report/live_user_report.go b/api/live/report/live_user_report.go index 7dc5948..7879df9 100644 --- a/api/live/report/live_user_report.go +++ b/api/live/report/live_user_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/live/report" ) // ListLiveUserReport 直播间报表 -func ListLiveUserReport(clt *core.SDKClient, accessToken string, req *report.ListLiveUserReportRequest) (*report.ListLiveReportResponse, error) { +func ListLiveUserReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.ListLiveUserReportRequest) (*report.ListLiveReportResponse, error) { var resp report.ListLiveReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/lp/consult_list.go b/api/lp/consult_list.go index 22283ae..ff27a67 100644 --- a/api/lp/consult_list.go +++ b/api/lp/consult_list.go @@ -1,14 +1,16 @@ package lp import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/lp" ) // ConsultList 获取可用咨询组件列表 -func ConsultList(clt *core.SDKClient, accessToken string, req *lp.ConsultListRequest) (*lp.ConsultListResponse, error) { +func ConsultList(ctx context.Context, clt *core.SDKClient, accessToken string, req *lp.ConsultListRequest) (*lp.ConsultListResponse, error) { var resp lp.ConsultListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/native/photo_list.go b/api/native/photo_list.go index b22da98..a168d96 100644 --- a/api/native/photo_list.go +++ b/api/native/photo_list.go @@ -1,13 +1,15 @@ package native import ( + "context" + "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) { +func PhotoList(ctx context.Context, clt *core.SDKClient, accessToken string, req *native.PhotoListRequest) (*native.PhotoListResponse, error) { var resp native.PhotoListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/native/upload.go b/api/native/upload.go index e6fe286..e794a62 100644 --- a/api/native/upload.go +++ b/api/native/upload.go @@ -1,13 +1,15 @@ package native import ( + "context" + "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) { +func Upload(ctx context.Context, clt *core.SDKClient, accessToken string, req *native.UploadRequest) (*native.UploadResponse, error) { var resp native.UploadResponse - err := clt.Upload(accessToken, req, &resp) + err := clt.Upload(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/native/user_list.go b/api/native/user_list.go index b84729b..e3e9a3d 100644 --- a/api/native/user_list.go +++ b/api/native/user_list.go @@ -1,13 +1,15 @@ package native import ( + "context" + "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) { +func UserList(ctx context.Context, clt *core.SDKClient, accessToken string, req *native.UserListRequest) (*native.UserListResponse, error) { var resp native.UserListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/oauth/access_token.go b/api/oauth/access_token.go index 94bfea4..5e287e8 100644 --- a/api/oauth/access_token.go +++ b/api/oauth/access_token.go @@ -1,20 +1,22 @@ package oauth import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/oauth" ) // AccessToken 获取token // 利用授权码auth_code,请求快手服务器,获取access_token和refresh_token及当前账户的广告主ID。 -func AccessToken(clt *core.SDKClient, authCode string) (*oauth.AccessTokenResponse, error) { +func AccessToken(ctx context.Context, clt *core.SDKClient, authCode string) (*oauth.AccessTokenResponse, error) { req := &oauth.AccessTokenRequest{ AppID: clt.AppID(), Secret: clt.Secret(), AuthCode: authCode, } var resp oauth.AccessTokenResponse - err := clt.Post("", req, &resp) + err := clt.Post(ctx, "", req, &resp) if err != nil { return nil, err } diff --git a/api/oauth/approval_list.go b/api/oauth/approval_list.go index 7c32d49..3aad9cf 100644 --- a/api/oauth/approval_list.go +++ b/api/oauth/approval_list.go @@ -1,12 +1,14 @@ package oauth import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/oauth" ) // ApprovalList 拉取token下授权广告账户接口 -func ApprovalList(clt *core.SDKClient, accessToken string, pageNo int, pageSize int) ([]uint64, error) { +func ApprovalList(ctx context.Context, clt *core.SDKClient, accessToken string, pageNo int, pageSize int) ([]uint64, error) { req := &oauth.ApprovalListRequest{ AppID: clt.AppID(), Secret: clt.Secret(), @@ -15,7 +17,7 @@ func ApprovalList(clt *core.SDKClient, accessToken string, pageNo int, pageSize PageSize: pageSize, } var resp oauth.ApprovalListResponse - err := clt.Post("", req, &resp) + err := clt.Post(ctx, "", req, &resp) if err != nil { return nil, err } diff --git a/api/oauth/refresh_token.go b/api/oauth/refresh_token.go index 90c7a7e..f6a90ef 100644 --- a/api/oauth/refresh_token.go +++ b/api/oauth/refresh_token.go @@ -1,20 +1,22 @@ package oauth import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/oauth" ) // RefreshToken 刷新tonken // 请求快手服务器,刷新access_token和refresh_token及token过期时间。 -func RefreshToken(clt *core.SDKClient, refreshToken string) (*oauth.AccessTokenResponse, error) { +func RefreshToken(ctx context.Context, clt *core.SDKClient, refreshToken string) (*oauth.AccessTokenResponse, error) { req := &oauth.RefreshTokenRequest{ AppID: clt.AppID(), Secret: clt.Secret(), RefreshToken: refreshToken, } var resp oauth.AccessTokenResponse - err := clt.Post("", req, &resp) + err := clt.Post(ctx, "", req, &resp) if err != nil { return nil, err } diff --git a/api/oauth/url.go b/api/oauth/url.go index 40212bf..88bdfc7 100644 --- a/api/oauth/url.go +++ b/api/oauth/url.go @@ -1,6 +1,7 @@ package oauth import ( + "context" "strings" "github.com/bububa/kwai-marketing-api/core" @@ -8,7 +9,7 @@ import ( ) // Url 生成授权链接 -func Url(clt *core.SDKClient, req *oauth.UrlRequest) string { +func Url(ctx context.Context, clt *core.SDKClient, req *oauth.UrlRequest) string { req.AppID = clt.AppID() var builder strings.Builder builder.WriteString(core.OAUTH_URL) diff --git a/api/page/batch_give.go b/api/page/batch_give.go index 6bbe23b..b41a427 100644 --- a/api/page/batch_give.go +++ b/api/page/batch_give.go @@ -1,14 +1,16 @@ package page import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/page" ) // BatchGive 批量转赠 -func BatchGive(clt *core.SDKClient, accessToken string, req *page.BatchGiveRequest) error { +func BatchGive(ctx context.Context, clt *core.SDKClient, accessToken string, req *page.BatchGiveRequest) error { var resp page.BatchGiveResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return err } if resp.IsError() { diff --git a/api/page/cid_info_update.go b/api/page/cid_info_update.go index 013dd87..020596f 100644 --- a/api/page/cid_info_update.go +++ b/api/page/cid_info_update.go @@ -1,14 +1,16 @@ package page import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/page" ) // CidInfoUpdate 魔力建站落地页更新CID信息 -func CidInfoUpdate(clt *core.SDKClient, accessToken string, req *page.CidInfoUpdateRequest) (uint64, error) { +func CidInfoUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *page.CidInfoUpdateRequest) (uint64, error) { var resp page.CidInfoUpdateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return 0, err } return resp.PageID.Value(), nil diff --git a/api/page/list.go b/api/page/list.go index 892f6e9..a063d52 100644 --- a/api/page/list.go +++ b/api/page/list.go @@ -1,14 +1,16 @@ package page import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/page" ) // List 获取魔力建站落地页组信息列表 -func List(clt *core.SDKClient, accessToken string, req *page.ListRequest) (*page.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *page.ListRequest) (*page.ListResponse, error) { var resp page.ListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/region/district_list.go b/api/region/district_list.go index ab76d59..32790de 100644 --- a/api/region/district_list.go +++ b/api/region/district_list.go @@ -1,17 +1,19 @@ package region import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/region" ) // DistrictList 获取商圈地域定向 -func DistrictList(clt *core.SDKClient, accessToken string, advertiserID uint64) (map[string]region.District, error) { +func DistrictList(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID uint64) (map[string]region.District, error) { req := ®ion.DistrictListRequest{ AdvertiserID: advertiserID, } resp := make(map[string]region.District) - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/region/list.go b/api/region/list.go index c25b980..1db3ba4 100644 --- a/api/region/list.go +++ b/api/region/list.go @@ -1,15 +1,17 @@ package region import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/region" ) // List 获取地域定向 -func List(clt *core.SDKClient, accessToken string) (map[string]region.Region, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string) (map[string]region.Region, error) { req := ®ion.ListRequest{} resp := make(map[string]region.Region) - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/account_report.go b/api/report/account_report.go index cab757a..4dcde4c 100644 --- a/api/report/account_report.go +++ b/api/report/account_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report" ) // AccountReport 广告主数据(实时) -func AccountReport(clt *core.SDKClient, accessToken string, req *report.AccountReportRequest) (*report.ReportResponse, error) { +func AccountReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.AccountReportRequest) (*report.ReportResponse, error) { var resp report.ReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/agent_report.go b/api/report/agent_report.go index daee2ae..7057530 100644 --- a/api/report/agent_report.go +++ b/api/report/agent_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report" ) // AgentReport 代理商数据(t-1数据需要第二天9点以后获取) -func AgentReport(clt *core.SDKClient, accessToken string, req *report.AgentReportRequest) (*report.AgentReportResponse, error) { +func AgentReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.AgentReportRequest) (*report.AgentReportResponse, error) { var resp report.AgentReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/asynctask/create.go b/api/report/asynctask/create.go index 5a65d49..16d355b 100644 --- a/api/report/asynctask/create.go +++ b/api/report/asynctask/create.go @@ -1,14 +1,16 @@ package asynctask import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report/asynctask" ) // Create 创建历史数据查询任务 -func Create(clt *core.SDKClient, accessToken string, req *asynctask.CreateRequest) (*asynctask.CreateResponse, error) { +func Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *asynctask.CreateRequest) (*asynctask.CreateResponse, error) { var resp asynctask.CreateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/asynctask/download.go b/api/report/asynctask/download.go index 0af3ac8..a724207 100644 --- a/api/report/asynctask/download.go +++ b/api/report/asynctask/download.go @@ -1,10 +1,12 @@ package asynctask import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report/asynctask" ) -func Download(clt *core.SDKClient, accessToken string, req *asynctask.DownloadRequest) ([]byte, error) { - return clt.GetBytes(accessToken, req) +func Download(ctx context.Context, clt *core.SDKClient, accessToken string, req *asynctask.DownloadRequest) ([]byte, error) { + return clt.GetBytes(ctx, accessToken, req) } diff --git a/api/report/asynctask/list.go b/api/report/asynctask/list.go index 72c5034..26cad96 100644 --- a/api/report/asynctask/list.go +++ b/api/report/asynctask/list.go @@ -1,13 +1,15 @@ package asynctask import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report/asynctask" ) -func List(clt *core.SDKClient, accessToken string, req *asynctask.ListRequest) (*asynctask.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *asynctask.ListRequest) (*asynctask.ListResponse, error) { var resp asynctask.ListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/audience_report.go b/api/report/audience_report.go index 7cc3e41..2191b77 100644 --- a/api/report/audience_report.go +++ b/api/report/audience_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report" ) // AudienceReport 人群分析报表 -func AudienceReport(clt *core.SDKClient, accessToken string, req *report.AudienceReportRequest) (*report.ReportResponse, error) { +func AudienceReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.AudienceReportRequest) (*report.ReportResponse, error) { var resp report.ReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/campaign_report.go b/api/report/campaign_report.go index f821071..d3b42ab 100644 --- a/api/report/campaign_report.go +++ b/api/report/campaign_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report" ) // CampaignReport 广告计划数据(实时) -func CampaignReport(clt *core.SDKClient, accessToken string, req *report.CampaignReportRequest) (*report.ReportResponse, error) { +func CampaignReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.CampaignReportRequest) (*report.ReportResponse, error) { var resp report.ReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/creative_report.go b/api/report/creative_report.go index ec45efb..f983ea5 100644 --- a/api/report/creative_report.go +++ b/api/report/creative_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report" ) // CreativeReport 广告创意数据-自定义 -func CreativeReport(clt *core.SDKClient, accessToken string, req *report.CreativeReportRequest) (*report.ReportResponse, error) { +func CreativeReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.CreativeReportRequest) (*report.ReportResponse, error) { var resp report.ReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/material_report.go b/api/report/material_report.go index f8d5e31..8398f6a 100644 --- a/api/report/material_report.go +++ b/api/report/material_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report" ) // MaterialReport 素材报表 -func MaterialReport(clt *core.SDKClient, accessToken string, req *report.MaterialReportRequest) (*report.ReportResponse, error) { +func MaterialReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.MaterialReportRequest) (*report.ReportResponse, error) { var resp report.MaterialReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/merchant_detail_report.go b/api/report/merchant_detail_report.go index 1a8c587..fb5857e 100644 --- a/api/report/merchant_detail_report.go +++ b/api/report/merchant_detail_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report" ) // MerchantDetailReport 小店通转化数据报表 -func MerchantDetailReport(clt *core.SDKClient, accessToken string, req *report.MerchantDetailReportRequest) (*report.MerchantDetailReportResponse, error) { +func MerchantDetailReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.MerchantDetailReportRequest) (*report.MerchantDetailReportResponse, error) { var resp report.MerchantDetailReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/program_creative_report.go b/api/report/program_creative_report.go index 873f548..4343a81 100644 --- a/api/report/program_creative_report.go +++ b/api/report/program_creative_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report" ) // ProgramCreativeReport 程序化创意2.0数据 -func ProgramCreativeReport(clt *core.SDKClient, accessToken string, req *report.ProgramCreativeReportRequest) (*report.ReportResponse, error) { +func ProgramCreativeReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.ProgramCreativeReportRequest) (*report.ReportResponse, error) { var resp report.ReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/query_word_report.go b/api/report/query_word_report.go index ecbe525..199d595 100644 --- a/api/report/query_word_report.go +++ b/api/report/query_word_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report" ) // QueryWordReport 搜索词报表 -func QueryWordReport(clt *core.SDKClient, accessToken string, req *report.QueryWordReportRequest) (*report.ReportResponse, error) { +func QueryWordReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.QueryWordReportRequest) (*report.ReportResponse, error) { var resp report.ReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/unit_report.go b/api/report/unit_report.go index 3caafdb..8d1b0fd 100644 --- a/api/report/unit_report.go +++ b/api/report/unit_report.go @@ -1,14 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report" ) // UnitReport 广告组数据 -func UnitReport(clt *core.SDKClient, accessToken string, req *report.UnitReportRequest) (*report.ReportResponse, error) { +func UnitReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.UnitReportRequest) (*report.ReportResponse, error) { var resp report.ReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/report/word_info_report.go b/api/report/word_info_report.go index e218037..1d158d6 100644 --- a/api/report/word_info_report.go +++ b/api/report/word_info_report.go @@ -1,15 +1,16 @@ package report import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/report" ) - // WordInfoReport 关键词报表 -func WordInfoReport(clt *core.SDKClient, accessToken string, req *report.WordInfoReportRequest) (*report.ReportResponse, error) { +func WordInfoReport(ctx context.Context, clt *core.SDKClient, accessToken string, req *report.WordInfoReportRequest) (*report.ReportResponse, error) { var resp report.ReportResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/search/word_info_list.go b/api/search/word_info_list.go index 08d974b..8f042bb 100644 --- a/api/search/word_info_list.go +++ b/api/search/word_info_list.go @@ -1,14 +1,16 @@ package search import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/search" ) // WordInfoList 获取关键词列表 -func WordInfoList(clt *core.SDKClient, accessToken string, req *search.WordInfoListRequest) (*search.WordInfoListResponse, error) { +func WordInfoList(ctx context.Context, clt *core.SDKClient, accessToken string, req *search.WordInfoListRequest) (*search.WordInfoListResponse, error) { var resp search.WordInfoListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/target/template_create.go b/api/target/template_create.go index 828bff5..56f3499 100644 --- a/api/target/template_create.go +++ b/api/target/template_create.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/target" ) // TemplateCreate 创建定向模板 -func TemplateCreate(clt *core.SDKClient, accessToken string, req *target.TemplateCreateRequest) (*target.Template, error) { +func TemplateCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateCreateRequest) (*target.Template, error) { var resp target.Template - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/target/template_delete.go b/api/target/template_delete.go index 2901f92..7e68f83 100644 --- a/api/target/template_delete.go +++ b/api/target/template_delete.go @@ -1,11 +1,13 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/target" ) // TemplateDelete 删除定向模板 -func TemplateDelete(clt *core.SDKClient, accessToken string, req *target.TemplateDeleteRequest) error { - return clt.Post(accessToken, req, nil) +func TemplateDelete(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateDeleteRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/target/template_list.go b/api/target/template_list.go index b641a0c..cf7e99d 100644 --- a/api/target/template_list.go +++ b/api/target/template_list.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/target" ) // TemplateList 查询定向模板接口 -func TemplateList(clt *core.SDKClient, accessToken string, req *target.TemplateListRequest) (*target.TemplateListResponse, error) { +func TemplateList(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateListRequest) (*target.TemplateListResponse, error) { var resp target.TemplateListResponse - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/target/template_update.go b/api/target/template_update.go index 058f719..c38066c 100644 --- a/api/target/template_update.go +++ b/api/target/template_update.go @@ -1,14 +1,16 @@ package target import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/target" ) // TemplateUpdate 修改定向模板 -func TemplateUpdate(clt *core.SDKClient, accessToken string, req *target.TemplateUpdateRequest) (*target.Template, error) { +func TemplateUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *target.TemplateUpdateRequest) (*target.Template, error) { var resp target.Template - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/target_v2/template_list.go b/api/target_v2/template_list.go index 3dbfb86..f6955e4 100644 --- a/api/target_v2/template_list.go +++ b/api/target_v2/template_list.go @@ -1,14 +1,16 @@ package target_v2 import ( + "context" + "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) { +func TemplateDetails(ctx context.Context, clt *core.SDKClient, accessToken string, req *target_v2.TemplateDetailsRequest) (*target_v2.TemplateDetailsResponse, error) { var resp target_v2.TemplateDetailsResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/tool/app_search.go b/api/tool/app_search.go index b3e8fdb..4e24b5c 100644 --- a/api/tool/app_search.go +++ b/api/tool/app_search.go @@ -1,14 +1,16 @@ package tool import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool" ) // AppSearch 获取可选的应用定向 -func AppSearch(clt *core.SDKClient, accessToken string, req *tool.AppSearchRequest) (*tool.TargetingApp, error) { +func AppSearch(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.AppSearchRequest) (*tool.TargetingApp, error) { var resp tool.TargetingApp - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/tool/audience_predict.go b/api/tool/audience_predict.go index d5d8c2c..f9da425 100644 --- a/api/tool/audience_predict.go +++ b/api/tool/audience_predict.go @@ -1,14 +1,16 @@ package tool import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool" ) // AudiencePredict 定向人群预估查询 -func AudiencePredict(clt *core.SDKClient, accessToken string, req *tool.AudiencePredictRequest) (int64, error) { +func AudiencePredict(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.AudiencePredictRequest) (int64, error) { var resp tool.AudiencePredictResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/tool/convert_list.go b/api/tool/convert_list.go index 47699e6..ba21e3d 100644 --- a/api/tool/convert_list.go +++ b/api/tool/convert_list.go @@ -1,14 +1,16 @@ package tool import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool" ) // ConvertList 获取可用的转化目标 -func ConvertList(clt *core.SDKClient, accessToken string, req *tool.ConvertListRequest) (*tool.ConvertListResponse, error) { +func ConvertList(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.ConvertListRequest) (*tool.ConvertListResponse, error) { var resp tool.ConvertListResponse - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/tool/creative_word_list.go b/api/tool/creative_word_list.go index 5007144..7e10806 100644 --- a/api/tool/creative_word_list.go +++ b/api/tool/creative_word_list.go @@ -1,17 +1,19 @@ package tool import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool" ) // CreativeWordList 获取可选的动态词包 -func CreativeWordList(clt *core.SDKClient, accessToken string, advertiserID uint64) ([]tool.CreativeWord, error) { +func CreativeWordList(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID uint64) ([]tool.CreativeWord, error) { req := &tool.CreativeWordListRequest{ AdvertiserID: advertiserID, } var resp []tool.CreativeWord - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/tool/creative_word_styles.go b/api/tool/creative_word_styles.go index a156e3e..3c708b6 100644 --- a/api/tool/creative_word_styles.go +++ b/api/tool/creative_word_styles.go @@ -1,17 +1,19 @@ package tool import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool" ) // CreativeWordStyles 获取可选的封面贴纸样式 -func CreativeWordStyles(clt *core.SDKClient, accessToken string, advertiserID uint64) ([]tool.CreativeWordStyle, error) { +func CreativeWordStyles(ctx context.Context, clt *core.SDKClient, accessToken string, advertiserID uint64) ([]tool.CreativeWordStyle, error) { req := &tool.CreativeWordStylesRequest{ AdvertiserID: advertiserID, } var resp []tool.CreativeWordStyle - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/tool/key_frame.go b/api/tool/key_frame.go index c70820a..3064d28 100644 --- a/api/tool/key_frame.go +++ b/api/tool/key_frame.go @@ -1,14 +1,16 @@ package tool import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool" ) // KeyFrame 获取可选的推荐封面 -func KeyFrame(clt *core.SDKClient, accessToken string, req *tool.KeyFrameRequest) ([]string, error) { +func KeyFrame(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.KeyFrameRequest) ([]string, error) { var resp []string - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/tool/operation_record_list.go b/api/tool/operation_record_list.go index fd43f8c..b468f02 100644 --- a/api/tool/operation_record_list.go +++ b/api/tool/operation_record_list.go @@ -1,14 +1,16 @@ package tool import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool" ) // OperationRecordList 账户操作记录信息查询 -func OperationRecordList(clt *core.SDKClient, accessToken string, req *tool.OperationRecordListRequest) (*tool.OperationRecordListResponse, error) { +func OperationRecordList(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.OperationRecordListRequest) (*tool.OperationRecordListResponse, error) { var resp tool.OperationRecordListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/tool/preput/predication_task_create.go b/api/tool/preput/predication_task_create.go index 3cc8904..d1be564 100644 --- a/api/tool/preput/predication_task_create.go +++ b/api/tool/preput/predication_task_create.go @@ -1,14 +1,16 @@ package preput import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool/preput" ) // PredicationTaskCreate 创建投前预估任务 -func PredicationTaskCreate(clt *core.SDKClient, accessToken string, req *preput.PredicationTaskCreateRequest) (*preput.RealTaskResult, error) { +func PredicationTaskCreate(ctx context.Context, clt *core.SDKClient, accessToken string, req *preput.PredicationTaskCreateRequest) (*preput.RealTaskResult, error) { var resp preput.RealTaskResult - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/tool/preput/predication_task_details.go b/api/tool/preput/predication_task_details.go index 7848f6d..b365e76 100644 --- a/api/tool/preput/predication_task_details.go +++ b/api/tool/preput/predication_task_details.go @@ -1,14 +1,16 @@ package preput import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool/preput" ) // PredicationTaskDetails 投前预估详情 -func PredicationTaskDetails(clt *core.SDKClient, accessToken string, req *preput.PredicationTaskCreateRequest) (*preput.AdPredicationTaskDetail, error) { +func PredicationTaskDetails(ctx context.Context, clt *core.SDKClient, accessToken string, req *preput.PredicationTaskCreateRequest) (*preput.AdPredicationTaskDetail, error) { var resp preput.AdPredicationTaskDetail - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/tool/preput/predication_task_list.go b/api/tool/preput/predication_task_list.go index f266c4e..fbcbd65 100644 --- a/api/tool/preput/predication_task_list.go +++ b/api/tool/preput/predication_task_list.go @@ -1,14 +1,16 @@ package preput import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool/preput" ) // PredicationTaskList 投前预估列表页接口 -func PredicationTaskList(clt *core.SDKClient, accessToken string, req *preput.PredicationTaskListRequest) (*preput.PredicationTaskListResponse, error) { +func PredicationTaskList(ctx context.Context, clt *core.SDKClient, accessToken string, req *preput.PredicationTaskListRequest) (*preput.PredicationTaskListResponse, error) { var resp preput.PredicationTaskListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/tool/preput/predication_task_management.go b/api/tool/preput/predication_task_management.go index fb39409..3f234ee 100644 --- a/api/tool/preput/predication_task_management.go +++ b/api/tool/preput/predication_task_management.go @@ -1,14 +1,16 @@ package preput import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool/preput" ) // PredicationTaskManagement 投前预估任务管理接口 -func PredicationTaskManagement(clt *core.SDKClient, accessToken string, req *preput.PredicationTaskManagementRequest) (*preput.RealTaskResult, error) { +func PredicationTaskManagement(ctx context.Context, clt *core.SDKClient, accessToken string, req *preput.PredicationTaskManagementRequest) (*preput.RealTaskResult, error) { var resp preput.RealTaskResult - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/tool/quota_info.go b/api/tool/quota_info.go index 47c0f2b..b83fc2c 100644 --- a/api/tool/quota_info.go +++ b/api/tool/quota_info.go @@ -1,14 +1,16 @@ package tool import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool" ) // MAPI Quota 白盒化 https://developers.e.kuaishou.com/docs?docType=DSP&documentId=2244 -func QuotaInfo(clt *core.SDKClient, accessToken string, req *tool.QuotaInfoRequest) (*tool.QuotaInfoResponse, error) { +func QuotaInfo(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.QuotaInfoRequest) (*tool.QuotaInfoResponse, error) { var resp tool.QuotaInfoResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/tool/targeting_tags_list.go b/api/tool/targeting_tags_list.go index 6fe63c7..4293e73 100644 --- a/api/tool/targeting_tags_list.go +++ b/api/tool/targeting_tags_list.go @@ -1,14 +1,16 @@ package tool import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool" ) // TargetingTagsList 获取可选的定向标签 -func TargetingTagsList(clt *core.SDKClient, accessToken string, req *tool.TargetingTagsListRequest) (*tool.TargetingTag, error) { +func TargetingTagsList(ctx context.Context, clt *core.SDKClient, accessToken string, req *tool.TargetingTagsListRequest) (*tool.TargetingTag, error) { var resp tool.TargetingTag - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/tool/unit/bid_predict.go b/api/tool/unit/bid_predict.go index 3156d9d..7ff5fef 100644 --- a/api/tool/unit/bid_predict.go +++ b/api/tool/unit/bid_predict.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool/unit" ) // BidPredict 获取广告组曝光、转化预估 -func BidPredict(clt *core.SDKClient, accessToken string, req *unit.BidPredictRequest) (*unit.BidPredict, error) { +func BidPredict(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.BidPredictRequest) (*unit.BidPredict, error) { var resp unit.BidPredict - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/tool/unit/bid_trend_predict_detail.go b/api/tool/unit/bid_trend_predict_detail.go index 1b0e3bb..b4d8328 100644 --- a/api/tool/unit/bid_trend_predict_detail.go +++ b/api/tool/unit/bid_trend_predict_detail.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool/unit" ) // BidTrendPredictDetail 获取广告组投放预估曲线 -func BidTrendPredictDetail(clt *core.SDKClient, accessToken string, req *unit.BidTrendPredictDetailRequest) (*unit.BidTrendPredict, error) { +func BidTrendPredictDetail(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.BidTrendPredictDetailRequest) (*unit.BidTrendPredict, error) { var resp unit.BidTrendPredict - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/tool/unit/suggest_bid_detail.go b/api/tool/unit/suggest_bid_detail.go index 2fdf346..a5a39c7 100644 --- a/api/tool/unit/suggest_bid_detail.go +++ b/api/tool/unit/suggest_bid_detail.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/tool/unit" ) // SuggestBidDetail 获取广告组出价建议 -func SuggestBidDetail(clt *core.SDKClient, accessToken string, req *unit.SuggestBidDetailRequest) ([]unit.SuggestBidUnit, error) { +func SuggestBidDetail(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.SuggestBidDetailRequest) ([]unit.SuggestBidUnit, error) { var resp []unit.SuggestBidUnit - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp, nil diff --git a/api/unit/create.go b/api/unit/create.go index f3184b7..b57dd7e 100644 --- a/api/unit/create.go +++ b/api/unit/create.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/unit" ) // Create 创建广告组 -func Create(clt *core.SDKClient, accessToken string, req *unit.CreateRequest) (uint64, error) { +func Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.CreateRequest) (uint64, error) { var resp unit.CreateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/unit/create_union.go b/api/unit/create_union.go index b1cbb9c..a133314 100644 --- a/api/unit/create_union.go +++ b/api/unit/create_union.go @@ -1,6 +1,8 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/unit" ) @@ -9,9 +11,9 @@ import ( // 【注】白名单账户支持定投联盟广告,创建广告组接口不变,有以下几点限制: // 1. 仅支持计划类型为“提升应用安装”;“收集销售线索”;“获取电商下单”“提高应用活跃”的广告; // 2. 仅支持部分定向;3. 转化目标参数convert_id、深度转化目标deep_conversion_type有特殊要求。 -func CreateUnion(clt *core.SDKClient, accessToken string, req *unit.CreateUnionRequest) (uint64, error) { +func CreateUnion(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.CreateUnionRequest) (uint64, error) { var resp unit.CreateUnionResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/unit/list.go b/api/unit/list.go index 89dbf86..624999d 100644 --- a/api/unit/list.go +++ b/api/unit/list.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/unit" ) // List 获取广告组信息 -func List(clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) { var resp unit.ListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/unit/ocpc_conversion_infos.go b/api/unit/ocpc_conversion_infos.go index 9943160..57e36ed 100644 --- a/api/unit/ocpc_conversion_infos.go +++ b/api/unit/ocpc_conversion_infos.go @@ -1,15 +1,17 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/unit" ) // OcpcConversionInfos 获取可选的深度转化目标 // 新门槛标准: 1.应用下载类—— 1)账户维度,相应的 event_type 回传 >=1; 或2)应用包维度,用转化追踪联调通过相应的 event_type 2.落地页类 账户维度,相应的 event_type 回传 >=1; -func OcpcConversionInfos(clt *core.SDKClient, accessToken string, req *unit.OcpcConversionInfosRequest) (*unit.OcpcConversionInfosResponse, error) { +func OcpcConversionInfos(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.OcpcConversionInfosRequest) (*unit.OcpcConversionInfosResponse, error) { var resp unit.OcpcConversionInfosResponse - err := clt.Get(accessToken, req, &resp) + err := clt.Get(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/unit/update.go b/api/unit/update.go index 69bcefe..b5806d5 100644 --- a/api/unit/update.go +++ b/api/unit/update.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/unit" ) // Update 修改广告组 -func Update(clt *core.SDKClient, accessToken string, req *unit.UpdateRequest) (uint64, error) { +func Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateRequest) (uint64, error) { var resp unit.UpdateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/unit/update_bid.go b/api/unit/update_bid.go index 0d92c38..781af97 100644 --- a/api/unit/update_bid.go +++ b/api/unit/update_bid.go @@ -1,11 +1,13 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/unit" ) // UpdateBid 修改广告组出价 -func UpdateBid(clt *core.SDKClient, accessToken string, req *unit.UpdateBidRequest) error { - return clt.Post(accessToken, req, nil) +func UpdateBid(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateBidRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/unit/update_day_budget.go b/api/unit/update_day_budget.go index 2075f52..83470cc 100644 --- a/api/unit/update_day_budget.go +++ b/api/unit/update_day_budget.go @@ -1,11 +1,13 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/unit" ) // UpdateDayBudget 修改广告组预算 -func UpdateDayBudget(clt *core.SDKClient, accessToken string, req *unit.UpdateDayBudgetRequest) error { - return clt.Post(accessToken, req, nil) +func UpdateDayBudget(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateDayBudgetRequest) error { + return clt.Post(ctx, accessToken, req, nil) } diff --git a/api/unit/update_status.go b/api/unit/update_status.go index 681e838..826b523 100644 --- a/api/unit/update_status.go +++ b/api/unit/update_status.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/unit" ) // UpdateStatus 修改广告组状态 -func UpdateStatus(clt *core.SDKClient, accessToken string, req *unit.UpdateStatusRequest) ([]uint64, error) { +func UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateStatusRequest) ([]uint64, error) { var resp unit.UpdateStatusResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/unit/update_union.go b/api/unit/update_union.go index 26f189a..d97a044 100644 --- a/api/unit/update_union.go +++ b/api/unit/update_union.go @@ -1,15 +1,17 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/unit" ) // UpdateUnion 修改联盟定投广告组 // 【注】白名单账户支持定投联盟广告,修改广告组接口不变,有以下限制:1. 仅支持部分定向。 -func UpdateUnion(clt *core.SDKClient, accessToken string, req *unit.UpdateUnionRequest) (uint64, error) { +func UpdateUnion(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.UpdateUnionRequest) (uint64, error) { var resp unit.UpdateUnionResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/v2.2/campaign/create.go b/api/v2.2/campaign/create.go index 2b0d4dd..692cae1 100644 --- a/api/v2.2/campaign/create.go +++ b/api/v2.2/campaign/create.go @@ -1,14 +1,16 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/v2.2/campaign" ) // Create 创建广告计划 -func Create(clt *core.SDKClient, accessToken string, req *campaign.CreateRequest) (uint64, error) { +func Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.CreateRequest) (uint64, error) { var resp campaign.CreateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/v2.2/campaign/list.go b/api/v2.2/campaign/list.go index 7dd5863..2ce1ca6 100644 --- a/api/v2.2/campaign/list.go +++ b/api/v2.2/campaign/list.go @@ -1,14 +1,16 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/v2.2/campaign" ) // List 查询广告计划 -func List(clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.ListRequest) (*campaign.ListResponse, error) { var resp campaign.ListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/v2.2/campaign/status_update.go b/api/v2.2/campaign/status_update.go index b195c0c..02dbddd 100644 --- a/api/v2.2/campaign/status_update.go +++ b/api/v2.2/campaign/status_update.go @@ -1,15 +1,16 @@ package campaign - import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/v2.2/campaign" ) // Create 创建广告组 -func StatusUpdate(clt *core.SDKClient, accessToken string, req *campaign.StatusUpdateRequest) ([]uint64, error) { +func StatusUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.StatusUpdateRequest) ([]uint64, error) { var resp campaign.StatusUpdateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/v2.2/campaign/update.go b/api/v2.2/campaign/update.go index 65fa6da..3e9a522 100644 --- a/api/v2.2/campaign/update.go +++ b/api/v2.2/campaign/update.go @@ -1,14 +1,16 @@ package campaign import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/v2.2/campaign" ) // Update 更新广告计划 -func Update(clt *core.SDKClient, accessToken string, req *campaign.UpdateRequest) (uint64, error) { +func Update(ctx context.Context, clt *core.SDKClient, accessToken string, req *campaign.UpdateRequest) (uint64, error) { var resp campaign.UpdateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/v2.2/creative/create.go b/api/v2.2/creative/create.go index b801fc8..5b08888 100644 --- a/api/v2.2/creative/create.go +++ b/api/v2.2/creative/create.go @@ -1,15 +1,17 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/v2.2/creative" ) // Create 创建创意 // 【注】联盟广告不支持便利贴图片素材,只有联盟广告支持横版竖版图片素材。 -func Create(clt *core.SDKClient, accessToken string, req *creative.CreateRequest) (uint64, error) { +func Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.CreateRequest) (uint64, error) { var resp creative.CreateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/v2.2/creative/list.go b/api/v2.2/creative/list.go index 0458d59..ecc4cc1 100644 --- a/api/v2.2/creative/list.go +++ b/api/v2.2/creative/list.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/v2.2/creative" ) // List 查询广告创意 -func List(clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.ListRequest) (*creative.ListResponse, error) { var resp creative.ListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/v2.2/creative/list_advanced_creative.go b/api/v2.2/creative/list_advanced_creative.go index c32cb18..789f263 100644 --- a/api/v2.2/creative/list_advanced_creative.go +++ b/api/v2.2/creative/list_advanced_creative.go @@ -1,14 +1,16 @@ package creative import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/v2.2/creative" ) // AdvancedCreativeList 查询程序化广告创意 -func AdvancedCreativeList(clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeListRequest) (*creative.ListAdvancedCreativeResponse, error) { +func AdvancedCreativeList(ctx context.Context, clt *core.SDKClient, accessToken string, req *creative.AdvancedCreativeListRequest) (*creative.ListAdvancedCreativeResponse, error) { var resp creative.ListAdvancedCreativeResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/v2.2/unit/bid_updte.go b/api/v2.2/unit/bid_updte.go index f5a4095..31654d4 100644 --- a/api/v2.2/unit/bid_updte.go +++ b/api/v2.2/unit/bid_updte.go @@ -1,13 +1,15 @@ package unit import ( + "context" + "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) { +func BidUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.BidUpdateRequest) ([]uint64, error) { var resp unit.BidUpdateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/v2.2/unit/budget_update.go b/api/v2.2/unit/budget_update.go index 7a94a5e..273f156 100644 --- a/api/v2.2/unit/budget_update.go +++ b/api/v2.2/unit/budget_update.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "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) { +func BudgetUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.BudgetUpdateRequest) ([]uint64, error) { var resp unit.BudgetUpdateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/v2.2/unit/create.go b/api/v2.2/unit/create.go index 2c2746d..15213ed 100644 --- a/api/v2.2/unit/create.go +++ b/api/v2.2/unit/create.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/v2.2/unit" ) // Create 创建广告组 -func Create(clt *core.SDKClient, accessToken string, req *unit.CreateRequest) (uint64, error) { +func Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.CreateRequest) (uint64, error) { var resp unit.CreateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return 0, err } diff --git a/api/v2.2/unit/list.go b/api/v2.2/unit/list.go index 3397e96..ceddf31 100644 --- a/api/v2.2/unit/list.go +++ b/api/v2.2/unit/list.go @@ -1,14 +1,16 @@ package unit import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/v2.2/unit" ) // List 查询广告组 -func List(clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.ListRequest) (*unit.ListResponse, error) { var resp unit.ListResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/v2.2/unit/status_update.go b/api/v2.2/unit/status_update.go index 529ad91..39f478b 100644 --- a/api/v2.2/unit/status_update.go +++ b/api/v2.2/unit/status_update.go @@ -1,15 +1,16 @@ package unit - import ( + "context" + "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) { +func StatusUpdate(ctx context.Context, clt *core.SDKClient, accessToken string, req *unit.StatusUpdateRequest) ([]uint64, error) { var resp unit.StatusUpdateResponse - err := clt.Post(accessToken, req, &resp) + err := clt.Post(ctx, accessToken, req, &resp) if err != nil { return nil, err } diff --git a/api/wordinfo/create.go b/api/wordinfo/create.go index fe076a6..da8462a 100644 --- a/api/wordinfo/create.go +++ b/api/wordinfo/create.go @@ -1,14 +1,16 @@ package wordinfo import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/wordinfo" ) // Create 创建关键词 -func Create(clt *core.SDKClient, accessToken string, req *wordinfo.CreateRequest) (*wordinfo.CreateResponse, error) { +func Create(ctx context.Context, clt *core.SDKClient, accessToken string, req *wordinfo.CreateRequest) (*wordinfo.CreateResponse, error) { var resp wordinfo.CreateResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/wordinfo/list.go b/api/wordinfo/list.go index 4b725a7..02938d0 100644 --- a/api/wordinfo/list.go +++ b/api/wordinfo/list.go @@ -1,14 +1,16 @@ package wordinfo import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/wordinfo" ) // List 获取关键词列表 -func List(clt *core.SDKClient, accessToken string, req *wordinfo.ListRequest) (*wordinfo.ListResponse, error) { +func List(ctx context.Context, clt *core.SDKClient, accessToken string, req *wordinfo.ListRequest) (*wordinfo.ListResponse, error) { var resp wordinfo.ListResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return &resp, nil diff --git a/api/wordinfo/update_match_type.go b/api/wordinfo/update_match_type.go index 2eabc97..903c856 100644 --- a/api/wordinfo/update_match_type.go +++ b/api/wordinfo/update_match_type.go @@ -1,14 +1,16 @@ package wordinfo import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/wordinfo" ) // UpdateMatchType 修改关键词匹配方式 -func UpdateMatchType(clt *core.SDKClient, accessToken string, req *wordinfo.UpdateMatchTypeRequest) ([]uint64, error) { +func UpdateMatchType(ctx context.Context, clt *core.SDKClient, accessToken string, req *wordinfo.UpdateMatchTypeRequest) ([]uint64, error) { var resp wordinfo.UpdateMatchTypeResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp.WordInfoIDs, nil diff --git a/api/wordinfo/update_status.go b/api/wordinfo/update_status.go index aa6adc5..a5a6195 100644 --- a/api/wordinfo/update_status.go +++ b/api/wordinfo/update_status.go @@ -1,14 +1,16 @@ package wordinfo import ( + "context" + "github.com/bububa/kwai-marketing-api/core" "github.com/bububa/kwai-marketing-api/model/wordinfo" ) // UpdateStatus 修改关键词投放状态 -func UpdateStatus(clt *core.SDKClient, accessToken string, req *wordinfo.UpdateStatusRequest) ([]uint64, error) { +func UpdateStatus(ctx context.Context, clt *core.SDKClient, accessToken string, req *wordinfo.UpdateStatusRequest) ([]uint64, error) { var resp wordinfo.UpdateStatusResponse - if err := clt.Post(accessToken, req, &resp); err != nil { + if err := clt.Post(ctx, accessToken, req, &resp); err != nil { return nil, err } return resp.WordInfoIDs, nil diff --git a/core/client.go b/core/client.go index 06bed7b..d5f5436 100644 --- a/core/client.go +++ b/core/client.go @@ -2,23 +2,46 @@ package core import ( "bytes" + "context" "encoding/json" "fmt" "io" "mime/multipart" "net/http" "strings" + "sync" + "time" "github.com/bububa/kwai-marketing-api/core/internal/debug" "github.com/bububa/kwai-marketing-api/model" ) +var ( + onceInit sync.Once + httpClient *http.Client +) + +func defaultHttpClient() *http.Client { + onceInit.Do(func() { + transport := http.DefaultTransport.(*http.Transport).Clone() + transport.MaxIdleConns = 100 + transport.MaxConnsPerHost = 100 + transport.MaxIdleConnsPerHost = 100 + httpClient = &http.Client{ + Transport: transport, + Timeout: time.Second * 60, + } + }) + return httpClient +} + // SDKClient api client type SDKClient struct { - appID uint64 + client *http.Client + tracer *Otel secret string + appID uint64 debug bool - client *http.Client } // NewSDKClient init sdk client @@ -26,7 +49,7 @@ func NewSDKClient(appID uint64, secret string) *SDKClient { return &SDKClient{ appID: appID, secret: secret, - client: http.DefaultClient, + client: defaultHttpClient(), } } @@ -49,6 +72,10 @@ func (c *SDKClient) SetHttpClient(client *http.Client) { c.client = client } +func (c *SDKClient) WithTracer(namespace string) { + c.tracer = NewOtel(namespace, c.AppID()) +} + // PostUrl post请求地址 func (c *SDKClient) PostUrl(req model.PostRequest) string { return fmt.Sprintf("%s/%s", BASE_URL, req.Url()) @@ -65,14 +92,14 @@ func (c *SDKClient) UploadUrl(req model.UploadRequest) string { } // Post execute post api request -func (c *SDKClient) Post(accessToken string, req model.PostRequest, resp interface{}) error { +func (c *SDKClient) Post(ctx context.Context, accessToken string, req model.PostRequest, resp interface{}) error { var reqResp model.Response if v, ok := resp.(model.Response); ok { reqResp = v } else { reqResp = &model.BaseResponse{} } - err := c.post(accessToken, c.PostUrl(req), req.Encode(), reqResp) + err := c.post(ctx, accessToken, c.PostUrl(req), req.Encode(), reqResp) if err != nil { return err } @@ -93,9 +120,9 @@ func (c *SDKClient) Post(accessToken string, req model.PostRequest, resp interfa } // Get execute get api request -func (c *SDKClient) Get(accessToken string, req model.GetRequest, resp interface{}) error { +func (c *SDKClient) Get(ctx context.Context, accessToken string, req model.GetRequest, resp interface{}) error { var reqResp model.BaseResponse - err := c.get(accessToken, c.GetUrl(req), &reqResp) + err := c.get(ctx, accessToken, c.GetUrl(req), &reqResp) if err != nil { return err } @@ -112,27 +139,32 @@ func (c *SDKClient) Get(accessToken string, req model.GetRequest, resp interface } // GetBytes get bytes api -func (c *SDKClient) GetBytes(accessToken string, req model.GetRequest) ([]byte, error) { +func (c *SDKClient) GetBytes(ctx context.Context, accessToken string, req model.GetRequest) ([]byte, error) { reqUrl := c.GetUrl(req) debug.PrintGetRequest(reqUrl, c.debug) - httpReq, err := http.NewRequest("GET", reqUrl, nil) + httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, reqUrl, nil) if err != nil { return nil, err } if accessToken != "" { httpReq.Header.Add("Access-Token", accessToken) } - httpResp, err := c.client.Do(httpReq) - if err != nil { - return nil, err - } - defer httpResp.Body.Close() - return io.ReadAll(httpResp.Body) + var ret []byte + c.WithSpan(ctx, httpReq, nil, nil, func(httpReq *http.Request, resp interface{}) (*http.Response, error) { + httpResp, err := c.client.Do(httpReq) + if err != nil { + return httpResp, err + } + defer httpResp.Body.Close() + ret, err = io.ReadAll(httpResp.Body) + return httpResp, err + }) + return ret, nil } -func (c *SDKClient) GetOnBody(accessToken string, req model.PostRequest, resp interface{}) error { +func (c *SDKClient) GetOnBody(ctx context.Context, accessToken string, req model.PostRequest, resp interface{}) error { var reqResp model.BaseResponse - err := c.getOnBody(accessToken, c.PostUrl(req), req.Encode(), &reqResp) + err := c.getOnBody(ctx, accessToken, c.PostUrl(req), req.Encode(), &reqResp) if err != nil { return err } @@ -149,7 +181,7 @@ func (c *SDKClient) GetOnBody(accessToken string, req model.PostRequest, resp in } // Upload multipart/form-data post -func (c *SDKClient) Upload(accessToken string, req model.UploadRequest, resp interface{}) error { +func (c *SDKClient) Upload(ctx context.Context, accessToken string, req model.UploadRequest, resp interface{}) error { var buf bytes.Buffer mw := multipart.NewWriter(&buf) params := req.Encode() @@ -180,7 +212,7 @@ func (c *SDKClient) Upload(accessToken string, req model.UploadRequest, resp int mw.Close() reqUrl := c.UploadUrl(req) debug.PrintPostMultipartRequest(reqUrl, mp, c.debug) - httpReq, err := http.NewRequest("POST", reqUrl, &buf) + httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, reqUrl, &buf) if err != nil { return err } @@ -189,14 +221,9 @@ func (c *SDKClient) Upload(accessToken string, req model.UploadRequest, resp int httpReq.Header.Add("Access-Token", accessToken) } - httpResp, err := c.client.Do(httpReq) - if err != nil { - return err - } - defer httpResp.Body.Close() var reqResp model.BaseResponse - err = debug.DecodeJSONHttpResponse(httpResp.Body, &reqResp, c.debug) - if err != nil { + bs, _ := json.Marshal(mp) + if err := c.WithSpan(ctx, httpReq, reqResp, bs, c.fetch); err != nil { debug.PrintError(err, c.debug) return err } @@ -213,9 +240,9 @@ func (c *SDKClient) Upload(accessToken string, req model.UploadRequest, resp int } // post data through api -func (c *SDKClient) post(accessToken string, reqUrl string, reqBytes []byte, resp interface{}) error { +func (c *SDKClient) post(ctx context.Context, accessToken string, reqUrl string, reqBytes []byte, resp interface{}) error { debug.PrintPostJSONRequest(reqUrl, reqBytes, c.debug) - httpReq, err := http.NewRequest("POST", reqUrl, bytes.NewReader(reqBytes)) + httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, reqUrl, bytes.NewReader(reqBytes)) if err != nil { return err } @@ -223,23 +250,13 @@ func (c *SDKClient) post(accessToken string, reqUrl string, reqBytes []byte, res httpReq.Header.Add("Access-Token", accessToken) } httpReq.Header.Add("Content-Type", "application/json") - httpResp, err := c.client.Do(httpReq) - if err != nil { - return err - } - defer httpResp.Body.Close() - err = debug.DecodeJSONHttpResponse(httpResp.Body, resp, c.debug) - if err != nil { - debug.PrintError(err, c.debug) - return err - } - return nil + return c.WithSpan(ctx, httpReq, resp, reqBytes, c.fetch) } // get data through api -func (c *SDKClient) get(accessToken string, reqUrl string, resp interface{}) error { +func (c *SDKClient) get(ctx context.Context, accessToken string, reqUrl string, resp interface{}) error { debug.PrintGetRequest(reqUrl, c.debug) - httpReq, err := http.NewRequest("GET", reqUrl, nil) + httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, reqUrl, nil) if err != nil { return err } @@ -247,22 +264,12 @@ func (c *SDKClient) get(accessToken string, reqUrl string, resp interface{}) err httpReq.Header.Add("Access-Token", accessToken) } httpReq.Header.Add("Content-Type", "application/json") - httpResp, err := c.client.Do(httpReq) - if err != nil { - return err - } - defer httpResp.Body.Close() - err = debug.DecodeJSONHttpResponse(httpResp.Body, resp, c.debug) - if err != nil { - debug.PrintError(err, c.debug) - return err - } - return nil + return c.WithSpan(ctx, httpReq, resp, nil, c.fetch) } -func (c *SDKClient) getOnBody(accessToken string, reqUrl string, reqBytes []byte, resp interface{}) error { +func (c *SDKClient) getOnBody(ctx context.Context, accessToken string, reqUrl string, reqBytes []byte, resp interface{}) error { debug.PrintPostJSONRequest(reqUrl, reqBytes, c.debug) - httpReq, err := http.NewRequest("GET", reqUrl, bytes.NewReader(reqBytes)) + httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, reqUrl, bytes.NewReader(reqBytes)) if err != nil { return err } @@ -270,15 +277,26 @@ func (c *SDKClient) getOnBody(accessToken string, reqUrl string, reqBytes []byte httpReq.Header.Add("Access-Token", accessToken) } httpReq.Header.Add("Content-Type", "application/json") + return c.WithSpan(ctx, httpReq, resp, reqBytes, c.fetch) +} + +func (c *SDKClient) fetch(httpReq *http.Request, resp interface{}) (*http.Response, error) { httpResp, err := c.client.Do(httpReq) if err != nil { - return err + return httpResp, err } defer httpResp.Body.Close() - err = debug.DecodeJSONHttpResponse(httpResp.Body, resp, c.debug) - if err != nil { + if err = debug.DecodeJSONHttpResponse(httpResp.Body, resp, c.debug); err != nil { debug.PrintError(err, c.debug) + return httpResp, err + } + return httpResp, nil +} + +func (c *SDKClient) WithSpan(ctx context.Context, req *http.Request, resp interface{}, payload []byte, fn func(*http.Request, interface{}) (*http.Response, error)) error { + if c.tracer == nil { + _, err := fn(req, resp) return err } - return nil + return c.tracer.WithSpan(ctx, req, resp, payload, fn) } diff --git a/core/otel.go b/core/otel.go new file mode 100644 index 0000000..e0ca4a5 --- /dev/null +++ b/core/otel.go @@ -0,0 +1,102 @@ +package core + +import ( + "context" + "fmt" + "net/http" + "strconv" + "time" + + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + semconv10 "go.opentelemetry.io/otel/semconv/v1.10.0" + semconv "go.opentelemetry.io/otel/semconv/v1.26.0" + "go.opentelemetry.io/otel/trace" +) + +const instrumentationName = "github.com/bububa/kwai-marketing-api" + +type Otel struct { + traceProvider trace.TracerProvider + tracer trace.Tracer + meterProvider metric.MeterProvider + meter metric.Meter + histogram metric.Int64Histogram + counter metric.Int64Counter + attrs []attribute.KeyValue +} + +func NewOtel(namespace string, appID uint64) *Otel { + ret := &Otel{ + traceProvider: otel.GetTracerProvider(), + meterProvider: otel.GetMeterProvider(), + attrs: []attribute.KeyValue{ + attribute.String("sdk", "kwai-marketing-api"), + attribute.String("appid", strconv.FormatUint(appID, 10)), + }, + } + if namespace == "" { + namespace = instrumentationName + } + ret.tracer = ret.traceProvider.Tracer(namespace) + ret.meter = ret.meterProvider.Meter(namespace) + if histogram, err := ret.meter.Int64Histogram( + semconv.HTTPClientRequestDurationName, + metric.WithDescription(semconv.HTTPClientRequestDurationDescription), + metric.WithUnit("milliseconds"), + ); err == nil { + ret.histogram = histogram + } + if counter, err := ret.meter.Int64Counter( + semconv.HTTPClientActiveRequestsName, + metric.WithDescription(semconv.HTTPClientActiveRequestsDescription), + metric.WithUnit(semconv.HTTPClientActiveRequestsUnit), + ); err == nil { + ret.counter = counter + } + return ret +} + +func (o *Otel) WithSpan(ctx context.Context, req *http.Request, resp interface{}, payload []byte, fn func(*http.Request, interface{}) (*http.Response, error)) error { + startTime := time.Now() + attrs := append(o.attrs, + semconv10.HTTPURLKey.String(req.URL.String()), + semconv10.HTTPMethodKey.String(req.Method), + semconv10.HTTPTargetKey.String(req.URL.Path), + semconv.URLFull(req.URL.String()), + semconv.HTTPRequestMethodKey.String(req.Method), + semconv.URLPath(req.URL.Path), + semconv.URLDomain(req.URL.Host), + semconv.HTTPRequestSizeKey.Int64(req.ContentLength), + ) + if payload != nil { + attrs = append(attrs, attribute.String("payload", string(payload))) + } + + _, span := o.tracer.Start(ctx, fmt.Sprintf("http.", req.Method), + trace.WithSpanKind(trace.SpanKindClient), + trace.WithAttributes(attrs...), + ) + defer span.End() + httpResp, err := fn(req, resp) + if o.histogram != nil { + o.histogram.Record(ctx, time.Since(startTime).Milliseconds(), metric.WithAttributes(o.attrs...)) + } + if o.counter != nil { + counterAttrs := append(o.attrs, semconv10.HTTPTargetKey.String(req.URL.Path)) + o.counter.Add(ctx, 1, metric.WithAttributes(counterAttrs...)) + } + if !span.IsRecording() { + return err + } + if httpResp != nil { + span.SetAttributes(semconv.HTTPResponseStatusCode(httpResp.StatusCode), semconv.HTTPResponseSizeKey.Int64(httpResp.ContentLength), semconv.NetworkProtocolName(httpResp.Proto)) + } + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, err.Error()) + } + return err +} diff --git a/go.mod b/go.mod index 3dac6c8..58c0cfd 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,14 @@ module github.com/bububa/kwai-marketing-api -go 1.19 +go 1.21 + +require ( + go.opentelemetry.io/otel v1.29.0 + go.opentelemetry.io/otel/metric v1.29.0 + go.opentelemetry.io/otel/trace v1.29.0 +) + +require ( + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e0171f9 --- /dev/null +++ b/go.sum @@ -0,0 +1,21 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= +go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8= +go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc= +go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8= +go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4= +go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/model/dsp/unit/target.go b/model/dsp/unit/target.go index 5f31105..bac66d3 100644 --- a/model/dsp/unit/target.go +++ b/model/dsp/unit/target.go @@ -44,7 +44,7 @@ type Target struct { // AppIDs APP 行为-按 APP 名称 // id 不能重复且必须准确,具体 id 可通过下方应用接口获取,建议不超过 10 个,否则可能出现报错;仅包含安卓数据,若操作系统定向 IOS 则无效;不能同时选择 app_interest。该定向仅支持快手站内广告位,不支持联盟广告位。 AppIDs []uint64 `json:"app_ids,omitempty"` - // FilterConvertedLevel 过滤已转化人群纬度 + // FilterConvertedLevel 过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP 6:运营自定义产品名 7:企微号 // 搜索广告、联盟广告、小店通不支持。优化目标不支持【封面曝光数】和【封面点击数】非应用下载类推广不支持过滤【APP】纬度。0(默认):不限;1:广告组 2:广告计划;3:本账户;4:公司主体;5:APP;6:运营自定义产品名 FilterConvertedLevel int `json:"filter_converted_level,omitempty"` // Population 人群包定向