1.0.6 • Published 2 years ago

quikshope_client v1.0.6

Weekly downloads
-
License
BSD -3-Clause
Repository
github
Last release
2 years ago

QuikShope Client SDK

Class definition availlable in the SDK , which can be returned by functions or used internally will be dicussed in the later part

Class NamePurpose
ConfigHold all the config of project such as API Endpoints and . Also store username of shop as static member which is used by another functions
AuthenticateUserIt has the functions to handle the OTP verification and generate auth token / generate Customer Object GLOBAL
CustomerThis consists all the information of the customer. This call include functions for update details / fetch all orders / get a particular order details / checkout CUSTOMER
ProductAll details of an product
ProductCategoryAll detaiks of a product category. It has function to fetch all the products under the category
OrderStatusIt has two members : status_code, datetime ORDER
TransactionHolds all information for a transaction , related to order ORDER
PromoCodeHolds promocode details that has been applied for order ORDER
HomeDeliveryHold home delivery related details for order details ORDER
SelfPickupHold self pickup mode delivery related details for order details ORDER
TableOrderHold table order related details for order details ORDER
AdvancedTableOrderHold advanced table order related details for order details ORDER
OrderHold details of order ORDER
ShopProfileHold information like owner's name, shop name and logo SHOP
ShopContactEmail Id, Mobile number of shop and also have information whether email id and mobile number verified or not SHOP
ShopAddressHold address of shop SHOP
ShopAccountHold details whether user in on free_account mode , also have template name and configuration of the template SHOP
PaymentModeHold pod and online params which indicate that payment mode is available or not. It is used by another class . No direct iimplementation.SHOP
HomeDeliveryConfigHold home delivery related details for order details SHOP
SelfPicupConfigHold self pickup mode delivery related details for order details SHOP
TableOrderConfigHold table order related details for order details SHOP
AdvancedTableOrderConfigHold advanced table order related details for order details SHOP
ShopDaysStore information in which days shop will be opened for taking orders SHOP
ShopConfigStore information of shop like , shop is force closed or not , opening time, closing time, working days, delivery & payment configurations SHOP
ShopPromoCodeHolds information for promo code available to apply . It holds the code, discount details and its description SHOP
ShopMain Class which hold all the details related to a shop. SHOP

Install QuikShope Client Library

Install by npm

npm i quikshope_client

If you are not using any frontend framework or nodejs , then prefer to use the below method to import library.

To install directly in HTML, use the cdn link provided below

<script src="https://cdn.jsdelivr.net/gh/GiantsMeet/quikshope_client@main/dist/client.min.js"></script>

Import Library

In case of NodeJS / Frontend framework , the standard ES5 & ES6 import strategy will work

// For type "module"
const client = require("quikshope_client")

// For type "commonjs"
import client from "quikshope_client"

// For HTML javascript
let client = QuikShopeClient;

Initialize Library

For initialization, the username of the shop needed , that can be found in dashboard of seller

client.init("shop2")

Authenticate User Customer

Process flow for authentication 1. Create object of AuthenticateUser 1. Send OTP 2. Verify OTP If failed, resent OTP 3. Generate Auth Token or Generate Customer Object

Create AuthenticateUser object

The 10 digit phone number of customer without country code need to be pass as arguments.

Note : If the customer has not any account, account will be created , there is no need to check existance of customer account

const auth = new client.authenticate("9999999999")

Send OTP

await auth.sendOtp()

In return , we will receive a list of two items in the below format

[success (boolean), message(string)]

If success is true that's indicate OTP has been sent , in same way we will get message which can be shown to the user

Send OTP

await auth.sendOtp()

In return , we will receive a list of two items in the below format

[success (boolean), message(string)]

If success is true that's indicate OTP has been sent , in same way we will get message which can be shown to the user

Resend OTP

await auth.resendOtp()

In return , we will receive a list of two items in the below format

[success (boolean), message(string)]

If success is true that's indicate OTP has been resent , in same way we will get message which can be shown to the user

Verify OTP

It takes 6 digit otp as parameter

await auth.verifyOtp("111111")

In return , we will receive a list of two items in the below format

[success (boolean), message(string)]

If success is true that's indicate OTP has been verified so that we can proceed for generate auth token or customer object , in same way we will get message which can be shown to the user

Generate Auth Token

await auth.generateToken()

In return , we will receive a list of two items in the below format

[success (boolean), message(string), token(string)]

If success is true that's indicate user has been verified through otp verification and received auth token , in same way we will get message which can be shown to the user. the 3rd parmeter we will receive the Auth Token

There is various method to store the token in clientside 1. Cookie 2. LocalStorage 3. IndexedDB

Generate Customer Object

await auth.generateTokenAndCustomerDetils()

In return , we will receive a list of two items in the below format

[success (boolean), message(string), customer(Customer Object)]

If success is true that's indicate user has been verified through otp verification and received customer object , in same way we will get message which can be shown to the user. If success is false then the customer 3rd parameter will be null


Customer Object

The members of teh customer object

  • id
  • name
  • phone_no
  • address
  • pincode
  • country
  • country_code
  • token

Intialize a customer object

To initialize a customer object , the authentication token of the customer needed which have been discussed in Authenticate User section

const customer = new client.customer("authentication token")

Fetch all details of customer from server

await customer.fetchDetails()

In return , we will receive a list of two items in the below format

[success (boolean), message(string)]

If success is true that's indicate that customer details has been fetch successfully , in same way we will get message which can be shown to the user.

To get the customer details in JSON format,

customer.toJSON()

Update Customer Details

Note that, Mobile number of customer is not allowed. Only change of name, address, pincode is allowed

// all 3 parameters are required
await customer.updateDetails("Tanmoy", "Kolkata", 700032)

In return , we will receive a list of two items in the below format

[success (boolean), message(string)]

If success is true that's indicating that customer details has been updated successfully , in same way we will get message which can be shown to the user.

Fetch All Orders

await customer.fetchAllOrders()

In return , we will receive a list of three items in the below format

[success (boolean), message(string), List<Order>]

Get Particular Order By ID

Pass order id as argument

await customer.getOrderById(1)

In return , we will receive a list of three items in the below format

[success (boolean), message(string), Order]

Checkout

For checkout we need to collect the checkout details

// Schema
{
	"<product_id>" : quantity
}
// Example
{
    "1": 1,
    "2": 8,
    "6": 5
}
await customer.checkout(shop, {
    "1": 1,
    "2": 8,
    "6": 5
}, "YTUI", "home_delivery", "online", "" , "", "")

In return , we will receive a list of three items in the below format

[success (boolean), message(string), data(JSON)]

In JSON response, online_payment_redirection is true, then redirect user to redirection_link for payment. If online_payment_redirection is false , then either redirect user to redirection_link as default order confirmation page or fetch order details by order_id and show custom UI


Product Class

Data members


ProductCategory Class

Data members

  • id
  • picture
  • title

Functions

  • fetchProducts : Will fetch all the product under this category
await category.fetchProducts()

In return we will get

[status(boolean), message(string), List<Product>]

Order Class

Data members


Inventory

Fetch All Categories

await client.inventory.FetchAllCategroies()

In return

[status(boolean), message(string), List<ProductCategory>]

Get Category By ID

await client.inventory.GetCategoryById("category_id")

In return

[status(boolean), message(string), ProductCategory]

Fetch All Products

await client.inventory.FetchAllProducts()

In return

[status(boolean), message(string), List<ProductCategory>, List<Product>]

Get Product By Id

await client.inventory.FetchAllProducts()

In return

[status(boolean), message(string), Product]

Search Products By Query

await client.inventory.SearchProducts("boat headphone")

In return

[status(boolean), message(string), List<ProductCategory>, List<Product>]

Filter Products By Selected Products Ids

await client.inventory.SearchProductsByIdsList([1,2,3])

In return

[status(boolean), message(string), List<ProductCategory>, List<Product>]

Shop

Data Members

Functions

  • fetch_details() : This will load all the information regarding that shop.
const shop = new client.shop()
console.log(await shop.fetch_details())

In return

[status(boolean), message(string)]

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago