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 | |
guard let USD: GlobalUnit = currencies.findWith(code: "USD") else { | |
// .findWith() returns an optional. If we end up here, Amatino | |
// doesn't support a currency with the supplied code. | |
} | |
// Do cool stuff with our new currency | |
print("Loaded a currency! Name: \(USD.name)") |
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 GlobalUnitList.retrieve( | |
session: session, | |
callback: { (error: Error?, units: GlobalUnitsList?) in | |
guard error == nil else { | |
// Handle errors | |
} | |
guard currencies: GlobalUnitList = units else { |
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 RecursiveBalance.retrieve( | |
session: session, | |
entity: starkIndustries, | |
account: cashAccount, | |
callback: { (error: Error?, balance: RecursiveBalance?) in | |
guard error == nil else { | |
// Handle error, e.g. 404 account not found, 403 you are not |
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 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 |
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 | |
GlobalUnit.retrieve( | |
unitId: 5, // The ID for U.S. dollars | |
session: session, | |
callback: { (error: Error?, unit: GlobalUnit?) in | |
guard error == nil else { | |
// Handle errors, e.g. a 404 for an unknown unit | |
} |
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 Account.create( | |
session: session, | |
entity: starkIndustries, | |
name: "Suit Cash", | |
type: .asset, | |
description: "A stash of cash for building new Iron Man suits", | |
globalUnit: usd, |
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 |
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 Account.retrieve( | |
session: session, | |
entity: starkIndustries, | |
accountId: cashAccountId, | |
callback: { (error: Error?, account: Account?) in | |
guard error == nil else { | |
// Handle error, e.g. a 404 for an account that does not |
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 Entity.retrieve( | |
session: session, | |
entityId: starkIndustriesId, | |
callback: { (error: Error?, retrievedEntity: Entity?) in | |
guard error == nil else { | |
// Handle errors, e.g. a 404 for a non-existant entity id | |
} |
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 Entity.create( | |
session: session, | |
name: "Stark Industries", | |
callback: { (error, newEntity) in | |
guard error == nil else { | |
// Handle errors | |
} |