Skip to main content

CartApi

All URIs are relative to http://localhost

MethodHTTP requestDescription
addItemsPOST /cartUpdate cart items by adding new items to the cart
applyPromoCodePOST /cart/promo_codeApply promo code
checkoutPOST /cart/checkoutCheckout last payment cart
checkoutOrderPOST /cart/checkout/{id}Checkout saved cart by id
clearCartDELETE /cartRemove all items from cart
convertOrderToDraftPOST /cart/convert_to_draftConvert pending payment cart back into Draft status
deletePaymentMethodsDELETE /payment_methods/{id}Delete payment method
getItemsGET /cartReturn cart content
listPaymentMethodsGET /payment_methodsFetch payment methods for the user
removeItemDELETE /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#

NameTypeDescriptionNotes
bodyAddItemsCartRequest

Return type#

DisplayOrder

Authorization#

apiKey

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#

NameTypeDescriptionNotes
bodyApplyPromoCodeRequest

Return type#

DisplayOrder

Authorization#

apiKey

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#

NameTypeDescriptionNotes
bodyCheckoutCartRequest

Return type#

DisplayOrder

Authorization#

apiKey

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#

NameTypeDescriptionNotes
idString
bodyCheckoutCartRequest

Return type#

DisplayOrder

Authorization#

apiKey

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#

DisplayOrder

Authorization#

apiKey

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#

DisplayOrder

Authorization#

apiKey

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#

NameTypeDescriptionNotes
idString

Return type#

PaymentMethod

Authorization#

apiKey

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#

DisplayOrder

Authorization#

apiKey

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#

[PaymentMethod]

Authorization#

apiKey

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#

NameTypeDescriptionNotes
cartItemIdString

Return type#

DisplayOrder

Authorization#

apiKey

HTTP request headers#

  • Content-Type: Not defined
  • Accept: /