1.0.17 • Published 2 years ago

@ashish_agarwal/online-ordering v1.0.17

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

E-commerce Abstraction

Package Conception

This npm module has been created with a motive to provide abstraction to the apis used from various API layers in the CS ecommerce module. This module can be imported to projects as a package and the API's can be used to support solutions in e-commerce

Features

  • Easy to use API to support solution in Elastic
  • Perform operations to SFDC and Elastic API directly

Package Usage

Installation

This package is only accessible through CloudSense’s private NPM repository.

npm i @ashish_agarwal/online-ordering

IMP: create registry file (.npmrc) on root folder with the registry key from cs

Dependencies

Install express and dotenv

npm i express
npm i dotenv

API Specification

Details of all the API's are mentioned in the API Specifications which can be accessed from

Here is a sequence diagram to explain how our API's works and how it can be implemented end to end for each use case scenario

alt text

NPM Module Setup

Implementing cache

This project includes an object for caching implementation which can be overriden to apply custom cache implementation. This is embeded into the abstract api calls to get and set the data to the cache

the below code shows how to add custom cache implementaiton and inject into the npm module

const api = require('@ashish_agarwal/online-ordering');

api.caching.cachingObj.prototype.getCacheData = cachingImp.getCacheData
api.caching.cachingObj.prototype.setCacheData = cachingImp.setCacheData

Using API's

1.) Let's import the package and call it as api wherever the API needs to be called.

// Importing the package as api
const api = require('@ashish_agarwal/online-ordering');

2.) To perform operation on EAPI and SFDC, authentication details needs to be shared. Create a .env file and add the below details

CLIENT_ID = //shared by cs security team
CLIENT_SECRET = //shared by cs security team
target_Heroku_instance_domain = //shared by cs security team
SFDC_URL = //your salesforce domain url
SFDC_USERNAME = //your sfdc user name for fetching data
SFDC_PASSWORD = //your sfdc user name for fetching data
SFDC_TOKEN = //sfdc token
dispatcherHost = //shared by cs security team
orgId = //salesforce org id
private_key = //private key for the certificate shared between sfdc instance and heroku instance
rsa_pvt_key = //rsa private key for the certificate shared between sfdc instance and heroku instance
catalogueId = //catalogue salesforce id published to the heroku

3.) Let us see some scenarios with implementation examples

a.) List solution - Assume a scenario where all the solution templates needs to be fetched from the org.

  • Assuming there is an app cache module in place which caches solution templates request. If the app cache already stores the details of the org then the soution templates can be fetched from the app cache without requesting the module.
  • Once the solution templates are listed, select a solution component which can be used to add offers and products

    example :

    const express = require('express');
    require('dotenv').config();
    const api = require('@ashish_agarwal/online-ordering');
    
    app.use(express.json());
    
    app.use('/api/getsolutiontemplates',(req, res, next)=>{
      api.caching.cachingObj.prototype.key = 'solutionTemplates' //defining key to store the data into cache
      next()
    }, api.solutionTemplates)
1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

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

1.0.0

2 years ago