trackthis

0.6.2 • Public • Published

Trackthis

A module that simplifies working with the TrackThis endpoints.

Installation

Simply run npm install --save trackthis and start implementing.

Usage

Usage is very simple. You can find the available methods below.

var TrackThis = require('trackthis'),
    trackthis = new TrackThis({
      tracker : {
        websiteKey   : null,
        productGroup : 'webcamsv4',
        websiteDomain: null,
        product      : 'vpscash4'
      },
      api     : {
        endpoint   : 'http://trackthat.nl',
        credentials: {
          username: '',
          password: ''
        }
      }
    });
 
// Start making API calls.

API

You can find a complementary documentation page in the trackthis API docs. This library is loosely based on the API.

Note: All methods in this library support both callback style and promises. It's entirely up to you which you use. This library uses the bluebird promises library.

=====

.searchAccounts(filters[, done])

Search for accounts based on filters. You can find the properties available to filter on here, under AccountV2 (search).

Example

trackthis.api.searchAccounts({username : 'kaatje'})
  .then(function (accounts) {
    // Yeah!
  }).catch(function (error) {
    // Exception.
  });

Parameters

Parameter Type Description
filters Object The name of the recipient
[done] Function Optional callback, if you don't want to use promises.

=====

.findFull(partnerCode[, done])

Retrieve all known information for an account based on partner code.

Example

trackthis.api.findFull(123)
  .then(function (account) {
    // Yeah!
  }).catch(function (error) {
    // Exception.
  });

Parameters

Parameter Type Description
partnerCode Number The partnerCode to get the information for.
[done] Function Optional callback, if you don't want to use promises.

=====

.findAccount(username[, done])

Find information for an account username.

Example

trackthis.api.findAccount('kaatje')
  .then(function (account) {
    // Yeah!
  }).catch(function (error) {
    // Exception.
  });

Parameters

Parameter Type Description
username Object/String An object of filters, or the username as string.
[done] Function Optional callback, if you don't want to use promises.

Note: The available filters are the same as those supplied by .searchAccounts().

=====

.findPerformer(username[, done])

Find information based on a performer username.

Note: This convenience method uses .findAccount(), but adds {type:'webcam'}.

Example

trackthis.api.findPerformer('kaatje')
  .then(function (performer) {
    // Yeah!
  }).catch(function (error) {
    // Exception.
  });

Parameters

Parameter Type Description
username Object/String An object of filters, or the username as string.
[done] Function Optional callback, if you don't want to use promises.

Note: The available filters are the same as those supplied by .searchAccounts().

=====

.findStudio(username[, done])

Find information based on a studio username.

Note: This convenience method uses .findAccount(), but adds {type:'studio'}.

Example

trackthis.api.findStudio('studioName')
  .then(function (studio) {
    // Yeah!
  }).catch(function (error) {
    // Exception.
  });

Parameters

Parameter Type Description
username Object/String An object of filters, or the username as string.
[done] Function Optional callback, if you don't want to use promises.

Note: The available filters are the same as those supplied by .searchAccounts().

=====

.createAccount(accountOptions[, done])

Register a new account with TrackThis. Parameter accountOptions accepts a type and a username.

Example

trackthis.api.createAccount({type: 'webcam', username: 'lookatme'})
  .then(function (response) {
    // Yeah!
  }).catch(function (error) {
    // Exception.
  });

Parameters

Parameter Type Description
accountOptions Object Username and Type for the new account.
[done] Function Optional callback, if you don't want to use promises.

=====

.editAccount(partnerCode, changes[, done])

Edit the account properties for partnerCode. You can find the properties available to supply here, under AccountV2 (edit), parameter changes.

Example

trackthis.api.editAccount(123, {email: 'new@domain.org})
  .then(function (response) {
    // Yeah!
  }).catch(function (error) {
    // Exception.
  });

Parameters

Parameter Type Description
partnerCode Number The partnerCode to update the account for.
changes Object The changes to apply.
[done] Function Optional callback, if you don't want to use promises.

=====

.registerPerformer(performerOptions[, done])

Create a new performer account. This convenience method combines .createAccount() and .editAccount(). The performerOptions available to supply are those from .createAccount() and .editAccount() mixed.

Example

trackthis.api.registerPerformer({
  username    : 'lookatme',
  email       : 'lookatme@now.net',
  password    : 'hard2guessss',
  account_iban: 'foobar123'
}).then(function (response) {
  // Yeah!
}).catch(function (error) {
  // Exception.
});

Parameters

Parameter Type Description
performerOptions Object Options for the new performer account.
[done] Function Optional callback, if you don't want to use promises.

=====

.validateCredentials(credentials[, done])

Validate the credentials for an account. This method checks if the credentials match with trackthis, and if so returns account information. Argument credentials accepts properties type, username and password.

Example

trackthis.api.validateCredentials({
  type    : 'studio',
  username: 'studioname',
  password: 'foobar123'
}).then(function (result) {
  if (result.valid) {
    // Something to work with.
    var accountInfo = result.details;
  }
}).catch(function (error) {
  // Exception.
});

Parameters

Parameter Type Description
credentials Object Credentials to check.
[done] Function Optional callback, if you don't want to use promises.

=====

.findPayments(filterOptions[, done])

This method searches for payments with the given criteria, and if so return the payment data otherwise an false Argument filterOptions accepts properties grouping, period, date and filters.

Example

trackthis.api.findPayments({
  grouping: 'day',
  period  : 'custom',
  date    : {
    start: '2015-01-01',
    end  : '2015-01-31'
  }
}).then(function (result) {
  if (result) {
    // Something to work with.
    var paymentInfo = result.data;
  }
}).catch(function (error) {
  // Exception.
});

Parameters

Parameter Type Description
filterOptions Object Filter options
[done] Function Optional callback, if you don't want to use promises.

=====

.addProvisionCode(promotorCode, performerCode[, done])

Add the provision code to an existing performer.

Example

trackthis.api.addProvisionCode(61, 100012).then(function (result) {
  if (result) {
    // Something to work with.
    var performerInfo = result.data;
  }
}).catch(function (error) {
  // Exception.
});

Parameters

Parameter Type Description
promotorCode Integer The promotorcode
performerCode Integer The performercode
[done] Function Optional callback, if you don't want to use promises.

Readme

Keywords

Package Sidebar

Install

npm i trackthis

Weekly Downloads

5

Version

0.6.2

License

ISC

Last publish

Collaborators

  • ronaldbaltus
  • rwoverdijk
  • vbindraban