2.0.1 • Published 2 years ago

@knawat/suppliers v2.0.1

Weekly downloads
12
License
MIT
Repository
github
Last release
2 years ago

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

variableDefaultRequiredDescription
SET_ASYNC1noif SET_ASYNC = 0 then all postputdeletepatch request will not use async apis
BASIC_USER-conditionalrequired for basic authentication
BASIC_PASS-conditionalrequired 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

OptionTypeRequiredDescription
keystringconditionalYour Store's API consumer key. this field is required
secretstringconditionalYour 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);
ParamsTypeRequiredDescription
limitNumberNoNumber of products to retrieve. Default: 10
pageNumberNoNumber of the page to retrieve. Default: 1
qualifiedNumberNoNumber = 1: Qualified, 2: Needs to review, 4: Disqualified, 5 : Draft Default: null
category_idStringNoString of category_id, Default: null
if category_id = -1, get all un-categories products
keywordStringNoText to search in product SKU or name Default: null
stockObjectNostock : { stock_from: Number,stock_to: Number } Default: null
priceObjectNoprice : { price_from: Number, price_to: Number } Default: null
sort_byStringNoallowed fields :name, stock, qualified, price, stock Default: null
sort_ascStringNosort_asc: 1 = acs, -1 = desc Default: -1
languageStringNotr, en, ar Default: tr

https://knawat-suppliers.restlet.io/#operation_get_list_of_products

addProducts

Add products to my list

sa.addProducts(products, options);
OptionTypeRequiredDescription
productsarrayyesArray 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);
ParamsTypeDescription
skustringSKU 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);
ParamsTypeDescription
dataobject`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);
ParamsTypeDescription
dataobject`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);
OptionTypeRequiredDescription
dataobjectyesCheck 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);
ParamsTypeDescription
limitNumberNumber of orders to retrieve. Default: 20
pageNumberNumber of the page to retrieve. Default: 1
statusStringStatus of order. open/issued/cancelled/billed/closed/token
purchaseorderNumberStringString of purchase order number.

https://knawat-suppliers.restlet.io/#operationget_order_s

getOrderById (GET Order By Knawat Order Id)

sa.getOrderById(order_id);
ParamsTypeDescription
order_idstringKnawat 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);
ParamsTypeDescription
order_idstringKnawat Order ID
order_dataobjectArray 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);
ParamsTypeDescription
order_idstringKnawat Order ID
order_dataobjectArray 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);
ParamsTypeDescription
supplierobjectObject of supplier

https://knawat-suppliers.restlet.io/#operation_create_a_supplier

getSupplierKeys (Get Supplier Keys)

suppliers.getSupplierKeys(supplier_id);
ParamsTypeDescription
supplier_idstringId of supplier

https://knawat-suppliers.restlet.io/#operation_get_suppliers_keys

updateSupplier (Update Supplier)

sa.updateSupplier(supplier, options);
ParamsTypeDescription
supplierobjectObject 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();
ParamsTypeDescription
limitnumberlimit of data in response
pagenumberpage number
sortnumbersort data in response

https://knawat-suppliers.restlet.io/#operation_get_all_weight_rules

createWeightRule (Create Weight Rules)

weightRules.createWeightRule(weightRules, options);
ParamsTypeDescription
weightRulesobjectObject 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);
ParamsTypeDescription
idstringId of weight rule
weightRulesobjectObject 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);
ParamsTypeDescription
idstringId 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.

Check also

2.0.1

2 years ago

2.0.0

3 years ago

2.0.0-beta.0

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.6

3 years ago

1.4.7

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.6

3 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago