Created
December 29, 2017 19:54
-
-
Save azamsharp/de0ac1b8465671d296b8605edab15f1d to your computer and use it in GitHub Desktop.
Transactions
This file contains hidden or 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
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