Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): api update #41

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const client = new Conductor({
});

async function main() {
const page = await client.qbd.invoices.list({ 'Conductor-End-User-Id': 'end_usr_1234567abcdefg' });
const page = await client.qbd.invoices.list({ 'Conductor-End-User-Id': 'YOUR_END_USER_ID' });
const invoice = page.data[0];

console.log(invoice.id);
Expand All @@ -50,7 +50,7 @@ const client = new Conductor({
});

async function main() {
const params: Conductor.Qbd.InvoiceListParams = { 'Conductor-End-User-Id': 'end_usr_1234567abcdefg' };
const params: Conductor.Qbd.InvoiceListParams = { 'Conductor-End-User-Id': 'YOUR_END_USER_ID' };
const [invoice]: [Conductor.Qbd.Invoice] = await client.qbd.invoices.list(params);
}

Expand All @@ -69,7 +69,7 @@ a subclass of `APIError` will be thrown:
```ts
async function main() {
const page = await client.qbd.invoices
.list({ 'Conductor-End-User-Id': 'end_usr_1234567abcdefg' })
.list({ 'Conductor-End-User-Id': 'YOUR_END_USER_ID' })
.catch(async (err) => {
if (err instanceof Conductor.APIError) {
console.log(err.status); // 400
Expand Down Expand Up @@ -113,7 +113,7 @@ const client = new Conductor({
});

// Or, configure per-request:
await client.qbd.invoices.list({ 'Conductor-End-User-Id': 'end_usr_1234567abcdefg' }, {
await client.qbd.invoices.list({ 'Conductor-End-User-Id': 'YOUR_END_USER_ID' }, {
maxRetries: 5,
});
```
Expand All @@ -130,7 +130,7 @@ const client = new Conductor({
});

// Override per-request:
await client.qbd.invoices.list({ 'Conductor-End-User-Id': 'end_usr_1234567abcdefg' }, {
await client.qbd.invoices.list({ 'Conductor-End-User-Id': 'YOUR_END_USER_ID' }, {
timeout: 5 * 1000,
});
```
Expand All @@ -148,9 +148,7 @@ You can use the `for await … of` syntax to iterate through items across all pa
async function fetchAllQbdInvoices(params) {
const allQbdInvoices = [];
// Automatically fetches more pages as needed.
for await (const invoice of client.qbd.invoices.list({
'Conductor-End-User-Id': 'end_usr_1234567abcdefg',
})) {
for await (const invoice of client.qbd.invoices.list({ 'Conductor-End-User-Id': 'YOUR_END_USER_ID' })) {
allQbdInvoices.push(invoice);
}
return allQbdInvoices;
Expand All @@ -160,7 +158,7 @@ async function fetchAllQbdInvoices(params) {
Alternatively, you can request a single page at a time:

```ts
let page = await client.qbd.invoices.list({ 'Conductor-End-User-Id': 'end_usr_1234567abcdefg' });
let page = await client.qbd.invoices.list({ 'Conductor-End-User-Id': 'YOUR_END_USER_ID' });
for (const invoice of page.data) {
console.log(invoice);
}
Expand All @@ -184,14 +182,12 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
```ts
const client = new Conductor();

const response = await client.qbd.invoices
.list({ 'Conductor-End-User-Id': 'end_usr_1234567abcdefg' })
.asResponse();
const response = await client.qbd.invoices.list({ 'Conductor-End-User-Id': 'YOUR_END_USER_ID' }).asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: page, response: raw } = await client.qbd.invoices
.list({ 'Conductor-End-User-Id': 'end_usr_1234567abcdefg' })
.list({ 'Conductor-End-User-Id': 'YOUR_END_USER_ID' })
.withResponse();
console.log(raw.headers.get('X-My-Header'));
for await (const invoice of page) {
Expand Down Expand Up @@ -301,7 +297,7 @@ const client = new Conductor({

// Override per-request:
await client.qbd.invoices.list(
{ 'Conductor-End-User-Id': 'end_usr_1234567abcdefg' },
{ 'Conductor-End-User-Id': 'YOUR_END_USER_ID' },
{
httpAgent: new http.Agent({ keepAlive: false }),
},
Expand Down