Documentation
¶
Overview ¶
Package moneyloverapi provides access to MoneyLover APIs.
Index ¶
- Constants
- Variables
- type Client
- type CredentialsProvider
- type InMemoryTokenStorage
- type Option
- func WithBaseURL(baseURL string) Option
- func WithClock(clock clock.Clock) Option
- func WithCredentials(username string, password string) Option
- func WithCredentialsProvider(provider CredentialsProvider) Option
- func WithCredentialsProviderAtLast(provider CredentialsProvider) Option
- func WithPassword(password string) Option
- func WithTimeout(timeout time.Duration) Option
- func WithTokenProvider(provider auth.TokenProvider) Option
- func WithTokenStorage(storage auth.TokenStorage) Option
- func WithUsername(username string) Option
- type RoundTripperFunc
Constants ¶
const ( // BaseURL is API Base URL. BaseURL = api.DefaultBaseURL )
Variables ¶
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") )
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 (*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 ¶
func (s *InMemoryTokenStorage) Get(_ context.Context, key string) (auth.OAuthToken, error)
Get gets OAuthToken from memory.
func (*InMemoryTokenStorage) Set ¶
func (s *InMemoryTokenStorage) Set(_ context.Context, key string, token auth.OAuthToken) error
Set sets OAuthToken to memory.
type Option ¶
type Option func(c *Client)
Option configures Client.
func WithCredentials ¶
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 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.
type RoundTripperFunc ¶
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.
Source Files
¶
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. |