link

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClicksByDay

type ClicksByDay struct {
	Date   string `json:"date"`
	Total  int    `json:"total"`
	Unique int    `json:"unique"`
}

ClicksByDay represents daily click statistics

type ClicksStats

type ClicksStats struct {
	Total  int           `json:"total"`
	Unique int           `json:"unique"`
	ByDay  []ClicksByDay `json:"byDay"`
}

ClicksStats represents click statistics

type CreateQRCodeOptions

type CreateQRCodeOptions struct {
	Title           string `json:"title,omitempty"`
	BackgroundColor string `json:"backgroundColor,omitempty"`
	Color           string `json:"color,omitempty"`
	Size            QRSize `json:"size,omitempty"`
}

CreateQRCodeOptions contains optional parameters for creating QR codes

type CreateShortCodeOptions

type CreateShortCodeOptions struct {
	Code  string   `json:"code,omitempty"`
	Title string   `json:"title,omitempty"`
	Tags  []string `json:"tags,omitempty"`
}

CreateShortCodeOptions contains optional parameters for creating short codes

type GetCodeStatsResponse

type GetCodeStatsResponse struct {
	Clicks    ClicksStats `json:"clicks"`
	Referrals []any       `json:"referrals"`
	Browsers  []any       `json:"browsers"`
	Devices   []any       `json:"devices"`
	Locations []any       `json:"locations"`
}

GetCodeStatsResponse represents code statistics response

type GetQRCodesResponse

type GetQRCodesResponse struct {
	Total    int              `json:"total"`
	PageNum  int              `json:"pageNum"`
	PageSize int              `json:"pageSize"`
	Data     []QRCodeResponse `json:"data"`
}

GetQRCodesResponse represents a paginated response of QR codes

type GetShortCodesResponse

type GetShortCodesResponse struct {
	Total    int                 `json:"total"`
	PageNum  int                 `json:"pageNum"`
	PageSize int                 `json:"pageSize"`
	Data     []ShortCodeResponse `json:"data"`
}

GetShortCodesResponse represents a paginated response of short codes

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

Link is the client for URL shortening services

func New

func New(options ...Option) (*Link, error)

New creates a new Link client with functional options

func (*Link) CreateQRCode

func (l *Link) CreateQRCode(ctx context.Context, code string, opts *CreateQRCodeOptions) (*QRCodeResponse, error)

CreateQRCode creates a QR code for a specific short code

func (*Link) CreateShortCode

func (l *Link) CreateShortCode(ctx context.Context, longURL, domain string, opts *CreateShortCodeOptions) (*ShortCodeResponse, error)

CreateShortCode creates a short code for a long URL

func (*Link) DeleteQRCode

func (l *Link) DeleteQRCode(ctx context.Context, code, qrID string) error

DeleteQRCode deletes a QR code by its ID

func (*Link) DeleteShortCode

func (l *Link) DeleteShortCode(ctx context.Context, code string) error

DeleteShortCode deletes a short code

func (*Link) GetCodeStats

func (l *Link) GetCodeStats(ctx context.Context, code string, startDate, endDate time.Time) (*GetCodeStatsResponse, error)

GetCodeStats retrieves statistics for a specific short code

func (*Link) GetQRCode

func (l *Link) GetQRCode(ctx context.Context, code, qrID string) (*QRCodeResponse, error)

GetQRCode retrieves a QR code by its ID

func (*Link) GetQRCodes

func (l *Link) GetQRCodes(ctx context.Context, code string, pageNumber, pageSize int) (*GetQRCodesResponse, error)

GetQRCodes retrieves all QR codes for a short code

func (*Link) GetShortCode

func (l *Link) GetShortCode(ctx context.Context, code string) (*ShortCodeResponse, error)

GetShortCode retrieves a short code by its code

func (*Link) GetShortCodes

func (l *Link) GetShortCodes(ctx context.Context, titleSearch string, tags []string, pageNumber, pageSize int) (*GetShortCodesResponse, error)

GetShortCodes retrieves all short codes for the organization

func (*Link) GetTags

func (l *Link) GetTags(ctx context.Context) ([]string, error)

GetTags retrieves all tags associated with the organization's short codes

func (*Link) SetErrorHandler

func (l *Link) SetErrorHandler(handler func(error))

SetErrorHandler sets a custom error handler function

func (*Link) UpdateShortCode

func (l *Link) UpdateShortCode(ctx context.Context, code string, opts *UpdateShortCodeOptions) (*ShortCodeResponse, error)

UpdateShortCode updates a short code

type Option

type Option func(*Options)

Option is a functional option for configuring the Link client

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets the API key for authentication

func WithOrganizationID

func WithOrganizationID(id string) Option

WithOrganizationID sets the organization ID

func WithURIs

func WithURIs(uris []string) Option

WithURIs sets the base URIs for the Link service

type Options

type Options struct {
	URIs           []string
	OrganizationID string
	APIKey         string
}

Options represents configuration options for the Link client

type OrganizationID

type OrganizationID struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

OrganizationID represents the organization identifier in responses

type QRCodeResponse

type QRCodeResponse struct {
	ID          string `json:"id"`
	Title       string `json:"title,omitempty"`
	QRCode      string `json:"qrCode"`
	QRCodeBytes []byte `json:"-"`
	QRLink      string `json:"qrLink"`
}

QRCodeResponse represents a QR code response

type QRSize

type QRSize string

QRSize represents the size of a QR code

const (
	QRSizeSmall  QRSize = "small"
	QRSizeMedium QRSize = "medium"
	QRSizeLarge  QRSize = "large"
)

type ShortCodeResponse

type ShortCodeResponse struct {
	ID             string         `json:"id"`
	Code           string         `json:"code"`
	LongURL        string         `json:"long_url"`
	Domain         string         `json:"domain"`
	CreatedAt      string         `json:"createdAt"`
	Title          string         `json:"title,omitempty"`
	Tags           []string       `json:"tags,omitempty"`
	OrganizationID OrganizationID `json:"organizationId"`
}

ShortCodeResponse represents a short code response

type UpdateShortCodeOptions

type UpdateShortCodeOptions struct {
	LongURL string   `json:"long_url,omitempty"`
	Title   string   `json:"title,omitempty"`
	Tags    []string `json:"tags,omitempty"`
}

UpdateShortCodeOptions contains optional parameters for updating short codes

Jump to

Keyboard shortcuts

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