Migrated from Redmine #341 | Author: Keith Lyne
Status: New | Priority: Normal | Created: 2019-02-15
I’m having a performance issue with api.
It is taking 7-8 seconds for the sequence, i.e., login and getEventList() functions
I have tried a few options to speed it up but no luck.
One of the things I tried was to cache the token and not do login in every API call.
With the token caching I could get to 5 seconds. 5 seconds is very slow.
The online version, is using v2 of their API. That is pretty fast.
is it possible to get access to your V2 API
sample code
function getClient(){
var jrc = require(‘./json-rpc-client.js’);
var loginClient = new jrc.JSONRpcClient({
‘url’: ‘https://user-api.simplybook.me’ + ‘/login’,
‘onerror’: function (error) { },
});
var YOUR_COMPANY_LOGIN = ‘mygp’
var YOUR_API_KEY = ‘gjgkj’
// var token = ‘yjgjhg’;
var token = loginClient.getToken(YOUR_COMPANY_LOGIN, YOUR_API_KEY);
console.log(token);
return new jrc.JSONRpcClient({
‘url’: ‘https://user-api.simplybook.me’,
‘headers’: {
‘X-Company-Login’: YOUR_COMPANY_LOGIN,
‘X-Token’: token
},
‘onerror’: function (error) { console.log(error) }
});
}
function bookAppointmentHandler(agent) {
console.log(‘Starting book appointment’);
this.client = getClient();
console.log(‘got time’);
let services = this.client.getEventList();
Object.keys(services).forEach(function(key){
var service = services[key];
console.log(‘service unit map,’,service.unit_map);
agent.add(new Card({