-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package advertiser | ||
|
||
import ( | ||
"github.com/bububa/oceanengine/marketing-api/core" | ||
"github.com/bububa/oceanengine/marketing-api/model/advertiser" | ||
) | ||
|
||
// AvatarSubmit 更新广告主账户头像 | ||
func AvatarSubmit(clt *core.SDKClient, accessToken string, req *advertiser.AvatarSubmitRequest) error { | ||
// var resp advertiser.AvatarSubmitResponse | ||
return clt.Post("2/advertiser/avatar/submit/", req, nil, accessToken) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package advertiser | ||
|
||
import ( | ||
"github.com/bububa/oceanengine/marketing-api/core" | ||
"github.com/bububa/oceanengine/marketing-api/model/advertiser" | ||
) | ||
|
||
// AvatarUpload 获取广告主账户头像ID | ||
// 本接口用户获取广告主账户头像的image_id,您可使用该id调用「更新广告主账户头像」接口完成账户头像更新 | ||
// 【注意】本接口的功能仅用于获取image_id,上传成功 ≠ 更新头像,更新头像的接口是「更新广告主账户头像」接口 | ||
func AvatarUpload(clt *core.SDKClient, accessToken string, req *advertiser.AvatarUploadRequest) (string, error) { | ||
var resp advertiser.AvatarUploadResponse | ||
if err := clt.Upload("2/advertiser/avatar/upload/", req, &resp, accessToken); err != nil { | ||
return "", err | ||
} | ||
return resp.Data.ImageID, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package advertiser | ||
|
||
import ( | ||
"github.com/bububa/oceanengine/marketing-api/model" | ||
"github.com/bububa/oceanengine/marketing-api/util" | ||
) | ||
|
||
// AvatarSubmitRequest 更新广告主账户头像 API Request | ||
type AvatarSubmitRequest struct { | ||
// AdvertiserID 广告主ID | ||
AdvertiserID uint64 `json:"advertiser_id,omitempty"` | ||
// ImageID 账户头像id,例:web.business.image/201910225d0d5a39ae2e246645b486 | ||
// 您可调用「获取广告主账户头像ID」接口获取头像的image_id | ||
// 格式:jpg/jpeg/png/bmp | ||
// 大小:<=5M | ||
// 像素:<=300*300 | ||
ImageID string `json:"image_id,omitempty"` | ||
// SourceInfo 品牌名称 | ||
SourceInfo string `json:"source_info,omitempty"` | ||
} | ||
|
||
// Encode implement PostRequest interface | ||
func (r AvatarSubmitRequest) Encode() []byte { | ||
return util.JSONMarshal(r) | ||
} | ||
|
||
// AvatarSubmitResponse 更新广告主账户头像 API Response | ||
type AvatarSubmitResponse struct { | ||
model.BaseResponse | ||
Data struct { | ||
// AdvertiserID 更新头像成功的广告主账户id | ||
AdvertiserID model.Uint64 `json:"advertiser_id,omitempty"` | ||
} `json:"data,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package advertiser | ||
|
||
import ( | ||
"io" | ||
"strconv" | ||
|
||
"github.com/bububa/oceanengine/marketing-api/model" | ||
) | ||
|
||
// AvatarUploadRequest 获取广告主账户头像ID API Request | ||
type AvatarUploadRequest struct { | ||
// AdvertiserID 广告主账户id | ||
AdvertiserID uint64 `json:"advertiser_id,omitempty"` | ||
// ImageData 图片数据 | ||
// 格式要求:bmp,jpeg,jpg,png | ||
// 文件大小:<=5M | ||
// 像素:<=300*300 | ||
ImageData io.Reader `json:"image_data,omitempty"` | ||
// Filename 文件名 | ||
Filename string `json:"filename,omitempty"` | ||
} | ||
|
||
// Encode implement UploadReqeust interface | ||
func (r AvatarUploadRequest) Encode() []model.UploadField { | ||
ret := make([]model.UploadField, 0, 4) | ||
ret = append(ret, model.UploadField{ | ||
Key: "advertiser_id", | ||
Value: strconv.FormatUint(r.AdvertiserID, 10), | ||
}) | ||
ret = append(ret, model.UploadField{ | ||
Key: "image_file", | ||
Value: r.Filename, | ||
Reader: r.ImageData, | ||
}) | ||
return ret | ||
} | ||
|
||
// AvatarUploadResponse 获取广告主账户头像ID API Response | ||
type AvatarUploadResponse struct { | ||
model.BaseResponse | ||
Data struct { | ||
// ImageID 账户头像图片ID,您可使用此ID前往「更新广告主账户头像」接口更新头像 | ||
ImageID string `json:"image_id,omitempty"` | ||
} `json:"data,omitempty"` | ||
} |