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 21, 2024
1 parent 62e438d commit f74126d
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 171 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 108
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/intercom%2Fintercom-74554ca4b1e947254782b93352448c7a35a528fc0f88e9686e91f77e682b1669.yml
configured_endpoints: 106
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/intercom%2Fintercom-a202b2b4aa0e356eb61376a3bf484132be2e9e3bff3796e1fe4606ab2a3734fd.yml
2 changes: 0 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ Types:

Methods:

- <code title="post /contacts/{id}/companies">client.contacts.companies.<a href="./src/resources/contacts/companies.ts">create</a>(id, { ...params }) -> Company</code>
- <code title="get /contacts/{id}/companies">client.contacts.companies.<a href="./src/resources/contacts/companies.ts">list</a>(id, { ...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
109 changes: 0 additions & 109 deletions src/resources/contacts/companies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,6 @@ import * as CompaniesAPI from './companies';
import * as Shared from '../shared';

export class Companies extends APIResource {
/**
* You can attach a company to a single contact.
*/
create(
id: string,
params: CompanyCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.Company> {
const { company_id, 'Intercom-Version': intercomVersion, ...body } = params;
return this._client.post(`/contacts/${id}/companies`, {
body: { id: company_id, ...body },
...options,
headers: {
...(intercomVersion?.toString() != null ?
{ 'Intercom-Version': intercomVersion?.toString() }
: undefined),
...options?.headers,
},
});
}

/**
* You can fetch a list of companies that are associated to a contact.
*/
list(
id: string,
params?: CompanyListParams,
options?: Core.RequestOptions,
): Core.APIPromise<ContactAttachedCompanies>;
list(id: string, options?: Core.RequestOptions): Core.APIPromise<ContactAttachedCompanies>;
list(
id: string,
params: CompanyListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<ContactAttachedCompanies> {
if (isRequestOptions(params)) {
return this.list(id, {}, params);
}
const { 'Intercom-Version': intercomVersion } = params;
return this._client.get(`/contacts/${id}/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 @@ -145,63 +95,6 @@ export namespace ContactAttachedCompanies {
}
}

export interface CompanyCreateParams {
/**
* Body param: The unique identifier for the company which is given by Intercom
*/
company_id: string;

/**
* Header param: 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 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 @@ -230,7 +123,5 @@ 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;
}
2 changes: 0 additions & 2 deletions src/resources/contacts/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -963,8 +963,6 @@ export namespace Contacts {
export import ContactUnarchiveParams = ContactsAPI.ContactUnarchiveParams;
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: 1 addition & 7 deletions src/resources/contacts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ export {
ContactUnarchiveParams,
Contacts,
} from './contacts';
export {
ContactAttachedCompanies,
CompanyCreateParams,
CompanyListParams,
CompanyDeleteParams,
Companies,
} from './companies';
export { ContactAttachedCompanies, CompanyDeleteParams, Companies } from './companies';
export { ContactSegments, SegmentListParams, Segments } from './segments';
export { NoteList, NoteCreateParams, NoteListParams, Notes } from './notes';
export {
Expand Down
49 changes: 0 additions & 49 deletions tests/api-resources/contacts/companies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,6 @@ const intercom = new Intercom({
});

describe('resource companies', () => {
test('create: only required params', async () => {
const responsePromise = intercom.contacts.companies.create('string', {
company_id: '6657add46abd0167d9419cd2',
});
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('create: required and optional params', async () => {
const response = await intercom.contacts.companies.create('string', {
company_id: '6657add46abd0167d9419cd2',
'Intercom-Version': '2.11',
});
});

test('list', async () => {
const responsePromise = intercom.contacts.companies.list('63a07ddf05a32042dffac965');
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('63a07ddf05a32042dffac965', { 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(
'63a07ddf05a32042dffac965',
{ '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 f74126d

Please sign in to comment.