Skip to content

Commit 6471160

Browse files
committed
feat(api): update via SDK Studio
1 parent 536cfac commit 6471160

File tree

6 files changed

+95
-2
lines changed

6 files changed

+95
-2
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 107
1+
configured_endpoints: 108
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/intercom%2Fintercom-a202b2b4aa0e356eb61376a3bf484132be2e9e3bff3796e1fe4606ab2a3734fd.yml

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ Types:
175175
Methods:
176176

177177
- <code title="post /contacts/{contact_id}/companies">client.contacts.companies.<a href="./src/resources/contacts/companies.ts">create</a>(contactId, { ...params }) -> Company</code>
178+
- <code title="get /contacts/{contact_id}/companies">client.contacts.companies.<a href="./src/resources/contacts/companies.ts">list</a>(contactId, { ...params }) -> ContactAttachedCompanies</code>
178179
- <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>
179180

180181
## Notes

src/resources/contacts/companies.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,35 @@ export class Companies extends APIResource {
2828
});
2929
}
3030

31+
/**
32+
* You can fetch a list of companies that are associated to a contact.
33+
*/
34+
list(
35+
contactId: string,
36+
params?: CompanyListParams,
37+
options?: Core.RequestOptions,
38+
): Core.APIPromise<ContactAttachedCompanies>;
39+
list(contactId: string, options?: Core.RequestOptions): Core.APIPromise<ContactAttachedCompanies>;
40+
list(
41+
contactId: string,
42+
params: CompanyListParams | Core.RequestOptions = {},
43+
options?: Core.RequestOptions,
44+
): Core.APIPromise<ContactAttachedCompanies> {
45+
if (isRequestOptions(params)) {
46+
return this.list(contactId, {}, params);
47+
}
48+
const { 'Intercom-Version': intercomVersion } = params;
49+
return this._client.get(`/contacts/${contactId}/companies`, {
50+
...options,
51+
headers: {
52+
...(intercomVersion?.toString() != null ?
53+
{ 'Intercom-Version': intercomVersion?.toString() }
54+
: undefined),
55+
...options?.headers,
56+
},
57+
});
58+
}
59+
3160
/**
3261
* You can detach a company from a single contact.
3362
*/
@@ -147,6 +176,32 @@ export interface CompanyCreateParams {
147176
| 'Unstable';
148177
}
149178

179+
export interface CompanyListParams {
180+
/**
181+
* Intercom API version.By default, it's equal to the version set in the app
182+
* package.
183+
*/
184+
'Intercom-Version'?:
185+
| '1.0'
186+
| '1.1'
187+
| '1.2'
188+
| '1.3'
189+
| '1.4'
190+
| '2.0'
191+
| '2.1'
192+
| '2.2'
193+
| '2.3'
194+
| '2.4'
195+
| '2.5'
196+
| '2.6'
197+
| '2.7'
198+
| '2.8'
199+
| '2.9'
200+
| '2.10'
201+
| '2.11'
202+
| 'Unstable';
203+
}
204+
150205
export interface CompanyDeleteParams {
151206
/**
152207
* Intercom API version.By default, it's equal to the version set in the app
@@ -176,5 +231,6 @@ export interface CompanyDeleteParams {
176231
export namespace Companies {
177232
export import ContactAttachedCompanies = CompaniesAPI.ContactAttachedCompanies;
178233
export import CompanyCreateParams = CompaniesAPI.CompanyCreateParams;
234+
export import CompanyListParams = CompaniesAPI.CompanyListParams;
179235
export import CompanyDeleteParams = CompaniesAPI.CompanyDeleteParams;
180236
}

src/resources/contacts/contacts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ export namespace Contacts {
883883
export import Companies = CompaniesAPI.Companies;
884884
export import ContactAttachedCompanies = CompaniesAPI.ContactAttachedCompanies;
885885
export import CompanyCreateParams = CompaniesAPI.CompanyCreateParams;
886+
export import CompanyListParams = CompaniesAPI.CompanyListParams;
886887
export import CompanyDeleteParams = CompaniesAPI.CompanyDeleteParams;
887888
export import Notes = NotesAPI.Notes;
888889
export import NoteList = NotesAPI.NoteList;

src/resources/contacts/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ export {
1616
ContactUnarchiveParams,
1717
Contacts,
1818
} from './contacts';
19-
export { ContactAttachedCompanies, CompanyCreateParams, CompanyDeleteParams, Companies } from './companies';
19+
export {
20+
ContactAttachedCompanies,
21+
CompanyCreateParams,
22+
CompanyListParams,
23+
CompanyDeleteParams,
24+
Companies,
25+
} from './companies';
2026
export { ContactSegments, SegmentListParams, Segments } from './segments';
2127
export { NoteList, NoteCreateParams, NoteListParams, Notes } from './notes';
2228
export {

tests/api-resources/contacts/companies.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,35 @@ describe('resource companies', () => {
2929
});
3030
});
3131

32+
test('list', async () => {
33+
const responsePromise = intercom.contacts.companies.list('string');
34+
const rawResponse = await responsePromise.asResponse();
35+
expect(rawResponse).toBeInstanceOf(Response);
36+
const response = await responsePromise;
37+
expect(response).not.toBeInstanceOf(Response);
38+
const dataAndResponse = await responsePromise.withResponse();
39+
expect(dataAndResponse.data).toBe(response);
40+
expect(dataAndResponse.response).toBe(rawResponse);
41+
});
42+
43+
test('list: request options instead of params are passed correctly', async () => {
44+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
45+
await expect(
46+
intercom.contacts.companies.list('string', { path: '/_stainless_unknown_path' }),
47+
).rejects.toThrow(Intercom.NotFoundError);
48+
});
49+
50+
test('list: request options and params are passed correctly', async () => {
51+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
52+
await expect(
53+
intercom.contacts.companies.list(
54+
'string',
55+
{ 'Intercom-Version': '2.11' },
56+
{ path: '/_stainless_unknown_path' },
57+
),
58+
).rejects.toThrow(Intercom.NotFoundError);
59+
});
60+
3261
test('delete', async () => {
3362
const responsePromise = intercom.contacts.companies.delete(
3463
'58a430d35458202d41b1e65b',

0 commit comments

Comments
 (0)