Skip to content

Instantly share code, notes, and snippets.

@hwjeremy
Created July 17, 2018 10:10
Show Gist options
  • Save hwjeremy/6fc71fbda13f9710ea6b974de2e33356 to your computer and use it in GitHub Desktop.
Save hwjeremy/6fc71fbda13f9710ea6b974de2e33356 to your computer and use it in GitHub Desktop.
Retrieve a Transaction 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 Transaction.retrieve(
session: session,
entity: starkIndustries,
transactionId: borrowedCashTxId,
callback: { (error: Error?, transaction: Transaction?) in
guard error == nil else {
// Handle error. E.g. 404 for an unknown Transaction, or 403
// for a Transaction you are not authorised to retrieve.
}
guard let borrowedCash: Transaction = transaction {
// Should never happen, but we guard against nil because we
// are good little Swift programmers
}
// Do cool stuff with the newly retrieved Transaction
print("Retrieved Transaction: \(borrowedCash.description)")
return
})
@hwjeremy
Copy link
Author

hwjeremy commented Jul 17, 2018

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

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