Documentation ¶
Index ¶
- Constants
- type AccessCode
- type Data
- type ExpireUnit
- type UsageType
- type Voucher
- func (v *Voucher) AccessCode() AccessCode
- func (v *Voucher) HttpPayload() *bytes.Reader
- func (v *Voucher) Published() bool
- func (v *Voucher) PublishedSuccesfully()
- func (v *Voucher) SetDataLimitMB(limit int)
- func (v *Voucher) SetDownloadLimitMbps(limit int)
- func (v *Voucher) SetExpire(expiration int, unit ExpireUnit)
- func (v *Voucher) SetId(id string)
- func (v *Voucher) SetUploadLimitMbps(limit int)
- func (v *Voucher) String() string
Constants ¶
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 ¶
HttpPayload returns the NewVoucherRequestPayload struct as a strings.Reader to be used in as a http request body.
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 ¶
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 ¶
HttpPayload returns the Voucher struct as a bytes.Reader to be used in as a http request body.
func (*Voucher) Published ¶
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 ¶
SetDataLimitMB sets the `Data Limit` in MB. If not set, the default is unlimited.
func (*Voucher) SetDownloadLimitMbps ¶
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) SetUploadLimitMbps ¶
SetUploadLimitMbps sets the `Upload Limit` in Mbps. If not set, the default is unlimited.