1.2.2 • Published 1 year ago

sam-absinthe-sdk v1.2.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Absinthe SDK

Welcome to the Absinthe SDK! This SDK provides an interface to interact with the Absinthe API, making it easier to manage and distribute points within your applications.

Installation

Install the SDK via npm:

npm install sam-absinthe-sdk

Usage

Initialization

First, import and initialize the SDK with your API key, campaign ID, and optionally, a custom API URL:

import AbsintheSdk from 'sam-absinthe-sdk';

const apiKey = 'your-api-key';
const campaignId = 123;
const customApiUrl = 'https://custom-api-url.com'; // Optional

const absinthe = new AbsintheSdk(apiKey, campaignId, customApiUrl);

Methods

Distribute Points

To distribute points to an address:

const pointsData = {
  points: 100,
  address: '0xef0FA6458b661128E54B36cd44f257F727a5D7e3',
  metadata: { reason: 'reward' },
};

absinthe.distribute('eventName', pointsData)
  .then(response => console.log('Points distributed:', response))
  .catch(error => console.error('Error distributing points:', error));

Get Points

To get points associated with an address:

const address = '0xef0FA6458b661128E54B36cd44f257F727a5D7e3';

absinthe.getPoints(address)
  .then(points => console.log('Points:', points))
  .catch(error => console.error('Error getting points:', error));

API Reference

Class: AbsintheSdk

Constructor

new AbsintheSdk(apiKey: string, campaignId: number, customApiUrl?: string)
  • apiKey: Your Absinthe API key.
  • campaignId: The ID of your campaign.
  • customApiUrl: Optional custom API URL.

Methods

distribute(eventName: string, pointsData: { points: number; address: string; metadata?: object }): Promise<Points>

Distribute points to a specific address.

  • eventName: The name of the event.
  • pointsData: An object containing points, address, and optional metadata.
getPoints(address: string, eventName?: string): Promise<Points[]>

Retrieve points associated with a specific address.

  • address: The address to query.
  • eventName: Optional event name to filter points.

Contributing

Contributions are welcome! Please check the issues to see what needs help and feel free to open a new issue or pull request.


If you encounter any issues or have any questions, feel free to open an issue on GitHub.


Happy coding!

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.0

1 year ago