ProductInteractor

public protocol ProductInteractor: class

Product interactor that can retrieve a full product and handles all the business logic around the PCF product feature.

  • Type of the product.

    Declaration

    Swift

    var product: ProductType?
  • Type of the SKU.

    Declaration

    Swift

    associatedtype SkuType: Sku
  • Product data manager generic type.

    Declaration

    Swift

    associatedtype DataManagerType: ProductDataManager
  • Product data generic type.

    Declaration

    Swift

    associatedtype ProductType: Product
  • Data manager used to establish network communication and retrieve data.

    Declaration

    Swift

    var dataManager: DataManagerType
  • product(forProductId:completion:) Default implementation

    Fetches the product with the given product id.

    • Parameters:
      • productId: The product id to use.
      • completion: Completion block for the response of getting the full product.

    Default Implementation

    Returns a Bool that indicates if the product is out of stock.

    Declaration

    Swift

    func product(forProductId productId: String,

    Parameters

    productId

    The product id to use.

    completion

    Completion block for the response of getting the full product.

  • sku(forSKUId:productId:completion:) Default implementation

    Fetches the SKU with the given SKU id and product id.

    • Parameters:
      • skuId: The SKU id to use.
      • productId: The product id to use.
      • completion: The completion block.

    Default Implementation

    Returns a Bool that indicates if the product is out of stock.

    Declaration

    Swift

    func sku(forSKUId skuId: String,

    Parameters

    skuId

    The SKU id to use.

    productId

    The product id to use.

    completion

    The completion block.

  • imageURL(withImageId:usage:) Default implementation

    Convenience method to return the image URL for an imageId with a specific usage

    Default Implementation

    Returns a Bool that indicates if the product is out of stock.

    Declaration

    Swift

    func imageURL(withImageId imageId: String, usage: String) -> URL?

    Parameters

    imageId

    A valid imageId

    usage

    A kPCFImageUsage constant

    Return Value

    A URL for the image with the given usage

  • sizes() Default implementation

    Returns all the sizes for the product, available or not.

    Returns

    All the product sizes.

    Default Implementation

    Returns a Bool that indicates if the product is out of stock.

    Declaration

    Swift

    func sizes() -> [Size]

    Return Value

    All the product sizes.

  • colors() Default implementation

    Returns all the colors for the product, available or not.

    Returns

    All the product colors.

    Default Implementation

    Returns a Bool that indicates if the product is out of stock.

    Declaration

    Swift

    func colors() -> [Self.ProductType.SkuType.ColorType]

    Return Value

    All the product colors.

  • availableSizes() Default implementation

    Returns all available sizes for the product.

    Default Implementation

    Returns a Bool that indicates if the product is out of stock.

    Declaration

    Swift

    func availableSizes() -> [Size]

    Return Value

    An array of String sizes.

  • availableColors() Default implementation

    Returns all available colors for the product.

    Default Implementation

    Returns a Bool that indicates if the product is out of stock.

    Declaration

    Swift

    func availableColors() -> [Self.ProductType.SkuType.ColorType]

    Return Value

    An array of ColorType colors.

  • availableSizes(forColor:) Default implementation

    Returns

    Returns all available sizes for a specific product color.

    Default Implementation

    Returns a Bool that indicates if the product is out of stock.

    Declaration

    Swift

    func availableSizes(forColor color: Self.ProductType.SkuType.ColorType?) -> [Size]
  • availableColors(forSize:) Default implementation

    Returns all available colors for a specific product size.

    Default Implementation

    Returns a Bool that indicates if the product is out of stock.

    Declaration

    Swift

    func availableColors(forSize size: Size?) -> [Self.ProductType.SkuType.ColorType]

    Parameters

    size The product size

    .

    Return Value

    An array of ColorType colors.

  • sku(forColor:size:) Default implementation

    Returns a SKU for specific product color and size.

    Default Implementation

    Returns a Bool that indicates if the product is out of stock.

    Declaration

    Swift

    func sku(forColor color: Self.ProductType.SkuType.ColorType?, size: Size?) -> Self.ProductType.SkuType?

    Parameters

    color The product color

    .

    size The product size

    .

    Return Value

    A SkuType corresponding to the selected color and size. Returns nil if there is no SKUs matching the color or if the SKU is unavailable.

  • availableQuantities(forSKU:) Default implementation

    Returns an array of all the available quantities for a specific SKU. If the quantities are integers, the array is ordered lower to higher. Use this method to build a data source for a picker that you can show to the user so he can select a quantity based on the SKU.

    Default Implementation

    Declaration

    Swift

    func availableQuantities(forSKU sku: Self.ProductType.SkuType) -> [Int]

    Parameters

    sku The selected SKU

    .

    Return Value

    An array of quantities.

  • availableQuantities(forSKU:limit:) Default implementation

    Returns an array of all the available quantities for a specific SKU. If the quantities are integers, the array is ordered lower to higher. Use this method to build a data source for a picker that you can show to the user so he can select a quantity based on the SKU.

    Default Implementation

    Declaration

    Swift

    func availableQuantities(forSKU sku: Self.ProductType.SkuType, limit: NSInteger) -> [Int]

    Parameters

    sku The selected SkuType

    .

    limit Optional

    . The quantity limit.

    Return Value

    An array of quantities.

  • isProductOutOfStock() Default implementation

    Returns a Bool that indicates if the product is out of stock.

    Default Implementation

    Declaration

    Swift

    func isProductOutOfStock() -> Bool

    Return Value

    true if the product is out of stock. false if not.