Skip to content

Commit

Permalink
feat(api): api update (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 23, 2025
1 parent 962276b commit 8430b7a
Showing 1 changed file with 10 additions and 14 deletions.
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

0 comments on commit 8430b7a

Please sign in to comment.