Skip to content

Commit b8175d9

Browse files
committed
Add doc comments for exported symbols.
1 parent ecf771d commit b8175d9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

client.go

+10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var cookieBaseURL = &url.URL{
3535
Host: "www.opal.com.au",
3636
}
3737

38+
// NewClient constructs a new Client.
3839
func NewClient(as AuthStore) (*Client, error) {
3940
a, err := as.Load()
4041
if err != nil {
@@ -57,11 +58,13 @@ func NewClient(as AuthStore) (*Client, error) {
5758
return c, nil
5859
}
5960

61+
// WriteConfig writes the configuration to the client's AuthStore.
6062
func (c *Client) WriteConfig() error {
6163
c.a.Cookies = c.hc.Jar.Cookies(cookieBaseURL)
6264
return c.as.Save(c.a)
6365
}
6466

67+
// Overview fetches the account overview.
6568
func (c *Client) Overview() (*Overview, error) {
6669
body, err := c.get("https://www.opal.com.au/registered/index")
6770
if err != nil {
@@ -70,13 +73,15 @@ func (c *Client) Overview() (*Overview, error) {
7073
return parseOverview(body)
7174
}
7275

76+
// An ActivityRequest configures the operation of Activity.
7377
type ActivityRequest struct {
7478
CardIndex int
7579
// Offset is how many pages into the past to fetch.
7680
// Zero is the most recent activity.
7781
Offset int
7882
}
7983

84+
// Activity fetches a subset of the activity data for a card.
8085
func (c *Client) Activity(req ActivityRequest) (*Activity, error) {
8186
u := fmt.Sprintf("https://www.opal.com.au/registered/opal-card-transactions/?cardIndex=%d", req.CardIndex)
8287
if req.Offset > 0 {
@@ -155,13 +160,18 @@ func (c *Client) login() error {
155160
return nil
156161
}
157162

163+
// An AuthStore is an interface for loading and saving authentication information.
164+
// See FileAuthStore for a file-based implementation.
158165
type AuthStore interface {
159166
Load() (*Auth, error)
160167
Save(*Auth) error
161168
}
162169

170+
// DefaultAuthFile is a default place to store authentication information.
171+
// Pass this to FileAuthStore if an alternate path isn't required.
163172
var DefaultAuthFile = filepath.Join(os.Getenv("HOME"), ".opal")
164173

174+
// FileAuthStore returns an AuthStore that stores authentication information in a named file.
165175
func FileAuthStore(filename string) AuthStore {
166176
return fileAuthStore{filename}
167177
}

parse.go

+6
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ import (
1313
"code.google.com/p/go.net/html/atom"
1414
)
1515

16+
// Overview represents an overview of an Opal account.
1617
type Overview struct {
1718
Cards []Card
1819
}
1920

21+
// Card represents a single Opal card.
2022
type Card struct {
2123
Name string // either a name or number
2224
Balance int // in cents
@@ -101,11 +103,15 @@ func parseOverview(input []byte) (*Overview, error) {
101103
return o, nil
102104
}
103105

106+
// Activity represents a subset of activity for a single card.
104107
type Activity struct {
105108
CardName string
106109
Transactions []*Transaction
107110
}
108111

112+
// Transaction represents a single transaction on a card.
113+
// This may be a single journey, or a top-up.
114+
// Not all fields may be set.
109115
type Transaction struct {
110116
Number int
111117
When time.Time

0 commit comments

Comments
 (0)