CartRequest
public class CartRequest : MoltinRequest
An entry point to make API calls relating to Cart
-
The API endpoint for this resource.
Declaration
Swift
public var endpoint: String -
A typealias which allows automatic casting of a collection to
[CartItem].Declaration
Swift
public typealias DefaultCollectionRequestHandler = CollectionRequestHandler<[CartItem]> -
Return instance of type
CartbyidDeclaration
Swift
@discardableResult public func get(forID id: String, completionHandler: @escaping ObjectRequestHandler<Cart>) -> MoltinRequestParameters
forIDThe ID of the object
completionHandlerThe handler to be called on success or failure
Return Value
A instance of
MoltinRequestwhich encapsulates the request. -
Declaration
Swift
@discardableResult public func items(forCartID id: String, completionHandler: @escaping DefaultCollectionRequestHandler) -> MoltinRequestParameters
forCartIDThe ID of the object
completionHandlerThe handler to be called on success or failure
Return Value
A instance of
MoltinRequestwhich encapsulates the request. -
Adds an amount of products with
productIDto a specifiedCartwithtoCartDeclaration
Swift
@discardableResult public func addProduct(withID productID: String, ofQuantity quantity: Int, toCart cart: String, completionHandler: @escaping ObjectRequestHandler<[CartItem]>) -> MoltinRequestParameters
withIDThe ID of the product
ofQuantityThe amount of this product to add to the cart
toCartThe cart ID to add this product to
completionHandlerThe handler to be called on success or failure
Return Value
A instance of
MoltinRequestwhich encapsulates the request. -
Adds a custom cart item to a cart
Declaration
Swift
@discardableResult public func addCustomItem(_ customItem: CustomCartItem, toCart cart: String, completionHandler: @escaping ObjectRequestHandler<[CartItem]>) -> MoltinRequestParameters
customItemThe custom cart item to add to this cart
toCartThe cart ID to add this item to
completionHandlerThe handler to be called on success or failure
Return Value
A instance of
MoltinRequestwhich encapsulates the request. -
Adds a promotion to a cart
Declaration
Swift
@discardableResult public func addPromotion(_ promotion: String, toCart cart: String, completionHandler: @escaping ObjectRequestHandler<[CartItem]>) -> MoltinRequestParameters
promotionThe promotion code
toCartThe cart ID to add this promo to
completionHandlerThe handler to be called on success or failure
Return Value
A instance of
MoltinRequestwhich encapsulates the request. -
Removes an item from the cart
Declaration
Swift
@discardableResult public func removeItem(_ itemID: String, fromCart cart: String, completionHandler: @escaping ObjectRequestHandler<[CartItem]>) -> MoltinRequestParameters
itemIDThe cart item ID to remove
fromCartThe cart ID to remove this item from
completionHandlerThe handler to be called on success or failure
Return Value
A instance of
MoltinRequestwhich encapsulates the request. -
Updates an item in the cart
Declaration
Swift
@discardableResult public func updateItem(_ itemID: String, withQuantity quantity: Int, inCart cart: String, completionHandler: @escaping ObjectRequestHandler<[CartItem]>) -> MoltinRequestParameters
itemIDThe item ID to update
withQuantityThe amount of this item ID to update too.
inCartThe cart ID to update this item in
completionHandlerThe handler to be called on success or failure
Return Value
A instance of
MoltinRequestwhich encapsulates the request. -
Begins the checkout process for this cart
Declaration
Swift
@discardableResult public func checkout(cart: String, withCustomer customer: Customer, withBillingAddress billingAddress: Address, withShippingAddress shippingAddress: Address?, completionHandler: @escaping ObjectRequestHandler<Order>) -> MoltinRequestReturn Value
A instance of
MoltinRequestwhich encapsulates the request. -
Pay for an order
forOrderID: The order to pay for
withPaymentMethod: The payment method to pay with
completionHandler: The handler to be called on success or failure
Declaration
Swift
@discardableResult public func pay(forOrderID order: String, withPaymentMethod paymentMethod: PaymentMethod, completionHandler: @escaping ObjectRequestHandler<OrderSuccess>) -> MoltinRequestReturn Value
A instance of
MoltinRequestwhich encapsulates the request. -
Delete a cart
Declaration
Swift
@discardableResult public func deleteCart(_ cart: String, completionHandler: @escaping ObjectRequestHandler<[Cart]>) -> MoltinRequestParameters
cartThe cart ID to delete
completionHandlerThe handler to be called on success or failure
Return Value
A instance of
MoltinRequestwhich encapsulates the request.
View on GitHub
CartRequest Class Reference