@whiterabbitjs/client
TypeScript icon, indicating that this package has built-in type declarations

4.1.1 • Public • Published

WhiteRabbit client

Simple frontend library to integrate WhiteRabbit on your streaming website.

Usage

Option 1. Install from npm

Install @whiterabbitjs/client package

npm install --save @whiterabbitjs/client

Then use it on your webpage

import { WhiteRabbitClient } from '@whiterabbitjs/client';

const client = new WhiteRabbitClient({ apiKey: '....your API key' });

client.requestPayment('tt8367814');

Option 2. Use as module

import { WhiteRabbitClient } from 'https://unpkg.com/@whiterabbitjs/client@2.40.1/dist/index.min.mjs';
const client = new WhiteRabbitClient({ apiKey: '....your API key' });

client.requestPayment('tt8367814');

API

new WhiteRabbitClient(whiterabbitConfig)

Create a new client instance.

Arguments:

  • whiteRabbitConfig — config object with attributes:

    • apiKey — API key of the partner. Could test or production one

client.requestPayment(imdbId, [pssAddress], [medium])

Request a payment by movie's imdb ID. Example: tt8367814. Returns a Promise which resolves with the status of the payment.

Arguments:

  • imdbId - imdb ID for the movie.

Response:

  • movieId — Number. Movie id as encoded by utils.imdbToToken function.
  • paymentId - String. Unique ID for the payment
  • status - Boolean. Result of the payment. true means the payment was successful, false — the payment was either declined by user or failure happened

Response example:

{
  movieId: "423557889"
  paymentId: "0x3202b4ef03ef29d87d81357e4c50105206be0396c5e5c4624d498b8cb7e2a083"
  status: true
}

Utils API

import { utils } from '@whiterabbitjs/client';

utils.imdbToToken(imdbId)

Convert given imdbId to WhiteRabbit token.

Arguments:

  • imdbId — imdbID for the Movie.

utils.tokenToImdb(tokenId)

Convert given WhiteRabbit tokenId to imdbId.

Arguments:

  • tokenId — tokenId for the MovieToken.

utils.getRegionByCode(regionCode)

Given a three digit M49 region code returns a two-letter ISO 3166-1 alpha-2 country code

Arguments:

  • regionCode — M49 region code. Three digits, zero-padded (e.g. 008).

Readme

Keywords

none

Package Sidebar

Install

npm i @whiterabbitjs/client

Weekly Downloads

1

Version

4.1.1

License

MIT

Unpacked Size

139 kB

Total Files

62

Last publish

Collaborators

  • vlad17451
  • troggy
  • whiterabbit-cd