npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lakshya-sdk

v1.0.14

Published

A full fledged module for laksha-event-management

Downloads

19

Readme

LakshyaSDK Documentation

LakshyaSDK is a TypeScript class that provides methods for interacting with the Lakshya SDK, enabling you to manage user information, events, event tickets, and event registrations. It is designed to work with a Supabase database instance and is intended for use in JavaScript or TypeScript applications.

Table of Contents

Installation

To use the LakshyaSDK in your project, you'll need to install the required dependencies. First, make sure you have the following installed:

To install LakshyaSDK, you can use npm or yarn:

npm install @supabase/supabase-js
npm i lakshya-sdk

Initialization

Before using the LakshyaSDK, you need to initialize it with a SupabaseClient instance. Here's how you can do it:

import { createClient } from "@supabase/supabase-js";
import LakshyaSDK from "lakshya-sdk";

// Initialize a Supabase client
const supabase = createClient("your-supabase-url", "your-supabase-api-key");

// Initialize the LakshyaSDK using the Supabase client
const lakshya = LakshyaSDK.initialize(supabase);

Replace "your-supabase-url" and "your-supabase-api-key" with your actual Supabase URL and API key.

Now you have an instance of LakshyaSDK ready to use.

Class Methods

getUserInfo

Method Signature:

async getUserInfo(userId: string): Promise<User>
  • Retrieves user information from the database by user ID.

Parameters:

  • userId (string): The unique identifier of the user you want to retrieve information for.

Returns:

  • A Promise that resolves with a User object containing the retrieved user data.

Example:

const user = await lakshya.getUserInfo(userId);
console.log("User Information:", user);

updateUser

Method Signature:

async updateUser(updatedUser: User): Promise<void>
  • Updates user information in the database.

Parameters:

  • updatedUser (User): An instance of the User class with updated user data.

Returns:

  • A Promise indicating the success or failure of the update operation.

Example:

const updatedUser = await lakshya.updateUser(updatedUser);
console.log("User updated successfully");

getEvents

Method Signature:

async getEvents(): Promise<LakshyaEvent[]>
  • Fetches a list of events from the database.

Returns:

  • A Promise that resolves to an array of LakshyaEvent objects.

Throws:

  • An error if there is an issue with the database query.

Example:

const events = await lakshya.getEvents();
console.log("List of Events:", events);

getMyEvents

Method Signature:

async getMyEvents(userId: string): Promise<LakshyaEvent[]>
  • Gets events associated with a specific user.

Parameters:

  • userId (string): The user's ID for whom you want to retrieve events.

Returns:

  • A Promise that resolves to an array of LakshyaEvent objects.

Throws:

  • An error if there is an issue with the database query.

Example:

const myEvents = await lakshya.getMyEvents(userId);
console.log("User's Events:", myEvents);

getTickets

Method Signature:

async getTickets(): Promise<EventTicket[]>
  • Retrieves a list of event tickets from the database.

Returns:

  • A Promise that resolves to an array of EventTicket instances if successful, or rejects with an error.

Throws:

  • An error if there is an issue with the database operation or if the supplied error handler is triggered.

Example:

const tickets = await lakshya.getTickets();
console.log("Event Tickets:", tickets);

registerEvent

Method Signature:

async registerEvent(events: LakshyaEvent[]): Promise<boolean>
  • Registers the authenticated user for multiple LakshyaEvent instances.

Parameters:

  • events (LakshyaEvent[]): An array of LakshyaEvent instances to register for.

Returns:

  • A Promise that resolves to a boolean, indicating the success of the registration process.

Throws:

  • An error if there is an issue with user authentication or the database operation.

Example:

const eventsToRegister = []; // List of LakshyaEvent instances to register 
const registrationSuccess = await lakshya.registerEvent(eventsToRegister);

if (registrationSuccess) {
  console.log("User registered for events successfully");
}

requestPayment

Method Signature:

async requestPayment(
  events: LakshyaEvent[],
  headers: any,
  endpoint: string
): Promise<RequestPaymentResponse>
  • Sends a payment request to a specified endpoint for a list of events.

Parameters:

  • events (LakshyaEvent[]): An array containing event objects for which payment is requested.
  • headers (any): HTTP headers to be included in the request.
  • endpoint (string): The endpoint URL to which the payment request will be sent.

Returns:

  • A Promise that resolves to a RequestPaymentResponse object representing the response from the payment request.

Throws:

  • An error if there is an issue with the payment request or if the supplied error handler is triggered.

Example:

const paymentEvents = [...]; // List of LakshyaEvent instances for payment
const paymentHeaders = {...}; // HTTP headers for payment request
const paymentEndpoint = 'https://example.com/payment'; // Payment endpoint

try {
  const paymentResponse = await lakshya.requestPayment(paymentEvents, paymentHeaders, paymentEndpoint);
  console.log("Payment Response:", paymentResponse);
} catch (error) {
  console.error("Payment Error:", error.message);
}

That's the complete documentation for the LakshyaSDK class. You can use these methods to interact with your Supabase database

and manage user information, events, event tickets, event registrations, and make payment requests within your Lakshya-based application.