fio

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 12 Imported by: 0

README

fio

GoDoc Build Status Go Report Card

API client for Fio Banka written in Go.

Install

go get github.com/jbub/fio

Docs

https://pkg.go.dev/github.com/jbub/fio

Example

package main

import (
    "fmt"
    "log"
    "time"
    "context"

    "github.com/jbub/fio"
)

func main() {
    client := fio.NewClient("mytoken", nil)

    opts := fio.ByPeriodOptions{
        DateFrom: time.Now(),
        DateTo:   time.Now(),
    }

    resp, err := client.Transactions.ByPeriod(context.Background(), opts)
    if err != nil {
        log.Fatal(err)
    }

    for _, tx := range resp.Transactions {
        fmt.Println(tx.ID)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeURL

func SanitizeURL(token string, u *url.URL) *url.URL

SanitizeURL redacts the token part of the URL.

Types

type ByPeriodOptions

type ByPeriodOptions struct {
	DateFrom time.Time
	DateTo   time.Time
}

ByPeriodOptions represents options passed to ByPeriod.

type Client

type Client struct {
	Token        string
	BaseURL      *url.URL
	Transactions *TransactionsService
	// contains filtered or unexported fields
}

Client is fio http api client.

func NewClient

func NewClient(token string, client *http.Client) *Client

NewClient returns new fio http client.

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response
	Message  string
	Token    string
}

ErrorResponse wraps http response errors.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type ExportFormat

type ExportFormat string

ExportFormat represents export formats supported by Export.

const (
	JSONFormat ExportFormat = "json"
	XMLFormat  ExportFormat = "xml"
	CSVFormat  ExportFormat = "csv"
	GPCFormat  ExportFormat = "gpc"
	HTMLFormat ExportFormat = "html"
	OFXFormat  ExportFormat = "ofx"
)

Supported ExportFormat types.

type ExportOptions

type ExportOptions struct {
	DateFrom time.Time
	DateTo   time.Time
	Format   ExportFormat
}

ExportOptions represents options passed to Export.

type ExportStatementOptions

type ExportStatementOptions struct {
	Year   int
	ID     int
	Format ExportFormat
}

type GetStatementOptions

type GetStatementOptions struct {
	Year int
	ID   int
}

GetStatementOptions represents options passed to GetStatement.

type SetLastDownloadDateOptions

type SetLastDownloadDateOptions struct {
	Date time.Time
}

SetLastDownloadDateOptions represents options passed to SetLastDownloadDate.

type SetLastDownloadIDOptions

type SetLastDownloadIDOptions struct {
	ID int
}

SetLastDownloadIDOptions represents options passed to SetLastDownloadID.

type StatementInfo

type StatementInfo struct {
	AccountID      int64
	BankID         string
	Currency       string
	IBAN           string
	BIC            string
	OpeningBalance decimal.Decimal
	ClosingBalance decimal.Decimal
	DateStart      time.Time
	DateEnd        time.Time
	YearList       int64
	IDFrom         int64
	IDTo           int64
	IDLastDownload int64
	IDList         int64
}

StatementInfo represents account statement info.

type Transaction

type Transaction struct {
	ID                 int64
	Date               time.Time
	Amount             decimal.Decimal
	Currency           string
	Account            string
	AccountName        string
	BankName           string
	BankCode           string
	ConstantSymbol     string
	VariableSymbol     string
	SpecificSymbol     string
	UserIdentification string
	RecipientMessage   string
	Type               string
	Specification      string
	Comment            string
	BIC                string
	OrderID            string
	PayerReference     string
}

Transaction represents transaction.

type TransactionsResponse

type TransactionsResponse struct {
	Info         StatementInfo
	Transactions []Transaction
}

TransactionsResponse represents response transactions.

type TransactionsService

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

TransactionsService is a service for working with transactions.

func (*TransactionsService) ByPeriod

ByPeriod returns transactions in date period.

func (*TransactionsService) Export

Export writes transactions in date period to provided writer.

func (*TransactionsService) ExportStatement

func (s *TransactionsService) ExportStatement(ctx context.Context, opts ExportStatementOptions, w io.Writer) error

ExportStatement writes statement by its year/id to provided writer.

func (*TransactionsService) GetStatement

GetStatement returns statement by its year/id.

func (*TransactionsService) SetLastDownloadDate

func (s *TransactionsService) SetLastDownloadDate(ctx context.Context, opts SetLastDownloadDateOptions) error

SetLastDownloadDate sets the last download date of statement.

func (*TransactionsService) SetLastDownloadID

func (s *TransactionsService) SetLastDownloadID(ctx context.Context, opts SetLastDownloadIDOptions) error

SetLastDownloadID sets the last downloaded id of statement.

func (*TransactionsService) SinceLastDownload

func (s *TransactionsService) SinceLastDownload(ctx context.Context) (*TransactionsResponse, error)

SinceLastDownload returns transactions since last download.

Jump to

Keyboard shortcuts

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