Initializes library.
Arguments:
config.key
required (string): Merchant API key.
config.user
optional (user): User object. Could be provided either at initialization or at request.
config.method
optional ('jsonp' || 'post'): Request method. Default 'jsonp'.
config.log
optional (boolean): Defines, should Findify log requests on server.
config.url
optional (string): Search API url. Used to overwrite the default Search API url.
config.timeout
optional (number): Request timeout duration. Defaults to 5000ms.
config.retryCount
optional (number): Retry count before rqeuest fails. Defaults to 3.
config.jsonpCallback
optional (string): JSONP callback function name. It is required for method: 'jsonp'
parameter.
Types:
user.uid
required (string): Unique customer id.
user.sid
required (string): Session id.
user.email
optional (string): Customer email.
user.ip
optional (number): Customer ip.
user.ua
optional (string): Customer user agent.
user.lang
optional (string[]): Languages.
Returns:
Client instance, which could be used further for sending requests to the server.
Examples of usage:
var client = FindifySDK.init({
method: 'post',
key: 'b9h348b89h439g43',
user: {
uid: 'f892hf2938f2g9p2',
sid: 'g2984hg2jg9823g9',
}
});
// After, you can send requests to server:
client.send(request).then(function (response) {
// handle response
});