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 implementationFetches 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
productIdThe product id to use.
completionCompletion block for the response of getting the full product.
- Parameters:
-
sku(forSKUId:productId:completion:)Default implementationFetches 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
skuIdThe SKU id to use.
productIdThe product id to use.
completionThe completion block.
- Parameters:
-
imageURL(withImageId:usage:)Default implementationConvenience 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
imageIdA valid imageId
usageA kPCFImageUsage constant
Return Value
A URL for the image with the given usage
-
sizes()Default implementationReturns 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 implementationReturns 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 implementationReturns 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 implementationReturns 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 implementationReturns
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 implementationReturns 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 implementationReturns 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 implementationReturns 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 implementationReturns 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 implementationReturns a Bool that indicates if the product is out of stock.
Default Implementation
Declaration
Swift
func isProductOutOfStock() -> BoolReturn Value
true if the product is out of stock. false if not.
ProductInteractor Protocol Reference