GithubHelp home page GithubHelp logo

heroesplaygames / extra-life-ts Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 29 KB

Yet another Extra Life API wrapper

Home Page: https://www.npmjs.com/package/extra-life-ts

License: ISC License

Shell 0.62% TypeScript 99.38%
extra-life api wrapper

extra-life-ts's Introduction

extra-life-ts

Yet another Extra Life API wrapper. extra-life-ts adds some endpoints that are missing from other libraries and supports filtering/ordering on endpoints that allow it.

Installation

# NPM
$ npm i extra-life-ts

# Yarn
$ yarn add extra-life-ts

# PNPM
$ pnpm i extra-life-ts

Usage

Node

const { getParticipantDonations } = require('extra-life-ts')

getParticipantDonations(479600, { limit: 1, orderBy: 'amount ASC' }).then((result) => console.log(result))

Browser

const { getParticipantDonations } from 'extra-life-ts'

const donations = await getParticipantDonations(479600, { limit: 1, orderBy: 'amount ASC' })

API

Before Getting Started

All endpoints that that return an array support filtering, ordering and limiting. These collections have the following response format:

interface Result<T> {
  totalRecords: number
  data: T
}

These endpoints also accept an options object with the following properties:

interface Options<T, IncludedFields extends keyof T | undefined = undefined> {
  limit?: number
  page?: number
  orderBy?: `${Exclude<keyof T, symbol>} ${'DESC' | 'ASC'}`
  where?: {
    fieldName: keyof T
    operator: 'LIKE' | '>' | '>=' | '<' | '<=' | '='
    term: string | number
  }
}

For example, to limit to 2, order by amount and filter by amount greater than or equal to $50:

getTeamDonations(60010, {
  limit: 2,
  orderBy: 'amount ASC',
  where: {
    fieldName: 'amount',
    operator: '>=',
    term: 50,
  },
})

Endpoints that only return a single object (getParticipant() and getTeam()) do not support filtering/ordering/limiting. The response is:

interface Result<T> {
  data: T
}

Methods

Participants

  • getParticipant(id)
  • getParticipantActivity(id, options)
  • getParticipantBadges(id, options)
  • getParticipantDonations(id, options)
  • getParticipantDonors(id, options)
  • getParticipantIncentives(id, options)
  • getParticipantMilestones(id, options)

Teams

  • getTeam(id)
  • getTeamActivity(id, options)
  • getTeamBadges(id, options)
  • getTeamDonations(id, options)
  • getTeamDonors(id, options)

Inspiration

License

See LICENSE.md

extra-life-ts's People

Contributors

marceloalves avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.