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.
npm install genuka
or
yarn add genuka
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" });
Initialize your company information before using the SDK.
await genuka.initialize({ domain: "domain_or_subdomain.genuka.com" });
To retrieve your company details:
const company = await genuka.company.retrieve();
List all available shops:
const shops = await genuka.shops.list();
To retrieve the details of a specific shop by its ID:
const shop = await genuka.shops.retrieve({ id: "01hhfzx7ftzrqjxhx8fbb6ddfs" });
To count all available products:
const productsCount = await genuka.products.count();
List all products:
const products = await genuka.products.list();
To retrieve the details of a specific product by its ID:
const product = await genuka.products.retrieve({
id: "01hkav9sz3qsj4tfdn3yd7214p",
});
To log in a customer:
const { token, customer } = await genuka.customers.login({
email: "customer@email.com",
password: "password",
});
Genuka.setToken(token);
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.
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();
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.)
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,
});
To retrieve the current contents of the cart:
const cart = genuka.cart.retrieve();
To update the quantity of a specific item in the cart:
genuka.cart.update("variant_id", {
quantity: 2,
});
const updatedCart = genuka.cart.retrieve();
To remove an item from the cart:
genuka.cart.remove("variant_id");
const cartAfterRemoval = genuka.cart.retrieve();
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
.)
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.