From b688b909e879c8ab89403ef0adfb5367897f0b94 Mon Sep 17 00:00:00 2001 From: liangzy Date: Tue, 4 Aug 2020 12:23:34 +0800 Subject: [PATCH] init project --- sdk/client.go | 14 ++++++++++++++ sdk/requests/common_request.go | 17 +++++++++++++++++ sdk/requests/http_request.go | 16 ++++++++++++++++ sdk/requests/request.go | 6 ++++++ services/jedi/client.go | 17 +++++++++++++++-- services/jedi/send_sms.go | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 100 insertions(+), 2 deletions(-) diff --git a/sdk/client.go b/sdk/client.go index f7f1e86..b7ef8f6 100644 --- a/sdk/client.go +++ b/sdk/client.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/auth" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/auth/credentials" "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" "net" @@ -28,6 +29,19 @@ type Client struct { config *Config } +func (client *Client) InitClientConfig() (config *Config) { + +} + +func (client *Client) InitWithAccessKey(accessKeyId, accessKeySecret, source string) (err error) { + config := client.InitWithConfig() + credential := &credentials.BaseCredential{ + AccessKeyId: accessKeyId, + AccessKeySecret: accessKeySecret, + } + return client.InitWithOptions("", config, credential) +} + func (client *Client) InitWithOptions(host string, config *Config, credential auth.Credential) (err error) { client.httpClient = &http.Client{} diff --git a/sdk/requests/common_request.go b/sdk/requests/common_request.go index f442971..cbf1d65 100644 --- a/sdk/requests/common_request.go +++ b/sdk/requests/common_request.go @@ -2,4 +2,21 @@ package requests type CommonRequest struct { *baseRequest + Product string + Ontology AcsRequest +} + +func (request *CommonRequest) TransToAscRequest() { + httpReqeust := &HttpRequest{} + httpReqeust.baseRequest = request.baseRequest + httpReqeust.product = request.Product + request.Ontology = httpReqeust +} + +func (request *CommonRequest) BuildUrl() string { + return request.Ontology.BuildUrl() +} + +func (request *CommonRequest) BuildQueries() string { + return request.Ontology.BuildQueries() } diff --git a/sdk/requests/http_request.go b/sdk/requests/http_request.go index 44e87ad..c1bacf2 100644 --- a/sdk/requests/http_request.go +++ b/sdk/requests/http_request.go @@ -4,6 +4,11 @@ type HttpRequest struct { *baseRequest } +func (request *HttpRequest) init() { + request.baseRequest = defaultBaseRequest() + request.Method = POST +} + func (request *HttpRequest) BuildUrl() string { return "" } @@ -11,3 +16,14 @@ func (request *HttpRequest) BuildUrl() string { func (request *HttpRequest) BuildQueries() string { return "" } + +func (request *HttpRequest) GetActionName() string { + return request.actionName +} + +func (request *HttpRequest) InitWithApiInfo(product, version, action string) { + request.init() + request.product = product + request.version = version + request.actionName = action +} diff --git a/sdk/requests/request.go b/sdk/requests/request.go index e6ae2cb..d8611e6 100644 --- a/sdk/requests/request.go +++ b/sdk/requests/request.go @@ -46,6 +46,7 @@ type AcsRequest interface { GetMethod() string GetScheme() string GetDomain() string + GetActionName() string BuildUrl() string BuildQueries() string @@ -67,6 +68,7 @@ type baseRequest struct { isInsecure *bool AcceptFormat string + actionName string userAgent map[string]string product string @@ -81,6 +83,10 @@ type baseRequest struct { stringToSign string } +func (request *baseRequest) GetActionName() string { + return request.actionName +} + func (request *baseRequest) SetScheme(scheme string) { request.Scheme = scheme } diff --git a/services/jedi/client.go b/services/jedi/client.go index 70705df..24336d2 100644 --- a/services/jedi/client.go +++ b/services/jedi/client.go @@ -2,10 +2,23 @@ package jedi import "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk" +const ( + PRODUCT = "jedi" + VERSION = "2020-08-04" +) + type Client struct { sdk.Client } -func NewClientWithAccessKey(accesskey, secrect string) *Client { - return nil +func (c *Client) SendSms(req *SendSmsRequest) (response *SendSmsResponse, err error) { + response = CreateSendSmsResponse() + err = c.DoAction(req, response) + return +} + +func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) { + client = &Client{} + err = client.InitWithOptions("", nil, "") + return } diff --git a/services/jedi/send_sms.go b/services/jedi/send_sms.go index 7148051..122c4f5 100644 --- a/services/jedi/send_sms.go +++ b/services/jedi/send_sms.go @@ -1 +1,33 @@ package jedi + +import ( + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" +) + +type SendSmsRequest struct { + *requests.HttpRequest + User string `position:"Query" name:"User" default:""` + Code string `position:"Query" name:"Code" default:"-"` + Prams string `position:"Query" name:"Prams" default:"-"` +} + +type SendSmsResponse struct { + *responses.BaseResponse + BizId string `json:"BizId"` +} + +func CreateSendSmsRequest() (req *SendSmsRequest) { + req = &SendSmsRequest{ + HttpRequest: &requests.HttpRequest{}, + } + req.InitWithApiInfo(PRODUCT, VERSION, "/api/sms/send") + return +} + +func CreateSendSmsResponse() (response *SendSmsResponse) { + response = &SendSmsResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +}