Documentation
¶
Overview ¶
Package qrpro is the official Go SDK for Abundera QR Pro.
See https://pro.qr.abundera.ai/docs/ for the full API reference.
Index ¶
- func VerifyWebhookSignature(signature string, body []byte, secret string, toleranceSeconds int) error
- type Analytics
- type AnalyticsParams
- type Client
- func (c *Client) CheckSlug(ctx context.Context, slug string) (bool, error)
- func (c *Client) CreateCode(ctx context.Context, in CodeCreate) (*Code, error)
- func (c *Client) CreateGroup(ctx context.Context, name, description string) (*Group, error)
- func (c *Client) CreateWebhook(ctx context.Context, webhookURL string, events []string) (*Webhook, error)
- func (c *Client) DeleteCode(ctx context.Context, id string) error
- func (c *Client) DeleteGroup(ctx context.Context, id string) error
- func (c *Client) DeleteWebhook(ctx context.Context, id string) error
- func (c *Client) GetAnalytics(ctx context.Context, codeID string, p *AnalyticsParams) (*Analytics, error)
- func (c *Client) GetAnalyticsCSV(ctx context.Context, codeID string, p *AnalyticsParams) (string, error)
- func (c *Client) GetCode(ctx context.Context, id string) (*Code, error)
- func (c *Client) ListCodes(ctx context.Context, params *ListCodesParams) (*ListResult[Code], error)
- func (c *Client) ListGroups(ctx context.Context) (*ListResult[Group], error)
- func (c *Client) ListWebhooks(ctx context.Context) (*ListResult[Webhook], error)
- func (c *Client) Me(ctx context.Context) (map[string]any, error)
- func (c *Client) UpdateCode(ctx context.Context, id string, patch CodePatch) (*Code, error)
- type Code
- type CodeCreate
- type CodePatch
- type Error
- type Group
- type ListCodesParams
- type ListResult
- type Option
- type Pagination
- type Webhook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VerifyWebhookSignature ¶
func VerifyWebhookSignature(signature string, body []byte, secret string, toleranceSeconds int) error
VerifyWebhookSignature verifies a Stripe-compatible webhook signature of the form: "t=<unix_ts>,v1=<hex>". It recomputes HMAC-SHA256 of "{t}.{body}" with secret and compares in constant time. Returns nil on success or an error on mismatch / timestamp skew > toleranceSeconds.
Pass 0 for toleranceSeconds to use the default (300s).
Types ¶
type Analytics ¶
type Analytics struct {
CodeID string `json:"code_id"`
TotalScans int `json:"total_scans"`
UniqueDays int `json:"unique_days"`
ByDay []struct {
Date string `json:"date"`
Scans int `json:"scans"`
} `json:"by_day"`
ByCountry []struct {
Country string `json:"country"`
Scans int `json:"scans"`
} `json:"by_country"`
ByDevice []struct {
DeviceClass string `json:"device_class"`
Scans int `json:"scans"`
} `json:"by_device"`
}
type AnalyticsParams ¶
type AnalyticsParams struct{ From, To string }
type Client ¶
type Client struct {
APIKey string
BaseURL string
HTTPClient *http.Client
MaxRetries int
UserAgent string
}
Client is the Abundera QR Pro API client.
func (*Client) CreateCode ¶
func (*Client) CreateGroup ¶
func (*Client) CreateWebhook ¶
func (c *Client) CreateWebhook(ctx context.Context, webhookURL string, events []string) (*Webhook, error)
CreateWebhook returns a Webhook with Secret populated — store it immediately.
func (*Client) GetAnalytics ¶
func (*Client) GetAnalyticsCSV ¶
func (*Client) ListCodes ¶
func (c *Client) ListCodes(ctx context.Context, params *ListCodesParams) (*ListResult[Code], error)
func (*Client) ListGroups ¶
func (*Client) ListWebhooks ¶
type Code ¶
type Code struct {
ID string `json:"id"`
Slug string `json:"slug"`
DestinationURL string `json:"destination_url"`
Label string `json:"label,omitempty"`
Tags []string `json:"tags,omitempty"`
GroupID *string `json:"group_id,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ScanCount int `json:"scan_count,omitempty"`
LastScanAt *string `json:"last_scan_at,omitempty"`
Active bool `json:"active"`
ShortURL string `json:"short_url"`
}
type CodeCreate ¶
type Error ¶
type Error struct {
Status int `json:"status"`
Code string `json:"code"`
Message string `json:"message"`
RequestID string `json:"request_id,omitempty"`
}
Error is returned for any non-2xx API response.
type ListCodesParams ¶
type ListResult ¶
type ListResult[T any] struct { Data []T `json:"data"` Pagination Pagination `json:"pagination"` }
type Option ¶
type Option func(*Client)
Option configures a Client.