Documentation
¶
Index ¶
- Constants
- Variables
- func FeedUrl(input FeedUrlInput) (string, error)
- func ListingURL(listingId string, numTickets int) string
- func ValidateURL(urlString string) error
- type Artist
- type Client
- type ClientOpt
- type Country
- type Currency
- type Date
- type DateTime
- type Event
- type FeedUrlInput
- type FetchTicketListingsInput
- type Lineup
- type Location
- type Price
- type Region
- type TicketListing
- func (l TicketListing) Discount() float64
- func (l TicketListing) DiscountString() string
- func (l TicketListing) OriginalTicketPrice() Price
- func (l TicketListing) TicketPriceExclFee() Price
- func (l TicketListing) TicketPriceInclFee() Price
- func (l TicketListing) TotalPriceInclFee() Price
- func (l TicketListing) TwicketsFeePerTicket() Price
- func (l TicketListing) URL() string
- type TicketListings
- type Time
- type Tour
- type UnixTime
- type Venue
Constants ¶
const (
TwicketsURL = "https://www.twickets.live"
)
Variables ¶
var ( CountryUnitedKingdom = country.Add(Country{"GB"}) Countries = country.Enum() )
var ( RegionEastAnglia = region.Add(Region{"GBEA"}) RegionLondon = region.Add(Region{"GBLO"}) RegionMidlands = region.Add(Region{"GBMI"}) RegionNorth = region.Add(Region{"GBNO"}) RegionNorthEast = region.Add(Region{"GBNE"}) RegionNorthernIsland = region.Add(Region{"GBNI"}) RegionNorthWest = region.Add(Region{"GBNW"}) RegionScotland = region.Add(Region{"GBSC"}) RegionSouth = region.Add(Region{"GBSO"}) RegionSouthEast = region.Add(Region{"GBSE"}) RegionSouthWest = region.Add(Region{"GBSW"}) RegionWales = region.Add(Region{"GBWA"}) Regions = region.Enum() )
var ( CurrencyGBP = currency.Add(Currency{"GBP"}) Currencies = currency.Enum() )
Functions ¶
func FeedUrl ¶
func FeedUrl(input FeedUrlInput) (string, error)
FeedUrl gets the url of a ticket listings feed. Note: The number of ticket listings (that are non-delisted) in the feed at this url will ALWAYS be 10. There may be any number of additional delisted ticket listings.
Format is: https://www.twickets.live/services/catalogue?q=countryCode=GB&count=10&api_key=<api_key>
func ListingURL ¶
ListingURL gets the url of a listing given its id and the number of tickets in the listing.
Format is: https://www.twickets.live/app/block/<ticketId>,<numTickets>
func ValidateURL ¶ added in v0.7.0
ValidateURL checks if a url string is a valid.
Types ¶
type Artist ¶
type Artist struct {
Id string `json:"id"`
Name string `json:"name"`
Slug string `json:"linkName"`
}
Artist contains the details of an artist.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) FetchTicketListings ¶
func (c *Client) FetchTicketListings( ctx context.Context, input FetchTicketListingsInput, ) (TicketListings, error)
FetchTicketListings gets ticket listings using the specified input.
func (*Client) FetchTicketListingsByFeedUrl ¶
func (c *Client) FetchTicketListingsByFeedUrl( ctx context.Context, feedUrl string, ) (TicketListings, error)
FetchTicketListings gets ticket listings using the specified feel url.
type ClientOpt ¶ added in v0.7.0
func WithFlareSolverr ¶ added in v0.7.0
type Country ¶
func (Country) MarshalJSON ¶ added in v0.6.1
func (*Country) UnmarshalJSON ¶
func (*Country) UnmarshalText ¶
type Currency ¶
func (Currency) MarshalJSON ¶ added in v0.6.1
func (*Currency) UnmarshalJSON ¶
type Event ¶
type Event struct {
Id string `json:"id"`
Name string `json:"eventName"`
Category string `json:"category"`
Date Date `json:"date"`
Time Time `json:"showStartingTime"`
OnSale *DateTime `json:"onSaleTime"` // 2023-11-17T10:00:00Z
Announced *DateTime `json:"created"` // 2023-11-17T10:00:00Z
Venue Venue `json:"venue"`
Lineup []Lineup `json:"participants"`
}
Event contains the details of an event.
type FeedUrlInput ¶
type FeedUrlInput struct {
// Required fields
APIKey string
Country Country
// Optional fields
Regions []Region // Defaults to all country regions
BeforeTime time.Time // Defaults to current time
}
func (FeedUrlInput) Validate ¶ added in v0.1.3
func (f FeedUrlInput) Validate() error
Validate the input struct used to get the feed url. This is used internally to check the input, but can also be used externally.
type FetchTicketListingsInput ¶
type FetchTicketListingsInput struct {
// Required fields
Country Country
// Regions for which to fetch ticket listings from.
// Leave this unset or empty to fetch listings from any region.
// Defaults to any region (unset).
Regions []Region
// MaxNumber is the maximum number of ticket listings to fetch.
// If getting ticket listings within in a time period using `CreatedAfter`, set this to an arbitrarily
// large number (e.g. 250) to ensure all listings in the period are fetched, while preventing
// accidentally fetching too many listings and possibly being rate limited or blocked.
// Defaults to 10.
// Set to -1 if no limit is desired. This is dangerous and should only be used with well constrained time periods.
MaxNumber int
// CreatedAfter is the time which ticket listings must have been created after to be fetched.
// Set this to fetch listings within a time period.
// Set `MaxNumber` to an arbitrarily large number (e.g. 250) to ensure all listings in the period are fetched,
// while preventing accidentally fetching too many listings and possibly being rate limited or blocked.
CreatedAfter time.Time
// CreatedBefore is the time which ticket listings must have been created before to be fetched.
// Set this to fetch listings within a time period.
// Defaults to current time.
CreatedBefore time.Time
}
FetchTicketListingsInput defines parameters when getting ticket listings.
Ticket listings can either be fetched by maximum number or by time period. The default is to get a maximum number of ticket listings.
If both a maximum number and a time period are set, whichever condition is met first will stop the fetching of ticket listings.
func (FetchTicketListingsInput) Validate ¶ added in v0.1.3
func (f FetchTicketListingsInput) Validate() error
Validate the input struct used to get ticket listings. This is used internally to check the input, but can also be used externally.
type Location ¶
type Location struct {
Id string `json:"id"`
Name string `json:"shortName"`
FullName string `json:"name"`
Country Country `json:"countryCode"`
Region Region `json:"regionCode"`
}
Venue contains the details of an event location.
type Price ¶
type Price struct {
Currency Currency `json:"currencyCode"`
// Amount is the cost in Cents, Pennies etc.
// Prefer using `Number`
Amount int `json:"amountInCents"`
}
type Region ¶
func (Region) MarshalJSON ¶ added in v0.6.1
func (*Region) UnmarshalJSON ¶
func (*Region) UnmarshalText ¶
type TicketListing ¶
type TicketListing struct {
Id string `json:"blockId"`
CreatedAt UnixTime `json:"created"`
ExpiresAt UnixTime `json:"expires"`
// Number of tickets in the listing
NumTickets int `json:"ticketQuantity"`
// TotalPriceExclFee is the total price of all tickets, excluding fee.
// Use TotalPriceInclFee to get the total price of all tickets, including fee.
// Use TicketPriceExclFee to get the price of a single ticket, excluding fee.
// Use TicketPriceInclFee to get the price of a single ticket, including fee.
TotalPriceExclFee Price `json:"totalSellingPrice"`
// TwicketsFee is the total twickets fee for all tickets.
// Use TwicketsFeePerTicket to get the twickets fee per ticket.
TwicketsFee Price `json:"totalTwicketsFee"`
// OriginalTotalPrice is the original total price of all tickets, including any fee.
// Use OriginalTicketPrice to get the original price of a single ticket, including any fee.
OriginalTotalPrice Price `json:"faceValuePrice"`
SellerWillConsiderOffers bool `json:"sellerWillConsiderOffers"`
// The type of the ticket e.g. seated, Standing, Box etc.
TicketType string `json:"priceTier"`
SeatAssigned bool `json:"seatAssigned"`
Section string `json:"section"` // Can be empty
Row string `json:"row"` // Can be empty
Event Event `json:"event"`
Tour Tour `json:"tour"`
}
TicketListing is a listing of ticket(s) on Twickets
func UnmarshalTwicketsFeedJson ¶
func UnmarshalTwicketsFeedJson(data []byte) ([]TicketListing, error)
func (TicketListing) Discount ¶
func (l TicketListing) Discount() float64
Discount is the discount on the original price of a single ticket, including any fee.
Discount is returned as a value between 0 and 1 (with 1 representing 100% off). If ticket is being sold at its original price, the addition of the twickets fee will cause discount to be < 0 i.e. the total ticket price will have gone up.
func (TicketListing) DiscountString ¶
func (l TicketListing) DiscountString() string
DiscountString is the discount on the original price of a single ticket, including any fee as a percentage string between 0-100 with a % suffix.
If ticket is being sold at its original price, the addition of the twickets fee will cause discount to be < 0% i.e. the total ticket price will have gone up. If this is the / case "none" will be returned instead of a negative percentage
func (TicketListing) OriginalTicketPrice ¶
func (l TicketListing) OriginalTicketPrice() Price
OriginalTotalPrice is the original price of a single ticket, including any fee.
Use OriginalTotalPrice to get the original total price of all tickets, including any fee.
func (TicketListing) TicketPriceExclFee ¶
func (l TicketListing) TicketPriceExclFee() Price
TicketPriceExclFee is price of a single ticket, excluding fee.
Use TotalPriceExclFee to get the total price of all tickets, excluding fee.
Use TotalPriceInclFee to get the total price of all tickets, including fee.
Use TicketPriceInclFee to get the price of a single ticket, including fee.
func (TicketListing) TicketPriceInclFee ¶
func (l TicketListing) TicketPriceInclFee() Price
TicketPriceExclFee is price of a single ticket, including fee.
Use TotalPriceExclFee to get the total price of all tickets, excluding fee.
Use TotalPriceInclFee to get the total price of all tickets, including fee.
Use TicketPriceExclFee to get the price of a single ticket, excluding fee.
func (TicketListing) TotalPriceInclFee ¶
func (l TicketListing) TotalPriceInclFee() Price
TotalPriceExclFee is the total price of all tickets, including fee.
Use TotalPriceExclFee to get the total price of all tickets, excluding fee.
Use TicketPriceExclFee to get the price of a single ticket, excluding fee.
Use TicketPriceInclFee to get the price of a single ticket, including fee.
func (TicketListing) TwicketsFeePerTicket ¶
func (l TicketListing) TwicketsFeePerTicket() Price
TwicketsFeePerTicket is the twickets fee per ticket.
Use TwicketsFee to get the total fee for all tickets.
func (TicketListing) URL ¶
func (l TicketListing) URL() string
URL of the ticket listing
Format is: https://www.twickets.live/app/block/<ticketId>,<quanitity>
type TicketListings ¶
type TicketListings []TicketListing
TicketListings is a slice of ticket listings.
func (TicketListings) GetById ¶
func (l TicketListings) GetById(id string) *TicketListing
GetById gets the first ticket listing with a matching id, or returns nil if one does not exist.
type Tour ¶
type Tour struct {
Id string `json:"tourId"`
Name string `json:"tourName"`
Slug string `json:"slug"`
FirstEvent *Date `json:"minDate"` // 2024-06-06
LastEvent *Date `json:"maxDate"` // 2024-11-14
Countries []string `json:"countryCodes"` // TODO use enum - requires all countries to be added
}
Event contains the details of a tour.
