mono

package
v0.0.0-...-0eb1532 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// We do not use this internally but can be helpful for people who want to parse the date
	// correctly
	DateFormat = "02-01-2006"
)
View Source
const (
	Version = "0.1.0"
)

Variables

View Source
var ErrInvalidReauthorisationRequestScope = errors.New("not a valid ReauthorisationRequestScope")
View Source
var ErrInvalidTransactionType = errors.New("not a valid TransactionType")

Functions

func ToReader

func ToReader[T NoopRequestBody | any](t T) (io.Reader, error)

ToReader converts any struct into a io#Reader that can be used

Types

type AccountDetails

type AccountDetails struct {
	Account struct {
		ID            string `json:"id"`
		Name          string `json:"name"`
		Currency      string `json:"currency"`
		Type          string `json:"type"`
		AccountNumber string `json:"account_number"`
		Balance       int    `json:"balance"`
		Bvn           string `json:"bvn"`
		Institution   struct {
			Name     string `json:"name"`
			BankCode string `json:"bank_code"`
			Type     string `json:"type"`
		} `json:"institution"`
	} `json:"account"`
	Meta struct {
		DataStatus string `json:"data_status"`
		AuthMethod string `json:"auth_method"`
	} `json:"meta"`
}

type AccountDetailsResponse

type AccountDetailsResponse struct {
	BaseMonoResponse
	Data AccountDetails `json:"data"`
}

type AccountReauthorisation

type AccountReauthorisation struct {
	MonoURL  string `json:"mono_url"`
	Customer string `json:"customer"`
	Meta     struct {
		Ref string `json:"ref"`
	} `json:"meta"`
	Scope       string    `json:"scope"`
	RedirectURL string    `json:"redirect_url"`
	CreatedAt   time.Time `json:"created_at"`
}

type AccountService

type AccountService service

func (*AccountService) Balance

func (a *AccountService) Balance(ctx context.Context,
	opts FetchBalanceOptions) (int64, error)

func (*AccountService) Details

func (a *AccountService) Details(ctx context.Context,
	accountID string) (AccountDetails, error)
func (a *AccountService) Unlink(ctx context.Context,
	accountID string) error

type AuthorisationService

type AuthorisationService service

func (*AuthorisationService) ExchangeToken

func (a *AuthorisationService) ExchangeToken(ctx context.Context,
	opts ExchangeTokenRequest) (string, error)

func (*AuthorisationService) Reauthorise

type BaseMonoResponse

type BaseMonoResponse struct {
	Status    string    `json:"status"`
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
}

type Client

type Client struct {
	Account       *AccountService
	Authorisation *AuthorisationService
	Transaction   *TransactionService
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*Client, error)

func (*Client) Do

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

type ExchangeTokenRequest

type ExchangeTokenRequest struct {
	Code string `json:"code,omitempty"`
}

type ExchangeTokenResponse

type ExchangeTokenResponse struct {
	BaseMonoResponse
	Data struct {
		ID string `json:"id,omitempty"`
	} `json:"data,omitempty"`
}

type FetchBalanceOptions

type FetchBalanceOptions struct {
	AccountID string
	Realtime  bool
}

type InflowResponse

type InflowResponse = heatmapResponse

type NoopRequestBody

type NoopRequestBody struct{}

type Option

type Option func(*Client)

func WithAPISecret

func WithAPISecret(a string) Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

func WithUserAgent

func WithUserAgent(s string) Option

type OutflowResponse

type OutflowResponse = heatmapResponse

type ReauthorisationRequest

type ReauthorisationRequest struct {
	Meta struct {
		Ref string `json:"ref,omitempty"`
	} `json:"meta,omitempty"`
	RedirectURL string                      `json:"redirect_url,omitempty"`
	AccountID   string                      `json:"account,omitempty"`
	Scope       ReauthorisationRequestScope `json:"scope,omitempty"`
}

type ReauthorisationRequestScope

type ReauthorisationRequestScope string

ENUM(reauth)

const (
	// ReauthorisationRequestScopeReauth is a ReauthorisationRequestScope of type reauth.
	ReauthorisationRequestScopeReauth ReauthorisationRequestScope = "reauth"
)

func ParseReauthorisationRequestScope

func ParseReauthorisationRequestScope(name string) (ReauthorisationRequestScope, error)

ParseReauthorisationRequestScope attempts to convert a string to a ReauthorisationRequestScope.

func (ReauthorisationRequestScope) IsValid

func (x ReauthorisationRequestScope) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (ReauthorisationRequestScope) String

String implements the Stringer interface.

type ReauthorisationResponse

type ReauthorisationResponse struct {
	BaseMonoResponse
	Data AccountReauthorisation `json:"data,omitempty"`
}

type Response

type Response struct {
	*http.Response
}

type Transaction

type Transaction struct {
	ID        string    `json:"id"`
	Narration string    `json:"narration"`
	Amount    int       `json:"amount"`
	Type      string    `json:"type"`
	Balance   int       `json:"balance"`
	Date      time.Time `json:"date"`
	Category  string    `json:"category"`
}

type TransactionMetadata

type TransactionMetadata struct {
	Total    int    `json:"total"`
	Page     int    `json:"page"`
	Previous any    `json:"previous"`
	Next     string `json:"next"`
}

type TransactionService

type TransactionService service

func (*TransactionService) All

func (*TransactionService) Credits

func (t *TransactionService) Credits(ctx context.Context, accountID string) (
	InflowResponse, error)

func (*TransactionService) Debits

func (t *TransactionService) Debits(ctx context.Context, accountID string) (
	OutflowResponse, error)

type TransactionType

type TransactionType string

ENUM(debit,credit)

const (
	// TransactionTypeDebit is a TransactionType of type debit.
	TransactionTypeDebit TransactionType = "debit"
	// TransactionTypeCredit is a TransactionType of type credit.
	TransactionTypeCredit TransactionType = "credit"
)

func ParseTransactionType

func ParseTransactionType(name string) (TransactionType, error)

ParseTransactionType attempts to convert a string to a TransactionType.

func (TransactionType) IsValid

func (x TransactionType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (TransactionType) String

func (x TransactionType) String() string

String implements the Stringer interface.

type TransactionsFilter

type TransactionsFilter struct {
	Paginate  bool            `url:"paginate,omitempty"`
	End       string          `url:"end,omitempty"`
	Start     string          `url:"start,omitempty"`
	Narration string          `url:"narration,omitempty"`
	Type      TransactionType `url:"type,omitempty"`
	Limit     int             `url:"limit,omitempty"`
}

type TransactionsResponse

type TransactionsResponse struct {
	BaseMonoResponse
	Data []Transaction       `json:"data"`
	Meta TransactionMetadata `json:"meta"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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