GithubHelp home page GithubHelp logo

chamathpali / earnshark-sdk-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 99x-incubator/earnshark-sdk-js

1.0 1.0 0.0 1.43 MB

JavaScript SDK to call https://app.earnshark.com API

License: MIT License

JavaScript 100.00%

earnshark-sdk-js's Introduction

earnshark-sdk-js

Join the chat at https://gitter.im/99xt/earnshark-sdk-js serverless npm version license

This is a JavaScript SDK to call https://app.earnshark.com API. Contains methods to call the EarnShark API making the application integration fast.

This Plugin Requires

  • NodeJS Runtime Environment

Installation

npm install earnshark-sdk

Then you will be able to access the EarnShark API through your code.

After installation require the EarnShark npm through: var earnsharknpm = require('earnshark-sdk');

Available Methods

  • getAccountInformation - Retrieve information on a particular account/subscription
  • getLicenseInformation - Retrieve information on a particular license
  • getAllLicensesOfProduct - Retrieve all the license data for a particular product
  • addNewSubscription - Add a new subscription to a product
  • getPaymentURL - Returns the payment portal URL for a subscription(linked to PayPal)
  • getAccountPayments - Returns all the payment transactions associated with the account

##Usage Sample

To Switch between Debug and Live modes use the following function,

earnsharknpm.isTest(true);

Initialize the ID's needed

var earnsharknpm = require('earnshark-sdk');

var key = 'YOUR KEY FROM EarnShark Dashboard';

var account_id = 'ACCOUNT_ID';

var product_id = 'PRODUCT_ID'; // integer

###To retrieve the account information###

earnsharknpm.getAccountInformation(product_id,key,account_id).then(function(data){
    console.log(data)
},function(err){
    console.log(err)
});

###To get the information related to a license###

var license_id = 'ID'; // integer

var license_token = 'YOUR LICENSE TOKEN'

earnsharknpm.getLicenseInformation(product_id, license_token, license_id).then(function(data) {
    console.log(data)

}, function(err) {
    console.log(err)
});

###To get all the product licenses###

earnsharknpm.getAllLicensesOfProduct(product_id, key).then(function(data) {
    console.log(data)
    
}, function(err) {
    console.log(err)
});

###To create a new user account###

var body = {
            "account":{
                    "name":"Account Name",
                    "email":"[email protected]",
                    "accountID":"123456",
                    "start_date":"01/01/2016"
                },
                "license_id":0,
                "enableNotifications" : false,
                "sendInvoiceNow" : true
            }

earnsharknpm.addNewSubscription(product_id, key, body).then(function(data) {
    console.log(data)

}, function(err) {
    console.log(err)
})

###Generate Payment URL for an Account###

earnsharknpm.getPaymentURL(product_id, key,  data.account_id, data.redirect)

###To retrieve All Payment Transactions for an Account###

earnsharknpm.getAccountPayments(product_id, account_id,key).then(function(data) {
    console.log(data)
}, function(err) {
    console.log(err)
});

earnshark-sdk-js's People

Contributors

ashanfernando avatar chamathpali avatar gitter-badger avatar jehanwijesinghe avatar

Stargazers

 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.