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

1.0.5 • Public • Published

Genuka JS SDK

The Genuka JavaScript SDK allows developers to easily integrate the features of the Genuka platform into their web applications. This SDK provides methods to manage companies, shops, products, pages, blogs, articles, collections, customers, addresses, orders, carts, and payment methods.

Installation

npm install genuka

or

yarn add genuka

Usage

To start using the SDK, you must first import it into your project and initialize it with your company information.

import genuka from "genuka";

// Initialize the instance with your company's domain
genuka.initialize({ domain: "your.domain.com" });

Company

Initialization

Initialize your company information before using the SDK.

await genuka.initialize({ domain: "domain_or_subdomain.genuka.com" });

Retrieving Company Details

To retrieve your company details:

const company = await genuka.company.retrieve();

Shops

Listing Shops

List all available shops:

const shops = await genuka.shops.list();

Shop Details

To retrieve the details of a specific shop by its ID:

const shop = await genuka.shops.retrieve({ id: "01hhfzx7ftzrqjxhx8fbb6ddfs" });

Products

Counting Products

To count all available products:

const productsCount = await genuka.products.count();

Listing Products

List all products:

const products = await genuka.products.list();

Product Details

To retrieve the details of a specific product by its ID:

const product = await genuka.products.retrieve({
  id: "01hkav9sz3qsj4tfdn3yd7214p",
});

Customers

Logging in a Customer

To log in a customer:

const { token, customer } = await genuka.customers.login({
  email: "customer@email.com",
  password: "password",
});
Genuka.setToken(token);

Retrieving Customer Details

To retrieve the details of the current customer:

const customerDetails = await genuka.customers.retrieve();

Sure, here are detailed sections of the documentation for the orders and carts parts of your Genuka package.


Orders

List All Orders for a Customer

To list all orders for a customer, you must first log in the customer and then use the list method:

// Log in the customer
const { token } = await genuka.customers.login({
  email: "customer2@email.com",
  password: "password",
});
genuka.setToken(token);

// List all orders for the customer
const orders = await genuka.orders.list();

Create an Order

To create a new order, use the create method. You must provide details about the customer, shipping, billing, and products included in the order:

const order = await genuka.orders.create({
  customer: {
    first_name: "John",
    last_name: "Doe",
    phone: "123456789",
    email: "customer@email.com",
  },
  shipping: {
    mode: "delivery",
    amount: 0,
    address: {
      first_name: "John",
      last_name: "Doe",
      phone: "123456789",
      line1: "line1",
      line2: "line2",
      city: "city",
      state: "state",
      postal_code: "postal_code",
      country: "country",
    },
  },
  billing: {
    method: "cash",
    address: {
      first_name: "John",
      last_name: "Doe",
      phone: "123456789",
      line1: "line1",
      line2: "line2",
      city: "city",
      state: "state",
      postal_code: "postal_code",
      country: "country",
    },
  },
  products: [
    {
      title: "My product here",
      price: 2000,
      quantity: 1,
    },
  ],
});

(Note: Add more details and available configurations as needed for your API.)

Carts

Add to Cart

To add a product to the cart, use the add method by providing the necessary details:

genuka.cart.add({
  product_id: "product_id",
  variant_id: "variant_id",
  quantity: 1,
  price: 2000,
});

Retrieve Cart

To retrieve the current contents of the cart:

const cart = genuka.cart.retrieve();

Update Cart Item

To update the quantity of a specific item in the cart:

genuka.cart.update("variant_id", {
  quantity: 2,
});
const updatedCart = genuka.cart.retrieve();

Remove from Cart

To remove an item from the cart:

genuka.cart.remove("variant_id");
const cartAfterRemoval = genuka.cart.retrieve();

Clear Cart

To empty the cart:

genuka.cart.clear();
const emptyCart = genuka.cart.retrieve();

(Note: This is a basic example for the most important sections. You should continue this pattern for all other methods and classes you have defined, such as pages, blogs, articles, collections, addresses, and paymentMethods.)

Contribution

If you wish to contribute to this SDK, please contact us via Whatsapp (+237 6 95 76 25 95) or send an email to wdjopa@lamater.tech. We welcome contributions in the form of pull requests, bug reports, and suggestions for new features.

Package Sidebar

Install

npm i genuka

Weekly Downloads

14

Version

1.0.5

License

ISC

Unpacked Size

86.7 kB

Total Files

10

Last publish

Collaborators

  • lamater