1.0.0 • Published 3 years ago

bloom-api v1.0.0

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

Getting started

Bloom API

How to Build

The generated SDK relies on Node Package Manager (NPM) being available to resolve dependencies. If you don't already have NPM installed, please go ahead and follow instructions to install NPM from here. The SDK also requires Node to be installed. If Node isn't already installed, please install it from here

NPM is installed by default when Node is installed

To check if node and npm have been successfully installed, write the following commands in command prompt:

  • node --version
  • npm -version

Version Check

Now use npm to resolve all dependencies by running the following command in the root directory (of the SDK folder):

npm install

Resolve Dependencies

Resolve Dependencies

This will install all dependencies in the node_modules folder.

Once dependencies are resolved, you will need to move the folder Bloom in to your node_modules folder.

How to Use

The following section explains how to use the library in a new project.

1. Open Project Folder

Open an IDE/Text Editor for JavaScript like Sublime Text. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.

Click on File and select Open Folder.

Open Folder

Select the folder of your SDK and click on Select Folder to open it up in Sublime Text. The folder will become visible in the bar on the left.

Open Project

2. Creating a Test File

Now right click on the folder name and select the New File option to create a new test file. Save it as index.js Now import the generated NodeJS library using the following lines of code:

var lib = require('lib');

Save changes.

Create new file

Save new file

3. Running The Test File

To run the index.js file, open up the command prompt and navigate to the Path where the SDK folder resides. Type the following command to run the file:

node index.js

Run file

How to Test

These tests use Mocha framework for testing, coupled with Chai for assertions. These dependencies need to be installed for tests to run. Tests can be run in a number of ways:

Method 1 (Run all tests)

  1. Navigate to the root directory of the SDK folder from command prompt.
  2. Type mocha --recursive to run all the tests.

Method 2 (Run all tests)

  1. Navigate to the ../test/Controllers/ directory from command prompt.
  2. Type mocha * to run all the tests.

Method 3 (Run specific controller's tests)

  1. Navigate to the ../test/Controllers/ directory from command prompt.
  2. Type mocha BloomController to run all the tests in that controller file.

To increase mocha's default timeout, you can change the TEST_TIMEOUT parameter's value in TestBootstrap.js.

Run Tests

Initialization

API client can be initialized as following:

const lib = require('lib');

Class Reference

List of Controllers

Class: HinaController

Get singleton instance

The singleton instance of the HinaController class can be accessed from the API Client.

var controller = lib.HinaController;

Method: getResize

Gets Resized image of album from db

function getResize(width, height, id, num, callback)

Parameters

ParameterTagsDescription
widthRequiredOutput Width (Optional)
heightRequiredOutput Height (Optional)
idRequiredPath param id of the album
numRequiredWhich Image to resize

Example Usage

    var width = 215;
    var height = 215;
    var id = 'id';
    var num = 215;

    controller.getResize(width, height, id, num, function(error, response, context) {

    
    });

Method: getAlbum

Gets Album from db

function getAlbum(id, callback)

Parameters

ParameterTagsDescription
idRequiredId of the album

Example Usage

    var id = 'OQl0Cp';

    controller.getAlbum(id, function(error, response, context) {

    
    });

Method: getPagination

Get's Pagination data from db

function getPagination(op, page, source, idol, callback)

Parameters

ParameterTagsDescription
opRequiredNumber of items per page
pageRequiredPage
sourceOptionalSource filter, use comma to use multiple source as filter
idolOptionalidol Filter, use comma to use multiple idol as filter

Example Usage

    var op = 30;
    var page = 1;
    var source = 'source';
    var idol = 'idol';

    controller.getPagination(op, page, source, idol, function(error, response, context) {

    
    });

Method: search

Gets Text query data from db

Strict Termed Searches are to be made with a double quote

 eg: "Skinny"

Exclusion are to be made in this format after any prefilter

 eg: "thick" ~"skinny"
function search(page, query, op, source, idol, callback)

Parameters

ParameterTagsDescription
pageRequiredPage number
queryRequiredsearch term
opOptionalNumber of items per page
sourceOptionalSource filter, use comma to use multiple source as filter
idolOptionalidol Filter, use comma to use multiple idol as filter

Example Usage

    var page = 1;
    var query = 'blonde';
    var op = 50;
    var source = 'source';
    var idol = 'idol';

    controller.search(page, query, op, source, idol, function(error, response, context) {

    
    });

Method: getSources

Gets a List of sources Hina Supports

function getSources(callback)

Example Usage

    controller.getSources(function(error, response, context) {

    
    });

Method: getIdol

Get List of Idols/Artists

function getIdol(callback)

Example Usage

    controller.getIdol(function(error, response, context) {

    
    });

Method: getThumb

Gets Thumb of the album

function getThumb(id, callback)

Parameters

ParameterTagsDescription
idRequiredTODO: Add a parameter description

Example Usage

    var id = 'id';

    controller.getThumb(id, function(error, response, context) {

    
    });

Method: getRandom

Gets Random Album/s

function getRandom(many, callback)

Parameters

ParameterTagsDescription
manyRequired DefaultValuegets many albums

Example Usage

    var many = true;

    controller.getRandom(many, function(error, response, context) {

    
    });

Back to List of Controllers

1.0.0

3 years ago