aplos

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: MIT Imports: 13 Imported by: 0

README

Aplos API Client

GoDoc CI Workflow

Note: This is a pre-v1.0.0 library, expect the API surface to change.

This repo provides a minimal Aplos API client in Go, including authentication and a few basic read-only endpoints. Aplos is an online platform for nonprofits + churches to manage their general operations.

The covered API surface is currently quite minimal—if there's API endpoints or parameters that would be useful to you, feel free to file an issue!

Usage


import "github.com/Silicon-Ally/aplos"

...

See the examples/ directory for examples of using the API client.

Contributing

Contribution guidelines can be found on our website.

Documentation

Overview

Package aplos provides basic support for the Aplos API, see https://www.aplos.com/api This package is very much still under development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadPrivateKey

func LoadPrivateKey(dat []byte) (*rsa.PrivateKey, error)

LoadPrivateKey parses PKCS8-formatted bytes into an RSA key.

func LoadPrivateKeyFromFile

func LoadPrivateKeyFromFile(fp string) (*rsa.PrivateKey, error)

LoadPrivateKeyFromFile loads a base64-encoded, PKCS8-formatted RSA key file from disk. This is the format returned from the Aplos UI when creating and downloading an API key.

Types

type Account

type Account struct {
	AccountNumber int `json:"account_number"`
	Name          string

	// Populated in ListAccounts
	Category     string
	AccountGroup *AccountGroup `json:"account_group"`
	IsEnabled    bool          `json:"is_enabled"`
	Type         string
	Activity     string
}

type AccountGroup

type AccountGroup struct {
	ID   int
	Name string
	Seq  int
}

type Client

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

Client is an authenticated API client for connecting to Aplos.

func New

func New(clientID string, pk *rsa.PrivateKey) (*Client, error)

New returns an Aplos API client initialized with the given key credentials. If the credentials are invalid (expired, mismatched, malformed, etc), this call with fail.

func (*Client) Accounts

func (c *Client) Accounts(ctx context.Context, opts ...ListAccountOption) ([]Account, error)

Accounts returns a list of accounts satisfying the given options.

func (*Client) Transaction

func (c *Client) Transaction(ctx context.Context, id int) (*Transaction, error)

func (*Client) Transactions

func (c *Client) Transactions(ctx context.Context, opts ...ListTransactionOption) ([]Transaction, error)

Transactions returns a list of transactions satisfying the given options.

type Date

type Date struct {
	Year  int
	Month time.Month
	Day   int
}

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

type Fund

type Fund struct {
	ID   int
	Name string
}

type ListAccountOption

type ListAccountOption func(*listAccountsOpts)

func WithAccountName

func WithAccountName(acctName string) ListAccountOption

type ListTransactionOption

type ListTransactionOption func(*listTransactionsOpts)

func WithAccountNumber

func WithAccountNumber(acctNumber int) ListTransactionOption

func WithRangeEnd

func WithRangeEnd(year int, month time.Month, day int) ListTransactionOption

func WithRangeStart

func WithRangeStart(year int, month time.Month, day int) ListTransactionOption

type Time

type Time struct {
	time.Time
}

Time wraps the standard library's time.Time and supports the format returned by the Aplos API for time fields.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

type Transaction

type Transaction struct {
	ID             int
	Memo           string
	Date           Date
	IDNumber       int `json:"id_number"`
	Created        Time
	Amount         float64
	InClosedPeriod bool `json:"in_closed_period"`

	// Lines is only populated in the "get single transaction details" endpoint, e.g. GET /.../v1/transactions/{transactionID}
	Lines []TransactionLine
}

Transaction represents a single transaction recorded in a register.

type TransactionLine

type TransactionLine struct {
	ID      int
	Amount  float64
	Account Account
	Fund    Fund
}

TransactionLine is a single line in a larger transaction, like a journal entry.

Directories

Path Synopsis
examples
salary
Command salary provides an example of using the Aplos API to: 1.
Command salary provides an example of using the Aplos API to: 1.

Jump to

Keyboard shortcuts

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