1.0.23 • Published 10 months ago

pollz-js v1.0.23

Weekly downloads
-
License
ISC
Repository
github
Last release
10 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.22

10 months ago

1.0.21

10 months ago

1.0.23

10 months ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago