Documentation
¶
Overview ¶
Package opal provides programmatic access to Opal card information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultAuthFile = filepath.Join(os.Getenv("HOME"), ".opal")
DefaultAuthFile is a default place to store authentication information. Pass this to FileAuthStore if an alternate path isn't required.
Functions ¶
This section is empty.
Types ¶
type Activity ¶
type Activity struct {
CardName string
Transactions []*Transaction
}
Activity represents a subset of activity for a single card.
type ActivityRequest ¶
type ActivityRequest struct {
CardIndex int
// Offset is how many pages into the past to fetch.
// Zero is the most recent activity.
Offset int
}
An ActivityRequest configures the operation of Activity.
type AuthStore ¶
An AuthStore is an interface for loading and saving authentication information. See FileAuthStore for a file-based implementation.
func FileAuthStore ¶
FileAuthStore returns an AuthStore that stores authentication information in a named file.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an interface to the online Opal system.
func (*Client) Activity ¶
func (c *Client) Activity(req ActivityRequest) (*Activity, error)
Activity fetches a subset of the activity data for a card.
func (*Client) WriteConfig ¶
WriteConfig writes the configuration to the client's AuthStore.
type Overview ¶
type Overview struct {
Cards []Card
}
Overview represents an overview of an Opal account.
type Transaction ¶
type Transaction struct {
Number int
When time.Time
Mode string // "train", etc., if known
Details string
JourneyNumber int // if known; numbered within the week
FareApplied string // e.g. "Off-peak", "Travel Reward"
Fare, Discount, Amount int // in cents
}
Transaction represents a single transaction on a card. This may be a single journey, or a top-up. Not all fields may be set.
func (*Transaction) String ¶
func (t *Transaction) String() string