aicevote
TypeScript icon, indicating that this package has built-in type declarations

0.1.26 • Public • Published

aicevote - AICEVOTE API Client Library -

npm version install size npm downloads MIT License GitHub stars TypeScript

This project ends May 18, 2020

Installing

Using npm:

$ npm install aicevote

Using yarn:

$ yarn add aicevote

Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/aicevote/dist/aicevote.min.js"></script>

Using unpkg CDN:

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/aicevote/dist/aicevote.min.js"></script>

note: aicevote uses axios for http requests. Don't forget to load axios.

Example

aicevote.getAllThemes().then(themes => {
    console.log(themes);
});

// Want to use async/await? Add the "async" keyword to your outer function/method.
async function getAllThemes() {
    const themes = await aicevote.getAllThemes();
    console.log(themes);
}

note: async/await is part of ECMAScript 2017 and is not supported in Internet Explorer and older browsers, so use with caution.

CommonJS usage

while using CommonJS imports with require(), use the following approach:

const aicevote = require("aicevote");

// aicevote.<method> will now provide autocomplete and parameter typings

TypeScript usage

aicevote includes TypeScript definitions.

import aicevote from "aicevote";

aicevote API

Functions

// Auth
function getSessionToken(sessionID: string): Promise<string>;

// Index
function getArticles(): Promise<{
    latest: Article[];
    related: {
        themeID: number;
        articles: Article[];
    }[];
}>;
function postFeedback(feedback: string): Promise<void>;
function postApplication(application: string): Promise<void>;

// Theme
function getAllThemes(): Promise<Theme[]>;
function getTheme(themeID: number): Promise<Theme>;
function queryThemes(regex: string): Promise<Theme[]>;
function putTheme(themeID: number, sessionToken: string, isEnabled: boolean, 
    title: string, description: string, imageURI: string, genre: number, 
    choices: string, DRClass: number, isPersonalMatters: boolean): Promise<void>;

// User
function getMyProfile(sessionToken: string): Promise<Profile>;
function getProfiles(users: {
    userProvider: userProvider;
    userID: string;
}[]): Promise<Profile[]>;
function getInfluencers(): Promise<string[]>;

// Vote
function getResult(themeID: number): Promise<Result>;
function getVotes(themeID: number, sessionToken: string): Promise<Vote[]>;
function vote(themeID: number, sessionToken: string, answer: number): Promise<void>;
function getTransition(themeID: number): Promise<Transition>;
function getComments(themeID: number): Promise<Comment[]>;
function comment(themeID: number, sessionToken: string, message: string): Promise<void>;

Types

// Index
interface Article {
    source: string;
    author: string;
    title: string;
    description: string;
    uri: string;
    uriToImage: string;
    publishedAt: number;
}

// Theme
interface Theme {
    themeID: number;
    userProvider: string;
    userID: string;
    title: string;
    description: string;
    imageURI: string;
    genre: number;
    choices: string[];
    isPersonalMatters: boolean;
    topicality: number;
}

// User
type userProvider = "twitter" | "legacy";
interface Profile {
    userProvider: userProvider;
    userID: string;
    name: string;
    imageURI: string;
    friends: string[];
    isInfluencer: boolean;
    votes: Vote[];
    comments: Comment[];
    themes: Theme[];
}

// Vote
interface Result {
    themeID: number;
    percentage: number[];
}
interface Vote {    
    themeID: number;
    answer: number;
    userProvider: userProvider;
    userID: string;
    createdAt: number;
}
interface Transition {
    shortTransition: {
        timestamp: number;
        percentage: number[];
    }[];
    longTransition: {
        timestamp: number;
        percentage: number[];
    }[];
}
interface Comment {
    themeID: number;
    message: string;
    userProvider: userProvider;
    userID: string;
    createdAt: number;
}

(C) 2020 YUJI mail@yuji.ne.jp

Readme

Keywords

none

Package Sidebar

Install

npm i aicevote

Weekly Downloads

31

Version

0.1.26

License

MIT

Unpacked Size

62.2 kB

Total Files

37

Last publish

Collaborators

  • yujixr