voucher

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const AccessCodeLength = 10

AccessCodeLength is the length of a voucher code "12345-67890"

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessCode

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

AccessCode is a struct that represents a voucher code

func NewAccessCodeFromString

func NewAccessCodeFromString(voucherCode string) (AccessCode, error)

NewAccessCodeFromString creates a new AccessCode struct from a string

func (AccessCode) String

func (v AccessCode) String() string

String returns a string representation of a voucher code as it appears on the Unifi controller

type Data

type Data struct {
	Quota            int    `json:"quota"`
	Note             string `json:"note"`
	NumberOfVouchers int    `json:"n"`
	ExpireNumber     string `json:"expire_number"`
	ExpireUnit       int    `json:"expire_unit"`
	Cmd              string `json:"cmd"`
	Up               int    `json:"up,omitempty"`
	Down             int    `json:"down,omitempty"`
	Bytes            string `json:"bytes,omitempty"`
}

Data is a struct that holds the parameters that can be selected online.

func (*Data) HttpPayload

func (v *Data) HttpPayload() *strings.Reader

HttpPayload returns the NewVoucherRequestPayload struct as a strings.Reader to be used in as a http request body.

func (*Data) LogGroup

func (v *Data) LogGroup() slog.Value

LogGroup returns the NewVoucherRequestPayload struct as a slog.Value for logging.

func (*Data) String

func (v *Data) String() string

type ExpireUnit

type ExpireUnit int

ExpireUnit is the unit of time that the voucher will expire in

const (
	Minutes ExpireUnit = 1
	Hours   ExpireUnit = 60
	Days    ExpireUnit = 1440
)

type UsageType

type UsageType int

UsageType is the type of voucher that will be created. There is single, multi and unlimited use.

type Voucher

type Voucher struct {
	Id string

	AC AccessCode
	// contains filtered or unexported fields
}

Voucher is a struct that holds the information needed to create a new voucher.

func NewDefaultVoucher

func NewDefaultVoucher() *Voucher

NewDefaultVoucher creates a new Voucher struct to be used to create a new voucher.

func NewMultiUseVoucher

func NewMultiUseVoucher(quota int) *Voucher

NewMultiUseVoucher creates a new Multi Use Voucher.

func NewSingleUseVoucher

func NewSingleUseVoucher() *Voucher

NewSingleUseVoucher creates a new Single Use Voucher.

func NewUnlimitedUseVoucher

func NewUnlimitedUseVoucher() *Voucher

NewUnlimitedUseVoucher creates a new Unlimited use Voucher.

func (*Voucher) AccessCode

func (v *Voucher) AccessCode() AccessCode

AccessCode returns the AccessCode for the voucher. This is the 10-digit code that Guest can use to access the network.

func (*Voucher) HttpPayload

func (v *Voucher) HttpPayload() *bytes.Reader

HttpPayload returns the Voucher struct as a bytes.Reader to be used in as a http request body.

func (*Voucher) Published

func (v *Voucher) Published() bool

Published returns true if the voucher has been published and available on the UniFi Network Application.

func (*Voucher) PublishedSuccesfully

func (v *Voucher) PublishedSuccesfully()

PublishedSuccesfully sets the voucher as published.

func (*Voucher) SetDataLimitMB

func (v *Voucher) SetDataLimitMB(limit int)

SetDataLimitMB sets the `Data Limit` in MB. If not set, the default is unlimited.

func (*Voucher) SetDownloadLimitMbps

func (v *Voucher) SetDownloadLimitMbps(limit int)

SetDownloadLimitMbps sets the `Download Limit` in Mbps. If not set, the default is unlimited.

func (*Voucher) SetExpire

func (v *Voucher) SetExpire(expiration int, unit ExpireUnit)

SetExpire sets the `Expire Number` and `Expire Unit` for the voucher.

func (*Voucher) SetId

func (v *Voucher) SetId(id string)

SetId sets the `Note` for the voucher.

func (*Voucher) SetUploadLimitMbps

func (v *Voucher) SetUploadLimitMbps(limit int)

SetUploadLimitMbps sets the `Upload Limit` in Mbps. If not set, the default is unlimited.

func (*Voucher) String

func (v *Voucher) String() string

String Stringer interface implementation

Jump to

Keyboard shortcuts

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