@knawat/suppliers
v2.0.1
Published
A Node.js package for the Knawat Dropshipping Suppliers REST API
Downloads
39
Readme
Knawat Node.js NPM Package (Suppliers)
A Node.js package for Knawat Suppliers REST API. Easily interact with the Knawat Suppliers REST API using this library.
Installation
npm install --save @knawat/suppliers
Getting started
Check out the Knawat Suppliers REST API endpoints and data that can be manipulated in this link.
Setup
Setup for the new Knawat Suppliers REST API integration:
ENV variables
| variable | Default | Required | Description |
| ------------ | ------- | ----------- | --------------------------------- | --- | ------ | ------------------------------------- |
| SET_ASYNC
| 1 | no | if SET_ASYNC = 0 then all post | put | delete | patch request will not use async apis |
| BASIC_USER
| - | conditional | required for basic authentication |
| BASIC_PASS
| - | conditional | required for basic authentication |
Note: you can pass options = { SET_ASYNC: 0 } for individual functions instead of env to change async setting for only few functions
// define environment to deploy on production. default is development
process.env.KNAWAT_ENV = 'production';
const { Suppliers, Products } = require('@knawat/suppliers');
const sa = new Products({
key: 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
secret: 'XXXXXXXXXXXXXXXXXXXXXXXX',
});
Options
| Option | Type | Required | Description |
| -------- | -------- | ----------- | -------------------------------------------------------- |
| key
| string
| conditional | Your Store's API consumer key. this field is required |
| secret
| string
| conditional | Your Store's API consumer secret. this field is required |
https://knawat-suppliers.restlet.io/#operation_get_token
/*
* Set Environment variables for Suppliers methods
* BASIC_USER : XXXXXXXXXX
* BASIC_PASS : XXXXXXXXXX
*/
const { Suppliers, Products, WeightRules } = require('@knawat/suppliers');
const suppliers = new Suppliers();
const weightRules = new WeightRules();
Options
Methods
Product Methods
getProducts
Retrieve the list of all products or products for this channel, sorted by create date DESC
const filter = {
limit: 20,
page: 2,
qualified: null,
category_id: null,
keyword: null,
stock: null,
price: null,
sort_by: null,
sort_asc: null,
language: 'en',
};
sa.getProducts(filter);
| Params | Type | Required | Description |
| ------------- | -------- | -------- | ------------------------------------------------------------------------------------- |
| limit
| Number
| No | Number of products to retrieve. Default: 10
|
| page
| Number
| No | Number of the page to retrieve. Default: 1
|
| qualified
| Number
| No | Number = 1: Qualified, 2: Needs to review, 4: Disqualified, 5 : Draft Default: null
|
| category_id
| String
| No | String of category_id, Default: null
|
| | | | if category_id = -1, get all un-categories products |
| keyword
| String
| No | Text to search in product SKU or name Default: null
|
| stock
| Object
| No | stock : { stock_from: Number,stock_to: Number } Default: null
|
| price
| Object
| No | price : { price_from: Number, price_to: Number } Default: null
|
| sort_by
| String
| No | allowed fields :name, stock, qualified, price, stock Default: null
|
| sort_asc
| String
| No | sort_asc: 1 = acs, -1 = desc Default: -1
|
| language
| String
| No | tr, en, ar Default: tr
|
https://knawat-suppliers.restlet.io/#operation_get_list_of_products
addProducts
Add products to my list
sa.addProducts(products, options);
| Option | Type | Required | Description |
| ---------- | ------- | -------- | -------------------------------------------- |
| products
| array
| yes | Array of Products Object [{ sku: '1234' }]
|
https://knawat-suppliers.restlet.io/#operation_add_to_my_products
getProductBySku
Retrieve single product information by Product SKU. product should be under this store
sa.getProductBySku(sku);
| Params | Type | Description |
| ------ | -------- | ------------------------------ |
| sku
| string
| SKU of Product you want to get |
https://knawat-suppliers.restlet.io/#operation_get_product_by_sku
updateBulkProduct
Retrieve products information using bulk update. product should be under this store
sa.updateBulkProduct(data, options);
| Params | Type | Description |
| ------ | -------- | ----------- |
| data
| object
| ```JSON |
{
"products": [
{
"sku": "4646030019238",
"barcode": "1234567890",
"url": "https://example.com/product.php?id=123",
"name": { "tr": "DAR KALIP PEMBE GÖMLEK", "en": "Slimline Pink Shirt" },
"description": {
"tr": "Some Turkish text here, html allowed",
"en": "Some English text here, html allowed"
},
"brand": { "tr": "Defacto", "en": "Defacto" },
"images": [
"https://cdnp4.knawat.com/buyuk/788f8a17-d5d8-4ccb-b218-9e428b199228.jpg"
],
"attributes": [
{
"name": { "tr": "Beden", "en": "Size" },
"options": [
{ "tr": "S", "en": "S" },
{ "tr": "M", "en": "M" }
]
}
],
"variations": [
{
"sku": "4646030019238-S",
"barcode": "1234567890123",
"sale_price": 9.74,
"market_price": 11.99,
"weight": 0.5,
"quantity": 123,
"attributes": [
{
"name": { "tr": "Beden", "en": "Size" },
"option": { "tr": "S", "en": "S" }
}
]
}
]
}
]
}
https://knawat-suppliers.restlet.io/#operation_update_product
upsertProducts
_Retrieve products information using bulk update/create. if product exists then create else update
sa.upsertProducts(data, options);
| Params | Type | Description |
| ------ | -------- | ----------- |
| data
| object
| ```JSON |
{
"products": [
{
"sku": "4646030019238",
"barcode": "1234567890",
"url": "https://example.com/product.php?id=123",
"name": { "tr": "DAR KALIP PEMBE GÖMLEK", "en": "Slimline Pink Shirt" },
"description": {
"tr": "Some Turkish text here, html allowed",
"en": "Some English text here, html allowed"
},
"brand": { "tr": "Defacto", "en": "Defacto" },
"images": [
"https://cdnp4.knawat.com/buyuk/788f8a17-d5d8-4ccb-b218-9e428b199228.jpg"
],
"attributes": [
{
"name": { "tr": "Beden", "en": "Size" },
"options": [
{ "tr": "S", "en": "S" },
{ "tr": "M", "en": "M" }
]
}
],
"variations": [
{
"sku": "4646030019238-S",
"barcode": "1234567890123",
"sale_price": 9.74,
"market_price": 11.99,
"weight": 0.5,
"quantity": 123,
"attributes": [
{
"name": { "tr": "Beden", "en": "Size" },
"option": { "tr": "S", "en": "S" }
}
]
}
]
}
]
}
https://knawat-suppliers.restlet.io/#operation_update_product
updateProductBySku
Update imported product External IDs by SKU
sa.updateProductBySku(products, options);
| Option | Type | Required | Description |
| ------ | -------- | -------- | ---------------------- |
| data
| object
| yes | Check mp documentation |
https://knawat-suppliers.restlet.io/#operation_update_product
getCategories
Get all categories.
sa.getCategories();
https://knawat-suppliers.restlet.io/#operation_get_list_of_categories
Order Methods
getOrders (GET Orders)
sa.getOrders(limit, page);
| Params | Type | Description |
| --------------------- | -------- | ------------------------------------------------------------ |
| limit
| Number
| Number of orders to retrieve. Default: 20
|
| page
| Number
| Number of the page to retrieve. Default: 1
|
| status
| String
| Status of order. open/issued/cancelled/billed/closed/token
|
| purchaseorderNumber
| String
| String of purchase order number. |
https://knawat-suppliers.restlet.io/#operation_get_order_s_
getOrderById (GET Order By Knawat Order Id)
sa.getOrderById(order_id);
| Params | Type | Description |
| ---------- | -------- | --------------- |
| order_id
| string
| Knawat Order ID |
https://knawat-suppliers.restlet.io/#operation_order_by_id
updateOrder (Update Order)
const order_data = {
shipmentTrackingNumber: 'EJGGH000091',
shipVia: 'DFL',
};
sa.updateOrder(order_id, order_data, options);
| Params | Type | Description |
| ------------ | -------- | --------------------------- |
| order_id
| string
| Knawat Order ID |
| order_data
| object
| Array of Updated Order Data |
https://knawat-suppliers.restlet.io/#operation_update_order
Add order comment
const order_data = {
description: 'shipment on the way',
expectedDeliveryDate: '2021-05-20',
};
sa.addOrderComment(order_id, order_data, options);
| Params | Type | Description |
| ------------ | -------- | --------------------------- |
| order_id
| string
| Knawat Order ID |
| order_data
| object
| Array of Updated Order Data |
Suppliers Methods
getSupplier (Get Suppliers)
suppliers.getSuppliers();
https://knawat-suppliers.restlet.io/#operation_get_all_suppliers
createSupplier (Create Supplier)
suppliers.createSupplier(supplier, options);
| Params | Type | Description |
| ---------- | -------- | ------------------ |
| supplier
| object
| Object of supplier |
https://knawat-suppliers.restlet.io/#operation_create_a_supplier
getSupplierKeys (Get Supplier Keys)
suppliers.getSupplierKeys(supplier_id);
| Params | Type | Description |
| ------------- | -------- | -------------- |
| supplier_id
| string
| Id of supplier |
https://knawat-suppliers.restlet.io/#operation_get_suppliers_keys
updateSupplier (Update Supplier)
sa.updateSupplier(supplier, options);
| Params | Type | Description |
| ---------- | -------- | ------------------ |
| supplier
| object
| Object of supplier |
{"supplier": { "name" : "john", "url": "https://example.com.tr","logo": "https://example.com.tr/logo.png","currency": "TRY", "address": [array of addresses], "contacts": [array of contacts] } }
https://knawat-suppliers.restlet.io/#operation_update_a_supplier_2
Weight Rules Methods
getWeightRules (Get Weight Rules)
weightRules.getWeightRules();
| Params | Type | Description |
| ------- | -------- | ------------------------- |
| limit
| number
| limit of data in response |
| page
| number
| page number |
| sort
| number
| sort data in response |
https://knawat-suppliers.restlet.io/#operation_get_all_weight_rules
createWeightRule (Create Weight Rules)
weightRules.createWeightRule(weightRules, options);
| Params | Type | Description |
| ------------- | -------- | --------------------- |
| weightRules
| object
| Object of weightRules |
"weightRules": { "keyword" : "Shirt", "weight": 5 }
https://knawat-suppliers.restlet.io/#operation_create_a_supplier
updateWeightRule (Update Weight Rules)
weightRules.updateWeightRule(id, weightRules, options);
| Params | Type | Description |
| ------------- | -------- | ------------------------------ |
| id
| string
| Id of weight rule |
| weightRules
| object
| Object of parameters to update |
"weightRules": { "keyword" : "Shirt", "weight": 5 }
https://knawat-suppliers.restlet.io/#operation_update_weight_rule
deleteWeightRule (Delete Weight Rules)
weightRules.deleteWeightRule(id, options);
| Params | Type | Description |
| ------ | -------- | ----------------- |
| id
| string
| Id of weight rule |
https://knawat-suppliers.restlet.io/#operation_delete_weight_rule
Reporting Security Issues
To disclose a security issue to our team, please submit a report here.
Support & Chat
Developers are welcome here, please create issue or chat with us https://gitter.im/Knawat/Lobby. This repository is not suitable for Knawat customers support. Please don't use our issue tracker for support requests, but for Knawat Suppliers NPM Package issues only. Support can take place through Knawat support portal which is available for free.
Support requests in issues on this repository will be closed on sight.
Contributing to Knawat
If you have a patch or have stumbled upon an issue with Knawat NPM Package, you can contribute this back to the code. Please create a pull request.