Skip to content

Commit

Permalink
feat(api): update via SDK Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Jun 26, 2024
1 parent 536cfac commit 6471160
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 107
configured_endpoints: 108
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/intercom%2Fintercom-a202b2b4aa0e356eb61376a3bf484132be2e9e3bff3796e1fe4606ab2a3734fd.yml
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Types:
Methods:

- <code title="post /contacts/{contact_id}/companies">client.contacts.companies.<a href="./src/resources/contacts/companies.ts">create</a>(contactId, { ...params }) -> Company</code>
- <code title="get /contacts/{contact_id}/companies">client.contacts.companies.<a href="./src/resources/contacts/companies.ts">list</a>(contactId, { ...params }) -> ContactAttachedCompanies</code>
- <code title="delete /contacts/{contact_id}/companies/{id}">client.contacts.companies.<a href="./src/resources/contacts/companies.ts">delete</a>(contactId, id, { ...params }) -> Company</code>

## Notes
Expand Down
56 changes: 56 additions & 0 deletions src/resources/contacts/companies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,35 @@ export class Companies extends APIResource {
});
}

/**
* You can fetch a list of companies that are associated to a contact.
*/
list(
contactId: string,
params?: CompanyListParams,
options?: Core.RequestOptions,
): Core.APIPromise<ContactAttachedCompanies>;
list(contactId: string, options?: Core.RequestOptions): Core.APIPromise<ContactAttachedCompanies>;
list(
contactId: string,
params: CompanyListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<ContactAttachedCompanies> {
if (isRequestOptions(params)) {
return this.list(contactId, {}, params);
}
const { 'Intercom-Version': intercomVersion } = params;
return this._client.get(`/contacts/${contactId}/companies`, {
...options,
headers: {
...(intercomVersion?.toString() != null ?
{ 'Intercom-Version': intercomVersion?.toString() }
: undefined),
...options?.headers,
},
});
}

/**
* You can detach a company from a single contact.
*/
Expand Down Expand Up @@ -147,6 +176,32 @@ export interface CompanyCreateParams {
| 'Unstable';
}

export interface CompanyListParams {
/**
* Intercom API version.By default, it's equal to the version set in the app
* package.
*/
'Intercom-Version'?:
| '1.0'
| '1.1'
| '1.2'
| '1.3'
| '1.4'
| '2.0'
| '2.1'
| '2.2'
| '2.3'
| '2.4'
| '2.5'
| '2.6'
| '2.7'
| '2.8'
| '2.9'
| '2.10'
| '2.11'
| 'Unstable';
}

export interface CompanyDeleteParams {
/**
* Intercom API version.By default, it's equal to the version set in the app
Expand Down Expand Up @@ -176,5 +231,6 @@ export interface CompanyDeleteParams {
export namespace Companies {
export import ContactAttachedCompanies = CompaniesAPI.ContactAttachedCompanies;
export import CompanyCreateParams = CompaniesAPI.CompanyCreateParams;
export import CompanyListParams = CompaniesAPI.CompanyListParams;
export import CompanyDeleteParams = CompaniesAPI.CompanyDeleteParams;
}
1 change: 1 addition & 0 deletions src/resources/contacts/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ export namespace Contacts {
export import Companies = CompaniesAPI.Companies;
export import ContactAttachedCompanies = CompaniesAPI.ContactAttachedCompanies;
export import CompanyCreateParams = CompaniesAPI.CompanyCreateParams;
export import CompanyListParams = CompaniesAPI.CompanyListParams;
export import CompanyDeleteParams = CompaniesAPI.CompanyDeleteParams;
export import Notes = NotesAPI.Notes;
export import NoteList = NotesAPI.NoteList;
Expand Down
8 changes: 7 additions & 1 deletion src/resources/contacts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ export {
ContactUnarchiveParams,
Contacts,
} from './contacts';
export { ContactAttachedCompanies, CompanyCreateParams, CompanyDeleteParams, Companies } from './companies';
export {
ContactAttachedCompanies,
CompanyCreateParams,
CompanyListParams,
CompanyDeleteParams,
Companies,
} from './companies';
export { ContactSegments, SegmentListParams, Segments } from './segments';
export { NoteList, NoteCreateParams, NoteListParams, Notes } from './notes';
export {
Expand Down
29 changes: 29 additions & 0 deletions tests/api-resources/contacts/companies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,35 @@ describe('resource companies', () => {
});
});

test('list', async () => {
const responsePromise = intercom.contacts.companies.list('string');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

test('list: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.contacts.companies.list('string', { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Intercom.NotFoundError);
});

test('list: request options and params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.contacts.companies.list(
'string',
{ 'Intercom-Version': '2.11' },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Intercom.NotFoundError);
});

test('delete', async () => {
const responsePromise = intercom.contacts.companies.delete(
'58a430d35458202d41b1e65b',
Expand Down

0 comments on commit 6471160

Please sign in to comment.