Git Product home page Git Product logo

reporting-api-client's Introduction

reporting-api-client

CircleCI

A thin Avocarrot reporting API consumer

Development

Please see the CONTRIBUTING instructions before contributing to this repository


Getting Started

Install the required dependencies

make yarn
make npm

To build the library use

npm start

Tests

To run the tests use

npm test

To produce a test coverage report use

npm run cov

You can access the report by running open coverage/lcov-report/index.html.

▶️ Code coverage results for the latest build


API Reference

To generate the JSDoc API Reference run

npm run docs

You can access the generated docs by running open docs/index.html

▶️ API Reference for the latest build


Usage

Setup

Initialize client

/**
 * Initialize ReportingAPIClient
 */
var ReportingAPIClient = require('reporting-api-client');

var client = new ReportingAPIClient({
  host: 'http://reporting.avocarrot.com/v1'
});

Configure credentials

/**
 * Set your credentials and resource to fetch data from
 *
 * @memberof ReportingAPIClient
 * @method setCredentials
 * @param {String} resource - The resource to fetch from
 * @param {String} access_token - The access token to use
 * @return {Void}
 */
client.setCredentials('<resource>', '<access_token>');

Fetch data

Fetch totals

/**
 * Returns totals from API
 *
 * @memberof ReportingAPIClient
 * @method getTotals
 * @param {Array} propertiesArray
 * @param {Object} propertiesArray[0] - properties: The configuration properties to use (timestamp, filters)
 * @return {Promise}
 */
client.getTotals([{
  timestamp: {
    from: '2016-01-07T00:00:00.000Z',
    to: '2016-01-08T00:00:00.000Z'
  },
  filters: {
    country: 'USA',
    // ...
  }
}]).then(function(data) {
  //...
});

Fetch breakdown

/**
 * Returns breakdown data from Reporting API
 *
 * @memberof ReportingAPIClient
 * @method getBreakdown
 * @param {Array} propertiesArray
 * @param {Object} propertiesArray[0] - properties: The configuration properties to use (timestamp, filters, granularity, groups)
 * @return {Promise}
 */
client.getBreakdown([{
  timestamp: {
    from: '2016-01-07T00:00:00.000Z',
    to: '2016-01-08T00:00:00.000Z'
  },
  filters: {
    country: 'USA',
    // ...
  },
  group: {
    groups: ['country', 'platform'],
    // ...
  }
}]).then(function(data) {
  //...
});

Fetch timeseries

/**
 * Returns timeseries from Reporting API
 *  - Granularity split should always be in the back of the splits queue
 *
 * @memberof ReportingAPIClient
 * @method getTimeseries
 * @param {Array} propertiesArray
 * @param {Object} propertiesArray[0] - properties: The configuration properties to use (timestamp, filters, granularity, groups)
 * @return {Promise}
 */
client.getBreakdown([{
  timestamp: {
    from: '2016-01-07T00:00:00.000Z',
    to: '2016-01-08T00:00:00.000Z'
  },
  filters: {
    country: 'USA',
    // ...
  },
  granularity: 'hour',
  group: {
    groups: ['granularity', 'platform'],
    // ...
  }
}]).then(function(data) {
  //...
});

Versioning

For the versions available, see the releases for this repository.

reporting-api-client's People

Contributors

emiliosnic avatar

Stargazers

 avatar

Watchers

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