@dazl/internal-api-client
v1.25.3
Published
Type-safe SDK for Dazl Internal APIs, generated from OpenAPI specifications
Readme
Dazl Internal API Client
Type-safe SDK for Dazl Internal APIs, generated from OpenAPI specifications.
Installation
npm install @dazl/internal-api-clientUsage
Upon application initialization, call client.setConfig to set global setting:
import { client } from '@dazl/internal-api-client';
client.setConfig({
baseUrl: 'http://api-server-url/private',
headers: {
'x-api-key': 'my-secret-api-key',
},
});Later, to use the APIs, import them directly and call the required method:
import { Billing } from '@dazl/internal-api-client';
const customerInfoRes = await Billing.getCustomerInfoByDazlId({
path: { dazlId: 'USER_DAZL_ID' },
});
if (currentPriceRes.error) {
throw new Error(currentPriceRes.error.message);
}
const customerInfo = customerInfoRes.data;Overriding the default client config
Configuration can be passed directly to an API call:
import { Billing } from '@dazl/internal-api-client';
const { data, error } = await Billing.getCustomerInfoByDazlId({
path: { dazlId: 'user-123' },
baseUrl: 'http://api-server-url/private',
headers: {
'x-api-key': 'my-secret-api-key',
},
});A custom client can be passed to a specific API call:
import { createClient } from '@dazl/internal-api-client/client';
import { Billing } from '@dazl/internal-api-client';
const client = createClient({
baseUrl: process.env.API_SERVICE_URL,
headers: {
'x-api-key': 'my-secret-api-key',
},
});
const customerInfoRes = await Billing.getCustomerInfoByDazlId({
path: { dazlId: 'USER_DAZL_ID' },
client
});Related Docs
Additional client fetch documentation can be found here: https://heyapi.dev/openapi-ts/clients/fetch
