0.6.2 • Published 8 years ago

trackthis v0.6.2

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

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

ParameterTypeDescription
filtersObjectThe name of the recipient
doneFunctionOptional 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

ParameterTypeDescription
partnerCodeNumberThe partnerCode to get the information for.
doneFunctionOptional 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

ParameterTypeDescription
usernameObject/StringAn object of filters, or the username as string.
doneFunctionOptional 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

ParameterTypeDescription
usernameObject/StringAn object of filters, or the username as string.
doneFunctionOptional 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

ParameterTypeDescription
usernameObject/StringAn object of filters, or the username as string.
doneFunctionOptional 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

ParameterTypeDescription
accountOptionsObjectUsername and Type for the new account.
doneFunctionOptional 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

ParameterTypeDescription
partnerCodeNumberThe partnerCode to update the account for.
changesObjectThe changes to apply.
doneFunctionOptional 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

ParameterTypeDescription
performerOptionsObjectOptions for the new performer account.
doneFunctionOptional 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

ParameterTypeDescription
credentialsObjectCredentials to check.
doneFunctionOptional 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

ParameterTypeDescription
filterOptionsObjectFilter options
doneFunctionOptional 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

ParameterTypeDescription
promotorCodeIntegerThe promotorcode
performerCodeIntegerThe performercode
doneFunctionOptional callback, if you don't want to use promises.
0.6.2

8 years ago

0.6.1

8 years ago

0.6.0

9 years ago

0.5.0

9 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago