marcelovue / lunes-lib

Official client-side library for mobile and web Lunes Wallet.

Home Page:https://www.npmjs.com/package/lunes-lib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lunes Lib

The Official and agnostic library to wrap Lunes API.

V 0.0.21

  • Coins: Get coins prices, history

Prerequisites

Instalation

Using NPM

$ npm i --save lunes-lib

Using Yarn

$ yarn add lunes-lib

Importing

//CommonJS's require
const LunesCore = require("lunes-core");
const { users, coins } = LunesCore;

//Webpack/es6
import { users, coins } from "lunes-core";

API

Users

.users.create({email,password,fullname})

Creates a new user into Firebase authentication and into realtime database. This user must to contain a valid email, password and fullname.

Returns an access token for current user.

.users.login({email,password})

User login into Lunes API, using email and password credentials.

Returns an access token for current user.

.users.resetPassword({email)

Request a password recovery e-mail.

Returns a confirmation object.

.users.obtain(id,acessToken)

Get the personal info from current logged user.

Returns user's personal info object.

.users.update(id, {fullname,small,birthDate,city,state,country,homeAddress}, accessToken)

Update user's profile.

Returns the updated user profile.

.users.createPin({pin},acessToken)

Create a new PIN to current logged user.

Returns a confirmation and pinIsVerified = true.

.users.confirmPin({pin},acessToken)

Confirm the PIN code before some operation that it is asked.

Returns a confirmation.

.users.confirmPhone({phoneNumber},acessToken)

Confirm the phone number.

Returns a confirmation and phoneIsVerified = true.

Coins

.coins.getPrice({fromSymbol,toSymbom,exchange})

Obtain the realtime price of one or more currencies.

fromSymbol => e.g. one of BTC, USD, BRL toSymbol => a comma separated list e.g. BTC,ETC,USD,EUR,BRL exchange => Exchange's name, default is CCCAGG

Returns an object containg the asked currency prices.

e.g

{"BTC":0.009878,"USD":10.79,"EUR":10.37}

.coins.getHistory({fromDate, toDate, fromSymbol,toSymbom, exchange})

Obtain an history of some currency (fromSymbol) and its conversion to another (toSymbol) in a period from "fromDate" to "toDate".

If the period is smaller than 1 day, the history is by hour. Otherwise, it will by daily.

fromSymbol => e.g. one of BTC, USD, BRL toSymbol => e.g. one of BTC, USD, BRL range => e.g. one of [RANGE_1D, RANGE_1W, RANGE_1M, RANGE_3M, RANGE_6M, RANGE_1Y, RANGE_MAX]

Return an object containing history metadata and an array containing the low, high values and date.

{
  "success": true,
  "status": 200,
  "message": "Historical chart - BTC to USD",
  "range": "RANGE_1D",
  "data": [
    {
      "close": 12787.35,
      "time": 1516903200
    },
    {
      "close": 11913.74,
      "time": 1516906800
    },
    {
      "close": 11388.52,
      "time": "1516914000
    }
  ]
}

Bitcoin

The following functions are specific when the currency is Bitcoin (BTC).

.coins.bitcoin.getBalance({address}, accessToken)

Read address, request Lunes API and returns balance.

.coins.bitcoin.getHistory({address}, accessToken)

Read address, request Lunes API and returns transaction history.

.coins.bitcoin.backupWallet({email}, accessToken)

Returns the user's wallet seed.

Tests (not tottaly covered)

$ npm test

Pull requests

Always at branch "develop".

License

MIT.

About

Official client-side library for mobile and web Lunes Wallet.

https://www.npmjs.com/package/lunes-lib

License:Apache License 2.0


Languages

Language:JavaScript 100.0%