7
0

init project

This commit is contained in:
liangzy 2020-08-04 12:23:34 +08:00
parent cd5642dbb7
commit b688b909e8
6 changed files with 100 additions and 2 deletions

View File

@ -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{}

View File

@ -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()
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}