1.0.20 • Published 3 months ago

pollz-js v1.0.20

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

Pollz Node.js SDK

GitHub license

Overview

pollz-js is a TypeScript library that provides a convenient way to interact with the Pollz API. It allows developers to easily integrate polling functionality into their applications.

Installation

npm install pollz-js

or

yarn add pollz-js

Getting Started

Prerequisites

Before using the Pollz-JS SDK, you need to obtain the following credentials:

  • App ID: Your application's unique identifier.
  • App Secret: Secret key for authentication.

Initialize the SDK

import { PollzSDK, InitInput } from "pollz-js";

const pollz = new PollzSDK();
const initInput: InitInput = {
  appId: "YOUR_APP_ID",
  appSecret: "YOUR_APP_SECRET",
};

pollz
  .init(initInput)
  .then(() => {
    console.log("Pollz SDK initialized successfully!");
  })
  .catch((error) => {
    console.error("Error initializing Pollz SDK:", error.message);
  });

Create a Poll

import { CreatePollInput } from "pollz-js";

const createPollInput: CreatePollInput = {
  name: "Favorite Programming Language",
  options: ["JavaScript", "Rust", "Python", "Java"],
  pollTypeId: 1, // Replace with the appropriate Poll Type ID
};

pollz.polls
  .create(createPollInput)
  .then((createdPoll) => {
    console.log("Poll created successfully:", createdPoll);
  })
  .catch((error) => {
    console.error("Error creating poll:", error.message);
  });

Vote for a Poll

import { VoteInputArgs } from "pollz-js";

const voteInput: VoteInputArgs = [1, 1, [1, 2], "user123"];

pollz.polls
  .vote(...voteInput)
  .then((votedPoll) => {
    console.log("Vote recorded successfully:", votedPoll);
  })
  .catch((error) => {
    console.error("Error voting:", error.message);
  });

API Reference

For detailed information on SDK methods and types, please refer to the API Reference.

License

This project is licensed under the MIT License.

1.0.20

3 months ago

1.0.19

3 months ago

1.0.18

3 months ago

1.0.17

4 months ago

1.0.16

5 months ago

1.0.15

5 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.11

6 months ago

1.0.10

6 months ago

1.0.14

6 months ago

1.0.13

6 months ago

1.0.12

6 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago