Price
public struct Price : Decodable
extension Price: ExpressibleByFloatLiteral
All prices come in this type that represents the value as well as the currency of the amount.
-
The base currency of the amount.
Declaration
Swift
public private(set) var baseCurrency: Currency -
A convenience computed property for displaying a localized description of the amount in its base currency. e.g. “$431.23”
Declaration
Swift
public var localizedDescriptionInBaseCurrency: String? { get } -
Undocumented
Declaration
Swift
public var roundedLocalizedDescriptionInBaseCurrency: String? { get } -
A localized descriptions of the amount in a currency of choice. If the price does not allow currency exchange and the given currency is different than its base, nil is returned.
currency: The
Currencyto convert and display the localized value
Declaration
Swift
public func localizedDescription(in currency: Currency) -> String?Return Value
A
Stringif the value could be converted to the givenCurrency. nil otherwise -
A localized descriptions of the rounded amount in a currency of choice. If the price does not allow currency exchange and the given currency is different than its base, nil is returned.
currency: The
Currencyto convert and display the localized value
Declaration
Swift
public func roundedLocalizedDescription(in currency: Currency) -> String?Return Value
A
Stringfor the rounded value if the value could be converted to the givenCurrency. nil otherwise -
The nominal value of the amount in its base currency
Declaration
Swift
public var valueInBaseCurrency: Double { get } -
The nominal value of the amount in its base currency. If the price does not allow currency conversion and the given currency is different than its base, an
ExchangeError.notAllowedis thrown.currency: The
Currencyto convert the nominal value
Throws
An
ExchangeError.notAllowedif the price doesn not allow currency conversion.Declaration
Swift
public func value(in currency: Currency) throws -> DoubleReturn Value
The nominal value of the price in given
Currency -
Undocumented
Declaration
Swift
public static func - (lhs: Price, rhs: Price) throws -> Price -
Undocumented
Declaration
Swift
public static func += (lhs: inout Price, rhs: Price) throws -
Undocumented
Declaration
Swift
public static func + (lhs: Price, rhs: Price) throws -> Price -
Undocumented
Declaration
Swift
public static func -= (lhs: inout Price, rhs: Price) throws -
Undocumented
Declaration
Swift
public static func * (lhs: Double, rhs: Price) -> Price -
Undocumented
Declaration
Swift
public static func * (lhs: Price, rhs: Double) -> Price -
Undocumented
Declaration
Swift
public static func *= (lhs: inout Price, rhs: Double) -
Declaration
Swift
public typealias FloatLiteralType = Double -
Declaration
Swift
public init(floatLiteral value: Double)
Price Structure Reference