offers

package
v0.0.0-...-b5277af Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDate

func CheckDate(w time.Time) bool

Check that string is after today

func DateAddTime

func DateAddTime(d, h string) time.Time

func FetchEntities

func FetchEntities(d time.Time) []byte

func FetchOffers

func FetchOffers(d time.Time, t string, sz int) []byte

func GetAuthCookieName

func GetAuthCookieName() string

func GetAuthURL

func GetAuthURL() string

func GetOffersURL

func GetOffersURL() string

func GetUserAgent

func GetUserAgent() string

func NormalizeDate

func NormalizeDate(b string) time.Time

func NormalizeMeal

func NormalizeMeal(s string) string

func SameDate

func SameDate(a time.Time, b string) bool

checks that a and b are the same date

func SetAuthCookieName

func SetAuthCookieName(n string)

Right now only saving need "Auth cookie" in the future it should save all needed cookies as defined int he configfile

func SetAuthURL

func SetAuthURL(u string) error

func SetOffersURL

func SetOffersURL(u string)

func SetUserAgent

func SetUserAgent(ua string)

func StringIn

func StringIn(set []string, t string) bool

Match if a any of the substrings, set, appear in string, t.

func ToInt

func ToInt(t string) int

Types

type AvailMap

type AvailMap []Available

type Available

type Available struct {
	When    time.Time
	Service string
	Seats   int
	URL     *url.URL
	Updated time.Time
}

type CurlAvail

type CurlAvail struct {
	HasAvailability        bool           `json:"hasAvailability"`
	AvailabilitySearchDate string         `json:"availabilitySearchDate"`
	Location               SingleLocation `json:"singleLocation"`
}

type CurlLocation

type CurlLocation struct {
	Error     string      `json:"error"`
	Locations []LocStruct `json:"locations"`
	Results   []ResStruct `json:"results"`
}

type CurlReturn

type CurlReturn struct {
	Error        string               `json:"error"`
	Availability map[string]CurlAvail `json:"availability"`
}

type DiningMap

type DiningMap map[int]DiningStruct

func GetOffersJSON

func GetOffersJSON(dt time.Time, availIn []byte, meal string, seats int) DiningMap

JSON List of offers return a DiningMap

func NewOffers

func NewOffers() DiningMap

func ParseEntities

func ParseEntities(results []byte) DiningMap

func (DiningMap) AddOffer

func (d DiningMap) AddOffer(id int, avail Available) bool

func (DiningMap) CountOffers

func (d DiningMap) CountOffers() int

func (DiningMap) Join

func (dst DiningMap) Join(src DiningMap) DiningMap

Join Dining Map, src with Dining Map dst

func (DiningMap) LoadOffers

func (d DiningMap) LoadOffers(n string)

func (DiningMap) Match

func (src DiningMap) Match(q MatchQuery) DiningMap

func (DiningMap) OfferExists

func (d DiningMap) OfferExists(id int, t time.Time) bool

func (DiningMap) PurgeOffers

func (d DiningMap) PurgeOffers(pTime time.Duration) int

func (DiningMap) SaveOffers

func (d DiningMap) SaveOffers(n string)

type DiningStruct

type DiningStruct struct {
	Location *Restaurant
	Offers   AvailMap
}

func (DiningStruct) ByIndex

func (d DiningStruct) ByIndex(i int) time.Time

Get an offer time by index

func (DiningStruct) FindOfferByTime

func (d DiningStruct) FindOfferByTime(t time.Time, seats int) int

func (DiningStruct) GroupByDate

func (d DiningStruct) GroupByDate() []time.Time

tells you what dates are currently on file

func (DiningStruct) MealsByDate

func (d DiningStruct) MealsByDate(t time.Time) []string

func (DiningStruct) NewOffers

func (d DiningStruct) NewOffers(src DiningStruct) bool

func (DiningStruct) RestaurantLocation

func (d DiningStruct) RestaurantLocation(i int) string

get the restaurant location, park or resort

func (DiningStruct) RestaurantName

func (d DiningStruct) RestaurantName() string

get the restaurant name

func (DiningStruct) RestaurantURL

func (d DiningStruct) RestaurantURL() string

get the restaurant url, the page about the place

func (DiningStruct) Seats

func (d DiningStruct) Seats(i int) int

Get seats by index

func (DiningStruct) SeatsByMeal

func (d DiningStruct) SeatsByMeal(t time.Time, meal string) []int

func (DiningStruct) TimesByMealDate

func (d DiningStruct) TimesByMealDate(t time.Time, meal string, seats int) []string

type LocStruct

type LocStruct struct {
	ID            string `json:"id"`
	Title         string `json:"title"`
	URLFriendlyId string `json:"urlFriendlyId"`
	LocationType  string `json:"locationType"`
}

type MatchQuery

type MatchQuery struct {
	Date       time.Time
	DateAfter  time.Time
	DateBefore time.Time
	Meal       string
	Seats      int
	Name       string
}

type OffersAvail

type OffersAvail struct {
	Date        string `json:"date"`
	Time        string `json:"time"`
	Label       string `json:"label"`
	URL         string `json:"url"`
	ProductType string `json:"productType"`
}

type ResStruct

type ResStruct struct {
	ID            string `json:"id"`
	URLFriendlyId string `json:"urlFriendlyId"`
	LocationName  string `json:"locationName"`
	ResURL        string `json:"url"`
	Name          string `json:"name"`
}

type Restaurant

type Restaurant struct {
	Name string
	Loc  []string
	ID   int
	URL  *url.URL
}

type SingleLocation

type SingleLocation struct {
	UnavailableReason string        `json:"unavailableReason"`
	Title             string        `json:"title"`
	Offers            []OffersAvail `json:"offers"`
}

Jump to

Keyboard shortcuts

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