UNPKG

gstin_checker

Version:

GSTIN Checker =========

50 lines (44 loc) 949 B
'use strict'; var Promise = require('bluebird') , request = require('request') , queryString = require('querystring') , api_key ; /** * options * @api_key - your api_key */ function GSTINChecker(options) { if (options.api_key !== undefined) { api_key = options.api_key } else { throw new Error('Expected an array of objects with "api_key" attributes'); } } /** * options * @GSTIN Number - GSTIN Number */ GSTINChecker.prototype.request = function(GSTIN) { return new Promise(function (resolve, reject) { var options = { method: 'GET', url: 'http://sheet.gstincheck.ml/check/'+api_key+'/'+GSTIN, json: true }; request.get(options, function (err, httpResponse, body) { if (err) { reject(err); } if(body.flag == true) { resolve(body.data); } else { resolve(body.message) } }); }); }; module.exports = GSTINChecker;