qrcode

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCreateQRCode = whatsapp.Error("failed to create qr code")
	ErrGetQRCode    = whatsapp.Error("failed to get qr code")
	ErrListQRCode   = whatsapp.Error("failed to list qr codes")
	ErrDeleteQRCode = whatsapp.Error("failed to delete qr code")
	ErrUpdateQRCode = whatsapp.Error("failed to update qr code")
)
View Source
const Endpoint = "message_qrdls"

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseClient

type BaseClient struct {
	Sender Sender
	Config config.Reader
}

func NewBaseClient

func NewBaseClient(s whttp.AnySender, reader config.Reader, middlewares ...SenderMiddleware) *BaseClient

func (*BaseClient) Create

func (c *BaseClient) Create(ctx context.Context, req *CreateRequest) (*CreateResponse, error)

func (*BaseClient) Delete

func (c *BaseClient) Delete(ctx context.Context, qrCodeID string) (*SuccessResponse, error)

func (*BaseClient) Get

func (c *BaseClient) Get(ctx context.Context, qrCodeID string) (*Information, error)

func (*BaseClient) List

func (c *BaseClient) List(ctx context.Context) (*ListResponse, error)

func (*BaseClient) Update

func (c *BaseClient) Update(ctx context.Context, req *UpdateRequest) (*SuccessResponse, error)

type BaseRequest

type BaseRequest struct {
	Method      string
	Type        whttp.RequestType
	QRCodeID    string
	QueryParams map[string]string
}

type BaseSender

type BaseSender struct {
	Sender whttp.AnySender
}

func (*BaseSender) Send

func (sender *BaseSender) Send(ctx context.Context, conf *config.Config, req *BaseRequest) (*Response, error)

type Client

type Client struct {
	Config *config.Config
	Sender Sender
}

func NewClient

func NewClient(ctx context.Context, reader config.Reader,
	sender Sender, middlewares ...SenderMiddleware,
) (*Client, error)

NewClient ...

func (*Client) Create

func (c *Client) Create(ctx context.Context, req *CreateRequest) (*CreateResponse, error)

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, qrCodeID string) (*SuccessResponse, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, qrCodeID string) (*Information, error)

func (*Client) List

func (c *Client) List(ctx context.Context) (*ListResponse, error)

func (*Client) Update

func (c *Client) Update(ctx context.Context, req *UpdateRequest) (*SuccessResponse, error)

type CreateRequest

type CreateRequest struct {
	PrefilledMessage string      `json:"prefilled_message"`
	ImageFormat      ImageFormat `json:"generate_qr_image"`
}

type CreateResponse

type CreateResponse struct {
	Code             string `json:"code"`
	PrefilledMessage string `json:"prefilled_message"`
	DeepLinkURL      string `json:"deep_link_url"`
	QRImageURL       string `json:"qr_image_url"`
}

func Create added in v0.0.5

func Create(ctx context.Context, sender Sender, conf *config.Config, req *CreateRequest) (*CreateResponse, error)

type ImageFormat

type ImageFormat string
const (
	ImageFormatPNG ImageFormat = "PNG"
	ImageFormatSVG ImageFormat = "SVG"
)

type Information

type Information struct {
	Code             string `json:"code"`
	PrefilledMessage string `json:"prefilled_message"`
	DeepLinkURL      string `json:"deep_link_url"`
}

func Get added in v0.0.5

func Get(ctx context.Context, sender Sender, conf *config.Config, qrCodeID string) (*Information, error)

type ListResponse

type ListResponse struct {
	Data []*Information `json:"data,omitempty"`
}

func List added in v0.0.5

func List(ctx context.Context, sender Sender, conf *config.Config) (*ListResponse, error)

type Response

type Response struct {
	Data             []*Information `json:"data,omitempty"`
	Success          bool           `json:"success"`
	Code             string         `json:"code"`
	PrefilledMessage string         `json:"prefilled_message"`
	DeepLinkURL      string         `json:"deep_link_url"`
	QRImageURL       string         `json:"qr_image_url"`
}

func (*Response) CreateResponse

func (response *Response) CreateResponse() *CreateResponse

func (*Response) ListResponse

func (response *Response) ListResponse() *ListResponse

type Sender

type Sender interface {
	Send(ctx context.Context, conf *config.Config, req *BaseRequest) (*Response, error)
}

type SenderFunc

type SenderFunc func(ctx context.Context, conf *config.Config, req *BaseRequest) (*Response, error)

func (SenderFunc) Send

func (fn SenderFunc) Send(ctx context.Context, conf *config.Config, req *BaseRequest) (*Response, error)

type SenderMiddleware

type SenderMiddleware func(senderFunc SenderFunc) SenderFunc

type Service

type Service interface {
	Get(ctx context.Context, qrCodeID string) (*Information, error)
	List(ctx context.Context) (*ListResponse, error)
	Create(ctx context.Context, req *CreateRequest) (*CreateResponse, error)
	Delete(ctx context.Context, qrCodeID string) (*SuccessResponse, error)
	Update(ctx context.Context, req *UpdateRequest) (*SuccessResponse, error)
}

type SuccessResponse

type SuccessResponse struct {
	Success bool `json:"success"`
}

func Delete added in v0.0.5

func Delete(ctx context.Context, sender Sender, conf *config.Config, qrCodeID string) (*SuccessResponse, error)

func Update added in v0.0.5

func Update(ctx context.Context, sender Sender, conf *config.Config, req *UpdateRequest) (*SuccessResponse, error)

type UpdateRequest

type UpdateRequest struct {
	QRCodeID         string      `json:"-"`
	PrefilledMessage string      `json:"prefilled_message,omitempty"`
	ImageFormat      ImageFormat `json:"generate_qr_image,omitempty"`
}

Jump to

Keyboard shortcuts

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