Skip to content

Commit 48276f3

Browse files
authored
Revert "Update the company.update method (#375)" (#393)
This reverts commit ddfa94d.
1 parent ddfa94d commit 48276f3

File tree

3 files changed

+7
-71
lines changed

3 files changed

+7
-71
lines changed

lib/company.ts

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ export default class Company {
2121
this.client = client;
2222
this.scroll = new Scroll<Company>(this.client, this.baseUrl);
2323
}
24-
/**
25-
* @deprecated Use `client.companies.createOrUpdate()` instead.
26-
*/
2724
create({
2825
createdAt,
2926
companyId,
@@ -34,34 +31,6 @@ export default class Company {
3431
website,
3532
industry,
3633
customAttributes,
37-
}: CreateCompanyData) {
38-
return this.createOrUpdate({
39-
createdAt,
40-
companyId,
41-
name,
42-
monthlySpend,
43-
plan,
44-
size,
45-
website,
46-
industry,
47-
customAttributes,
48-
});
49-
}
50-
/**
51-
* Create or update a company by its `companyId`.
52-
*
53-
* Companies are looked up via the `companyId` field. If a company with the given `companyId` does not exist, it will be created. If a company with the given `companyId` does exist, it will be updated.
54-
**/
55-
createOrUpdate({
56-
createdAt,
57-
companyId,
58-
name,
59-
monthlySpend,
60-
plan,
61-
size,
62-
website,
63-
industry,
64-
customAttributes,
6534
}: CreateCompanyData) {
6635
const data = {
6736
remote_created_at: createdAt,
@@ -80,23 +49,9 @@ export default class Company {
8049
data,
8150
});
8251
}
83-
84-
/**
85-
* Update a single company by its `id`.
86-
* @param id - The `id` field is required for updating a company. This is distinct from the `companyId` field on the Company object , which is an identifier for the company in your database.
87-
* @param createdAt - The time the company was created by you.
88-
* @param name - The name of the company.
89-
* @param monthlySpend - The amount the company spends on your product each month. How much revenue the company generates for your business.
90-
* Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647..
91-
* @param plan - The name of the plan you have associated with the company.
92-
* @param size - The number of employees the company has.
93-
* @param website -The URL for this company's website. Please note that the value specified here is not validated. Accepts any string.
94-
* @param industry - The industry the company operates in.
95-
* @param customAttributes - A hash of key/value pairs containing any other data about the company you want Intercom to store.
96-
*/
9752
update({
98-
id,
9953
createdAt,
54+
companyId,
10055
name,
10156
monthlySpend,
10257
plan,
@@ -117,7 +72,7 @@ export default class Company {
11772
};
11873

11974
return this.client.put<CompanyObject>({
120-
url: `/${this.baseUrl}/${id}`,
75+
url: `/${this.baseUrl}/${companyId}`,
12176
data,
12277
});
12378
}
@@ -205,9 +160,7 @@ interface CreateCompanyData {
205160
customAttributes?: JavascriptObject;
206161
}
207162
//
208-
interface UpdateCompanyData extends Omit<CreateCompanyData, 'companyId'> {
209-
id: string;
210-
}
163+
type UpdateCompanyData = CreateCompanyData;
211164
//
212165
interface FindCompanyData {
213166
companyId?: string;

test/integration/companies.test.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,10 @@ describe('Companies', () => {
3434

3535
assert.notEqual(response, undefined);
3636
});
37-
it('createOrUpdate', async () => {
38-
const response = await client.companies.createOrUpdate({
39-
createdAt: dateToUnixTimestamp(new Date()),
40-
companyId: '46029',
41-
name: 'BestCompanyInc.',
42-
monthlySpend: 9001,
43-
plan: '1. Get pizzaid',
44-
size: 62049,
45-
website: 'http://the-best.one',
46-
industry: 'The Best One',
47-
customAttributes: {},
48-
});
49-
50-
createdCompany = response;
51-
52-
assert.notEqual(response, undefined);
53-
});
5437
it('update', async () => {
5538
const response = await client.companies.update({
5639
createdAt: dateToUnixTimestamp(new Date()),
57-
id: createdCompany.id,
40+
companyId: createdCompany.id,
5841
name: 'BestCompanyInc',
5942
monthlySpend: 9001,
6043
plan: '1. Get pizzaid',

test/unit/company.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('companies', () => {
6464
assert.deepStrictEqual({}, response);
6565
});
6666
it('should be updated', async () => {
67-
const id = '625e90fc55ab113b6d92175f';
67+
const company_id = '46029';
6868
const requestBody = {
6969
remote_created_at: dateToUnixTimestamp(new Date()),
7070
name: 'BestCompanyInc.',
@@ -77,12 +77,12 @@ describe('companies', () => {
7777
};
7878

7979
nock('https://api.intercom.io')
80-
.put(`/companies/${id}`, requestBody)
80+
.put(`/companies/${company_id}`, requestBody)
8181
.reply(200, {});
8282

8383
const response = await client.companies.update({
8484
createdAt: requestBody.remote_created_at,
85-
id: id,
85+
companyId: company_id,
8686
name: requestBody.name,
8787
monthlySpend: requestBody.monthly_spend,
8888
plan: requestBody.plan,

0 commit comments

Comments
 (0)