Documentation
¶
Index ¶
- Constants
- Variables
- func FeedUrl(input FeedUrlInput) (string, error)
- func ListingURL(listingId string, numTickets int) string
- type Artist
- type Client
- type Country
- type Currency
- type Date
- type DateTime
- type Event
- type FeedUrlInput
- type FetchTicketListingsInput
- type Filter
- type Lineup
- type Location
- type Price
- type Region
- type TicketListing
- func (l TicketListing) Discount() float64
- func (l TicketListing) DiscountString() string
- func (l TicketListing) MatchesAnyFilter(filters ...Filter) (bool, error)
- 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() )
var DefaultClient = NewClient(nil)
Functions ¶
func FeedUrl ¶
func FeedUrl(input FeedUrlInput) (string, error)
FeedUrl gets the url of a feed of ticket listings
Format is: https://www.twigots.live/services/catalogue?q=countryCode=GB&count=100&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.twigots.live/app/block/<ticketId>,<numTickets>
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 Currency ¶
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 FetchTicketListingsInput ¶
type FetchTicketListingsInput struct {
// Required fields
APIKey string
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
// NumPerRequest is the number of ticket listings to fetch in each request.
// Not all requested listings are fetched at once - instead a series of requests are made,
// each fetching the number of listings specified here. In theory this can be arbitrarily
// large to prevent having to make too many requests, however it has been known that any
// other number than 10 can sometimes not work.
// Defaults to 10. Usually can be ignored.
NumPerRequest int
}
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.
type Filter ¶
type Filter struct {
// Name of event on ticket listing to match.
// Required.
Event string
// Similarity of event name on ticket listing to the event name specified in the filter.
// Specified as a float, between 0 and 1 (with 1 representing an exact match).
// Defaults to 0.85 to account for variances in event names.
// e.g. Taylor Swift and Taylor Swift: The Eras Tour should match.
EventSimilarity float64
// Regions on ticket listings to match.
// Leave this unset or empty to match any region.
// Defaults to unset.
Regions []Region
// Number of tickets in a listing to match.
// Leave this unset or 0 to match any number of tickets.
// Defaults to unset.
NumTickets int
// Minimum discount (including fee) of tickets in a listing to match.
// Specified as a float, between 0 and 1 (with 1 representing 100% off).
// Leave this unset or 0 to match any discount (including no discount).
// Defaults to unset.
MinDiscount float64
// Time a listing must be created before to be match
// Leave this unset to match any creation time.
// Defaults to unset.
CreatedBefore time.Time
// Time a listing must be created after to be match
// Leave this unset to match any creation time.
// Defaults to unset.
CreatedAfter time.Time
}
A filter to use on ticket listing(s). A ticket listing can either match the filter or not.
A ticket listing must satisfy all specified filter fields to match, making this an AND filter.
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 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).
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
func (TicketListing) MatchesAnyFilter ¶
func (l TicketListing) MatchesAnyFilter(filters ...Filter) (bool, error)
MatchesAnyFilter checks if a ticket listing matches any of the filters provided.
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.twigots.live/app/block/<ticketId>,<quanitity>
type TicketListings ¶
type TicketListings []TicketListing
TicketListings is a slice of ticket listings.
func (TicketListings) Filter ¶
func (l TicketListings) Filter(filters ...Filter) (TicketListings, error)
Filter ticket listings based on whether they match any of the filters provided.
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.