"use strict";

var Promise = require('bluebird');
var extend = require('extend');
var request = Promise.promisify(require('request'));
var tokenUpdateTime = 12 * 60 * 1000;

/**
 * Creates an instance of object, connected to Nfield API
 */
function ConnectedInstance (requestOptions, authToken, credentials) {
  this.__REQUEST_OPTIONS = requestOptions;
  this.__TOKEN = authToken;
  this.__CREDENTIALS = credentials;
}

/**
 * Creates NfieldClient object
 * @constructor NfieldClient
 */
function NfieldCliConstructor (defOptions) {
  
  var defaultRequestCliOptions = {
    baseUrl : 'https://api.nfieldmr.com/',
    headers : {
      'Content-Type' : 'application/json'
    }
  };
  
  extend(true, defaultRequestCliOptions, defOptions);
  
  /**
   * Returns a new instance of NfieldClient with new request parameters
   */
  this.defaults = function defaults (options) {
    if (typeof options !== 'object') throw new Error('`options` must be an object with request parameters');
    return new NfieldCliConstructor(options);
  };
  
}

module.exports = {
  NfieldClient : new NfieldCliConstructor()
};
@@ -167,16 +167,280 @@
  1000;%0A%0A
+/**%0A * SignIn to Nfield API%0A */%0Afunction SignIn (defOptions, credentials, callback) %7B%0A  var options = %7B%0A    method : 'POST',%0A    uri : 'v1/SignIn',%0A    json : credentials%0A  %7D;%0A  %0A  extend(true, options, defOptions);%0A  return request(options).nodeify(callback);%0A%7D%0A%0A
 /**%0A * C

Add SignIn function