GithubHelp home page GithubHelp logo

unbanksytv / btu.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from btuprotocol/btu.js

0.0 1.0 0.0 1.25 MB

BTU.js is a Javascript library for interacting with the BTU Protocol. Using it, you can easily make calls to the BTU smart contracts and API to build a booking app or dapp. Functionality includes searching and booking 2M hotels OR activities and booking them live! With BTU.js, every developer can become a booking company and earn $BTU tokens

JavaScript 100.00%

btu.js's Introduction

BTU.JS

BTU.JS is a javascript library that interacts with BTU Protocol. It allows any developer to build a booking application or a widget.

Getting started

Install BTU.JS

npm install btujs --save

Instantiate BTU.JS

const btujs = require('btujs');

const myBtujs = new btujs();

Components

DappBar

BTU Dappbar Technical documentation: The dappbar BTU is a tool for offer bringers to simplify cashback in BTU Token for their customers. In its current version (V2.1), the tool makes it possible to make the address of the wallet that is integrated in the user's browser available on the visited page in a uniform way. The dappbar use only requires HTML5, CSS3 and Javascript, (it is possible to integrate it on any JS framework: React, Angular etc ..). It allows to detect a wallet integrated to a Web3 compatible browser (Opera, plugins like Metamask, Dapp browsers like BTU-Direct, Trust, Coinbase etc ...)

  1. Installation

  2. Additional scripts First, the integration of the following scripts is necessary for the operation of the dappbar: ● JQuery (V3.4 or more) ● Web3 (1.0 or more) ● Dappbar.js (link updated)

If you have an html file, you can directly place the following HTML tags in the part of your file.

<script type="text/javacript"
src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/ethereum/[email protected]/dist/web3.min.js"> </script>
<script type="text/javascript"src="https://btu-cdn.s3.eu-west-3.amazonaws.com/public/dappbar.min.js"></script>

Otherwise you can insert the scripts by calling a JS functions.

const script = document.createElement('script')
script.src = 'https://cdn.jsdelivr.net/gh/ethereum/[email protected]/dist/web3.min.js'
script.async = true
document.head.appendChild(script)

Code to reproduce for each script previously mentioned.

  1. Place the dappbar First of all, for the Dappbar.js script to be able to generate the dappbar, it is necessary to decide on a place where it will be placed thanks to a
    </ div> tag with the specific "btu-placeholder" id. It is recommended to place it as early as possible in the code so that it takes up all the top space of the page.
<div id="btu-placeholder"></div>
  1. Use Once the dappbar has been installed, the user who visits the page will see his wallet connected automatically (or with an approbation request according to the system) to the dappbar. His information will be saved in the sessionStorage

● You can verify if the user is connected with the following call :

sessionStorage.getItem("BTU-walletConnected") // Return "false" or "true"

● You also can have acces to his wallet address by this call :

sessionStorage.getItem("BTU-walletAddr") // Return the BTU key (0xABF2...)

Finally, if your website is available in different domain names and you want to make the connexion possible to the wallet only in one of them (e.g. in the case you want the users who share the link of your website earns the cashback instead of the buyer, it is possible to specify the domain name(s) where you want the bar to appear. To add this content, please add a

"data-restrict-domain ="

attribute with the value(s) of the domain name(s).

<div id="btu-placeholder" data-restrict-domain=”test.com,test.fr”></div>

in the case this attribute is not specified, the dappbar is displayed by default without restrictions. The refund wallet address is to specify in the page URL, thanks to a parameter “w”, exemple : test.com?w=0xAB21...

Resources methods

searchResources()

Search for resources regardless of their availabilities.

Prototype

  myBtujs.resources.searchResources(String resourceType, Object body, Function callback)

Usage


getResource()

Query resource by its ID to get its details.

Prototype

  myBtujs.resources.getResource(String resourceType, String resourceId, Object body, Function callback)

Usage


getResourceItem()

Query resource by its ID and its sub-item ID to get sub-item details.

Prototype

  myBtujs.resource.getResourceItem(String resourceType, String resourceId, String itemId, Object body, Function callback)

Usage


Availabilities methods

searchAvailableResources()

Search for availables resources only.

Prototype

  myBtujs.availabilities.searchAvailableResources(String resourceType, Object body, Function callback)

Usage


getResourceAvailabilities()

Query a resource by its ID and get its availabilities.

Prototype

  myBtujs.availabilities.getResourceAvailabilities(String resourceType, String resourceId, Object body, Function callback)

isResourceAvailable()

Check if a resource is available under different conditions.

Prototype

  myBtujs.availabilities.isResourceAvailable(String resourceType, String resourceId, Object body, Function callback)

Usage

Response

  {
    isAvailable: true // or false
  }

bookResource()

Book a resource availability.

Prototype

  myBtujs.availabilities.bookResource(String resourceType, String resourceId, Object body, Function callback)

Usage


getBookingDetails()

Get informations about a booking you made.

Prototype

  myBtujs.availabilities.getBookingDetails(String resourceType, String bookingId, Object body, Function callback)

Usage


cancelBooking()

Cancel a reservation you booked through the bookResource method.

Prototype

  myBtujs.availabilities.cancelBooking(String resourceType, String bookingId, Object body, Function callback)

Usage

btu.js's People

Contributors

btu-admin avatar capitainekas avatar dosbtup avatar flerunigo avatar gadazeraf avatar pelluro avatar ragiri avatar trakercookie avatar vbrizion 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.