Skip to content

Commit

Permalink
feat(): add simple localisation config
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagosiebler committed Sep 13, 2024
1 parent c43b6cb commit 24996a7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/BaseRestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ export abstract class BaseRestClient {
},
};

if (restClientOptions.localisation) {
if (!this.globalRequestOptions.headers) {
this.globalRequestOptions.headers = {};
}

this.globalRequestOptions.headers['Accept-Language'] =
restClientOptions.localisation;
}

// If enabled, configure a https agent with keepAlive enabled
if (this.options.keepAlive) {
// For more advanced configuration, raise an issue on GitHub or use the "networkOptions"
Expand Down
20 changes: 20 additions & 0 deletions src/lib/requestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ export interface RestClientOptions {
privateKey: string;
};

/**
* https://docs.cdp.coinbase.com/coinbase-app/docs/localization
*
* The Coinbase App API supports localization for error messages and other strings.
* Localization is defined in each request with Accept-Language header.
*
* Accepted values are currently as below. Note: this may not work for all coinbase product groups.
*/
localisation?:
| 'de'
| 'en'
| 'es'
| 'es-mx'
| 'fr'
| 'id'
| 'it'
| 'nl'
| 'pt'
| 'pt-br';

/**
* Enable keep alive for REST API requests (via axios).
* See: https://github.com/tiagosiebler/bybit-api/issues/368
Expand Down

0 comments on commit 24996a7

Please sign in to comment.