Giter VIP home page Giter VIP logo

forgingblock-nodejs's Introduction

ForgingBlock

ForgingBlock is a peer-to-peer cryptocurrency payment system that facilitates developers in providing infrastructure similar to what is offered within the credit card payment industry. ForgingBlock offers APIs, libraries, and Ecommerce plugins to assist merchants and developers - who are familiar with the credit payment process โ€“ in adopting cryptocurrency, L2 networks & stable coins as a payment method with a minimal learning curve and easy adaptability.

The official Node.js library for the ForgingBlock API.

npm Links : https://www.npmjs.com/package/forgingblock.js

Table of contents

Node.js versions

Node.js v0.10.48 and above are supported.

Documentation

For more details visit ForgingBlock API Docs.

To start using this library register an account on ForgingBlock. You will find your Trade and Token keys from Settings.

Next initialize a Client for interacting with the API. The required parameters to initialize a client are Trade and Token, however, you can also pass in baseUrl, apiVersion and timeout. Parameters can be also be set post-initialization:

var forgingblock = require('forgingblock.js');
var Client = forgingblock.Client;

var clientObj = Client.init(Trade, Token);
clientObj.setRequestTimeout(3000);

The API resource class provides the following static methods: list, all, create, retrieve, updateById, deleteById. Additionally, the API resource class also provides the following instance methods: save, delete, insert, update.

Each API method returns an ApiResource which represents the JSON response from the API. When the response data is parsed into objects, the appropriate ApiResource subclass will automatically be used.

Installation

Install with npm:

npm install forgingblock.js --save

Usage

var forgingblock = require('forgingblock.js');
var Client = forgingblock.Client;

Client.init(Trade, Token);

Checkouts

Checkouts API docs

Load checkout resource class

var forgingblock = require('forgingblock.js');
var Checkout = forgingblock.resources.Checkout;

Retrieve

checkout_type is of type string, and can accept either "product" or "donation"

Checkout.retrieve(<checkout_id>, <checkout_type [product | donation]>, function (error, response) {
  console.log(error);
  console.log(response);
});

Create

checkout_type is of type string, and can accept either "product" or "donation"

var checkoutData = {
  amount: 550,
  currency: 'usd',
  description: 'Description for the product',
  email: '[email protected]',
  count: 2,
  name: 'IPhone'
};

Checkout.create(checkoutData, <checkout_type [product | donation]>,function (error, response) {
  console.log(error);
  console.log(response);
});

Update

var newParams = {
  description: 'thebesttool',
  name: 'product1',
  count: 12,
  item: '829f8bd302d0f2b24e8fe9b6d23ad494' // item or fund id is required
};

Checkout.update(<checkout_id>, newParams, function (error, response) {
  console.log(error);
  console.log(response);
});

Get all checkouts

Checkout.all({}, function (error, list) {
  console.log(error);
  console.log(list);
});

Sales

Sales API docs

Load Sale resource class

var forgingblock = require('forgingblock.js');
var Sale = forgingblock.resources.Sale;

Retrieve

Sale.retrieve(<invoiceId>, function (error, response) {
  console.log(error);
  console.log(response);
});

Get all sales

Sale.all({}, function (error, response) {
  console.log(error);
  console.log(response);
});

// OR you can pass the status parameter to get only the paid invoices

Sale.all({ status: 'paid' }, function (error, response) {
  console.log(error);
  console.log(response);
});

Balances

Load event resource class

var forgingblock = require('forgingblock.js');
var Balance = forgingblock.resources.Balance;

Get all balances

If you are using Single Wallet connection in your dashboard, you can simply call the all method and that will give you all the balances

Balance.all({}, function (error, list) {
  console.log(error);
  console.log(list);
});

If you are using Multi Wallet settings, you have to pass that multiwallet flag as below

Balance.all({ multiwallet: true }, function (error, list) {
  console.log(error);
  console.log(list);
});

License

MIT

forgingblock-nodejs's People

Contributors

asimkhan0 avatar somethingtodo123 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.