//native
type Brex = {
token: string;
};
/**
* Creates a referral
* This creates new referrals. The response will contain an identifier and a unique personalized link to an application flow. Many fields are optional and when they're provided they'll prefill the application flow for Brex. You should handle and store these references securely as they contain sensitive information about the referral.
*/
export async function main(
auth: Brex,
body: {
referral_code: string;
applicant: { last_name: string; first_name: string; email: string };
business?: {
legal_name?: string;
incorporation_type?:
| ("C_CORP" & {})
| ("S_CORP" & {})
| ("B_CORP" & {})
| ("LLC" & {})
| ("LLP" & {})
| ("SOLE_PROP" & {})
| ("ORG_501C3" & {})
| ("LP" & {});
employer_identification_number?: string;
website_url?: string;
activity_description?: string;
address?: {
line1?: string;
line2?: string;
city?: string;
state?: string;
country?: string;
postal_code?: string;
phone_number?: string;
} & {};
beneficial_owners?: {
legal_name: string;
company_relationship?:
| ("FOUNDER" & {})
| ("EXECUTIVE" & {})
| ("SENIOR_LEADERSHIP" & {})
| ("OTHER" & {});
date_of_birth?: string;
identity_document?: {
country: string;
type: "SSN" | "PASSPORT";
number: string;
} & {};
address?: {
line1?: string;
line2?: string;
city?: string;
state?: string;
country?: string;
postal_code?: string;
phone_number?: string;
} & {};
prong: "OWNERSHIP" | "CONTROL" | "BOTH";
}[];
alternate_address?: {
line1?: string;
line2?: string;
city?: string;
state?: string;
country?: string;
postal_code?: string;
phone_number?: string;
} & {};
} & {};
contact_preference?: ("NO_OUTBOUND" & {}) | ("EMAIL_OUTBOUND" & {});
},
) {
const url = new URL(`https://platform.brexapis.com/v1/referrals`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 169 days ago