work

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ObjDecodeErr 返回值对象解析错误
	ObjDecodeErr = web.NewErrorModel(-1, "json解析失败", nil, http.StatusBadRequest)
	// StructNotHasCommonError 请求需要解析的对象错误  没有commonError
	StructNotHasCommonError = web.NewErrorModel(-1, "需要解析的结构体错误", nil, http.StatusBadRequest)
)

Functions

This section is empty.

Types

type AccessTokenType

type AccessTokenType string
const (
	// ContactAccessTokenType 通讯录
	ContactAccessTokenType AccessTokenType = "contact_secret"
	// ExternalContactAccessTokenType 外部联系人
	ExternalContactAccessTokenType AccessTokenType = "external_contact_secret"
)

type Client

type Client struct {
	CorpID          string `json:"corp_id"`
	CorpSecret      string `json:"corp_secret"`
	CachePrefix     string `json:"cache_prefix" yaml:"cache_prefix"`
	AccessToken     string `json:"access_token" yaml:"access_token"`
	AccessTokenLock *sync.Mutex

	HttpClient interfaces.HttpClient
	Store      interfaces.Store
	Debug      bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(o ...Options) *Client

func (*Client) Get

func (c *Client) Get(url string, obj interface{}) ([]byte, error)

func (*Client) GetAccessToken

func (c *Client) GetAccessToken() (string, error)

GetAccessToken 获取access_token

func (*Client) GetCachePrefix

func (c *Client) GetCachePrefix() string

GetCachePrefix 获取缓存前缀

func (*Client) GetJsapiTicket added in v0.0.7

func (c *Client) GetJsapiTicket() (string, error)

GetJsapiTicket 获取企业的jsapi_ticket

func (*Client) HasQuery

func (c *Client) HasQuery(url string) bool

HasQuery 判断url中是否有参数

func (*Client) Post

func (c *Client) Post(url string, body []byte, obj interface{}, header map[string]string) ([]byte, error)

func (*Client) PostJSON

func (c *Client) PostJSON(url string, params interface{}, obj interface{}) ([]byte, error)

func (*Client) RefreshAccessToken

func (c *Client) RefreshAccessToken() (string, error)

RefreshAccessToken 刷新access_token

type GetAccessTokenResult

type GetAccessTokenResult struct {
	ErrCode     int    `json:"errcode"`
	ErrMsg      string `json:"errmsg"`
	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
}

GetAccessTokenResult 获取access_token结果

type HttpCliOptions

type HttpCliOptions func(*HttpClient)

func WithHttpClientCtx

func WithHttpClientCtx(c context.Context) HttpCliOptions

func WithHttpClientDebug added in v0.0.7

func WithHttpClientDebug(debug bool) HttpCliOptions

type HttpClient

type HttpClient struct {
	// contains filtered or unexported fields
}

func NewHttpClient

func NewHttpClient(opts ...HttpCliOptions) *HttpClient

func (*HttpClient) Get

func (h *HttpClient) Get(uri string) ([]byte, error)

func (*HttpClient) Post

func (h *HttpClient) Post(uri string, data []byte, header map[string]string) ([]byte, error)

func (*HttpClient) PostJSON

func (h *HttpClient) PostJSON(uri string, params interface{}) ([]byte, error)

type JsapiTicketResponse added in v0.0.7

type JsapiTicketResponse struct {
	ErrCode   int    `json:"errcode"`
	ErrMsg    string `json:"errmsg"`
	Ticket    string `json:"ticket"`
	ExpiresIn int    `json:"expires_in"`
}

type Options

type Options func(*Client)

func WithAccessToken

func WithAccessToken(accessToken string) Options

func WithAppidAndSecret

func WithAppidAndSecret(CorpID string, CorpSecret string) Options

func WithCachePrefix

func WithCachePrefix(prefix string) Options

WithCachePrefix 设置缓存前缀,必填

func WithDebug added in v0.0.7

func WithDebug(debug bool) Options

WithDebug 是否开启debug模式

func WithHttpClient

func WithHttpClient(cli interfaces.HttpClient) Options

func WithRedisStore

func WithRedisStore(cli *redis.Client) Options

type RedisStore

type RedisStore struct {
	Client *redis.Client
	// contains filtered or unexported fields
}

func NewRedisStore

func NewRedisStore(client *redis.Client) *RedisStore

func (*RedisStore) GetAccessToken

func (r *RedisStore) GetAccessToken(key string) (string, error)

func (*RedisStore) GetJsapiTicket added in v0.0.7

func (r *RedisStore) GetJsapiTicket(key string) (string, error)

func (*RedisStore) SetAccessToken

func (r *RedisStore) SetAccessToken(key string, accessToken string, expires int64) error

func (*RedisStore) SetJsapiTicket added in v0.0.7

func (r *RedisStore) SetJsapiTicket(key string, jsapiTicket string, expires int64) error

Jump to

Keyboard shortcuts

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