AccountService

public struct AccountService

Provides access to account operations

  • Retrieves a single account.

    Declaration

    Swift

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

    Parameters

    planId

    Id of the plan the account belongs to

    accountId

    Id of the account to be retrieved

    Return Value

    A single account

  • Retrieves all accounts for a single plan.

    Declaration

    Swift

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

    Parameters

    planId

    Id of the plan 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 plan.

    Declaration

    Swift

    public func newPlanAccount(
        planId: String,
        name: String,
        type: SaveAccountType,
        balance: Int
    ) async throws -> Account

    Parameters

    planId

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

    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