app

package
v0.0.0-...-630d023 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2017 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodyToHTML

func BodyToHTML(body *Body) (string, error)

Types

type Body

type Body struct {
	SearchGroups []*SearchGroup
}

Structs that map to templates

func NewBody

func NewBody(searches FlightSearchStates) *Body

type EmailFlightsNotifier

type EmailFlightsNotifier struct {
	SmtpAddress string
	Auth        smtp.Auth
	From        string
	To          string
}

func (*EmailFlightsNotifier) Notify

func (e *EmailFlightsNotifier) Notify(searchStates FlightSearchStates) error

type FlightFetcher

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

func NewFlightFetcher

func NewFlightFetcher(swClient *client.Client) *FlightFetcher

func (*FlightFetcher) Fetch

func (f *FlightFetcher) Fetch(search *FlightSearch) ([]*model.Flight, error)

Fetch all flights that match a given search

type FlightSearch

type FlightSearch struct {
	OriginAirports      []string  `json:"origin_airports"`
	DestinationAirports []string  `json:"destination_airports"`
	MinDepartureTime    time.Time `json:"min_departure_time"`
	MaxArrivalTime      time.Time `json:"max_arrival_time"`
	MaxFareCents        *uint32   `json:"max_fare_cents"`
	MaxNumberStops      *uint8    `json:"max_number_stops"`
	Note                *string   `json:"note"`
}

Config JSON representation of flight search

func FlightSearchesFromFile

func FlightSearchesFromFile(filename string) ([]*FlightSearch, error)

func FlightSearchesFromJson

func FlightSearchesFromJson(data []byte) ([]*FlightSearch, error)

func (*FlightSearch) String

func (f *FlightSearch) String() string

type FlightSearchByMinDepartureTime

type FlightSearchByMinDepartureTime []*FlightSearch

Helper to sort FlightSearch by MinDepartureTime

func (FlightSearchByMinDepartureTime) Len

func (FlightSearchByMinDepartureTime) Less

func (FlightSearchByMinDepartureTime) Swap

func (b FlightSearchByMinDepartureTime) Swap(i, j int)

type FlightSearchStates

type FlightSearchStates map[*FlightSearch]FlightStates

func NewFlightSearchStates

func NewFlightSearchStates() FlightSearchStates

func (FlightSearchStates) OnlyAvailable

func (f FlightSearchStates) OnlyAvailable() (available FlightSearchStates, improved bool)

func (FlightSearchStates) Update

func (f FlightSearchStates) Update(search *FlightSearch, flights []*model.Flight)

type FlightState

type FlightState struct {
	Flight *model.Flight
	Update FlightStateChange
}

type FlightStateByDepartureLocalTime

type FlightStateByDepartureLocalTime []FlightState

Helper to sort FlightState by flight DepartureLocalTime

func (FlightStateByDepartureLocalTime) Len

func (FlightStateByDepartureLocalTime) Less

func (FlightStateByDepartureLocalTime) Swap

func (b FlightStateByDepartureLocalTime) Swap(i, j int)

type FlightStateChange

type FlightStateChange int
const (
	Unchanged FlightStateChange = iota
	FareIncrease
	FareDecrease
	Added
	Removed
)

type FlightStates

type FlightStates map[model.FlightId]FlightState

func (FlightStates) OnlyAvailable

func (s FlightStates) OnlyAvailable() (available FlightStates, improved bool)

func (FlightStates) Update

func (s FlightStates) Update(flights []*model.Flight)

type SearchGroup

type SearchGroup struct {
	Date    string
	MaxFare *string
	Note    *string
	Trips   []*Trip
}

type SearchStateUpdater

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

Container to keep and update flight state.

func NewSearchStateUpdater

func NewSearchStateUpdater(searches []*FlightSearch, fetcher *FlightFetcher, notifier SearchUpdateNotifier) *SearchStateUpdater

func (*SearchStateUpdater) Update

func (c *SearchStateUpdater) Update() error

Fetch latest flight info, update state, and send updates to the notifier.

type SearchUpdateNotifier

type SearchUpdateNotifier interface {
	Notify(searchStates FlightSearchStates) error
}

type SearchUpdateNotifierChain

type SearchUpdateNotifierChain []SearchUpdateNotifier

func (SearchUpdateNotifierChain) Notify

func (s SearchUpdateNotifierChain) Notify(searchStates FlightSearchStates) error

type StdoutNotifier

type StdoutNotifier struct{}

func (*StdoutNotifier) Notify

func (s *StdoutNotifier) Notify(searchStates FlightSearchStates) error

type Trip

type Trip struct {
	OriginAirport      string
	DestinationAirport string
	DepartureTime      string
	ArrivalTime        string
	Stops              int
	Cost               string
	Update             FlightStateChange
}

Jump to

Keyboard shortcuts

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