Skip to content

Commit 7928b7c

Browse files
authored
Update w9 response type (#140)
1 parent 6af3da4 commit 7928b7c

File tree

7 files changed

+114
-9
lines changed

7 files changed

+114
-9
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@withabound/node-sdk",
3-
"version": "3.4.0",
3+
"version": "3.5.0",
44
"description": "The Abound Node library provides convenient access to the Abound API from applications written in server-side JavaScript.",
55
"author": "Abound <[email protected]>",
66
"license": "MIT",

src/resources/Documents.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
Ten99NECFormFields,
1616
} from "./document-types/1099NEC";
1717
import { AccountStatementDocumentRequest } from "./document-types/AccountStatement";
18-
import { W9DocumentRequest } from "./document-types/W9";
18+
import { W9DocumentRequest, W9FormFields } from "./document-types/W9";
1919

2020
export {
2121
StateTaxInfo,
@@ -50,13 +50,16 @@ export interface Document {
5050
readonly createdTimestamp: number;
5151
}
5252

53-
interface BaseTen99Document {
53+
interface BaseDocument {
5454
readonly year: string;
5555
readonly documentId: string;
5656
readonly documentURL: string;
5757
readonly documentName: string;
5858
readonly creationDate?: string;
5959
readonly createdTimestamp: number;
60+
}
61+
62+
interface BaseTen99Document extends BaseDocument {
6063
readonly status?: string;
6164
readonly message?: string;
6265
}
@@ -82,6 +85,13 @@ export interface Ten99NECDocument extends BaseTen99Document {
8285
Readonly<Ten99NECFormFields>;
8386
}
8487

88+
export interface W9Document extends BaseDocument {
89+
readonly type: DocumentType.W9;
90+
readonly formData: Readonly<W9Payer> &
91+
Readonly<W9User> &
92+
Readonly<W9FormFields>;
93+
}
94+
8595
interface User {
8696
readonly user: Readonly<{
8797
name: string;
@@ -107,6 +117,30 @@ interface Payer {
107117
}>;
108118
}
109119

120+
interface W9User {
121+
readonly user: Readonly<{
122+
name: string;
123+
businessName?: string;
124+
address: string;
125+
address2?: string;
126+
city: string;
127+
state: string;
128+
zipcode: string;
129+
country?: string;
130+
}>;
131+
}
132+
133+
interface W9Payer {
134+
readonly payer?: Readonly<{
135+
name: string;
136+
address: string;
137+
address2?: string;
138+
city: string;
139+
state: string;
140+
zipcode: string;
141+
}>;
142+
}
143+
110144
export enum DocumentType {
111145
/** @deprecated Our v2 API is now deprecated and will become completely unavailable on Tuesday May 16, 2023. Please consider upgrading to our v3 API as a way to prepare for the sunsetting of v2. For more detail on these product changes, what endpoints are changing in v3 and how that may affect your company, please view our [API Changelog](https://docs.withabound.com/changelog). */
112146
ACCOUNT_STATEMENT = "accountStatement",
@@ -126,7 +160,8 @@ export type DocumentResponse =
126160
| Document
127161
| Ten99INTDocument
128162
| Ten99KDocument
129-
| Ten99NECDocument;
163+
| Ten99NECDocument
164+
| W9Document;
130165

131166
/**
132167
* See https://docs.withabound.com/reference/documents

src/resources/document-types/W9.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { BaseDocumentRequest, DocumentType } from "../Documents";
22

33
// request body
4-
export interface W9DocumentRequest extends BaseDocumentRequest {
4+
export interface W9DocumentRequest extends BaseDocumentRequest, W9FormFields {
55
type: DocumentType.W9;
66
payerId?: string; // The payer filing or issuing this form.
77
year: number;
8+
}
9+
10+
export interface W9FormFields {
811
taxClassification: W9TaxClassification;
912
exemptPayeeCode?: ExemptPayeeCode;
1013
exemptFatcaCode?: ExemptFatcaCode;

src/util/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// Generated by genversion.
2-
export const version = "3.4.0";
2+
export const version = "3.5.0";

tests/resources/Documents.spec.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,20 @@ describe("Abound Documents", () => {
258258
w9ToCreate,
259259
]);
260260

261-
expect(response.data.at(0)).toMatchSnapshot({
261+
const document = response.data.at(0);
262+
expect(document).toMatchSnapshot({
262263
createdTimestamp: expect.any(Number),
263264
documentURL: expect.stringContaining(
264265
"https://tax-documents-sandbox.s3.us-west-2.amazonaws.com"
265266
),
267+
...(document &&
268+
"formData" in document &&
269+
"certificationTimestamp" in document.formData &&
270+
document?.formData?.certificationTimestamp && {
271+
formData: {
272+
certificationTimestamp: expect.any(Number),
273+
},
274+
}),
266275
});
267276
});
268277
});
@@ -277,6 +286,13 @@ describe("Abound Documents", () => {
277286
documentURL: expect.stringContaining(
278287
"https://tax-documents-sandbox.s3.us-west-2.amazonaws.com"
279288
),
289+
...("formData" in document &&
290+
"certificationTimestamp" in document.formData &&
291+
document?.formData?.certificationTimestamp && {
292+
formData: {
293+
certificationTimestamp: expect.any(Number),
294+
},
295+
}),
280296
});
281297
}
282298
});
@@ -292,6 +308,13 @@ describe("Abound Documents", () => {
292308
documentURL: expect.stringContaining(
293309
"https://tax-documents-sandbox.s3.us-west-2.amazonaws.com"
294310
),
311+
...("formData" in document &&
312+
"certificationTimestamp" in document.formData &&
313+
document?.formData?.certificationTimestamp && {
314+
formData: {
315+
certificationTimestamp: expect.any(Number),
316+
},
317+
}),
295318
});
296319
}
297320
});

tests/resources/__snapshots__/Documents.spec.ts.snap

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,24 @@ Object {
236236
"documentId": "documentId_testefbd5d3d9ee9526ef9ff89a7c6b879174170",
237237
"documentName": "2021 Form W-9",
238238
"documentURL": StringContaining "https://tax-documents-sandbox.s3.us-west-2.amazonaws.com",
239+
"formData": Object {
240+
"accountNumbers": Array [
241+
"430912910",
242+
],
243+
"certificationTimestamp": Any<Number>,
244+
"exemptFatcaCode": "A",
245+
"exemptPayeeCode": "1",
246+
"taxClassification": "soleProprietor",
247+
"user": Object {
248+
"address": "256 Byron Street",
249+
"address2": "Suite 32",
250+
"city": "Palo Alto",
251+
"country": "US",
252+
"name": "Ada Lovelace",
253+
"state": "CA",
254+
"zipcode": "94306",
255+
},
256+
},
239257
"type": "w9",
240258
"year": "2021",
241259
}
@@ -291,6 +309,19 @@ Object {
291309
"documentId": "documentId_testefbd5d3d9ee9526ef9ff89a7c6b879174170",
292310
"documentName": "2021 Form W-9",
293311
"documentURL": StringContaining "https://tax-documents-sandbox.s3.us-west-2.amazonaws.com",
312+
"formData": Object {
313+
"certificationTimestamp": Any<Number>,
314+
"taxClassification": "individual",
315+
"user": Object {
316+
"address": "256 Byron Street",
317+
"address2": "Suite 32",
318+
"city": "Palo Alto",
319+
"country": "US",
320+
"name": "Ada Lovelace",
321+
"state": "CA",
322+
"zipcode": "94306",
323+
},
324+
},
294325
"type": "w9",
295326
"year": "2021",
296327
}
@@ -313,6 +344,19 @@ Object {
313344
"documentId": "documentId_testefbd5d3d9ee9526ef9ff89a7c6b879174170",
314345
"documentName": "2023 Form W-9",
315346
"documentURL": StringContaining "https://tax-documents-sandbox.s3.us-west-2.amazonaws.com",
347+
"formData": Object {
348+
"certificationTimestamp": Any<Number>,
349+
"taxClassification": "individual",
350+
"user": Object {
351+
"address": "256 Byron Street",
352+
"address2": "Suite 32",
353+
"city": "Palo Alto",
354+
"country": "US",
355+
"name": "Ada Lovelace",
356+
"state": "CA",
357+
"zipcode": "94306",
358+
},
359+
},
316360
"type": "w9",
317361
"year": "2023",
318362
}

0 commit comments

Comments
 (0)