0.1.26 • Published 4 years ago

aicevote v0.1.26

Weekly downloads
8
License
MIT
Repository
github
Last release
4 years ago

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

0.1.26

4 years ago

0.1.25

4 years ago

0.1.24

4 years ago

0.1.20

4 years ago

0.1.21

4 years ago

0.1.22

4 years ago

0.1.23

4 years ago

0.1.19

4 years ago

0.1.17

4 years ago

0.1.18

4 years ago

0.1.16

4 years ago

0.1.15

4 years ago

0.1.14

4 years ago

0.1.13

4 years ago

0.1.12

4 years ago

0.1.10

4 years ago

0.1.11

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.2

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.5

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago