Created
July 17, 2018 10:10
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#The parameters supplied to
Transaction.retrieve()
come from the following examples:session
- Create SessionstarkIndustries
- Retrieve EntityborrowedCashTxId
- Create Transaction