zecko
v0.0.15
Published
Zecko JS SDK
Downloads
25
Readme
Zecko TypeScript and JavaScript SDK
Official TypeScript and JavaScript SDK for Zecko API.
Installation
Yarn
yarn add zecko
NPM
npm install zecko
Documentation
Documentation of Zecko API and their usage is available here.
Detailed TypeScript and JavaScript docs are available here
Basic Usage
Instantiate the Zecko instance with accessToken
. You can obtain the keys by contacting us at [email protected]
.
const zecko = new Zecko({ accessToken: 'YOUR_ACCESS_TOKEN' });
The resources can be accessed via the instance. All the methods invocations follows the namespaced signature:
{zeckoInstance}.{resourceName}.{methodName}([params])
// example
zecko.collectionClient.getById('YOUR_COLLECTION_ID');
Every resource method returns a promise. There is no callback support.
Usage examples
Collection
return zecko.collectionClient.getAll();
return zecko.collectionClient.getById('YOUR_COLLECTION_ID');
Product
return zecko.productClient.getAllByCollectionId('YOUR_COLLECTION_ID');
return zecko.productClient.getById('YOUR_PRODUCT_ID');
Cart
return zecko.cartClient.getByCustomerId('YOUR_CUSTOMER_ID');
return zecko.cartClient.addToCart({
customerId: 'YOUR_CUSTOMER_ID',
variantId: 'YOUR_PRODUCT_VARIANT_ID',
quantity: 'YOUR_PRODUCT_VARIANT_QUANTITY',
});
return zecko.cartClient.updateById('YOUR_CART_ID', {
customer: {
email: 'YOUR_CUSTOMER_EMAIL_ADDRESS',
},
shippingAddress: {
address1: 'YOUR_CUSTOMER_ADDRESS', // For Street address or PO Box number
address2: 'YOUR_CUSTOMER_ADDRESS', // Optional Field, For Apartment Details
city: 'YOUR_CUSTOMER_CITY',
country: 'YOUR_CUSTOMER_COUNTRY', // Optional Field
countryCode: 'YOUR_CUSTOMER_COUNTRY_CODE', // Optional Field
firstName: 'YOUR_CUSTOMER_FIRST_NAME',
lastName: 'YOUR_CUSTOMER_LAST_NAME', // Optional Field
phone: 'YOUR_CUSTOMER_PHONE_NUMBER',
province: 'REGION_OF_ADDRESS', // State or district, country
zip: 'YOUR_CUSTOMER_ZIP_CODE',
},
shippingLine: {
price: {
amount: 'PRICE_OF_SHIPPING_RATE';
},
title: 'TITLE_OF_SHIPPING_RATE',
},
});
return zecko.cartClient.addDiscountById('YOUR_CART_ID', {
discounts: [
{
type: 'DISCOUNT_CODE_TYPE',
code: 'DISCOUNT_CODE',
},
],
});
return zecko.cartClient.removeDiscountById('YOUR_CART_ID', {
discounts: [
{
type: 'DISCOUNT_CODE_TYPE',
code: 'DISCOUNT_CODE',
},
],
});
return zecko.cartClient.completeCartById('YOUR_CART_ID', {
payment: {
totalPrice: 'TOTAL_AMOUNT_OF_CART',
},
});
return zecko.cartClient.deleteFromCart({
customerId: 'YOUR_CUSTOMER_ID',
variantId: 'YOUR_PRODUCT_VARIANT_ID',
quantity: 'YOUR_PRODUCT_VARIANT_QUANTITY',
});
return zecko.cartClient.deleteCartByCustomerId('YOUR_CUSTOMER_ID');
Order
return zecko.orderClient.getById('YOUR_ORDER_ID');
return zecko.orderClient.getAllByCustomerId('YOUR_CUSTOMER_ID');
Inventory Unit
return zecko.inventoryUnitClient.cancelById('YOUR_INVENTORY_UNIT_ID', {
cancelReason: 'YOUR_REASON_FOR_CANCELLATION',
});
return zecko.inventoryUnitClient.returnById('YOUR_INVENTORY_UNIT_ID', {
returnReason: 'YOUR_REASON_FOR_RETURN',
});
return zecko.inventoryUnitClient.exchangeById('YOUR_INVENTORY_UNIT_ID', {
exchangeReason: 'YOUR_REASON_FOR_EXCHANGE',
});
return zecko.inventoryUnitClient.trackById('YOUR_INVENTORY_UNIT_ID');
- All examples available at https://github.com/zeckode/zecko-js-examples/tree/main/src/examples/js.
- For detailed documentation, visit respective class docs.