sbank

package module
v0.0.0-...-e189d2c Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2018 License: MIT Imports: 10 Imported by: 0

README

sbank

sbank is a package for accessing the Bank and Customer APIs from sbanken.

Getting started

Before using this package, you will need a developer account at sbanken

After registering, you will need to create an application and generate a password which will be used when authenticating with the API.

Installation

> go get -u github.com/torie/sbank

Usage

Authentication

Authentication can either be handled by the package:

c := sbank.New("client-id", "client-secret")

Or an http.Client which handles authentication can be provided.

client := MyHTTPClient()
c := sbank.NewWithClient(client)
Examples

Examples can be found in the examples folder

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	AccountNumber   string  `json:"accountNumber"`
	CustomerID      string  `json:"customerId"`
	OwnerCustomerID string  `json:"ownerCustomerId"`
	Name            string  `json:"name"`
	AccountType     string  `json:"accountType"`
	Available       float64 `json:"available"`
	Balance         float64 `json:"balance"`
	CreditLimit     float64 `json:"creditLimit"`
	DefaultAccount  bool    `json:"defaultAccount"`
}

func (AccountInfo) String

func (a AccountInfo) String() string

type AccountResponse

type AccountResponse struct {
	Account      AccountInfo `json:"item"`
	ErrorType    string      `json:"errorType"`
	IsError      bool        `json:"isError"`
	ErrorMessage string      `json:"errorMessage"`
	TraceID      string      `json:"traceId"`
}

type AccountsResponse

type AccountsResponse struct {
	AvailableItems int           `json:"availableItems"`
	Accounts       []AccountInfo `json:"items"`
	ErrorType      string        `json:"errorType"`
	IsError        bool          `json:"isError"`
	ErrorMessage   string        `json:"errorMessage"`
	TraceID        string        `json:"traceId"`
}

type Address

type Address struct {
	AddressLine1 string `json:"addressLine1"`
	AddressLine2 string `json:"addressLine2"`
	AddressLine3 string `json:"addressLine3"`
	AddressLine4 string `json:"addressLine4"`
	Country      string `json:"country"`
	ZipCode      string `json:"zipCode"`
	City         string `json:"city"`
}

func (Address) String

func (a Address) String() string

type Client

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

Client can be used to communicate with the sbank APIs. https://sbanken.no/bruke/utviklerportalen/

func New

func New(id, secret string) *Client

New returns a new Client using the provided id and secret for authentication.

func NewWithClient

func NewWithClient(c *http.Client) *Client

NewWithClient returns a new Client using the provided http.Client as underlying transport. Note that the provided http.Client must handle the authorization.

func (*Client) Account

func (a *Client) Account(uid, aid string) (AccountResponse, error)

Account returns the account information for a single account.

func (*Client) Accounts

func (a *Client) Accounts(uid string) (AccountsResponse, error)

Accounts returns the account information for all accounts which belongs to the provided user.

func (*Client) Customer

func (a *Client) Customer(uid string) (CustomersReponse, error)

Customer returns information about a bank customer.

func (*Client) Transactions

func (a *Client) Transactions(uid, aid string, from, to *time.Time, offset, limit *int) (TransactionsResponse, error)

Transactions returns transactions for a single account. Additional parameters can be provided to limit the results returned.

* from/to: the range of dates to retrieve transactions for. * offset/limit: pagination for results.

type Customer

type Customer struct {
	CustomerID    string        `json:"customerId"`
	FirstName     string        `json:"firstName"`
	LastName      string        `json:"lastName"`
	EmailAddress  string        `json:"emailAddress"`
	DateOfBirth   string        `json:"dateOfBirth"`
	PostalAddress Address       `json:"postalAddress"`
	StreetAddress Address       `json:"streetAddress"`
	PhoneNumbers  []PhoneNumber `json:"phoneNumbers"`
}

Customer contains all information about a banking customer in sbank.

func (Customer) String

func (c Customer) String() string

type CustomersReponse

type CustomersReponse struct {
	Customer     Customer `json:"item"`
	ErrorType    string   `json:"errorType"`
	IsError      bool     `json:"isError"`
	ErrorMessage string   `json:"errorMessage"`
	TraceID      string   `json:"traceId"`
}

type PhoneNumber

type PhoneNumber struct {
	CountryCode string `json:"countryCode"`
	Number      string `json:"number"`
}

func (PhoneNumber) String

func (p PhoneNumber) String() string

type Transaction

type Transaction struct {
	TransactionID    string    `json:"transactionId"`
	CustomerID       string    `json:"customerId"`
	AccountNumber    string    `json:"accountNumber"`
	Amount           float64   `json:"amount"`
	Text             string    `json:"text"`
	TransactionType  string    `json:"transactionType"`
	RegistrationDate time.Time `json:"registrationDate"`
	AccountingDate   time.Time `json:"accountingDate"`
	InterestDate     time.Time `json:"interestDate"`
}

func (Transaction) String

func (t Transaction) String() string

type TransactionsResponse

type TransactionsResponse struct {
	AvailableItems int           `json:"availableItems"`
	Transactions   []Transaction `json:"items"`
	ErrorType      string        `json:"errorType"`
	IsError        bool          `json:"isError"`
	ErrorMessage   string        `json:"errorMessage"`
	TraceID        string        `json:"traceId"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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