Documentation ¶
Index ¶
- Constants
- Variables
- func AddBizHeader(req *http.Request, token, sign, timestamp string)
- func AddBodyBizHeader(req *http.Request, token, sign, timestamp string)
- func AddEasyHeader(req *http.Request, sign, timestamp string)
- func DoAPIRequest(a APIRequest, resp interface{}) error
- func DoRequest(req *http.Request, resp interface{}) error
- func GetBizSign(token, timestamp string) string
- func GetEasySign(timestamp string) string
- func GetRefreshToken() (string, error)
- func GetTimestamp() string
- func GetToken() (string, error)
- func HmacSha256(data, key string) string
- func NewHTTPRequest(a APIRequest) (*http.Request, error)
- func SetTestEnv()
- func SetToken(token, refreshToken string, expire int)
- type APIRequest
- type ExampleData
- type GetTokenAPIResponse
- type GetTokenReq
- type Info
- type RefreshTokenReq
- type RefreshTokenResponse
- type RequestBody
- type TokenManage
Constants ¶
View Source
const RequestDelete = "DELETE"
View Source
const RequestGet = "GET"
View Source
const RequestPost = "POST"
View Source
const RequestPut = "PUT"
View Source
const URLCN = "https://openapi.tuyacn.com"
cn
View Source
const URLEU = "https://openapi.tuyaeu.com"
eu
View Source
const URLIN = "https://openapi.tuyain.com"
in
View Source
const URLUS = "https://openapi.tuyaus.com"
us
Variables ¶
View Source
var Ed = ExampleData{}
test data example
View Source
var ErrorGetTokenFailed = errors.New("get token failed")
View Source
var LocalToken = Info{Mu: &sync.RWMutex{}}
Functions ¶
func AddBizHeader ¶
func AddBodyBizHeader ¶
func AddEasyHeader ¶
func DoAPIRequest ¶
func DoAPIRequest(a APIRequest, resp interface{}) error
func GetBizSign ¶
func GetEasySign ¶
func GetRefreshToken ¶
func GetTimestamp ¶
func GetTimestamp() string
func HmacSha256 ¶
func NewHTTPRequest ¶
func NewHTTPRequest(a APIRequest) (*http.Request, error)
func SetTestEnv ¶
func SetTestEnv()
Types ¶
type APIRequest ¶
type ExampleData ¶
type ExampleData struct { TestDataAccessID string TestDataAccessKey string TestDataUID string TestDataDeviceID string TestDataTimeZoneID string TestDataThirdCloudDeviceId string TestDataCountryCode string TestDataAppSchema string TestDataTuyaUsername string TestDataTuyaProductId string TestDataParentDeviceId string TestDataPassword string TestDataSchema string }
type GetTokenAPIResponse ¶
type GetTokenAPIResponse struct { Success bool `json:"success"` // error info Code int `json:"code"` Msg string `json:"msg"` T int64 `json:"t"` Result struct { ExpireTime int `json:"expire_time"` UID string `json:"uid"` AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` } `json:"result"` }
func GetTokenAPI ¶
func GetTokenAPI() (*GetTokenAPIResponse, error)
type GetTokenReq ¶
type GetTokenReq struct { }
func (*GetTokenReq) API ¶
func (t *GetTokenReq) API() string
func (*GetTokenReq) Method ¶
func (t *GetTokenReq) Method() string
type RefreshTokenReq ¶
type RefreshTokenReq struct {
// contains filtered or unexported fields
}
func (*RefreshTokenReq) API ¶
func (t *RefreshTokenReq) API() string
func (*RefreshTokenReq) Method ¶
func (t *RefreshTokenReq) Method() string
type RefreshTokenResponse ¶
type RefreshTokenResponse struct { Success bool `json:"success"` // error info Code int `json:"code"` Msg string `json:"msg"` T int64 `json:"t"` Result struct { ExpireTime int `json:"expire_time"` UID string `json:"uid"` AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` } `json:"result"` }
func DoRefreshToken ¶
func DoRefreshToken() (*RefreshTokenResponse, error)
DoRefreshToken To refresh token
type RequestBody ¶
type RequestBody interface {
Body() []byte
}
type TokenManage ¶
TokenLocalManage token of local cache manage
var TokenLocalCache TokenManage = &tokenLocalCache{}
Click to show internal directories.
Click to hide internal directories.