This is a JavaScript SDK to call https://app.earnshark.com API. Contains methods to call the EarnShark API making the application integration fast.
- NodeJS Runtime Environment
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');
- 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
- renewSubscription - Renew/Update a Subscription
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'; // integerearnsharknpm.getAccountInformation(product_id,key,account_id).then(function(data){
console.log(data)
},function(err){
console.log(err)
});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)
});earnsharknpm.getAllLicensesOfProduct(product_id, key).then(function(data) {
console.log(data)
}, function(err) {
console.log(err)
});var body = {
"account":{
"name":"Account Name",
"email":"Account@example.com",
"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)
})earnsharknpm.getPaymentURL(product_id, key, data.account_id, data.redirect)earnsharknpm.getAccountPayments(product_id, account_id,key).then(function(data) {
console.log(data)
}, function(err) {
console.log(err)
});