AccountService

public struct AccountService

Provides access to account operations

  • Retrieves a single account.

    Declaration

    Swift

    public func account(budgetId: String, accountId: String) async throws -> Account

    Parameters

    budgetId

    Id of the budget the account belongs to

    accountId

    Id of the account to be retrieved

    Return Value

    A single account

  • Retrieves all accounts for a single budget.

    Declaration

    Swift

    public func accounts(
        budgetId: String,
        lastKnowledgeOfServer: ServerKnowledge? = nil
    ) async throws -> (accounts: [Account], lastKnowledgeOfServer: ServerKnowledge)

    Parameters

    budgetId

    Id of the budget the accounts belongs to

    lastKnowledgeOfServer

    If provided, only entities that have changed since lastKnowledgeOfServer will be included.

    Return Value

    A list of accounts and the last server knowledge

  • Creates a new unlinked account in a budget.

    Declaration

    Swift

    public func newBudgetAccount(
        budgetId: String,
        name: String,
        type: AccountType,
        balance: Int
    ) async throws -> Account

    Parameters

    budgetId

    The id of the budget (last_used can also be used to specify the last used budget)

    name

    The name of the new account

    type

    The type of the new account

    balance

    The initial balance of the new account in milliunits format

    Return Value

    A single account