新增母包Android SDK 支持版本获取 & 打包任务创建接口
This commit is contained in:
parent
5d941b865b
commit
857f7b9f90
@ -15,6 +15,7 @@ type JsonRequest struct {
|
||||
|
||||
func (request *JsonRequest) init() {
|
||||
request.baseRequest = defaultBaseRequest()
|
||||
request.baseRequest.AddHeaderParam("Content-Type", Json)
|
||||
request.Method = POST
|
||||
}
|
||||
|
||||
@ -35,7 +36,7 @@ func (request *JsonRequest) BuildUrl() string {
|
||||
}
|
||||
|
||||
func (request *JsonRequest) GetStyle() string {
|
||||
return RPC
|
||||
return STREAM
|
||||
}
|
||||
|
||||
func (request *JsonRequest) BuildQueries() string {
|
||||
@ -60,8 +61,8 @@ func (request *JsonRequest) InitWithApiInfo(domain Host, version, urlPath string
|
||||
}
|
||||
|
||||
func (request *JsonRequest) GetBodyReader() io.Reader {
|
||||
if request.FormParams != nil && len(request.FormParams) > 0 {
|
||||
body, err := json.Marshal(request.FormParams)
|
||||
if request.JsonParams != nil && len(request.JsonParams) > 0 {
|
||||
body, err := json.Marshal(request.JsonParams)
|
||||
if err == nil {
|
||||
return bytes.NewReader(body)
|
||||
}
|
||||
|
@ -32,15 +32,17 @@ const (
|
||||
HEAD = "HEAD"
|
||||
OPTIONS = "OPTIONS"
|
||||
|
||||
Json = "application/json"
|
||||
Xml = "application/xml"
|
||||
Raw = "application/octet-stream"
|
||||
Form = "application/x-www-form-urlencoded"
|
||||
Json = "application/json"
|
||||
Xml = "application/xml"
|
||||
Raw = "application/octet-stream"
|
||||
Form = "application/x-www-form-urlencoded"
|
||||
FormData = "multipart/form-data"
|
||||
|
||||
Header = "Header"
|
||||
Query = "Query"
|
||||
Body = "Body"
|
||||
Path = "Path"
|
||||
Header = "Header"
|
||||
Query = "Query"
|
||||
Body = "Body"
|
||||
BodyJson = "Json"
|
||||
Path = "Path"
|
||||
|
||||
TEST = "TEST"
|
||||
PRE = "PRE"
|
||||
@ -95,6 +97,7 @@ type AcsRequest interface {
|
||||
AddHeaderParam(key, value string)
|
||||
addQueryParam(key, value string)
|
||||
addFormParam(key, value string)
|
||||
addJsonParam(string, any)
|
||||
}
|
||||
|
||||
type baseRequest struct {
|
||||
@ -118,6 +121,7 @@ type baseRequest struct {
|
||||
QueryParams map[string]string
|
||||
Headers map[string]string
|
||||
FormParams map[string]string
|
||||
JsonParams map[string]any
|
||||
Content []byte
|
||||
|
||||
queries string
|
||||
@ -230,6 +234,10 @@ func (request *baseRequest) addFormParam(key, val string) {
|
||||
request.FormParams[key] = val
|
||||
}
|
||||
|
||||
func (request *baseRequest) addJsonParam(key string, val any) {
|
||||
request.JsonParams[key] = val
|
||||
}
|
||||
|
||||
func defaultBaseRequest() (request *baseRequest) {
|
||||
request = &baseRequest{
|
||||
Scheme: HTTP,
|
||||
@ -242,6 +250,7 @@ func defaultBaseRequest() (request *baseRequest) {
|
||||
"Accept-Encoding": Json,
|
||||
},
|
||||
FormParams: make(map[string]string),
|
||||
JsonParams: make(map[string]any),
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -290,14 +299,14 @@ func flatRepeatedList(reflectValue reflect.Value, request AcsRequest, position s
|
||||
value = fieldDefault
|
||||
}
|
||||
|
||||
err = addParam(request, fieldPosition, name, value)
|
||||
err = addParam(request, fieldPosition, name, value, reflectValue.Field(i).Interface())
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func addParam(request AcsRequest, position, key, value string) (err error) {
|
||||
func addParam(request AcsRequest, position, key, value string, vAny any) (err error) {
|
||||
if len(value) > 0 {
|
||||
switch position {
|
||||
case Header:
|
||||
@ -306,6 +315,8 @@ func addParam(request AcsRequest, position, key, value string) (err error) {
|
||||
request.addQueryParam(key, value)
|
||||
case Body:
|
||||
request.addFormParam(key, value)
|
||||
case BodyJson:
|
||||
request.addJsonParam(key, vAny)
|
||||
default:
|
||||
errmsg := fmt.Sprintf("unsupport positions add param `%s`", position)
|
||||
err = errors.New(errmsg)
|
||||
|
@ -13,6 +13,7 @@ type RpcRequest struct {
|
||||
|
||||
func (request *RpcRequest) init() {
|
||||
request.baseRequest = defaultBaseRequest()
|
||||
request.baseRequest.AddHeaderParam("Content-Type", Form)
|
||||
request.Method = POST
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ type StreamRequest struct {
|
||||
|
||||
func (s *StreamRequest) init() {
|
||||
s.baseRequest = defaultBaseRequest()
|
||||
s.baseRequest.AddHeaderParam("Content-Type", "application/form-data")
|
||||
s.baseRequest.AddHeaderParam("Content-Type", FormData)
|
||||
s.Method = POST
|
||||
}
|
||||
|
||||
|
30
services/capk/client.go
Normal file
30
services/capk/client.go
Normal file
@ -0,0 +1,30 @@
|
||||
package capk
|
||||
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
)
|
||||
|
||||
const (
|
||||
VERSION = "2024-10-30"
|
||||
)
|
||||
|
||||
var HOST requests.Host = requests.Host{
|
||||
Default: "capk.gaore.com",
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
sdk.Client
|
||||
}
|
||||
|
||||
func NewClient() (client *Client, err error) {
|
||||
client = new(Client)
|
||||
err = client.Init()
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) TaskCreate(req *TaskCreateRequest) (resp *TaskCreateResponse, err error) {
|
||||
resp = CreateTaskCreateResponse()
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
}
|
18
services/capk/client_test.go
Normal file
18
services/capk/client_test.go
Normal file
@ -0,0 +1,18 @@
|
||||
package capk
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestTask_Create(t *testing.T) {
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
req := CreateTaskCreateRequest()
|
||||
req.GameId = 7788
|
||||
req.GameVersion = "1.0.1"
|
||||
req.Config = "{\"data\":{\"sdkPath\":\"\",\"localPath\":\"\",\"plugins\":{\"addictioncheck\":\"\",\"msaid\":\"\",\"bugly\":\"\",\"gdt\":\"\",\"gdt_channel\":\"\"},\"decompileApk\":\"\"},\"game\":{\"appID\":\"7477\",\"appName\":\"xyxmz_xlhh_ylh\",\"appKey\":\"yWpx3hWQHFhSnTCj#7477#6KuRKuaAjLJ5sYRy\",\"appDescNew\":\"西游仙魔传\",\"orientation\":\"landscape\",\"cpuSupport\":\"armeabi-v7a|arm64-v8a\",\"minSdkVersion\":\"21\",\"targetSdkVersion\":\"31\",\"outputApkName\":\"{appName}_{appID}_{versionCode}_{versionName}_{time}.apk\",\"gameCategory\":\"25|771-2.0.4.3\",\"icon\":\"\",\"logoPath\":\"\",\"loadingPath\":\"\",\"certificatePath\":\"\"},\"channel\":{\"id\":\"1\",\"name\":\"gaore\",\"sdk\":\"gaore\",\"desc\":\"GRSDK\",\"suffix\":\"com.bjhr.xyxmz\",\"splash\":\"0\",\"splash_copy_to_unity\":\"0\",\"sdkParams\":{\"SCREEN_ORIENTATION\":\"0\",\"GAORE_CHANNELID\":\"1\",\"GAORE_VERSION_TAG\":\"1\",\"GAORE_LOGO_SHOW\":\"1\",\"GAORE_CHANNEL_KEY\":\"GRSDK\",\"GAORE_GAME_VERSION\":\"1.0.0\",\"GAORE_APPLICATION_PROXY_NAME\":\"com.gr.sdk.GaoreApplication,com.gr.sdk.MSAApplication,com.gr.sdk.addictioncheck.application.GaoreApplication,com.gr.sdk.BuglyProxyApplication,com.gr.sdk.GDTProxyApplication,com.gr.sdk.GDTChannelProxyApplication\",\"GAORE_WX_APP_ID\":\"\",\"GAORE_FLOAT_POSITION\":\"0|30\",\"GAORE_ROUND_ICON\":\"0\",\"GAORE_ROUND_ICON_PATH\":\"\",\"GAORE_ROUND_ICON_FOREGROUND_PATH\":\"\",\"GAORE_ROUND_ICON_BACKGROUND_PATH\":\"\",\"GR_AGEWARN\":\"true\",\"GR_REDPACKET\":\"1\",\"GR_REDPACKET_GUIDE\":\"1\",\"GAORE_INIT_SDK_TYPE\":\"2\",\"appkey_avscan\":\"\",\"seckey_avscan\":\"\",\"GDT_USER_ACTION_SET_ID\":\"1203968086\",\"GDT_APP_SECRET_KEY\":\"8ad271167be3dcf120468770a4ee9b21\",\"GISM_APPID\":\"\",\"GISM_APPNAME\":\"\",\"QL_APPID\":\"\",\"KUAISHOU_APPID\":\"\",\"KUAISHOU_APPNAME\":\"\",\"TOUTIAO_AID\":\"\",\"addPermissionActivity\":\"1\",\"VIVO_SRC_ID\":\"\"},\"sdkVersion\":{\"versionName\":\"2.6.1\"},\"plugins\":{\"addictioncheck\":\"\",\"msaid\":\"\",\"bugly\":\"\",\"gdt\":\"\",\"gdt_channel\":\"\"}}}"
|
||||
req.Env = 0 // 灰度为 1 正式为0
|
||||
resp, err := client.TaskCreate(req)
|
||||
t.Logf("%v", resp.Data.TaskId)
|
||||
}
|
38
services/capk/task_create.go
Normal file
38
services/capk/task_create.go
Normal file
@ -0,0 +1,38 @@
|
||||
package capk
|
||||
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||
)
|
||||
|
||||
type TaskCreateRequest struct {
|
||||
*requests.JsonRequest
|
||||
GameId int `position:"Json" field:"game_id"`
|
||||
GameVersion string `position:"Json" field:"game_version"`
|
||||
Config string `position:"Json" field:"config"`
|
||||
Env int `position:"Json" field:"env"`
|
||||
}
|
||||
|
||||
type TaskCreateResponse struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
TaskId string `json:"task_id"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
func CreateTaskCreateRequest() (req *TaskCreateRequest) {
|
||||
req = &TaskCreateRequest{
|
||||
JsonRequest: &requests.JsonRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/pack/task/create")
|
||||
return
|
||||
}
|
||||
|
||||
func CreateTaskCreateResponse() (resp *TaskCreateResponse) {
|
||||
resp = &TaskCreateResponse{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
return
|
||||
}
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
type GetApkVersionRequest struct {
|
||||
*requests.JsonRequest
|
||||
Filepath string `position:"Body" field:"filepath"`
|
||||
Filepath string `position:"Json" field:"filepath"`
|
||||
}
|
||||
|
||||
type GetApkVersionResponse struct {
|
||||
@ -15,8 +15,10 @@ type GetApkVersionResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
VersionCode string `json:"versionCode"`
|
||||
VersionName string `json:"versionName"`
|
||||
VersionCode string `json:"versionCode"`
|
||||
VersionName string `json:"versionName"`
|
||||
MinSdkVersion string `json:"minSdkVersion"`
|
||||
TargetSdkVersion string `json:"targetSdkVersion"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ func TestCreateInitMultipartUpload(t *testing.T) {
|
||||
|
||||
func TestClient_GetApkVersion(t *testing.T) {
|
||||
req := CreateGetApkVersionRequest()
|
||||
req.Filepath = "36c55c4c3a2f4c79e3917b989d580496.zip"
|
||||
req.Filepath = "51c68615b8d21f9b72b02f48c400cb87.zip"
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -15,12 +15,12 @@ const (
|
||||
|
||||
type InitMultipartUploadRequest struct {
|
||||
*requests.JsonRequest
|
||||
UploadType string `position:"Body" field:"upload_type"`
|
||||
TargetType string `position:"Body" field:"target_type"`
|
||||
TargetName string `position:"Body" field:"target_name"`
|
||||
FileHash string `position:"Body" field:"file_hash"`
|
||||
Filepath string `position:"Body" field:"filepath"`
|
||||
ExtInfo string `position:"Body" field:"ext_info"`
|
||||
UploadType string `position:"Json" field:"upload_type"`
|
||||
TargetType string `position:"Json" field:"target_type"`
|
||||
TargetName string `position:"Json" field:"target_name"`
|
||||
FileHash string `position:"Json" field:"file_hash"`
|
||||
Filepath string `position:"Json" field:"filepath"`
|
||||
ExtInfo string `position:"Json" field:"ext_info"`
|
||||
}
|
||||
|
||||
type InitMultipartUploadResponse struct {
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
|
||||
type DelOssRequest struct {
|
||||
*requests.JsonRequest
|
||||
BucketName string `position:"Body" field:"bucket_name" default:"image"`
|
||||
MediaUrl string `position:"Body" field:"url" default:"-"`
|
||||
BucketName string `position:"Json" field:"bucket_name" default:"image"`
|
||||
MediaUrl string `position:"Json" field:"url" default:"-"`
|
||||
}
|
||||
|
||||
type DelOssResponse struct {
|
||||
|
Loading…
Reference in New Issue
Block a user