Skip to content

Instantly share code, notes, and snippets.

@hwjeremy
Created July 19, 2018 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwjeremy/44aa66d235aa946e55d18ec8343c7d8a to your computer and use it in GitHub Desktop.
Save hwjeremy/44aa66d235aa946e55d18ec8343c7d8a to your computer and use it in GitHub Desktop.
Retrieve a Balance in Amatino Swift - A double-entry accounting library for iOS & MacOS
// Amatino Swift: https://github.com/amatino-code/amatino-swift
// Double entry accounting API
try Balance.retrieve(
session: session,
entity: starkIndustries,
account: cashAccount,
callback: { (error: Error?, balance: Balance?) in
guard error == nil else {
// Handle error, e.g. 404 account not found, 403 you are not
// authorised to view the account
}
guard let cashAccountBalance: Balance = balance else {
// Should never happen, but we guard against nil like good
// little programmers!
}
// Do cool stuff with the cashAccountBalance
print("Cash account balance: \(cashAccountBalance.magnitude)")
})
@hwjeremy
Copy link
Author

The parameters supplied to Balance.retrieve() come from the following examples:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment