CartApi
All URIs are relative to http://localhost
| Method | HTTP request | Description |
|---|---|---|
| addItems | POST /cart | Update cart items by adding new items to the cart |
| applyPromoCode | POST /cart/promo_code | Apply promo code |
| checkout | POST /cart/checkout | Checkout last payment cart |
| checkoutOrder | POST /cart/checkout/{id} | Checkout saved cart by id |
| clearCart | DELETE /cart | Remove all items from cart |
| convertOrderToDraft | POST /cart/convert_to_draft | Convert pending payment cart back into Draft status |
| deletePaymentMethods | DELETE /payment_methods/{id} | Delete payment method |
| getItems | GET /cart | Return cart content |
| listPaymentMethods | GET /payment_methods | Fetch payment methods for the user |
| removeItem | DELETE /cart/cart_items/{cart_item_id} | Removes an order item from the cart |
addItems#
/*** @returns DisplayOrder**/async function addItems(body: AddItemsCartRequest)Update cart items by adding new items to the cart
Notes:#
NOTE: user should have scope CartUpdate
Example#
const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
let body = new YatJs.AddItemsCartRequest(); // AddItemsCartRequest // populate body...
try { let res = await api.cart().addItems(body); // res is of type DisplayOrder console.log('API called successfully. Result: ', res);} catch (error) { console.error(error);}
Parameters#
| Name | Type | Description | Notes |
|---|---|---|---|
| body | AddItemsCartRequest | ||
Return type#
Authorization#
HTTP request headers#
- Content-Type: Not defined
- Accept: /
applyPromoCode#
/*** @returns DisplayOrder**/async function applyPromoCode(body: ApplyPromoCodeRequest)Apply promo code
Notes:#
NOTE: user should have scope CartUpdate Can only be applied to pending payment carts
Example#
const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
let body = new YatJs.ApplyPromoCodeRequest(); // ApplyPromoCodeRequest // populate body...
try { let res = await api.cart().applyPromoCode(body); // res is of type DisplayOrder console.log('API called successfully. Result: ', res);} catch (error) { console.error(error);}
Parameters#
| Name | Type | Description | Notes |
|---|---|---|---|
| body | ApplyPromoCodeRequest | ||
Return type#
Authorization#
HTTP request headers#
- Content-Type: Not defined
- Accept: /
checkout#
/*** @returns DisplayOrder**/async function checkout(body: CheckoutCartRequest)Checkout last payment cart
Notes:#
NOTE: user should have scope CartUpdate
Example#
const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
let body = new YatJs.CheckoutCartRequest(); // CheckoutCartRequest // populate body...
try { let res = await api.cart().checkout(body); // res is of type DisplayOrder console.log('API called successfully. Result: ', res);} catch (error) { console.error(error);}
Parameters#
| Name | Type | Description | Notes |
|---|---|---|---|
| body | CheckoutCartRequest | ||
Return type#
Authorization#
HTTP request headers#
- Content-Type: Not defined
- Accept: /
checkoutOrder#
/*** @returns DisplayOrder**/async function checkoutOrder(id: String, body: CheckoutCartRequest)Checkout saved cart by id
Notes:#
NOTE: user should have scope CartUpdate
Example#
const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
let id = null; // String // populate id...
let body = new YatJs.CheckoutCartRequest(); // CheckoutCartRequest // populate body...
try { let res = await api.cart().checkoutOrder(id, body); // res is of type DisplayOrder console.log('API called successfully. Result: ', res);} catch (error) { console.error(error);}
Parameters#
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | ||
| body | CheckoutCartRequest | ||
Return type#
Authorization#
HTTP request headers#
- Content-Type: Not defined
- Accept: /
clearCart#
/*** @returns DisplayOrder**/async function clearCart()Remove all items from cart
Notes:#
NOTE: user should have scope CartUpdate
Example#
const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
try { let res = await api.cart().clearCart(); // res is of type DisplayOrder console.log('API called successfully. Result: ', res);} catch (error) { console.error(error);}
Parameters#
This endpoint does not have any parameters.
Return type#
Authorization#
HTTP request headers#
- Content-Type: Not defined
- Accept: /
convertOrderToDraft#
/*** @returns DisplayOrder**/async function convertOrderToDraft()Convert pending payment cart back into Draft status
Notes:#
NOTE: user should have scope CartUpdate
Example#
const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
try { let res = await api.cart().convertOrderToDraft(); // res is of type DisplayOrder console.log('API called successfully. Result: ', res);} catch (error) { console.error(error);}
Parameters#
This endpoint does not have any parameters.
Return type#
Authorization#
HTTP request headers#
- Content-Type: Not defined
- Accept: /
deletePaymentMethods#
/*** @returns PaymentMethod**/async function deletePaymentMethods(id: String)Delete payment method
Notes:#
NOTE: user should have scope PaymentMethodDestroy
Example#
const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
let id = "id_example"; // String // populate id...
try { let res = await api.cart().deletePaymentMethods(id); // res is of type PaymentMethod console.log('API called successfully. Result: ', res);} catch (error) { console.error(error);}
Parameters#
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String |
Return type#
Authorization#
HTTP request headers#
- Content-Type: Not defined
- Accept: /
getItems#
/*** @returns DisplayOrder**/async function getItems()Return cart content
Notes:#
NOTE: user should have scope CartShow
Example#
const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
try { let res = await api.cart().getItems(); // res is of type DisplayOrder console.log('API called successfully. Result: ', res);} catch (error) { console.error(error);}
Parameters#
This endpoint does not have any parameters.
Return type#
Authorization#
HTTP request headers#
- Content-Type: Not defined
- Accept: /
listPaymentMethods#
/*** @returns [PaymentMethod]**/async function listPaymentMethods()Fetch payment methods for the user
Notes:#
NOTE: user should have scope PaymentMethodRead
Example#
const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
try { let res = await api.cart().listPaymentMethods(); // res is of type [PaymentMethod] console.log('API called successfully. Result: ', res);} catch (error) { console.error(error);}
Parameters#
This endpoint does not have any parameters.
Return type#
Authorization#
HTTP request headers#
- Content-Type: Not defined
- Accept: /
removeItem#
/*** @returns DisplayOrder**/async function removeItem(cartItemId: String)Removes an order item from the cart
Notes:#
NOTE: user should have scope CartUpdate
Example#
const yat = require('yatjs');const api = new yat.YatJs();
await api.login("[email protected]", "your_password");
let cartItemId = null; // String // populate cartItemId...
try { let res = await api.cart().removeItem(cartItemId); // res is of type DisplayOrder console.log('API called successfully. Result: ', res);} catch (error) { console.error(error);}
Parameters#
| Name | Type | Description | Notes |
|---|---|---|---|
| cartItemId | String | ||
Return type#
Authorization#
HTTP request headers#
- Content-Type: Not defined
- Accept: /