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
Cart
byid
Declaration
Swift
@discardableResult public func get(forID id: String, completionHandler: @escaping ObjectRequestHandler<Cart>) -> MoltinRequest
Parameters
forID
The ID of the object
completionHandler
The handler to be called on success or failure
Return Value
A instance of
MoltinRequest
which encapsulates the request. -
Declaration
Swift
@discardableResult public func items(forCartID id: String, completionHandler: @escaping DefaultCollectionRequestHandler) -> MoltinRequest
Parameters
forCartID
The ID of the object
completionHandler
The handler to be called on success or failure
Return Value
A instance of
MoltinRequest
which encapsulates the request. -
Adds an amount of products with
productID
to a specifiedCart
withtoCart
Declaration
Swift
@discardableResult public func addProduct(withID productID: String, ofQuantity quantity: Int, toCart cart: String, completionHandler: @escaping ObjectRequestHandler<[CartItem]>) -> MoltinRequest
Parameters
withID
The ID of the product
ofQuantity
The amount of this product to add to the cart
toCart
The cart ID to add this product to
completionHandler
The handler to be called on success or failure
Return Value
A instance of
MoltinRequest
which 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]>) -> MoltinRequest
Parameters
customItem
The custom cart item to add to this cart
toCart
The cart ID to add this item to
completionHandler
The handler to be called on success or failure
Return Value
A instance of
MoltinRequest
which encapsulates the request. -
Adds a promotion to a cart
Declaration
Swift
@discardableResult public func addPromotion(_ promotion: String, toCart cart: String, completionHandler: @escaping ObjectRequestHandler<[CartItem]>) -> MoltinRequest
Parameters
promotion
The promotion code
toCart
The cart ID to add this promo to
completionHandler
The handler to be called on success or failure
Return Value
A instance of
MoltinRequest
which encapsulates the request. -
Removes an item from the cart
Declaration
Swift
@discardableResult public func removeItem(_ itemID: String, fromCart cart: String, completionHandler: @escaping ObjectRequestHandler<[CartItem]>) -> MoltinRequest
Parameters
itemID
The cart item ID to remove
fromCart
The cart ID to remove this item from
completionHandler
The handler to be called on success or failure
Return Value
A instance of
MoltinRequest
which 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]>) -> MoltinRequest
Parameters
itemID
The item ID to update
withQuantity
The amount of this item ID to update too.
inCart
The cart ID to update this item in
completionHandler
The handler to be called on success or failure
Return Value
A instance of
MoltinRequest
which 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>) -> MoltinRequest
Return Value
A instance of
MoltinRequest
which 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>) -> MoltinRequest
Return Value
A instance of
MoltinRequest
which encapsulates the request. -
Delete a cart
Declaration
Swift
@discardableResult public func deleteCart(_ cart: String, completionHandler: @escaping ObjectRequestHandler<[Cart]>) -> MoltinRequest
Parameters
cart
The cart ID to delete
completionHandler
The handler to be called on success or failure
Return Value
A instance of
MoltinRequest
which encapsulates the request.