forked from woocommerce/woocommerce-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProductAction.swift
76 lines (63 loc) · 2.87 KB
/
ProductAction.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import Foundation
import Networking
/// ProductAction: Defines all of the Actions supported by the ProductStore.
///
public enum ProductAction: Action {
/// Searches products that contain a given keyword.
///
case searchProducts(siteID: Int64,
keyword: String,
pageNumber: Int,
pageSize: Int,
excludedProductIDs: [Int64] = [],
onCompletion: (Result<Void, Error>) -> Void)
/// Synchronizes the Products matching the specified criteria.
///
/// - Parameter onCompletion: called when sync completes, returns an error or a boolean that indicates whether there might be more products to sync.
///
case synchronizeProducts(siteID: Int64,
pageNumber: Int,
pageSize: Int,
stockStatus: ProductStockStatus?,
productStatus: ProductStatus?,
productType: ProductType?,
productCategory: ProductCategory?,
sortOrder: ProductsSortOrder,
excludedProductIDs: [Int64] = [],
shouldDeleteStoredProductsOnFirstPage: Bool = true,
onCompletion: (Result<Bool, Error>) -> Void)
/// Retrieves the specified Product.
///
case retrieveProduct(siteID: Int64, productID: Int64, onCompletion: (Result<Product, Error>) -> Void)
/// Retrieves a specified list of Products.
///
/// - Parameter onCompletion: called when retrieval for a page completes, returns an error or a tuple of a list of products and a boolean that
/// indicates whether there might be more products to fetch.
///
case retrieveProducts(siteID: Int64,
productIDs: [Int64],
pageNumber: Int = ProductsRemote.Default.pageNumber,
pageSize: Int = ProductsRemote.Default.pageSize,
onCompletion: (Result<(products: [Product], hasNextPage: Bool), Error>) -> Void)
/// Deletes all of the cached products.
///
case resetStoredProducts(onCompletion: () -> Void)
/// Requests the Products found in a specified Order.
///
case requestMissingProducts(for: Order, onCompletion: (Error?) -> Void)
/// Adds a new Product.
///
case addProduct(product: Product, onCompletion: (Result<Product, ProductUpdateError>) -> Void)
/// Delete an existing Product.
///
case deleteProduct(siteID: Int64, productID: Int64, onCompletion: (Result<Product, ProductUpdateError>) -> Void)
/// Updates a specified Product.
///
case updateProduct(product: Product, onCompletion: (Result<Product, ProductUpdateError>) -> Void)
/// Checks whether a Product SKU is valid against other Products in the store.
///
case validateProductSKU(_ sku: String?, siteID: Int64, onCompletion: (Bool) -> Void)
/// Upserts a product in our local storage
///
case replaceProductLocally(product: Product, onCompletion: () -> Void)
}