opensdk

package
v0.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2020 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExecuteYet = errors.New("not execute yet.")
)

Functions

func DefaultDecoder

func DefaultDecoder(data []byte, dataFormat string, out *Params) (err error)

func MD5

func MD5(s string) (string, error)

func PKCS12ToPem added in v0.1.14

func PKCS12ToPem(p12 []byte, password string) tls.Certificate

将Pkcs12转成Pem

func RandomString

func RandomString(n int) string

func Sha1

func Sha1(s string) (string, error)

func Sha256Hmac

func Sha256Hmac(s string, k []byte) (string, error)

func Sha256RSA

func Sha256RSA(origData string, key *rsa.PrivateKey) (string, error)

func ToGBK

func ToGBK(src []byte) io.Reader

func ToGBKData

func ToGBKData(src []byte) []byte

func ToUTF8

func ToUTF8(src []byte) io.Reader

func ToUTF8Data

func ToUTF8Data(src []byte) ([]byte, error)

Types

type Client

type Client interface {
	Sign(params, signType string) (string, error)
	VerifySign(params, signType string) (bool, error)
	// ff
	HttpClient(twowayAuthentication bool) (*http.Client, error)
}

type ClientBase added in v0.1.14

type ClientBase struct {
	GetHttpClient func(twowayAuthentication bool) (*http.Client, error)
	// contains filtered or unexported fields
}

func (*ClientBase) HttpClient added in v0.1.14

func (c *ClientBase) HttpClient(twowayAuthentication bool) (*http.Client, error)

type DefaultExecutor

type DefaultExecutor struct {
	Params
	Client       Client
	BuildRequest func(*DefaultExecutor) (req *http.Request, err error)

	Decoder    func(data []byte, dataFormat string, out *Params) (err error)
	TLS        bool
	DataFormat string
	Err        error
	APIURL     string
	HTTPMethod string
	// contains filtered or unexported fields
}

func (*DefaultExecutor) Execute

func (e *DefaultExecutor) Execute(verifySign ...bool) (res Results)

func (*DefaultExecutor) ResultValidator

func (e *DefaultExecutor) ResultValidator(f func(Params) (ok bool, code string, msg string, subcode string, submsg string)) Executor

func (*DefaultExecutor) Set

func (e *DefaultExecutor) Set(filed string, value interface{}) Executor

func (*DefaultExecutor) SetNotifyURL

func (e *DefaultExecutor) SetNotifyURL(url string, filedName ...string) Executor

SetNotifyURL 设置接口服务器主动通知调用服务器里指定的页面http/https路径。

func (*DefaultExecutor) UseTwowayAuthentication added in v0.1.14

func (e *DefaultExecutor) UseTwowayAuthentication(b bool) Executor

func (*DefaultExecutor) UseXML

func (e *DefaultExecutor) UseXML(b bool) Executor

type DefaultResults

type DefaultResults struct {
	Params
	Err           error
	Data          []byte `json:"-"`
	ResultCode    string
	ResultMsg     string
	ResultSubCode string
	ResultSubMsg  string
	ResultSuccess bool
}

func (*DefaultResults) Body

func (r *DefaultResults) Body() []byte

func (*DefaultResults) Code

func (r *DefaultResults) Code() string

func (*DefaultResults) Error

func (r *DefaultResults) Error() error

func (*DefaultResults) Get

func (r *DefaultResults) Get(key string) utils.Converter

func (*DefaultResults) Message

func (r *DefaultResults) Message() string

func (*DefaultResults) SubCode

func (r *DefaultResults) SubCode() string

func (*DefaultResults) SubMessage

func (r *DefaultResults) SubMessage() string

func (*DefaultResults) Success

func (r *DefaultResults) Success() bool

func (*DefaultResults) Values

func (r *DefaultResults) Values() Params

type Executor

type Executor interface {
	// Execute 执行请求并返回结果。
	// verifySign 表示是否需要同步验证签名,默认 `false` 不验证。
	Execute(verifySign ...bool) Results
	SetNotifyURL(url string, filedName ...string) Executor //设置支付宝服务器主动通知商户服务器里指定的页面http/https路径。
	UseTwowayAuthentication(b bool) Executor               // 是否需要双向认证
	UseXML(b bool) Executor                                //是否使用xml作为接口数据交换格式
	ResultValidator(f func(Params) (ok bool, code string, msg string, subcode string, submsg string)) Executor
	Set(filed string, value interface{}) Executor
}

Executor 用于执行请求的相关上下文。 每个 Executor 都可以被多次执行(注意:接口业务是否允许)。

type HttpClient added in v0.1.14

type HttpClient interface {
	Do(request *http.Request, tlsTwowayAuthentication bool) (*http.Response, error)
}

type JsonTime

type JsonTime time.Time

func (JsonTime) MarshalJSON

func (t JsonTime) MarshalJSON() ([]byte, error)

MarshalJSON 实现它的json序列化方法

type Pairs

type Pairs [][2]string

func (*Pairs) Append

func (p *Pairs) Append(k, v string)

func (Pairs) ToJSON

func (p Pairs) ToJSON(isNesting ...bool) string

func (Pairs) ToURLParams

func (p Pairs) ToURLParams(urlencode ...bool) string

func (Pairs) ToXML

func (p Pairs) ToXML() string

type Params

type Params map[string]interface{}

func (Params) Get

func (p Params) Get(key string) utils.Converter

func (Params) Sort

func (p Params) Sort(isNesting ...bool) Pairs

func (*Params) UnmarshalXML

func (m *Params) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Results

type Results interface {
	Get(key string) utils.Converter
	Code() string
	Message() string
	SubCode() string
	SubMessage() string
	Body() []byte
	Error() error
	Success() bool
	Values() Params
}

Results 执行接口返回的响应结果。

type Time

type Time struct {
	time.Time
	Format string
}

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON 实现它的json序列化方法

func (Time) MarshalXML

func (t Time) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML 实现它的json序列化方法

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL