starling

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

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

Go to latest
Published: Jan 2, 2022 License: MIT Imports: 15 Imported by: 0

README

Starling

Note: the project is now four years old and I believe the Starling API has moved on significantly and so this client may no longer function. I archived the project to reflect this. See https://developer.starlingbank.com as a good starting point for Starling development.

Build Status

This is an unofficial Go client for the Starling Bank API.

Both the Starling Bank API itself and this package are under active development and, whilst we try to keep breaking changes to a minimum, we cannot guarantee a stable interface. We use Semantic Versioning to quantify changes from one release to the next.

"Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable."

Installation

Use Go to fetch the latest version of the package.

go get -u 'github.com/billglover/starling'

Usage

It is assumed that you are able to provide an OAuth access-token when establishing the Starling client. Depending on your use case, it pay be as simple as passing in the personal access-token provided by Starling when you create an applicaiton. See the section on Personal Access Tokens in the Starling Developer Docs for more information on how to do this.

package main

import (
    "context"
    "fmt"

    "github.com/billglover/starling"
    "golang.org/x/oauth2"
)

func main() {
	ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: "{{YOUR_ACCESS_TOKEN}}"})
	ctx := context.Background()
	tc := oauth2.NewClient(ctx, ts)

	client := NewClient(tc)

	txns, _, _ := client.Transactions(ctx, nil)

	for _, txn := range txns {
		fmt.Println(txn.Created, txn.Amount, txn.Currency, txn.Narrative)
	}
}

If you want to use the production API rather than the sandbox, you need to create a client with additional options.

package main

import (
    "context"
    "fmt"
    "net/url"

    "github.com/billglover/starling"
    "golang.org/x/oauth2"
)

func main() {
	ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: "{{ACCESS_TOKEN}}"})
	ctx := context.Background()
	tc := oauth2.NewClient(ctx, ts)

	baseURL, _ := url.Parse(ProdURL)
	opts := ClientOptions{BaseURL: baseURL}
	client := NewClientWithOptions(tc, opts)

	txns, _, _ := client.Transactions(ctx, nil)

	for _, txn := range txns {
		fmt.Println(txn.Created, txn.Amount, txn.Currency, txn.Narrative)
	}
}

Starling Bank Developer Documentation

Contributors

Documentation

Overview

Package starling provides a client for using the Starling API.

Usage:

import "github.com/billglover/starling"

Construct a new Starling client, then call various methods on the API to access different functions of the Starling API. For example:

client := starling.NewClient(nil)

// retrieve transactions for the current user
txns, _, err := client.Transactions(ctx, nil)

The majority of the API calls will require you to pass in an access token:

ts := oauth2.StaticTokenSource(
	&oauth2.Token{AccessToken: "TOKEN"},
)
ctx := context.Background()
tc := oauth2.NewClient(ctx, ts)

client := starling.NewClient(tc)

The Starling API documentation is available at https://developer.starlingbank.com/docs.

Example (Live)
package main

import (
	"context"
	"fmt"
	"net/url"

	"github.com/billglover/starling"
	"golang.org/x/oauth2"
)

func main() {
	ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: "{{ACCESS_TOKEN}}"})
	ctx := context.Background()
	tc := oauth2.NewClient(ctx, ts)

	baseURL, _ := url.Parse(starling.ProdURL)
	opts := starling.ClientOptions{BaseURL: baseURL}
	client := starling.NewClientWithOptions(tc, opts)

	txns, _, _ := client.Transactions(ctx, nil)

	for _, txn := range txns {
		fmt.Println(txn.Created, txn.Amount, txn.Currency, txn.Narrative)
	}
}
Output:

Example (Sandbox)
package main

import (
	"context"
	"fmt"

	"github.com/billglover/starling"
	"golang.org/x/oauth2"
)

func main() {
	ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: "{{ACCESS_TOKEN}}"})
	ctx := context.Background()
	tc := oauth2.NewClient(ctx, ts)

	client := starling.NewClient(tc)

	txns, _, _ := client.Transactions(ctx, nil)

	for _, txn := range txns {
		fmt.Println(txn.Created, txn.Amount, txn.Currency, txn.Narrative)
	}
}
Output:

Index

Examples

Constants

View Source
const (
	// ProdURL for the production instance of the Starling API
	ProdURL = "https://api.starlingbank.com/"

	// SandboxURL for the sandbox instance of the Starling API
	SandboxURL = "https://api-sandbox.starlingbank.com/"
)

Variables

This section is empty.

Functions

func Validate

func Validate(r *http.Request, secret string) (bool, error)

Validate takes an http request and a web-hook secret and validates the request signature matches the signature provided in the X-Hook-Signature header. An error is returned if unable to parse the body of the request.

Types

type Account

type Account struct {
	UID           string `json:"id"`
	Name          string `json:"name"`
	AccountNumber string `json:"accountNumber"`
	SortCode      string `json:"sortCode"`
	Currency      string `json:"currency"`
	IBAN          string `json:"iban"`
	BIC           string `json:"bic"`
	CreatedAt     string `json:"createdAt"`
}

Account represents bank account details

type AccountID

type AccountID struct {
	ID     string `json:"accountIdentifier"`
	BankID string `json:"bankIdentifier"`
	IBAN   string `json:"iban"`
	BIC    string `json:"bic"`
}

AccountID represents the identifiers for an individual account

type AccountSummary

type AccountSummary struct {
	UID             string `json:"accountUid"`
	DefaultCategory string `json:"defaultCategory"`
	Currency        string `json:"currency"`
	CreatedAt       string `json:"createdAt"`
}

AccountSummary represents the basic account details

type Address

type Address struct {
	Street   string `json:"streetAddress"`
	City     string `json:"city"`
	Country  string `json:"country"`
	Postcode string `json:"postcode"`
}

Address is the physical address of the customer

type AddressHistory

type AddressHistory struct {
	Current  Address   `json:"current"`
	Previous []Address `json:"previous"`
}

AddressHistory are the current and previous physical addresses

type Amount

type Amount struct {
	Currency   string `json:"currency"`   // ISO-4217 3 character currency code
	MinorUnits int64  `json:"minorUnits"` // Amount in the minor units of the given currency; eg pence in GBP, cents in EUR
}

Amount represents the value and currency of a monetary amount

type AuthError

type AuthError string

AuthError indicates an issue with the authentication token

func (AuthError) Error

func (e AuthError) Error() string

func (AuthError) Temporary

func (e AuthError) Temporary() bool

Temporary indicates if an error is temporary

type Balance

type Balance struct {
	Cleared     float64 `json:"clearedBalance"`
	Effective   float64 `json:"effectiveBalance"`
	PendingTxns float64 `json:"pendingTransactions"`
	Available   float64 `json:"availableToSpend"`
	Overdraft   float64 `json:"acceptedOverdraft"`
	Currency    string  `json:"currency"`
	Amount      float64 `json:"amount"`
}

Balance represents the balance on an account

type Card

type Card struct {
	UID                 string `json:"id"`
	NameOnCard          string `json:"nameOnCard"`
	Type                string `json:"type"`
	Enabled             bool   `json:"enabled"`
	Cancelled           bool   `json:"cancelled"`
	ActivationRequested bool   `json:"activationRequested"`
	Activated           bool   `json:"activated"`
	DispatchDate        string `json:"dispatchDate"`
	LastFourDigits      string `json:"lastFourDigits"`
}

Card represents card details

type Client

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

Client holds configuration items for the Starling client and provides methods that interact with the Starling API.

func NewClient

func NewClient(cc *http.Client) *Client

NewClient returns a new Starling API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library). Inspiration: https://github.com/google/go-github/blob/master/github/github.go

func NewClientWithOptions

func NewClientWithOptions(cc *http.Client, opts ClientOptions) *Client

NewClientWithOptions takes ClientOptions, configures and returns a new client.

func (*Client) Account

func (c *Client) Account(ctx context.Context) (*Account, *http.Response, error)

Account returns the the account details for the current customer.

func (*Client) AccountBalance

func (c *Client) AccountBalance(ctx context.Context) (*Balance, *http.Response, error)

AccountBalance returns the the account balance for the current customer.

func (*Client) AccountID

func (c *Client) AccountID(ctx context.Context, uid string) (*AccountID, *http.Response, error)

AccountID returns the identifiers for an individual account

func (*Client) Accounts

func (c *Client) Accounts(ctx context.Context) ([]AccountSummary, *http.Response, error)

Accounts returns the the accounts held by the current user.

func (*Client) AddressHistory

func (c *Client) AddressHistory(ctx context.Context) (*AddressHistory, *http.Response, error)

AddressHistory returns the the customer details for the current customer.

func (*Client) Card

func (c *Client) Card(ctx context.Context) (*Card, *http.Response, error)

Card returns the the customer details for the current customer.

func (*Client) Contact

func (c *Client) Contact(ctx context.Context, uid string) (*Contact, *http.Response, error)

Contact returns an individual contact for the current customer.

func (*Client) ContactAccount

func (c *Client) ContactAccount(ctx context.Context, cUID, aUID string) (*ContactAccount, *http.Response, error)

ContactAccount returns the specified account for a given contact.

func (*Client) ContactAccounts

func (c *Client) ContactAccounts(ctx context.Context, uid string) ([]ContactAccount, *http.Response, error)

ContactAccounts returns the accounts for a given contact.

func (*Client) Contacts

func (c *Client) Contacts(ctx context.Context) ([]Contact, *http.Response, error)

Contacts returns the contacts for the current customer.

func (*Client) CreateContactAccount

func (c *Client) CreateContactAccount(ctx context.Context, ca ContactAccount) (string, *http.Response, error)

CreateContactAccount creates the specified account for a given contact.

func (*Client) CreateReceipt

func (c *Client) CreateReceipt(ctx context.Context, txnUID string, r Receipt) (*http.Response, error)

CreateReceipt creates a receipt for a given mastercard transaction.

func (*Client) CreateRecurringTransfer

func (c *Client) CreateRecurringTransfer(ctx context.Context, uid string, rtr RecurringTransferRequest) (string, *http.Response, error)

CreateRecurringTransfer sets up the recurring transfer for a savings goal. It takes the UID of the savings goal, along with a RecurringTransferRequest and returns the UID of the recurring transfer. It also returns the http response in case this is required for further processing. An error is returned on failure.

func (*Client) CreateSavingsGoal

func (c *Client) CreateSavingsGoal(ctx context.Context, uid string, sgReq SavingsGoalRequest) (*http.Response, error)

CreateSavingsGoal creates an individual savings goal based on a UID. It returns the http response in case this is required for further processing. An error will be returned if the API is unable to create the goal.

func (*Client) CreateScheduledPayment

func (c *Client) CreateScheduledPayment(ctx context.Context, p ScheduledPayment) (string, *http.Response, error)

CreateScheduledPayment creates a scheduled payment. It returns the UID for the scheduled payment.

func (*Client) CurrentUser

func (c *Client) CurrentUser(ctx context.Context) (*Identity, *http.Response, error)

CurrentUser returns the identity of the current user.

func (*Client) Customer

func (c *Client) Customer(ctx context.Context) (*Customer, *http.Response, error)

Customer returns the the customer details for the current customer.

func (*Client) DDTransaction

func (c *Client) DDTransaction(ctx context.Context, uid string) (*DDTransaction, *http.Response, error)

DDTransaction returns an individual transaction for the current customer.

func (*Client) DDTransactions

func (c *Client) DDTransactions(ctx context.Context, dr *DateRange) ([]DDTransaction, *http.Response, error)

DDTransactions returns a list of direct debit transactions for the current user. It accepts optional time.Time values to request transactions within a given date range. If these values are not provided the API returns the last 100 transactions.

func (*Client) DeleteContact

func (c *Client) DeleteContact(ctx context.Context, uid string) (*http.Response, error)

DeleteContact deletes an individual contact for the current customer. It returns http.StatusNoContent on success. No payload is returned.

func (*Client) DeleteDirectDebitMandate

func (c *Client) DeleteDirectDebitMandate(ctx context.Context, uid string) (*http.Response, error)

DeleteDirectDebitMandate deletes an individual DirectDebitMandate for the current customer.

func (*Client) DeleteRecurringTransfer

func (c *Client) DeleteRecurringTransfer(ctx context.Context, uid string) (*http.Response, error)

DeleteRecurringTransfer deletes the recurring transfer for a savings goal. It takes the UID of the savings goal and returns no content. It returns the http response in case this is required for further processing. An error is returned on failure.

func (*Client) DeleteSavingsGoal

func (c *Client) DeleteSavingsGoal(ctx context.Context, uid string) (*http.Response, error)

DeleteSavingsGoal deletes a savings goal for the current customer. It returns http.StatusNoContent on success. No payload is returned.

func (*Client) DirectDebitMandate

func (c *Client) DirectDebitMandate(ctx context.Context, uid string) (*DirectDebitMandate, *http.Response, error)

DirectDebitMandate returns a single DirectDebitMandate for the current customer.

func (*Client) DirectDebitMandates

func (c *Client) DirectDebitMandates(ctx context.Context) ([]DirectDebitMandate, *http.Response, error)

DirectDebitMandates returns the DirectDebitMandates for the current customer.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do sends a request and returns the response. An error is returned if the request cannot be sent or if the API returns an error. If a response is received, the body response body is decoded and stored in the value pointed to by v. Inspiration: https://github.com/google/go-github/blob/master/github/github.go

func (*Client) FPSTransactionIn

func (c *Client) FPSTransactionIn(ctx context.Context, uid string) (*Transaction, *http.Response, error)

FPSTransactionIn returns an individual transaction for the current customer.

func (*Client) FPSTransactionOut

func (c *Client) FPSTransactionOut(ctx context.Context, uid string) (*Transaction, *http.Response, error)

FPSTransactionOut returns an individual transaction for the current customer.

func (*Client) FPSTransactionsIn

func (c *Client) FPSTransactionsIn(ctx context.Context, dr *DateRange) ([]Transaction, *http.Response, error)

FPSTransactionsIn returns a list of inbound Faster Payments transaction summaries for the current user. It accepts optional time.Time values to request transactions within a given date range. If these values are not provided the API returns the last 100 transactions.

func (*Client) FPSTransactionsOut

func (c *Client) FPSTransactionsOut(ctx context.Context, dr *DateRange) ([]Transaction, *http.Response, error)

FPSTransactionsOut returns a list of inbound Faster Payments transaction summaries for the current user. It accepts optional time.Time values to request transactions within a given date range. If these values are not provided the API returns the last 100 transactions.

func (*Client) Feed

func (c *Client) Feed(ctx context.Context, act, cat string, opts *FeedOpts) ([]Item, *http.Response, error)

Feed returns a slice of Items for a given account and category. It returns an error if unable to retrieve the feed. Note: Feed uses the v2 API which is still under active development.

func (*Client) FeedItem

func (c *Client) FeedItem(ctx context.Context, act, cat, itm string) (*Item, *http.Response, error)

FeedItem returns a feed Item for a given account and category. It returns an error if unable to retrieve the feed Item. Note: FeedItem uses the v2 API which is still under active development.

func (*Client) MakeLocalPayment

func (c *Client) MakeLocalPayment(ctx context.Context, p LocalPayment) (*http.Response, error)

MakeLocalPayment creates a local payment.

func (*Client) MastercardTransaction

func (c *Client) MastercardTransaction(ctx context.Context, uid string) (*MastercardTransaction, *http.Response, error)

MastercardTransaction returns an individual mastercard transaction for the current customer.

func (*Client) MastercardTransactions

func (c *Client) MastercardTransactions(ctx context.Context, dr *DateRange) ([]MastercardTransaction, *http.Response, error)

MastercardTransactions returns a list of transaction summaries for the current user. It accepts optional time.Time values to request transactions within a given date range. If these values are not provided the API returns the last 100 transactions.

func (*Client) Merchant

func (c *Client) Merchant(ctx context.Context, uid string) (*Merchant, *http.Response, error)

Merchant returns an individual merchant based on the UID.

func (*Client) MerchantLocation

func (c *Client) MerchantLocation(ctx context.Context, mUID, lUID string) (*MerchantLocation, *http.Response, error)

MerchantLocation returns an individual merchant location based on the merchant UID and location UID.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an HTTP Request. The client baseURL is checked to confirm that it has a trailing slash. A relative URL should be provided without the leading slash. If a non-nil body is provided it will be JSON encoded and included in the request. Inspiration: https://github.com/google/go-github/blob/master/github/github.go

func (*Client) RecurringTransfer

func (c *Client) RecurringTransfer(ctx context.Context, uid string) (*RecurringTransferRequest, *http.Response, error)

RecurringTransfer returns the recurring savings for savings goal based on a UID. It also returns the http response in case this is required for further processing. An error will be returned if unable to retrieve the recurring savings set-up from the API.

func (*Client) SavingsGoal

func (c *Client) SavingsGoal(ctx context.Context, uid string) (*SavingsGoal, *http.Response, error)

SavingsGoal returns an individual savings goal based on a UID. It also returns the http response in case this is required for further processing. An error will be returned if unable to retrieve goals from the API.

func (*Client) SavingsGoalPhoto

func (c *Client) SavingsGoalPhoto(ctx context.Context, uid string) (*Photo, *http.Response, error)

SavingsGoalPhoto returns the photo for savings goal based on a UID. It also returns the http response in case this is required for further processing. An error will be returned if unable to retrieve the photo from the API.

func (*Client) SavingsGoals

func (c *Client) SavingsGoals(ctx context.Context) ([]SavingsGoal, *http.Response, error)

SavingsGoals returns the savings goals for the current user. It also returns the http response in case this is required for further processing. It is possible that the user has no savings goals in which case a nil value will be returned. An error will be returned if unable to retrieve goals from the API.

func (*Client) ScheduledPayments

func (c *Client) ScheduledPayments(ctx context.Context) ([]PaymentOrder, *http.Response, error)

ScheduledPayments retrieves a list of all the payment orders on the customer account. These may be orders for previous immediate payments or scheduled payment orders for future or on-going payments.

func (*Client) SetDDSpendingCategory

func (c *Client) SetDDSpendingCategory(ctx context.Context, uid, cat string) (*http.Response, error)

SetDDSpendingCategory updates the spending category for a given direct debit.

func (*Client) SetMastercardSpendingCategory

func (c *Client) SetMastercardSpendingCategory(ctx context.Context, uid, cat string) (*http.Response, error)

SetMastercardSpendingCategory updates the spending category for a given mastercard transaction.

func (*Client) Transaction

func (c *Client) Transaction(ctx context.Context, uid string) (*Transaction, *http.Response, error)

Transaction returns an individual transaction for the current customer.

func (*Client) Transactions

func (c *Client) Transactions(ctx context.Context, dr *DateRange) ([]Transaction, *http.Response, error)

Transactions returns a list of transaction summaries for the current user. It accepts optional time.Time values to request transactions within a given date range. If these values are not provided the API returns the last 100 transactions.

func (*Client) TransferFromSavingsGoal

func (c *Client) TransferFromSavingsGoal(ctx context.Context, goalUID string, a Amount) (string, *http.Response, error)

TransferFromSavingsGoal transfers money out of a savings goal. It returns the http response in case this is required for further processing. An error will be returned if the API is unable to transfer the amount out of the savings goal.

func (*Client) TransferToSavingsGoal

func (c *Client) TransferToSavingsGoal(ctx context.Context, goalUID string, a Amount) (string, *http.Response, error)

TransferToSavingsGoal transfers money into a savings goal. It returns the http response in case this is required for further processing. An error will be returned if the API is unable to transfer the amount into the savings goal.

type ClientOptions

type ClientOptions struct {
	BaseURL *url.URL
}

ClientOptions is a set of options that can be specified when creating a Starling client

type Contact

type Contact struct {
	UID  string `json:"id"`
	Name string `json:"name"`
}

Contact represents the details of a payee

type ContactAccount

type ContactAccount struct {
	UID           string `json:"id"`
	Type          string `json:"type"`
	Name          string `json:"name"`
	AccountNumber string `json:"accountNumber"`
	SortCode      string `json:"sortCode"`
}

ContactAccount holds payee account details

type Customer

type Customer struct {
	UID               string `json:"customerUid"`
	FirstName         string `json:"firstName"`
	LastName          string `json:"lastName"`
	DateOfBirth       string `json:"dateOfBirth"`
	Email             string `json:"email"`
	Phone             string `json:"phone"`
	AccountHolderType string `json:"accountHolderType"`
}

Customer represents the personal details of a customer

type DDTransaction

type DDTransaction struct {
	UID                 string  `json:"id"`
	Currency            string  `json:"currency"`
	Amount              float64 `json:"amount"`
	Direction           string  `json:"direction"`
	Created             string  `json:"created"`
	Narrative           string  `json:"narrative"`
	Source              string  `json:"source"`
	MandateUID          string  `json:"mandateId"`
	Type                string  `json:"type"`
	MerchantUID         string  `json:"merchantId"`
	MerchantLocationUID string  `json:"merchantLocationId"`
	SpendingCategory    string  `json:"spendingCategory"`
}

DDTransaction represents the details of a direct debit transaction.

type DateRange

type DateRange struct {
	From time.Time
	To   time.Time
}

DateRange holds two dates that represent a range. It is typically used when providing a range when querying the API.

type DirectDebitMandate

type DirectDebitMandate struct {
	UID            string `json:"uid"`
	Reference      string `json:"reference"`
	Status         string `json:"status"`
	Source         string `json:"source"`
	Created        string `json:"created"`
	Cancelled      string `json:"cancelled"`
	OriginatorName string `json:"originatorName"`
	OriginatorUID  string `json:"originatorUid"`
}

DirectDebitMandate represents a single mandate

type Error

type Error interface {
	error
	Temporary() bool
}

Error specifies additional methods on the standard error interface

type ErrorDetail

type ErrorDetail struct {
	Message string `json:"message"`
}

ErrorDetail holds the details of an error message

type Errors

type Errors []string

Errors contains a list of errors

func (Errors) Error

func (e Errors) Error() string

type FeedOpts

type FeedOpts struct {
	Since time.Time
}

FeedOpts defines options that can be passed when requesting a feed

type Identity

type Identity struct {
	UID              string   `json:"customerUid"`
	ExpiresAt        string   `json:"expiresAt"`
	Authenticated    bool     `json:"authenticated"`
	ExpiresInSeconds int64    `json:"expiresInSeconds"`
	Scopes           []string `json:"scopes"`
}

Identity is the identity of the current user

type Item

type Item struct {
	FeedItemUID              string    `json:"feedItemUid"`
	CategoryUID              string    `json:"categoryUid"`
	Amount                   Amount    `json:"amount"`
	SourceAmount             Amount    `json:"sourceAmount"`
	Direction                string    `json:"direction"`
	TransactionTime          time.Time `json:"transactionTime"`
	Source                   string    `json:"source"`
	SourceSubType            string    `json:"sourceSubType"`
	Status                   string    `json:"status"`
	CounterPartyType         string    `json:"counterPartyType"`
	CounterPartyUID          string    `json:"counterPartyUid"`
	CounterPartySubEntityUID string    `json:"counterPartySubEntityUid"`
	Reference                string    `json:"reference"`
	Country                  string    `json:"country"`
	SpendingCategory         string    `json:"spendingCategory"`
}

Item is a single customer transaction in their feed

type LocalPayment

type LocalPayment struct {
	Payment               PaymentAmount `json:"payment"`
	DestinationAccountUID string        `json:"destinationAccountUid"`
	Reference             string        `json:"reference"`
}

LocalPayment represents a local payment

type MastercardTransaction

type MastercardTransaction struct {
	Transaction
	Method            string  `json:"mastercardTransactionMethod"`
	Status            string  `json:"status"`
	SourceAmount      float64 `json:"sourceAmount"`
	SourceCurrency    string  `json:"sourceCurrency"`
	MerchantUID       string  `json:"merchantId"`
	SpendingCategory  string  `json:"spendingCategory"`
	Country           string  `json:"country"`
	POSTimestamp      string  `json:"posTimestamp"`
	AuthorisationCode string  `json:"authorisationCode"`
	EventUID          string  `json:"eventUid"`
	Receipt           Receipt `json:"receipt"`
	CardLast4         string  `json:"cardLast4"`
}

MastercardTransaction represents the details of a card transaction

type Merchant

type Merchant struct {
	UID             string `json:"merchantUid"`
	Name            string `json:"name"`
	Website         string `json:"website"`
	PhoneNumber     string `json:"phoneNumber"`
	TwitterUsername string `json:"twitterUsername"`
}

Merchant represents details of a merchant

type MerchantLocation

type MerchantLocation struct {
	UID                            string `json:"merchantLocationUid"`
	MerchantUID                    string `json:"merchantUid"`
	MerchantName                   string `json:"merchantName"`
	LocationName                   string `json:"locationName"`
	Address                        string `json:"address"`
	PhoneNumber                    string `json:"phoneNUmber"`
	GooglePlaceID                  string `json:"googlePlaceId"`
	MastercardMerchantCategoryCode int32  `json:"mastercardMerchantCategoryCode"`
}

MerchantLocation represents details of a merchant location

type PaymentAmount

type PaymentAmount struct {
	Currency string  `json:"currency"`
	Amount   float64 `json:"amount"`
}

PaymentAmount represents the currency and amount of a payment

type PaymentOrder

type PaymentOrder struct {
	UID                        string         `json:"paymentOrderId"`
	Currency                   string         `json:"currency"`
	Amount                     float64        `json:"amount"`
	Reference                  string         `json:"reference"`
	ReceivingContactAccountUID string         `json:"receivingContactAccountId"`
	RecipientName              string         `json:"recipientName"`
	Immediate                  bool           `json:"immediate"`
	RecurrenceRule             RecurrenceRule `json:"recurrenceRule"`
	StartDate                  string         `json:"startDate"`
	NextDate                   string         `json:"nextDate"`
	CancelledAt                string         `json:"cancelledAt"`
	PaymentType                string         `json:"paymentType"`
	MandateUID                 string         `json:"mandateId"`
}

PaymentOrder is a single PaymentOrder

type Photo

type Photo struct {
	Base64EncodedPhoto string `json:"base64EncodedPhoto"` // A text (base 64) encoded picture to associate with the savings goal
}

Photo is a photo associated to a savings goal

type Receipt

type Receipt struct {
	UID                string        `json:"receiptUid"`
	EventUID           string        `json:"eventUid"`
	MetadataSource     string        `json:"metadataSource"`
	ReceiptIdentifier  string        `json:"receiptIdentifier"`
	MerchantIdentifier string        `json:"merchantIdentifier"`
	MerchantAddress    string        `json:"merchantAddress"`
	TotalAmount        float64       `json:"totalAmount"`
	TotalTax           float64       `json:"totalTax"`
	TaxReference       string        `json:"taxNumber"`
	AuthCode           string        `json:"authCode"`
	CardLast4          string        `json:"cardLast4"`
	ProviderName       string        `json:"providerName"`
	Items              []ReceiptItem `json:"items"`
	Notes              []ReceiptNote `json:"notes"`
}

Receipt is a receipt for a transaction

type ReceiptItem

type ReceiptItem struct {
	UID         string  `json:"receiptItemUid"`
	Description string  `json:"description"`
	Quantity    int32   `json:"quantity"`
	Amount      float64 `json:"amount"`
	Tax         float64 `json:"tax"`
	URL         string  `json:"url"`
}

ReceiptItem is a single item on a Receipt

type ReceiptNote

type ReceiptNote struct {
	UID         string `json:"noteUid"`
	Description string `json:"description"`
	URL         string `json:"url"`
}

ReceiptNote is a single item on a Receipt

type RecurrenceRule

type RecurrenceRule struct {
	StartDate string `json:"startDate"`
	Frequency string `json:"frequency"`
	Interval  int32  `json:"interval,omitempty"`
	Count     int32  `json:"count,omitempty"`
	UntilDate string `json:"untilDate,omitempty"`
	WeekStart string `json:"weekStart"`
}

RecurrenceRule defines the pattern for recurring events

type RecurringTransferRequest

type RecurringTransferRequest struct {
	UID            string         `json:"transferUid,omitempty"`
	RecurrenceRule RecurrenceRule `json:"recurrenceRule"`
	Amount         `json:"currencyAndAmount"`
}

RecurringTransferRequest represents a request to create scheduled payment into a savings goal

type SavingsGoal

type SavingsGoal struct {
	UID             string `json:"uid"`  // Unique identifier of the savings goal
	Name            string `json:"name"` // Name of the savings goal
	Target          Amount `json:"target"`
	TotalSaved      Amount `json:"totalSaved"`
	SavedPercentage int32  `json:"savedPercentage"` // Percentage of target currently deposited in the savings goal
}

SavingsGoal is a goal defined by a customer to hold savings

type SavingsGoalRequest

type SavingsGoalRequest struct {
	Name               string `json:"name"`     // Name of the savings goal
	Currency           string `json:"currency"` // ISO-4217 3 character currency code of the savings goal
	Target             Amount `json:"target"`
	Base64EncodedPhoto string `json:"base64EncodedPhoto"` // A text (base 64) encoded picture to associate with the savings goal
}

SavingsGoalRequest is a request to create a new savings goal

type ScheduledPayment

type ScheduledPayment struct {
	LocalPayment
	Schedule RecurrenceRule `json:"recurrenceRule"`
}

ScheduledPayment represents a scheduled payment

type SpendingCategory

type SpendingCategory struct {
	SpendingCategory string `json:"spendingCategory"`
}

SpendingCategory is the category associated with a transaction

type Transaction

type Transaction struct {
	UID       string  `json:"id"`
	Currency  string  `json:"currency"`
	Amount    float64 `json:"amount"`
	Direction string  `json:"direction"`
	Created   string  `json:"created"`
	Narrative string  `json:"narrative"`
	Source    string  `json:"source"`
	Balance   float64 `json:"balance,omitempty"`
}

Transaction represents the details of a transaction.

type WebHookContent

type WebHookContent struct {
	Class          string  `json:"class"`
	TransactionUID string  `json:"transactionUid"`
	Amount         float64 `json:"amount"`
	SourceCurrency string  `json:"sourceCurrency"`
	SourceAmount   float64 `json:"sourceAmount"`
	CounterParty   string  `json:"counterParty"`
	Reference      string  `json:"reference"`
	Type           string  `json:"type"`
	ForCustomer    string  `json:"forCustomer"`
}

WebHookContent defines the structure of the Starling web hook content

type WebHookPayload

type WebHookPayload struct {
	WebhookNotificationUID string         `json:"webhookNotificationUid"`
	Timestamp              time.Time      `json:"timestamp"`
	Content                WebHookContent `json:"content"`
	AccountHolderUID       string         `json:"accountHolderUid"`
	WebhookType            string         `json:"webhookType"`
	CustomerUID            string         `json:"customerUid"`
	UID                    string         `json:"uid"`
}

WebHookPayload defines the structure of the Starling web hook payload

Jump to

Keyboard shortcuts

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