moneyloverapi

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 14 Imported by: 3

README

MoneyLover API for Golang

GitHub Releases Build Status codecov Go Report Card GoDevDoc Donate

Unofficial MoneyLover API Client for Golang.

Disclaimer

This project is NOT sponsored or funded by MoneyLover nor any of its competitors.

The client is built on a collection of observed API calls and methods.

Prerequisites

  • Go >= 1.18

Install

go get github.com/nhatthm/moneyloverapi

Usage

TBD

Examples

TBA

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

Paypal donation

paypal

       or scan this

Documentation

Overview

Package moneyloverapi provides access to MoneyLover APIs.

Index

Constants

View Source
const (
	// BaseURL is API Base URL.
	BaseURL = api.DefaultBaseURL
)

Variables

View Source
var (
	// ErrUsernameIsEmpty indicates that the username is empty.
	ErrUsernameIsEmpty = errors.New("missing username")
	// ErrPasswordIsEmpty indicates that the username is empty.
	ErrPasswordIsEmpty = errors.New("missing password")
)
View Source
var ErrTokenKeyEmpty = errors.New("token key is empty")

ErrTokenKeyEmpty indicates that the key of token is empty and we can not persist that.

Functions

This section is empty.

Types

type Client

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

Client provides all MoneyLover APIs.

func NewClient

func NewClient(options ...Option) *Client

NewClient initiates a new transaction.Finder.

func (*Client) FindAllTransactionsInRange

func (c *Client) FindAllTransactionsInRange(ctx context.Context, wallet wallet.Wallet, from time.Time, to time.Time) ([]transaction.Transaction, error)

FindAllTransactionsInRange finds all transactions in a time period.

type CredentialsProvider

type CredentialsProvider interface {
	// Username provides a username.
	Username() string
	// Password provides a password.
	Password() string
}

CredentialsProvider provides username and password for authentication.

func Credentials

func Credentials(username string, password string) CredentialsProvider

Credentials initiates a new credentials provider.

func CredentialsFromEnv

func CredentialsFromEnv() CredentialsProvider

CredentialsFromEnv initiates a new credentials provider.

type InMemoryTokenStorage

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

InMemoryTokenStorage persists auth.OAuthToken into its memory.

func NewInMemoryTokenStorage

func NewInMemoryTokenStorage() *InMemoryTokenStorage

NewInMemoryTokenStorage initiates a new InMemoryTokenStorage.

func (*InMemoryTokenStorage) Get

Get gets OAuthToken from memory.

func (*InMemoryTokenStorage) Set

Set sets OAuthToken to memory.

type Option

type Option func(c *Client)

Option configures Client.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL sets API Base URL.

func WithClock

func WithClock(clock clock.Clock) Option

WithClock sets the clock (for testing purpose).

func WithCredentials

func WithCredentials(username string, password string) Option

WithCredentials sets username and password to login.

func WithCredentialsProvider

func WithCredentialsProvider(provider CredentialsProvider) Option

WithCredentialsProvider chains a new credentials provider.

func WithCredentialsProviderAtLast

func WithCredentialsProviderAtLast(provider CredentialsProvider) Option

WithCredentialsProviderAtLast chains a new credentials provider at last position.

func WithPassword

func WithPassword(password string) Option

WithPassword sets password to login.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets API Timeout.

func WithTokenProvider

func WithTokenProvider(provider auth.TokenProvider) Option

WithTokenProvider chains a new token provider.

func WithTokenStorage

func WithTokenStorage(storage auth.TokenStorage) Option

WithTokenStorage sets token storage for the internal apiTokenProvider.

func WithUsername

func WithUsername(username string) Option

WithUsername sets username to login.

type RoundTripperFunc

type RoundTripperFunc func(*http.Request) (*http.Response, error)

RoundTripperFunc is an inline http.RoundTripper.

func TokenRoundTripper

func TokenRoundTripper(p auth.TokenProvider, tripper http.RoundTripper) RoundTripperFunc

TokenRoundTripper sets Bearer Authorization header to the given request with a token given by a auth.TokenProvider.

func (RoundTripperFunc) RoundTrip

func (fn RoundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip satisfies RoundTripperFunc.

Directories

Path Synopsis
internal
api
Package api contains autogenerated REST client.
Package api contains autogenerated REST client.
types
Package types provides custom types.
Package types provides custom types.
pkg
auth
Package auth provides contracts for authentication.
Package auth provides contracts for authentication.
category
Package category provides contracts for managing categories.
Package category provides contracts for managing categories.
testkit
Package testkit provides functionalities for testing the APIs.
Package testkit provides functionalities for testing the APIs.
testkit/auth
Package auth provides functionalities for testing authentication.
Package auth provides functionalities for testing authentication.
testkit/category
Package category provides functionalities for testing category contract.
Package category provides functionalities for testing category contract.
testkit/transaction
Package transaction provides functionalities for testing transaction contract.
Package transaction provides functionalities for testing transaction contract.
testkit/wallet
Package wallet provides functionalities for testing wallet contract.
Package wallet provides functionalities for testing wallet contract.
transaction
Package transaction provides contracts for managing transactions.
Package transaction provides contracts for managing transactions.
user
Package user provides contracts for managing users.
Package user provides contracts for managing users.
wallet
Package wallet provides contracts for managing wallets.
Package wallet provides contracts for managing wallets.

Jump to

Keyboard shortcuts

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