onResponse hook on XeroClient config that will be called every response
aprilmintacpineda opened this issue · 0 comments
aprilmintacpineda commented
SDK you're using (please complete the following information):
- Version: 4.29.0
Is your feature request related to a problem? Please describe.
Yes.Xero API's enforces the following rate limits:
- 5 concurrent request (per tenant)
- 60 requests per minute (per tenant)
- 5,000 request per day (per tenant)
- 10,000 requests per day (hard limit on the app level)
I'm currently creating a solution that works with these constraints.
Describe the solution you'd like
We want to be able to specify a hook on the XeroClient level like so:
import { XeroClient } from 'xero-node';
const client = new XeroClient({
clientId: process.env.XERO_CLIENT_ID,
clientSecret: process.env.XERO_CLIENT_SECRET,
redirectUris: [process.env.XERO_REDIRECT_URI],
scopes: [
'openid',
'profile',
'email',
'accounting.settings',
'payroll.employees',
'payroll.payruns',
'offline_access'
],
onResponse: (response: IncomingMessage) => {
const dayRemaining = response.headers['X-DayLimit-Remaining'];
const minuteRemaining = response.headers['X-MinLimit-Remaining'];
const AppMinLimit = response.headers['X-AppMinLimit-Remaining'];
// do something
}
});
Describe alternatives you've considered
No alternatives available other than to write your own helper function that handles these everytime you make a request which isn't as good and causes a lot of code repetition.
Additional context
N/A