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): update via SDK Studio #414

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
branches:
- v3
- next

jobs:
lint:
Expand Down
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This library provides convenient access to the Intercom REST API from server-side TypeScript or JavaScript.

The REST API documentation can be found [on developers.intercom.com](https://developers.intercom.com). The full API of this library can be found in [api.md](api.md).
The REST API documentation can be found on [developers.intercom.com](https://developers.intercom.com). The full API of this library can be found in [api.md](api.md).

It is generated with [Stainless](https://www.stainlessapi.com/).

Expand Down Expand Up @@ -281,14 +281,6 @@ TypeScript >= 4.5 is supported.

The following runtimes are supported:

- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
- Deno v1.28.0 or higher, using `import Intercom from "npm:intercom-client"`.
- Bun 1.0 or later.
- Cloudflare Workers.
- Vercel Edge Runtime.
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
- Nitro v2.6 or greater.

Note that React Native is not supported at this time.

If you are interested in other runtime environments, please open or upvote an issue on GitHub.
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ export namespace Intercom {
export import Conversations = API.Conversations;
export import ConversationList = API.ConversationList;
export import ConversationListResponse = API.ConversationListResponse;
export import ConversationListResponsesCursorPagination = API.ConversationListResponsesCursorPagination;
export import ConversationCreateParams = API.ConversationCreateParams;
export import ConversationRetrieveParams = API.ConversationRetrieveParams;
export import ConversationUpdateParams = API.ConversationUpdateParams;
Expand Down
8 changes: 4 additions & 4 deletions src/resources/conversations/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import { isRequestOptions } from '../../core';
import * as Core from '../../core';
import * as ConversationsAPI from './conversations';
import * as Shared from '../shared';
import { ConversationListResponsesCursorPagination } from '../shared';
import * as CustomersAPI from './customers';
import * as PartsAPI from './parts';
import * as ReplyAPI from './reply';
import * as RunAssignmentRulesAPI from './run-assignment-rules';
import * as TagsAPI from './tags';
import * as NewsItemsAPI from '../news/news-items';
import * as NewsfeedsAPI from '../news/newsfeeds/newsfeeds';
import { CursorPagination, type CursorPaginationParams } from '../../pagination';
import { type CursorPaginationParams } from '../../pagination';

export class Conversations extends APIResource {
tags: TagsAPI.Tags = new TagsAPI.Tags(this._client);
Expand Down Expand Up @@ -338,8 +339,6 @@ export class Conversations extends APIResource {
}
}

export class ConversationListResponsesCursorPagination extends CursorPagination<ConversationListResponse> {}

/**
* Conversations are how you can communicate with users in Intercom. They are
* created when a contact replies to an outbound message, or when one admin
Expand Down Expand Up @@ -728,7 +727,6 @@ export interface ConversationSearchParams {
export namespace Conversations {
export import ConversationList = ConversationsAPI.ConversationList;
export import ConversationListResponse = ConversationsAPI.ConversationListResponse;
export import ConversationListResponsesCursorPagination = ConversationsAPI.ConversationListResponsesCursorPagination;
export import ConversationCreateParams = ConversationsAPI.ConversationCreateParams;
export import ConversationRetrieveParams = ConversationsAPI.ConversationRetrieveParams;
export import ConversationUpdateParams = ConversationsAPI.ConversationUpdateParams;
Expand All @@ -749,3 +747,5 @@ export namespace Conversations {
export import CustomerCreateParams = CustomersAPI.CustomerCreateParams;
export import CustomerDeleteParams = CustomersAPI.CustomerDeleteParams;
}

export { ConversationListResponsesCursorPagination };
6 changes: 3 additions & 3 deletions tests/api-resources/admins/activity-logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const intercom = new Intercom({

describe('resource activityLogs', () => {
test('list: only required params', async () => {
const responsePromise = intercom.admins.activityLogs.list({ created_at_after: 'string' });
const responsePromise = intercom.admins.activityLogs.list({ created_at_after: 'created_at_after' });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -22,8 +22,8 @@ describe('resource activityLogs', () => {

test('list: required and optional params', async () => {
const response = await intercom.admins.activityLogs.list({
created_at_after: 'string',
created_at_before: 'string',
created_at_after: 'created_at_after',
created_at_before: 'created_at_before',
'Intercom-Version': '2.11',
});
});
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/articles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ describe('resource articles', () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.articles.search(
{ help_center_id: 0, highlight: true, phrase: 'string', state: 'string', 'Intercom-Version': '2.11' },
{ help_center_id: 0, highlight: true, phrase: 'phrase', state: 'state', 'Intercom-Version': '2.11' },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Intercom.NotFoundError);
Expand Down
12 changes: 6 additions & 6 deletions tests/api-resources/companies/companies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('resource companies', () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.companies.list(
{ order: 'string', page: 0, per_page: 0, 'Intercom-Version': '2.11' },
{ order: 'order', page: 0, per_page: 0, 'Intercom-Version': '2.11' },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Intercom.NotFoundError);
Expand Down Expand Up @@ -188,12 +188,12 @@ describe('resource companies', () => {
await expect(
intercom.companies.retrieveList(
{
company_id: 'string',
name: 'string',
company_id: 'company_id',
name: 'name',
page: 0,
per_page: 0,
segment_id: 'string',
tag_id: 'string',
segment_id: 'segment_id',
tag_id: 'tag_id',
'Intercom-Version': '2.11',
},
{ path: '/_stainless_unknown_path' },
Expand Down Expand Up @@ -223,7 +223,7 @@ describe('resource companies', () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.companies.scroll(
{ scroll_param: 'string', 'Intercom-Version': '2.11' },
{ scroll_param: 'scroll_param', 'Intercom-Version': '2.11' },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Intercom.NotFoundError);
Expand Down
10 changes: 5 additions & 5 deletions tests/api-resources/contacts/companies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const intercom = new Intercom({

describe('resource companies', () => {
test('create: only required params', async () => {
const responsePromise = intercom.contacts.companies.create('string', {
const responsePromise = intercom.contacts.companies.create('contact_id', {
company_id: '6657add46abd0167d9419cd2',
});
const rawResponse = await responsePromise.asResponse();
Expand All @@ -23,14 +23,14 @@ describe('resource companies', () => {
});

test('create: required and optional params', async () => {
const response = await intercom.contacts.companies.create('string', {
const response = await intercom.contacts.companies.create('contact_id', {
company_id: '6657add46abd0167d9419cd2',
'Intercom-Version': '2.11',
});
});

test('list', async () => {
const responsePromise = intercom.contacts.companies.list('string');
const responsePromise = intercom.contacts.companies.list('contact_id');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -43,15 +43,15 @@ describe('resource companies', () => {
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' }),
intercom.contacts.companies.list('contact_id', { 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',
'contact_id',
{ 'Intercom-Version': '2.11' },
{ path: '/_stainless_unknown_path' },
),
Expand Down
16 changes: 6 additions & 10 deletions tests/api-resources/contacts/contacts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ describe('resource contacts', () => {
avatar: 'https://www.example.com/avatar_image.jpg',
custom_attributes: {},
email: '[email protected]',
external_id: 'string',
external_id: 'external_id',
last_seen_at: 1571672154,
name: 'John Doe',
owner_id: 123,
phone: '+353871234567',
role: 'string',
role: 'role',
signed_up_at: 1571672154,
unsubscribed_from_emails: true,
'Intercom-Version': '2.11',
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('resource contacts', () => {
});

test('delete', async () => {
const responsePromise = intercom.contacts.delete('string');
const responsePromise = intercom.contacts.delete('id');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -133,19 +133,15 @@ describe('resource contacts', () => {

test('delete: 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.delete('string', { path: '/_stainless_unknown_path' })).rejects.toThrow(
await expect(intercom.contacts.delete('id', { path: '/_stainless_unknown_path' })).rejects.toThrow(
Intercom.NotFoundError,
);
});

test('delete: 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.delete(
'string',
{ 'Intercom-Version': '2.11' },
{ path: '/_stainless_unknown_path' },
),
intercom.contacts.delete('id', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Intercom.NotFoundError);
});

Expand Down Expand Up @@ -219,7 +215,7 @@ describe('resource contacts', () => {

test('search: required and optional params', async () => {
const response = await intercom.contacts.search({
query: { field: 'created_at', operator: '=', value: 'string' },
query: { field: 'created_at', operator: '=', value: 'value' },
pagination: { per_page: 5, starting_after: 'your-cursor-from-response' },
'Intercom-Version': '2.11',
});
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/contacts/notes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('resource notes', () => {
test('create: required and optional params', async () => {
const response = await intercom.contacts.notes.create(0, {
body: 'Hello',
admin_id: 'string',
admin_id: 'admin_id',
contact_id: '6657adde6abd0167d9419d00',
'Intercom-Version': '2.11',
});
Expand Down
4 changes: 2 additions & 2 deletions tests/api-resources/contacts/subscriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const intercom = new Intercom({
describe('resource subscriptions', () => {
test('create: only required params', async () => {
const responsePromise = intercom.contacts.subscriptions.create('63a07ddf05a32042dffac965', {
id: 'string',
id: 'id',
consent_type: 'opt_in',
});
const rawResponse = await responsePromise.asResponse();
Expand All @@ -25,7 +25,7 @@ describe('resource subscriptions', () => {

test('create: required and optional params', async () => {
const response = await intercom.contacts.subscriptions.create('63a07ddf05a32042dffac965', {
id: 'string',
id: 'id',
consent_type: 'opt_in',
'Intercom-Version': '2.11',
});
Expand Down
4 changes: 2 additions & 2 deletions tests/api-resources/contacts/tags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const intercom = new Intercom({

describe('resource tags', () => {
test('create: only required params', async () => {
const responsePromise = intercom.contacts.tags.create('63a07ddf05a32042dffac965', { id: 'string' });
const responsePromise = intercom.contacts.tags.create('63a07ddf05a32042dffac965', { id: 'id' });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -22,7 +22,7 @@ describe('resource tags', () => {

test('create: required and optional params', async () => {
const response = await intercom.contacts.tags.create('63a07ddf05a32042dffac965', {
id: 'string',
id: 'id',
'Intercom-Version': '2.11',
});
});
Expand Down
8 changes: 4 additions & 4 deletions tests/api-resources/conversations/conversations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('resource conversations', () => {
await expect(
intercom.conversations.retrieve(
123,
{ display_as: 'string', 'Intercom-Version': '2.11' },
{ display_as: 'display_as', 'Intercom-Version': '2.11' },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Intercom.NotFoundError);
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('resource conversations', () => {
intercom.conversations.update(
123,
{
display_as: 'string',
display_as: 'display_as',
custom_attributes: { issue_type: 'Billing', priority: 'High' },
read: true,
'Intercom-Version': '2.11',
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('resource conversations', () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.conversations.list(
{ per_page: 0, starting_after: 'string', 'Intercom-Version': '2.11' },
{ per_page: 0, starting_after: 'starting_after', 'Intercom-Version': '2.11' },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Intercom.NotFoundError);
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('resource conversations', () => {

test('search: required and optional params', async () => {
const response = await intercom.conversations.search({
query: { field: 'created_at', operator: '=', value: 'string' },
query: { field: 'created_at', operator: '=', value: 'value' },
pagination: { per_page: 5, starting_after: 'your-cursor-from-response' },
'Intercom-Version': '2.11',
});
Expand Down
6 changes: 3 additions & 3 deletions tests/api-resources/conversations/customers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('resource customers', () => {
intercom.conversations.customers.create(
'123',
{
admin_id: 'string',
admin_id: 'admin_id',
customer: {
intercom_user_id: '6657ae626abd0167d9419d6f',
customer: { intercom_user_id: '6329bd9ffe4e2e91dac76188' },
Expand All @@ -46,7 +46,7 @@ describe('resource customers', () => {
});

test('delete: only required params', async () => {
const responsePromise = intercom.conversations.customers.delete('123', '123', { admin_id: 'string' });
const responsePromise = intercom.conversations.customers.delete('123', '123', { admin_id: 'admin_id' });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -58,7 +58,7 @@ describe('resource customers', () => {

test('delete: required and optional params', async () => {
const response = await intercom.conversations.customers.delete('123', '123', {
admin_id: 'string',
admin_id: 'admin_id',
'Intercom-Version': '2.11',
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/api-resources/conversations/reply.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const intercom = new Intercom({
describe('resource reply', () => {
test('create: only required params', async () => {
const responsePromise = intercom.conversations.reply.create('123 or "last"', {
body: 'string',
body: 'body',
message_type: 'comment',
type: 'user',
});
Expand All @@ -26,7 +26,7 @@ describe('resource reply', () => {

test('create: required and optional params', async () => {
const response = await intercom.conversations.reply.create('123 or "last"', {
body: 'string',
body: 'body',
message_type: 'comment',
type: 'user',
attachment_urls: ['https://example.com', 'https://example.com', 'https://example.com'],
Expand Down
Loading