fares

package
v0.0.1-alpha.12 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFareNotInTable = errors.New("fare not in table")

Functions

func AddDir

func AddDir(c *pgx.Conn, dir string) (err error)

func AddFareObject

func AddFareObject(c *pgx.Conn, f *FareObject) (err error)

func AddXml

func AddXml(c *pgx.Conn, file io.ReadCloser) (err error)

func AddZip

func AddZip(c *pgx.Conn, path string) (err error)

func GetDatasets

func GetDatasets(dir string, nocs string) (err error)

Types

type ApiResponse

type ApiResponse struct {
	Results []ApiResult `json:"results"`
}

type ApiResult

type ApiResult struct {
	Id  int    `json:"id"`
	Url string `json:"url"`
}

type AttrRef

type AttrRef struct {
	Ref string `xml:"ref,attr"`
}

type DistanceMatrixElement

type DistanceMatrixElement struct {
	Id                 string  `xml:"id,attr"`
	StartTariffZoneRef AttrRef `xml:"StartTariffZoneRef"`
	EndTariffZoneRef   AttrRef `xml:"EndTariffZoneRef"`
}

type DistanceMatrixElementPrice

type DistanceMatrixElementPrice struct {
	Id                           string  `xml:"id,attr"`
	GeographicalIntervalPriceRef AttrRef `xml:"GeographicalIntervalPriceRef"`
	DistanceMatrixElementRef     AttrRef `xml:"DistanceMatrixElementRef"`
}

type Fare

type Fare struct {
	Amount                 currency.Amount        `json:"amount"`
	ValidBetween           ValidBetween           `json:"validBetween"`
	UserProfile            UserProfile            `json:"userProfile"`
	SalesOfferPackage      SalesOfferPackage      `json:"salesOfferPackage"`
	PreassignedFareProduct PreassignedFareProduct `json:"preassignedFareProduct"`
}

Type Fare is used when finding fares from an imported FareObject

type FareObject

type FareObject struct {
	XMLName             xml.Name                 `xml:"PublicationDelivery"`
	References          FareObjectReferences     `xml:"PublicationRequest>topics>NetworkFrameTopic>NetworkFilterByValue>objectReferences"`
	Currency            string                   `xml:"dataObjects>CompositeFrame>FrameDefaults>DefaultCurrency"`
	Operators           []Operator               `xml:"dataObjects>CompositeFrame>frames>ResourceFrame>organisations>Operator"`
	Lines               []Line                   `xml:"dataObjects>CompositeFrame>frames>ServiceFrame>lines>Line"`
	ScheduledStopPoints []ScheduledStopPoint     `xml:"dataObjects>CompositeFrame>frames>ServiceFrame>scheduledStopPoints>ScheduledStopPoint"`
	FareZones           []FareZone               `xml:"dataObjects>CompositeFrame>frames>FareFrame>fareZones>FareZone"`
	Tariffs             []Tariff                 `xml:"dataObjects>CompositeFrame>frames>FareFrame>tariffs>Tariff"`
	UserProfiles        []UserProfile            `xml:"dataObjects>CompositeFrame>frames>FareFrame>usageParameters>UserProfile"`
	FareProducts        []PreassignedFareProduct `xml:"dataObjects>CompositeFrame>frames>FareFrame>fareProducts>PreassignedFareProduct"`
	SalesOfferPackages  []SalesOfferPackage      `xml:"dataObjects>CompositeFrame>frames>FareFrame>salesOfferPackages>SalesOfferPackage"`
	PriceGroups         []PriceGroup             `xml:"dataObjects>CompositeFrame>frames>FareFrame>priceGroups>PriceGroup"`
	FareTables          []FareTable              `xml:"dataObjects>CompositeFrame>frames>FareFrame>fareTables>FareTable"`
}

func ParseXml

func ParseXml(data []byte) (FareObject, error)

func (*FareObject) GetFare

func (f *FareObject) GetFare(from, to Naptan) (fare Fare, err error)

type FareObjectReferences

type FareObjectReferences struct {
	Operator AttrRef `xml:"OperatorRef"`
	Line     AttrRef `xml:"LineRef"`
}

type FareObjects

type FareObjects struct {
	Objects []FareObject
}

type FareTable

type FareTable struct {
	TariffRef                 AttrRef              `xml:"usedIn>TariffRef"`
	UserProfileRef            AttrRef              `xml:"pricesFor>UserProfileRef"`
	SalesOfferPackageRef      AttrRef              `xml:"pricesFor>SalesOfferPackageRef"`
	PreassignedFareProductRef AttrRef              `xml:"pricesFor>PreassignedFareProductRef"`
	Columns                   []FareTableRowColumn `xml:"columns>FareTableColumn"`
	Rows                      []FareTableRowColumn `xml:"rows>FareTableRow"`
	Cells                     []FareTableCell      `xml:"includes>FareTable>cells>Cell"`
}

type FareTableCell

type FareTableCell struct {
	Id                         string                     `xml:"id,attr"`
	DistanceMatrixElementPrice DistanceMatrixElementPrice `xml:"DistanceMatrixElementPrice"`
	ColumnRef                  AttrRef                    `xml:"ColumnRef"`
	RowRef                     AttrRef                    `xml:"RowRef"`
}

type FareTableRowColumn

type FareTableRowColumn struct {
	Id           string    `xml:"id,attr"`
	Order        string    `xml:"order,attr"`
	Name         string    `xml:"Name"`
	FareZoneRefs []AttrRef `xml:"representing>FareZoneRef"` // only in columns
}

type FareZone

type FareZone struct {
	Id      string                  `xml:"id,attr"`
	Name    string                  `xml:"Name"`
	Members []ScheduledStopPointRef `xml:"members>ScheduledStopPointRef"`
}

type GeographicalIntervalPrice

type GeographicalIntervalPrice struct {
	Id     string `xml:"id,attr"`
	Amount string `xml:"Amount"`
}

type Line

type Line struct {
	LineRef     string  `xml:"id,attr"`
	PublicCode  string  `xml:"PublicCode"`
	PrivateCode string  `xml:"PrivateCode"`
	OperatorRef AttrRef `xml:"OperatorRef"`
}

type Naptan

type Naptan string

type Noc

type Noc = agency.Noc

type Operator

type Operator struct {
	Id   string `xml:"id,attr"`
	Name string `xml:"Name"`
}

type PreassignedFareProduct

type PreassignedFareProduct struct {
	Id             string `xml:"id,attr" json:"id"`
	Name           string `xml:"Name" json:"name"`
	ChargingMoment string `xml:"ChargingMomentType" json:"chargingMoment"`
	TariffBasis    string `xml:"ConditionSummary>TariffBasis" json:"tariffBasis"`
	ProductType    string `xml:"ProductType" json:"productType"`
}

type PriceGroup

type PriceGroup struct {
	Id                        string                      `xml:"id,attr"`
	GeographicalIntervalPrice []GeographicalIntervalPrice `xml:"members>GeographicalIntervalPrice"`
}

type SalesOfferPackage

type SalesOfferPackage struct {
	Id          string `xml:"id,attr" json:"id"`
	Name        string `xml:"Name" json:"name"`
	Description string `xml:"Description" json:"description"`
}

type ScheduledStopPoint

type ScheduledStopPoint struct {
	ScheduledStopPointRef string               `xml:"id,attr"`
	Name                  string               `xml:"Name"`
	TopographicPlaceView  TopographicPlaceView `xml:"TopographicPlaceView"`
}

type ScheduledStopPointRef

type ScheduledStopPointRef struct {
	Ref  string `xml:"ref,attr"`
	Name string `xml:",chardata"`
}

type Tariff

type Tariff struct {
	Id                     string                  `xml:"id,attr"`
	Name                   string                  `xml:"Name"`
	OperatorRef            AttrRef                 `xml:"OperatorRef"`
	LineRef                AttrRef                 `xml:"LineRef"`
	TariffBasis            string                  `xml:"TariffBasis"`
	DistanceMatrixElements []DistanceMatrixElement `xml:"fareStructureElements>FareStructureElement>distanceMatrixElements>DistanceMatrixElement"`
	TripType               string                  `xml:"fareStructureElements>FareStructureElement>GenericParameterAssignment>limitations>RoundTrip>TripType"`
	ValidBetween           ValidBetween            `xml:"validityConditions>ValidBetween"`
}

type TopographicPlaceView

type TopographicPlaceView struct {
	TopographicPlaceViewRef AttrRef `xml:"TopographicPlaceRef"`
	Name                    string  `xml:"Name"`
}

type UserProfile

type UserProfile struct {
	Id         string `xml:"id,attr" json:"id"`
	Name       string `xml:"Name" json:"name"`
	UserType   string `xml:"UserType" json:"userType"`
	MinimumAge string `xml:"MinimumAge" json:"minimumAge"`
	MaximumAge string `xml:"MaximumAge" json:"maximumAge"`
}

type ValidBetween

type ValidBetween struct {
	FromDate XmlTime `xml:"FromDate" json:"fromDate"`
	ToDate   XmlTime `xml:"ToDate" json:"toDate"`
}

type XmlTime

type XmlTime struct {
	time.Time `json:"time"`
}

XmlTime allows timestamps in FareXChange XML to be unmarshalled into time.Time objects.

func (*XmlTime) UnmarshalXML

func (x *XmlTime) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

Jump to

Keyboard shortcuts

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