Skip to content

Commit 621518c

Browse files
authored
Merge pull request #12 from julbrs/adjust-header-signature
Add header signature
2 parents a6635a5 + 944ca38 commit 621518c

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

.env.sample

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ consumer_key=""
22
consumer_secret_key=""
33
token=""
44
token_secret=""
5-
realm=""
5+
realm=""
6+
base_url=""

src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type NetsuiteRequestOptions = {
1616

1717
export type NetsuiteResponse = {
1818
statusCode: number;
19-
headers: any;
19+
headers: NodeJS.Dict<string | string[]>;
2020
data: any;
2121
};
2222

test/request.test.ts

+36-1
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,46 @@ describe("Test request method", () => {
4646
});
4747

4848
it("should make GET request - GET Customers", async () => {
49-
expect.assertions(1);
49+
expect.assertions(4);
5050
const response = await client.request({
5151
path: "record/v1/customer/",
5252
});
5353
expect(response.statusCode).toEqual(200);
54+
expect(response.data).toBeDefined();
55+
expect(response.data.items).toBeDefined();
56+
expect(response.data.count).toBeDefined();
57+
});
58+
59+
it("should make POST request - POST Customers", async () => {
60+
const response = await client.request({
61+
path: "record/v1/customer/",
62+
method: "POST",
63+
body: JSON.stringify({
64+
entityStatus: 6,
65+
firstName: "firstName",
66+
lastName: "lastName",
67+
subsidiary: "1",
68+
companyName: "netsuite-api-client-integration-test",
69+
}),
70+
});
71+
72+
expect(response.statusCode).toEqual(204);
73+
expect(response.data).toBeDefined();
74+
expect(response.data).toBeNull();
75+
expect(response.headers.location).toBeDefined();
76+
77+
const location = response.headers.location as string;
78+
79+
// extract id from location string
80+
const id = location.split("/").pop();
81+
82+
// delete the created company
83+
const responseDelete = await client.request({
84+
path: `record/v1/customer/${id}`,
85+
method: "DELETE",
86+
});
87+
88+
expect(responseDelete.statusCode).toEqual(204);
5489
});
5590

5691
it("should make POST request - SuiteQL Query", async () => {

0 commit comments

Comments
 (0)