reviewmerce
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Reviewmerce

MIT licensed NPM Version

Welcome to Reviewmerce 👋

Table of Contents

Installation

Setup

npm i reviewmerce

As a start and first example, after installation, we need to create a starting point for our products, comments, and reviews, creating the most important, the company which governs all these data.

import ReviewMerceAPI from "reviewmerce";

const reviews = new ReviewMerceAPI();
const data = {
  name: "company",
};
const company = await reviews.products.company(data);

Products

checkExisting

To check if a product exists in our database using a boolean:

import ReviewMerceAPI from "reviewmerce";

const reviews = new ReviewMerceAPI();
const product = await reviews.products.checkExisting("1");

create

This part is the most important because here we have to use the name we used for our company, and ensure that our product we're creating is linked to this company. It's important to note that the product id is your selection so it can match your architecture; remember it's a string.

import ReviewMerceAPI from "reviewmerce";

const reviews = new ReviewMerceAPI();

const data = {
  id: "0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c",
  name: "Elegant jacket",
  description: "Product description",
  companyName: "Company",
};

await reviews.products.create(data);

Reviews

Create user

To create a user for our reviews:

import ReviewMerceAPI from "reviewmerce";

const reviewMerceAPI = new ReviewMerceAPI();
const data = {
  username: "Standby",
};
const createUser = await reviewMerceAPI.reviews.createUser(data);

Create review

Using the product id we created, we submit our review rating from 1 to 5, and provide the username we created earlier.

import ReviewMerceAPI from "reviewmerce";

const reviewMerceAPI = new ReviewMerceAPI();

const data = {
  rating: 5,
  username: "Standby",
  productId: "0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c",
};
const review = await reviewMerceAPI.reviews.create(data);

rating

Calculating the percentage rating of a product from 1 to 5:

import ReviewMerceAPI from "reviewmerce";
const reviewMerceAPI = new ReviewMerceAPI();
const rating = await reviewMerceAPI.reviews.rating(
  "0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c"
);

product

if we want to see all the reviews in json format of our product it would be something like this;

import ReviewMerceAPI from "reviewmerce";
const reviewMerceAPI = new ReviewMerceAPI();
const rating = await reviewMerceAPI.reviews.product(
  "0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c"
);

Comments

Create comment

Creating a comment based on an id; these comments can also be anonymous, so it's not necessary to have a pre-created user, although if it doesn't exist, it will be created automatically.

import ReviewMerceAPI from "reviewmerce";
const reviews = new ReviewMerceAPI();
const data = {
  text: "Does this jacket have more colors?",
  username: "Standby",
  productId: "0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c",
};
const comment = await reviews.comments.create(data);

Product

To view the comments of a product:

import ReviewMerceAPI from "reviewmerce";
const reviews = new ReviewMerceAPI();
const comment = await reviews.comments.product("0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c");

Readme

Keywords

Package Sidebar

Install

npm i reviewmerce

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

73 kB

Total Files

50

Last publish

Collaborators

  • ztandby