MonetaryAmount
public struct MonetaryAmount : Decodable, Encodable
The amount in the selected currency.
-
Sum, a decimal number with a fixed point in the string representation.
Declaration
Swift
public let value: Decimal
-
ISO-4217 3-alpha character code of payment currency.
Declaration
Swift
public let currency: CurrencyCode
-
Creates instance of
MonetaryAmount
Declaration
Swift
public init(value: Decimal, currency: CurrencyCode)
Return Value
Instance of
MonetaryAmount
-
Creates a new instance by decoding from the given decoder. This initializer throws an error if reading from the decoder fails, or if the data read is corrupted or otherwise invalid.
Declaration
Swift
public init(from decoder: Decoder) throws
Parameters
decoder
The decoder to read data from.
-
Encodes this value into the given encoder. If the value fails to encode anything, encoder will encode an empty keyed container in its place. This function throws an error if any values are invalid for the given encoder’s format.
Declaration
Swift
public func encode(to encoder: Encoder) throws
Parameters
encoder
The encoder to write data to.