Skip to content

Commit 7f7da9f

Browse files
VoloVolo
authored andcommitted
Update Update Company's method
1 parent 443e52f commit 7f7da9f

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

lib/company.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,20 @@ export default class Company {
5959
industry,
6060
customAttributes,
6161
}: UpdateCompanyData) {
62-
return this.create({
63-
createdAt,
64-
companyId,
62+
const data = {
63+
remote_created_at: createdAt,
6564
name,
66-
monthlySpend,
65+
monthly_spend: monthlySpend,
6766
plan,
6867
size,
6968
website,
7069
industry,
71-
customAttributes,
70+
custom_attributes: customAttributes,
71+
};
72+
73+
return this.client.put<CompanyObject>({
74+
url: `/${this.baseUrl}/${companyId}`,
75+
data,
7276
});
7377
}
7478
find({ companyId, name }: FindCompanyData) {

test/company.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ const dummyCompany = {
2828
custom_attributes: {},
2929
};
3030
describe('companies', () => {
31-
let client: Client;
32-
before(() => {
33-
client = new Client('foo', 'bar');
34-
});
31+
const client = new Client('foo', 'bar');
32+
3533
it('should be created', async () => {
3634
const requestBody = {
3735
remote_created_at: dateToUnixTimestamp(new Date()),
@@ -66,7 +64,6 @@ describe('companies', () => {
6664
it('should be updated', async () => {
6765
const company_id = '46029';
6866
const requestBody = {
69-
company_id,
7067
remote_created_at: dateToUnixTimestamp(new Date()),
7168
name: 'BestCompanyInc.',
7269
monthly_spend: 9001,
@@ -78,7 +75,7 @@ describe('companies', () => {
7875
};
7976

8077
nock('https://api.intercom.io')
81-
.post('/companies', requestBody)
78+
.put(`/companies/${company_id}`, requestBody)
8279
.reply(200, {});
8380

8481
const response = await client.companies.update({

test/dataAttribute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Client } from '../lib';
33
import { DataType, ModelType } from '../lib/dataAttribute/dataAttribute.types';
44
import nock from 'nock';
55

6-
describe.only('data attributes', () => {
6+
describe('data attributes', () => {
77
const client = new Client('foo', 'bar');
88

99
it('should create', async () => {

0 commit comments

Comments
 (0)