Skip to content

Commit cadcc90

Browse files
authored
User updates (#78)
* Update user types and tests * Fix user tests * Fix tests after rebase * Cleanup PR diffs
1 parent 0e2e168 commit cadcc90

File tree

5 files changed

+208
-101
lines changed

5 files changed

+208
-101
lines changed

package-lock.json

Lines changed: 28 additions & 7 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"lint-staged": "11.1.2",
4444
"prettier": "2.4.1",
4545
"ts-jest": "27.0.5",
46+
"type-fest": "2.14.0",
4647
"typescript": "4.4.3",
4748
"xo": "0.39.x"
4849
},

src/resources/Users.ts

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import { Except } from "type-fest";
12
import { AboundBaseResource } from "./base/AboundBaseResource";
2-
import { Pagination } from "./base/AboundResource";
3+
import { Notes, Pagination } from "./base/AboundResource";
34
import { AboundBulkResponse, AboundResponse } from "./base/AboundResponse";
45

56
// request body
67
export interface UserRequest {
78
email?: string;
89
foreignId?: string;
10+
notes?: Notes;
911
profile?: UserProfile;
12+
business?: UserBusiness;
1013
}
1114

1215
export interface UserProfile {
@@ -21,7 +24,32 @@ export interface UserProfile {
2124
phoneNumber?: string; // no country code, numerical digits only
2225
dateOfBirth?: string; // YYYY-MM-DD
2326
socialSecurityNumber?: string; // no hyphens, numerical digits only
24-
ipAddress?: string;
27+
}
28+
29+
export interface UserBusiness {
30+
ein: string; // no hyphens, numerical digits only
31+
name: string;
32+
taxClassification?: TaxClassification;
33+
address?: string;
34+
address2?: string;
35+
city?: string;
36+
state?: string;
37+
country?: string; // The user's country of residence. Adhering to the ISO 3166-2 format.
38+
zipcode?: string;
39+
}
40+
41+
export enum TaxClassification {
42+
C_CORPORATION = "cCorporation",
43+
ESTATE = "estate",
44+
INDIVIDUAL = "individual",
45+
LLC_PARTNERSHIP = "llcPartnership",
46+
LLC_C_CORPORATION = "llcCCorporation",
47+
LLC_S_CORPORATION = "llcSCorporation",
48+
PARTNERSHIP = "partnership",
49+
S_CORPORATION = "sCorporation",
50+
SINGLE_MEMBER_LLC = "singleMemberLlc",
51+
SOLE_PROPRIETOR = "soleProprietor",
52+
TRUST = "trust",
2553
}
2654

2755
// query params
@@ -32,6 +60,30 @@ export interface UserParameters extends Pagination {
3260
// response body
3361
export interface User extends UserRequest {
3462
userId: Readonly<string>;
63+
einVerification: TinVerification;
64+
ssnVerification: TinVerification;
65+
}
66+
67+
// list response body
68+
export type BaseUser = Except<
69+
User,
70+
"business" | "einVerification" | "profile" | "ssnVerification"
71+
>;
72+
73+
export interface TinVerification {
74+
status: TinVerificationStatus;
75+
message?: string;
76+
lastVerifiedTimestamp?: number;
77+
unlockTimestamp?: number;
78+
}
79+
80+
export enum TinVerificationStatus {
81+
ERROR = "error",
82+
LOCKED_OUT = "lockedOut",
83+
MISMATCH = "mismatch",
84+
PENDING = "pending",
85+
UNVERIFIED = "unverified",
86+
VERIFIED = "verified",
3587
}
3688

3789
// The raw `User` object returned from the APIs returns one deprecated field, which the SDK will remove.
@@ -55,8 +107,20 @@ export default class Users extends AboundBaseResource<
55107

56108
public async list(
57109
parameters?: UserParameters
58-
): Promise<AboundBulkResponse<User>> {
59-
return super.listBaseResource(parameters);
110+
): Promise<AboundBulkResponse<BaseUser>> {
111+
const response = await super.listBaseResource(parameters);
112+
return {
113+
...response,
114+
data: response.data.map<BaseUser>(
115+
({
116+
business,
117+
einVerification,
118+
profile,
119+
ssnVerification,
120+
...baseUser
121+
}) => baseUser
122+
),
123+
};
60124
}
61125

62126
public async create(user: UserRequest): Promise<AboundResponse<User>> {

tests/resources/TaxPayments.spec.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,23 @@ describe("Abound Tax Payments", () => {
8080
const taxPayments: AboundBulkResponse<TaxPayment> =
8181
await abound.taxPayments.list(TEST_USER_ID, { foreignId: "29SMN2KD9" });
8282

83-
expect(taxPayments.data).toMatchInlineSnapshot(`
84-
Array [
85-
Object {
86-
"amount": 154.66,
87-
"createdDate": "2022-06-22",
88-
"entity": "IRS",
89-
"notes": Object {},
90-
"paymentMethodId": "paymentMethodId_test32920837fa800382b7ee5676f281fbfc18cb",
91-
"period": "Q2",
92-
"status": "created",
93-
"taxPaymentId": "taxPaymentId_test614d255d3048f6f7b3b5bb219b18f0f065d3",
94-
"year": "2020",
95-
},
96-
]
97-
`);
83+
expect(taxPayments.data[0]).toMatchInlineSnapshot(
84+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
85+
{ createdDate: expect.any(String) },
86+
`
87+
Object {
88+
"amount": 154.66,
89+
"createdDate": Any<String>,
90+
"entity": "IRS",
91+
"notes": Object {},
92+
"paymentMethodId": "paymentMethodId_test32920837fa800382b7ee5676f281fbfc18cb",
93+
"period": "Q2",
94+
"status": "created",
95+
"taxPaymentId": "taxPaymentId_test614d255d3048f6f7b3b5bb219b18f0f065d3",
96+
"year": "2020",
97+
}
98+
`
99+
);
98100
});
99101
});
100102

0 commit comments

Comments
 (0)