framework

package
v0.0.0-...-88fd450 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDatabase

func OpenDatabase(filename string, recreate bool) (*sql.DB, error)

OpenDatabase deletes the database (if recreate is true), then returns a connection to a new SQLite database, stored in the specified database file

Types

type AirportDataLoaderService

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

AirportDataLoaderService handles loading airport data from static CSV files.

func NewAirportDataLoader

func NewAirportDataLoader(logger domain.Logger) *AirportDataLoaderService

NewAirportDataLoader creates a new instance.

func (*AirportDataLoaderService) LoadAirports

func (service *AirportDataLoaderService) LoadAirports(filename string, countries map[string]string,
	regions map[string]string) (map[string]domain.Airport, error)

LoadAirports returns a slice of Airports, with country and region names populated. The data is read from the specified CSV file.

func (*AirportDataLoaderService) LoadCountries

func (service *AirportDataLoaderService) LoadCountries(filename string) (map[string]string, error)

LoadCountries returns a map of countries, keyed by country code. The data is read from the specified CSV file.

func (*AirportDataLoaderService) LoadRegions

func (service *AirportDataLoaderService) LoadRegions(filename string) (map[string]string, error)

LoadRegions returns a map of regions, keyed by region code. The data is read from the specified CSV file.

type ArgumentsLoaderService

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

ArgumentsLoaderService handles loading arguments from a JSON file.

func NewArgumentsLoader

func NewArgumentsLoader(logger domain.Logger) *ArgumentsLoaderService

NewArgumentsLoader creates a new instance.

func (*ArgumentsLoaderService) Load

func (service *ArgumentsLoaderService) Load(filename string) (*domain.Arguments, error)

Load reads a JSON file of arguments.

type FlightRepository

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

FlightRepository handles CRUD operations on flight data.

func NewFlightRepository

func NewFlightRepository(logger domain.Logger, db *sql.DB) *FlightRepository

NewFlightRepository creates a new instance.

func (*FlightRepository) CreateAirports

func (repo *FlightRepository) CreateAirports(airports []domain.Airport) error

CreateAirports inserts all specified airports into the repository.

func (*FlightRepository) InitialiseSchema

func (repo *FlightRepository) InitialiseSchema() error

InitialiseSchema populates a blank repository with the schema - ie empty tables.

func (*FlightRepository) ReadAllAirports

func (repo *FlightRepository) ReadAllAirports() ([]domain.Airport, error)

ReadAllAirports reads all airports from the repository.

type LogWrapper

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

LogWrapper wraps the logrus logger in methods compatible with domain.Logger.

func NewLogWrapper

func NewLogWrapper(name string, debug bool) *LogWrapper

NewLogWrapper creates a logger with the specified name.

func (*LogWrapper) Debug

func (l *LogWrapper) Debug(args ...interface{})

Debug writes a static message at debug level.

func (*LogWrapper) Debugf

func (l *LogWrapper) Debugf(format string, args ...interface{})

Debugf writes a formatted message at debug level.

func (*LogWrapper) Error

func (l *LogWrapper) Error(args ...interface{})

Error writes a static message at error level.

func (*LogWrapper) Errorf

func (l *LogWrapper) Errorf(format string, args ...interface{})

Errorf writes a formatted message at error level.

func (*LogWrapper) Fatal

func (l *LogWrapper) Fatal(args ...interface{})

Fatal writes a static message at fatal level, then quits.

func (*LogWrapper) Fatalf

func (l *LogWrapper) Fatalf(format string, args ...interface{})

Fatalf writes a formatted message at fatal level, then quits.

func (*LogWrapper) Info

func (l *LogWrapper) Info(args ...interface{})

Info writes a static message at info level.

func (*LogWrapper) Infof

func (l *LogWrapper) Infof(format string, args ...interface{})

Infof writes a formatted message at debug level.

func (*LogWrapper) Warn

func (l *LogWrapper) Warn(args ...interface{})

Warn writes a static message at warn level.

func (*LogWrapper) Warnf

func (l *LogWrapper) Warnf(format string, args ...interface{})

Warnf writes a formatted message at warn level.

type SkyScannerAgent

type SkyScannerAgent struct {
	ID                 int `json:"Id"`
	Name               string
	ImageURL           string `json:"ImageUrl"`
	Status             string // e.g. "UpdatesPending", "UpdatesComplete"
	OptimisedForMobile bool
	Type               string // e.g. "Airline", "TravelAgent"
}

SkyScannerAgent details who has quoted

type SkyScannerBookingDetailsLink struct {
	URI    string `json:"Uri"` // relative REST query to get the booking
	Body   string // query params to add
	Method string // e.g. "PUT"
}

SkyScannerBookingDetailsLink contains links to get booking details

type SkyScannerCarrier

type SkyScannerCarrier struct {
	ID          int    `json:"Id"`
	Code        string `json:"Code,omitempty"`
	Name        string
	ImageURL    string `json:"ImageUrl"`
	DisplayCode string
}

SkyScannerCarrier details an Airline

type SkyScannerCurrency

type SkyScannerCurrency struct {
	Code                        string // e.g. "GBP",
	Symbol                      string // e.g. "£"
	ThousandsSeparator          string // e.g. ","
	DecimalSeparator            string // e.g. "."
	SymbolOnLeft                bool
	SpaceBetweenAmountAndSymbol bool
	RoundingCoefficient         int // e.g. 0
	DecimalDigits               int // e.g. 2
}

SkyScannerCurrency details how to format monetary values

type SkyScannerFlightNumber

type SkyScannerFlightNumber struct {
	FlightNumber string // e.g. "433"
	CarrierID    int    `json:"CarrierId"`
}

SkyScannerFlightNumber can be several for same carrier

type SkyScannerItinerary

type SkyScannerItinerary struct {
	OutboundLegID      string `json:"OutboundLegId"`
	InboundLegID       string `json:"InboundLegId"`
	PricingOptions     []SkyScannerPricingOption
	BookingDetailsLink SkyScannerBookingDetailsLink
}

SkyScannerItinerary contains a combination of Legs

type SkyScannerLeg

type SkyScannerLeg struct {
	ID                 string `json:"Id"`
	SegmentIds         []int
	OriginStation      int
	DestinationStation int
	Departure          string // e.g. "2019-10-14T12:30:00"
	Arrival            string // e.g. "2019-10-15T12:20:00"
	Duration           int    // minutes
	JourneyMode        string // e.g. "Flight"
	Stops              []int
	Carriers           []int
	OperatingCarriers  []int
	Directionality     string // e.g. "Outbound", "Inbound"
	FlightNumbers      []SkyScannerFlightNumber
}

SkyScannerLeg contains details of part of an itinery, e.g. the outbound flight

type SkyScannerPlace

type SkyScannerPlace struct {
	ID       int    `json:"Id"`
	ParentID *int   `json:"ParentId,omitempty"`
	Code     string // e.g. Airport IATA code "LHR", ISO country code "GB"
	Type     string // e.g. "Airport", "Country", "City"
	Name     string // e.g. "London Heathrow"
}

SkyScannerPlace details somewhere involved in the quote

type SkyScannerPricingOption

type SkyScannerPricingOption struct {
	Agents            []int // Agent ID
	QuoteAgeInMinutes int
	Price             float64 // e.g. 758.42
	DeeplinkURL       string  `json:"DeeplinkUrl"`
}

SkyScannerPricingOption contains a quote from Agent(s)

type SkyScannerQuery

type SkyScannerQuery struct {
	Country          string
	Currency         string
	Locale           string
	Adults           int
	Children         int
	Infants          int
	OriginPlace      string // actually a Place ID
	DestinationPlace string // actually a Place ID
	OutboundDate     string // YYYY-MM-DD
	InboundDate      string // YYYY-MM-DD
	LocationSchema   string // e,g, "Default"
	CabinClass       string
	GroupPricing     bool
}

SkyScannerQuery contains the original input parameters

type SkyScannerResponse

type SkyScannerResponse struct {
	SessionKey  string
	Query       SkyScannerQuery
	Status      string // "UpdatesPending", "UpdatesComplete"
	Itineraries []SkyScannerItinerary
	Legs        []SkyScannerLeg
	Segments    []SkyScannerSegment
	Carriers    []SkyScannerCarrier
	Agents      []SkyScannerAgent
	Places      []SkyScannerPlace
	Currencies  []SkyScannerCurrency
}

SkyScannerResponse is the top-level result

type SkyScannerSegment

type SkyScannerSegment struct {
	ID                 int `json:"Id"`
	OriginStation      int
	DestinationStation int
	DepartureDateTime  string // e.g. "2019-10-14T12:30:00"
	ArrivalDateTime    string // e.g. "2019-10-14T14:06:00"
	Carrier            int
	OperatingCarrier   int
	Duration           int
	FlightNumber       string
	JourneyMode        string // e.g. "Flight"
	Directionality     string // e.g. "Outbound", "Inbound"
}

SkyScannerSegment details part of a Leg

type SkyScannerService

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

SkyScannerService handles calling the sky scanner API.

func NewSkyScannerService

func NewSkyScannerService(logger domain.Logger) *SkyScannerService

NewSkyScannerService creates a new instance.

func (*SkyScannerService) PollForQuotes

func (service *SkyScannerService) PollForQuotes(sessionKey string, apiHost string, apiKey string,
	airports map[string]domain.Airport) (*domain.Quote, error)

PollForQuotes calls the skyscanner "Poll session results" operation, to look for quotes

func (*SkyScannerService) StartSearch

func (service *SkyScannerService) StartSearch(arguments *domain.Arguments) (string, error)

StartSearch calls the skyscanner "Create session" operation, which returns a session key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳