Giter VIP home page Giter VIP logo

g4js-cognos's Introduction

g4js-cognos Build Status Code Climate Test Coverage

Node.js client for Cognos application integration utilizing CMS.

Install

$ npm install g4js-cognos

Usage

Require the module:

var Cms = require('g4js-cognos').Cms;

// Optional update defaults for request module.
// Cms.defaults.maxRedirects = 100;

Pass in configuration settings, authenticate and get a report by parameters:

var report = new Cms(serviceUrl, serviceNamespace, serviceUsername, servicePassword);

console.log('logging on...');

report.logon().then(function(response){

  console.log(response.statusCode, response.body);

  var qs = {
    p_prm1: 1,
    p_prm2: '2007-05-02',
    p_prm3: '2009-08-09',
    fmt: 'HTMLFragment'
  };

  console.log('getting report...');

  report.getReportById(reportId, qs).then(function(response){
    console.log(response.statusCode, response.body);
  });
  
});

Pass in configuration settings, authenticate and export a report by parameters:

var report = new Cms(serviceUrl, serviceNamespace, serviceUsername, servicePassword);
var fs = require('fs');

console.log('logging on...');

report.logon().then(function(response){

  console.log(response.statusCode, response.body);

  var qs = {
    p_prmFromDate: '2015-10-01',
    p_prmToDate: '2015-10-31',
    p_prmDetailOn: 'No'
  };

  console.log('getting export...');
  var file = '/tmp/export.xls';

  report.getExportById(reportId, qs, 'CSV').then(function(response){
    console.log('Status: ' + response.statusCode);

    fs.writeFile(file, response.body, 'utf8', function(err) {
      if (err) {
        return console.log(err);
      }

      console.log(file + ' was created!');
    });
  });
});

The example above exports a report in CSV format and then writes it to a file. A few output formats CSV, HTML, HTMLFragment, MHT, XML, spreadsheetML, supported formats vary on version.

Tests

$ npm test

License

MIT

Contribute

Pull Requests always welcome, as well as any feedback or issues. Made with <3 and promises.

g4js-cognos's People

Contributors

helloanoop avatar melkristian avatar nesbert 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.