onResponse hook on XeroClient config that will be called every response

Offen
#620 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
nodejs, typescript
Bereich
api

Rechercherichtung

The request is for an onResponse option on the XeroClient config, which would receive the raw response headers on every API call. Start from the XeroClient constructor and its config type, then find where requests are sent to see where a response callback could be invoked. The issue's example headers (X-DayLimit-Remaining and related) show the data the hook must expose. Done means the callback fires on each response with the headers available, and the README documents it.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Type: Enhancement Type: Feature Request

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

Vorherrschende Sprache
TypeScript
Sterne
264
Forks
177
Ø Merge
10 Std. 5 Min.
Gemergte PRs (30 T.)
5

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus XeroAPI/xero-node

Alle Issues in XeroAPI/xero-node

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.