afdian

package module
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2025 License: MIT Imports: 12 Imported by: 1

README ¶

âš¡ go-afdian-api

Go SDK for the Afdian open API

Go Report Card GitHub release GitHub License FOSSA Status

Go CI Release Dependabot Updates CodeQL Advanced


🚀 Features

  • WebHook
  • API
  • Unsafe API

License

FOSSA Status

Documentation ¶

Index ¶

Constants ¶

View Source
const (
	ECParamsIncomplete   = 400001
	ECTimeExpired        = 400002
	ECInvalidJSON        = 400003
	ECNoValidTokenFound  = 400004
	ECSignValidationFail = 400005
)

afdian custom error codes

Deprecated: use ec package instead

Variables ¶

This section is empty.

Functions ¶

This section is empty.

Types ¶

type CallBack ¶

type CallBack func(p *payload.WebHook, errs ...error)

CallBack for WebHook.

type Client ¶

type Client struct {
	WebHook *WebHook
	HTTP    *http.Client
	// contains filtered or unexported fields
}

func NewClient ¶

func NewClient(cfg *Config, hc ...*http.Client) *Client

func (*Client) Ping ¶

func (c *Client) Ping() (*payload.Ping, error)

func (*Client) QueryOrder ¶

func (c *Client) QueryOrder(page, perPage int, outTradeNo ...string) (*payload.QueryOrder, error)

func (*Client) QueryRandomReply ¶

func (c *Client) QueryRandomReply(outTradeNo ...string) (*payload.QueryRandomReply, error)

QueryRandomReply need one or more outTradeNo

func (*Client) QuerySponsor ¶

func (c *Client) QuerySponsor(page, perPage int, outTradeNo ...string) (*payload.QuerySponsor, error)

func (*Client) Send ¶

func (c *Client) Send(path string, params map[string]string) (*http.Response, error)

Send an API request WARNING: Be aware of potential resource leaks

type Config ¶

type Config struct {
	BaseURL string

	// Auth configuration
	UserID   string
	APIToken string

	// WebHook configuration
	WebHookListenAddr string
	WebHookPath       string
	WebHookCallback   CallBack
}

type RawResponder ¶ added in v1.0.2

type RawResponder interface {
	SetRawResponse(resp *http.Response)
}

type WebHook ¶

type WebHook struct {
	HTTPServer *http.Server
	// contains filtered or unexported fields
}

WebHook handler

func NewWebHook ¶

func NewWebHook(client *Client) *WebHook

NewWebHook creates a new WebHook handler.

func (*WebHook) Start ¶

func (wh *WebHook) Start() error

Start the WebHook server

Directories ¶

Path Synopsis
internal
debug command
pkg
tools
release command

Jump to

Keyboard shortcuts

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