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 Currency to convert and display the localized value

    Declaration

    Swift

    public func localizedDescription(in currency: Currency) -> String?

    Return Value

    A String if the value could be converted to the given Currency. 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 Currency to 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 given Currency. 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.notAllowed is thrown.

    • currency: The Currency to convert the nominal value

    Throws

    An ExchangeError.notAllowed if the price doesn not allow currency conversion.

    Declaration

    Swift

    public func value(in currency: Currency) throws -> Double

    Return 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)