export type GlobalAttrValue = {token?: string | undefined, value: string, type?: ('PhoneNumber' | 'Gender' | 'IdentificationNumber' | 'MaidenName' | 'SocialSecurity' | 'EmploymentName' | 'EmploymentAddress' | 'EmploymentPhone' | 'EmploymentOccupation' | 'EmploymentSupervisor' | 'SecondLastName' | 'BirthCountry' | 'SourceOfFunds' | 'DateOfBirth' | 'IdentificationType' | 'IDSelfieCollection' | 'City' | 'Country' | 'IdentificationExpiration' | 'Address1' | 'PostalCode' | 'GuardianFullName' | 'GuardianGovIDType' | 'GuardianGovIDNumber' | 'GuardianConsent' | 'EIN' | 'WalletAddress' | 'OAuthGrant' | 'SecurityAnswer') | undefined}; export type CreateApiAttributeUserTokenGlobalArgs = {user_token: string, 'Idempotency-Key'?: string | undefined, body: {values: Array}}; export type CreateApiAttributeUserTokenGlobalOptions = {baseUrl?: string | undefined, AUTHORIZERNAME?: string | undefined, fetch?: typeof fetch | undefined}; /** * Store global user attributes * * POST /attribute/{user_token}/global * * Also accepts auth: api_key */ export const createApiAttributeUserTokenGlobal = async (args: CreateApiAttributeUserTokenGlobalArgs, options?: CreateApiAttributeUserTokenGlobalOptions) => { const {baseUrl = "https://api.masspay.io/v1.0.0", fetch: fetchFn = fetch, AUTHORIZERNAME} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Idempotency-Key'] != null) headers.set("Idempotency-Key", String(args['Idempotency-Key'])) if (AUTHORIZERNAME !== undefined) headers.set("Authorization", AUTHORIZERNAME) const url = `${baseUrl.replace(/\/+$/, '')}/attribute/${encodeURIComponent(String(args.user_token))}/global${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };