Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created December 29, 2017 19:54
Show Gist options
  • Save azamsharp/de0ac1b8465671d296b8605edab15f1d to your computer and use it in GitHub Desktop.
Save azamsharp/de0ac1b8465671d296b8605edab15f1d to your computer and use it in GitHub Desktop.
Transactions
class Transaction :Codable {
var from :String
var to :String
var amount :Double
init(from :String, to :String, amount :Double) {
self.from = from
self.to = to
self.amount = amount
}
init?(request :Request) {
guard let from = request.data["from"]?.string,
let to = request.data["to"]?.string,
let amount = request.data["amount"]?.double
else {
return nil
}
self.from = from
self.to = to
self.amount = amount
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment