diff --git a/api.go b/api.go index bb90bed..5df98e1 100644 --- a/api.go +++ b/api.go @@ -334,15 +334,17 @@ func (auth *Client) GetContacts(retType string) (string, *Contacts) { return "", contacts } -func (auth *Client) GetLastTransactions() (*Transactions, error) { - return auth.GetTransactions(TimeStamp{}, TimeStamp{}) +func (auth *Client) GetLastTransactions(limit string) (*Transactions, error) { + return auth.GetTransactions(TimeStamp{}, TimeStamp{}, limit) } // Get transactions for the given time window. // Use the zero values for the time stamps if no restrictions are // desired (use the defaults on the server) -func (auth *Client) GetTransactions(from, to TimeStamp) (*Transactions, error) { - params := map[string]string{} +func (auth *Client) GetTransactions(from, to TimeStamp, limit string) (*Transactions, error) { + params := map[string]string{ + "limit": limit, + } //Filter is applied only if both values are set if !from.IsZero() && !to.IsZero() { params["from"] = fmt.Sprint(from.AsMillis()) diff --git a/cmd/n26/n26 b/cmd/n26/n26 new file mode 100755 index 0000000..8409d81 Binary files /dev/null and b/cmd/n26/n26 differ diff --git a/cmd/n26/n26.go b/cmd/n26/n26.go index b8a85f8..feb4e25 100644 --- a/cmd/n26/n26.go +++ b/cmd/n26/n26.go @@ -15,7 +15,7 @@ import ( ) const ( - appVersion = "1.4.3" + appVersion = "1.4.4" ) func check(e error) { @@ -231,6 +231,7 @@ func main() { Usage: "list your past transactions. Supports CSV output", ArgsUsage: "[csv|json|table]", Flags: []cli.Flag{ + cli.StringFlag{Name: "limit", Value: "10", Usage: "retrieve last N transactions. Default to 10."}, cli.StringFlag{Name: "from", Usage: "retrieve transactions from this date. " + "Also 'to' flag needs to be set. Calendar date in the format yyyy-mm-dd. E.g. 2018-03-01"}, cli.StringFlag{Name: "to", Usage: "retrieve transactions until this date. " + @@ -242,6 +243,7 @@ func main() { check(err) writer, err := getTransactionWriter(c.Args().First()) check(err) + limit := c.String("limit") var transactions *n26.Transactions if c.IsSet("from") && c.IsSet("to") { var from, to n26.TimeStamp @@ -249,9 +251,9 @@ func main() { check(err) to.Time, err = time.Parse(dateFormat, c.String("to")) check(err) - transactions, err = API.GetTransactions(from, to) + transactions, err = API.GetTransactions(from, to, limit) } else { - transactions, err = API.GetLastTransactions() + transactions, err = API.GetLastTransactions(limit) } check(err)