diff --git a/package-lock.json b/package-lock.json index 1d4b67f..dd79958 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,234 @@ { "name": "synapsenode", - "version": "2.0.0-alpha.1", - "lockfileVersion": 1, + "version": "2.0.0-beta", + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "synapsenode", + "version": "2.0.0-beta", + "license": "MIT", + "dependencies": { + "axios": "^1.1.3" + }, + "devDependencies": { + "@types/axios": "^0.14.0", + "@types/chai": "^4.3.3", + "@types/node": "^18.11.3", + "chai": "^4.3.6", + "typescript": "^4.9.4" + } + }, + "node_modules/@types/axios": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@types/axios/-/axios-0.14.0.tgz", + "integrity": "sha512-KqQnQbdYE54D7oa/UmYVMZKq7CO4l8DEENzOKc4aBRwxCXSlJXGz83flFx5L7AWrOQnmuN3kVsRdt+GZPPjiVQ==", + "deprecated": "This is a stub types definition for axios (https://github.com/mzabriskie/axios). axios provides its own type definitions, so you don't need @types/axios installed!", + "dev": true, + "dependencies": { + "axios": "*" + } + }, + "node_modules/@types/chai": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", + "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", + "dev": true + }, + "node_modules/@types/node": { + "version": "18.11.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.3.tgz", + "integrity": "sha512-fNjDQzzOsZeKZu5NATgXUPsaFaTxeRgFXoosrHivTl8RGeV733OLawXsGfEk9a8/tySyZUyiZ6E8LcjPFZ2y1A==", + "dev": true + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.1.3.tgz", + "integrity": "sha512-00tXVRwKx/FZr/IDVFt4C+f9FYairX517WoGCL6dpOntqLkZofjhu43F/Xl44UOpqa+9sLFDrG/XAnFsUYgkDA==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/chai": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", + "integrity": "sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==", + "dev": true, + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "loupe": "^2.3.1", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/loupe": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", + "integrity": "sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.0" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/typescript": { + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + } + }, "dependencies": { "@types/axios": { "version": "0.14.0", @@ -150,9 +376,9 @@ "dev": true }, "typescript": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", "dev": true } } diff --git a/package.json b/package.json index 1475123..4a0306c 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "files": [ "dist" ], + "types": "types/index.d.ts", "scripts": { "test": "mocha --recursive --timeout 100000", "test-nodes": "mocha --recursive test/nodesTests/*.js --timeout 100000", @@ -27,7 +28,7 @@ "@types/chai": "^4.3.3", "@types/node": "^18.11.3", "chai": "^4.3.6", - "typescript": "^4.8.4" + "typescript": "^4.9.4" }, "dependencies": { "axios": "^1.1.3" diff --git a/tsconfig.json b/tsconfig.json index 1fd57af..0658582 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "downlevelIteration": true, "module": "commonjs", "declaration": true, + "declarationDir": "./types", "outDir": "./dist", "allowSyntheticDefaultImports": true, "strict": true, @@ -22,4 +23,4 @@ "lib": [ "ESNext" ] -} \ No newline at end of file +} diff --git a/types/constants/apiReqNames.d.ts b/types/constants/apiReqNames.d.ts new file mode 100644 index 0000000..7b9ce57 --- /dev/null +++ b/types/constants/apiReqNames.d.ts @@ -0,0 +1,61 @@ +export declare const _grabRefreshToken = "_grabRefreshToken"; +export declare const _oauthUser = "_oauthUser"; +export declare const addUserKyc = "addUserKyc"; +export declare const commentOnStatus = "commentOnStatus"; +export declare const createBatchTransactions = "createBatchTransactions"; +export declare const createNode = "createNode"; +export declare const createSubnet = "createSubnet"; +export declare const createSubscription = "createSubscription"; +export declare const createTransaction = "createTransaction"; +export declare const createUser = "createUser"; +export declare const deleteCardShipment = "deleteCardShipment"; +export declare const deleteExistingDocument = "deleteExistingDocument"; +export declare const deleteNode = "deleteNode"; +export declare const deleteTransaction = "deleteTransaction"; +export declare const disputeCardTransaction = "disputeCardTransaction"; +export declare const generateApplePayToken = "generateApplePayToken"; +export declare const generateUboForm = "generateUboForm"; +export declare const getAllCardShipments = "getAllCardShipments"; +export declare const getAllNodeTransactions = "getAllNodeTransactions"; +export declare const getAllSubscriptions = "getAllSubscriptions"; +export declare const getAllSubnets = "getAllSubnets"; +export declare const getAllUserNodes = "getAllUserNodes"; +export declare const getAllUsers = "getAllUsers"; +export declare const getCardShipment = "getCardShipment"; +export declare const getCryptoMarketData = "getCryptoMarketData"; +export declare const getCryptoQuotes = "getCryptoQuotes"; +export declare const getInstitutions = "getInstitutions"; +export declare const getNode = "getNode"; +export declare const getPlatformNodes = "getPlatformNodes"; +export declare const getPlatformTransactions = "getPlatformTransactions"; +export declare const getStatementsByNode = "getStatementsByNode"; +export declare const getStatementsByUser = "getStatementsByUser"; +export declare const getSubnet = "getSubnet"; +export declare const getSubscription = "getSubscription"; +export declare const getTradeMarketData = "getTradeMarketData"; +export declare const getTransaction = "getTransaction"; +export declare const getWebhookLogs = "getWebhookLogs"; +export declare const getUserDuplicates = "getUserDuplicates"; +export declare const getUser = "getUser"; +export declare const getUserTransactions = "getUserTransactions"; +export declare const issuePublicKey = "issuePublicKey"; +export declare const locateAtms = "locateAtms"; +export declare const pushToMobileWallet = "pushToMobileWallet"; +export declare const triggerDummyTransactions = "triggerDummyTransactions"; +export declare const updateSubscription = "updateSubscription"; +export declare const registerNewFingerprint = "registerNewFingerprint"; +export declare const reinitiateMicroDeposits = "reinitiateMicroDeposits"; +export declare const resetCardNode = "resetCardNode"; +export declare const shipCard = "shipCard"; +export declare const shipCardNode = "shipCardNode"; +export declare const supplyDevice2FA = "supplyDevice2FA"; +export declare const swapDuplicateUsers = "swapDuplicateUsers"; +export declare const updateIpAddress = "updateIpAddress"; +export declare const updateNode = "updateNode"; +export declare const updateSubnet = "updateSubnet"; +export declare const updateUser = "updateUser"; +export declare const verifyAddress = "verifyAddress"; +export declare const verifyFingerprint2FA = "verifyFingerprint2FA"; +export declare const verifyAchMfa = "verifyAchMfa"; +export declare const verifyMicroDeposits = "verifyMicroDeposits"; +export declare const verifyRoutingNumber = "verifyRoutingNumber"; diff --git a/types/helpers/buildHeaders.d.ts b/types/helpers/buildHeaders.d.ts new file mode 100644 index 0000000..e342ee4 --- /dev/null +++ b/types/helpers/buildHeaders.d.ts @@ -0,0 +1,5 @@ +import { AxiosRequestConfig } from 'axios'; +import { IHeadersObject, IHeadersValues } from '../interfaces/helpers'; +declare const buildHeaders: ({ client_id, client_secret, oauth_key, fingerprint, ip_address, idempotency_key, }: Partial) => IHeadersObject; +export declare const makePostPatchConfig: (headers: IHeadersObject) => Partial; +export default buildHeaders; diff --git a/types/helpers/buildUrls.d.ts b/types/helpers/buildUrls.d.ts new file mode 100644 index 0000000..89c7ba3 --- /dev/null +++ b/types/helpers/buildUrls.d.ts @@ -0,0 +1,2 @@ +import { IBuildQueryParamsArgs } from "../interfaces/helpers"; +export declare const addQueryParams: ({ originalUrl, amount, query, page, per_page, filter, show_refresh_tokens, full_dehydrate, force_refresh, type, zip, lat, lon, radius, limit, currency, foreign_transaction, is_credit, subnet_id, ticker }: IBuildQueryParamsArgs) => string; diff --git a/types/helpers/clientHelpers.d.ts b/types/helpers/clientHelpers.d.ts new file mode 100644 index 0000000..f7cf659 --- /dev/null +++ b/types/helpers/clientHelpers.d.ts @@ -0,0 +1,9 @@ +import { IUserObject } from '../interfaces/user'; +import Client from '../lib/Client'; +import User from '../lib/User'; +export declare const checkOptions: (headerObj: any, options: any) => any; +export declare const instantiateUser: ({ data, headerObj, client }: { + data: IUserObject; + headerObj: any; + client: Client; +}) => Promise; diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..26e85f8 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,2 @@ +export { default as Client } from './lib/Client'; +export { default as User } from './lib/User'; diff --git a/types/interfaces/client.d.ts b/types/interfaces/client.d.ts new file mode 100644 index 0000000..c141d66 --- /dev/null +++ b/types/interfaces/client.d.ts @@ -0,0 +1,8 @@ +export interface ISynapseClient { + client_id: string; + client_secret: string; + fingerprint: string; + ip_address: string; + host: string; + isProduction: boolean; +} diff --git a/types/interfaces/helpers.d.ts b/types/interfaces/helpers.d.ts new file mode 100644 index 0000000..393a8d3 --- /dev/null +++ b/types/interfaces/helpers.d.ts @@ -0,0 +1,119 @@ +export interface IQueryParams { + amount?: number; + query?: string; + page?: number; + per_page?: number; + filter?: string; + show_refresh_tokens?: string; + full_dehydrate?: string; + force_refresh?: string; + type?: string; + zip?: string; + lat?: string | number; + lon?: string | number; + radius?: string | number; + limit?: number; + currency?: string; + foreign_transaction?: string; + is_credit?: string; + subnet_id?: string; + ticker?: string; + routing_num?: string; + address_city?: string; + address_country_code?: string; + address_postal_code?: string; + address_street?: string; + address_subdivision?: string; +} +export interface IBuildQueryParamsArgs extends IQueryParams { + originalUrl: string; +} +export interface IHeadersValues { + client_id: string; + client_secret: string; + fingerprint: string; + ip_address: string; + oauth_key: string; + idempotency_key?: string; +} +export interface IHeadersObject { + 'X-SP-USER-IP': string; + 'Content-Type': string; + 'X-SP-GATEWAY'?: string; + 'X-SP-USER'?: string; + 'X-SP-IDEMPOTENCY-KEY'?: string; + [index: string]: string | undefined; +} +export interface IHeadersOptions { + fingerprint?: string; + ip_address?: string; + full_dehydrate?: string; + idempotency_key?: string; +} +export interface IVerifiedRoutingNum { + address: string; + bank_code: string; + bank_name: string; + horizontal_logo: string; + logo: string; + meta: { + primary_color: string; + secondary_color: string; + }; + name: string; + url: string; +} +export interface IDeliverabilityObject { + deliverability: string; + deliverability_analysis: { + partial_valid: boolean; + primary_number_invalid: boolean; + primary_number_missing: boolean; + secondary_invalid: boolean; + secondary_missing: boolean; + }; + normalized_address: { + address_city: string; + address_country_code: string; + address_postal_code: string; + address_street: string; + address_subdivision: string; + }; +} +export interface IGetAtmLocationsResponse { + atms: IAtmLocationObject[]; + atms_count: number; + error_code: string; + http_code: string; + limit: number; + page: number; + page_count: number; + "success": boolean; +} +export interface IAtmLocationObject { + atmLocation: { + DistanceMeters: string; + DistanceUnit: string; + ImageURL: string; + LocationID: string; + LocationName: string; + LocationType: string; + LocationTypeLabel: string; + MapIcon: string; + MapUrl: string; + SurchargeFree: string; + address: { + city: string; + country: string; + postalCode: string; + state: string; + street: string; + }; + coordinates: { + latitude: string; + longitude: string; + }; + }; + atm_network_type: string; + distance: number; +} diff --git a/types/interfaces/node.d.ts b/types/interfaces/node.d.ts new file mode 100644 index 0000000..dc378bc --- /dev/null +++ b/types/interfaces/node.d.ts @@ -0,0 +1,155 @@ +export interface IGetNodesApiResponse { + "error_code": string; + "http_code": string; + "limit": number; + "page": number; + "page_count": number; + "success": boolean; + "nodes": INodeDetailsObject[]; + "node_count": number; +} +export interface INodeTimeline { + date: number; + note: string; +} +/** + * {@link [Node Object Details](https://docs.synapsefi.com/api-references/nodes/node-object-details)} + */ +export interface INodeDetailsObject { + _id: string; + _links: object; + allowed: string; + allowed_status_code: string | null; + client: object; + extra: INodeDetailsExtra; + info: INodeDetailsInfo; + is_active: boolean; + timeline: INodeTimeline[]; + type: string; + user_id: string; +} +export interface INodeDetailsInfo { + nickname: string; + loan_type?: string; + auto_pay?: boolean; + payment_node_id?: string; + reserve_node_id?: string; + next_payment?: number; + installment_amount?: number; + credit_limit?: { + amount: number; + currency: string; + }; + agreements?: { + type: string; + url: string; + }[]; + deposit_addresses?: { + BTC?: string; + ETH?: string; + [index: string]: string | undefined; + }; + portfolio?: { + BTC: number; + ETH: number; + DAI: number; + }; + balances?: { + [index: string]: string | number; + }; + balance?: { + amount: number; + currency: string; + }; + bank_logo?: string; + bank_hlogo?: string; + bank_url?: string; + bank_code?: string; + bank_name?: string; + bank_long_name?: string; + account_num?: string; + routing_num?: string; + routing_number?: string; + swift?: string; + bsb_number?: string; + clabe?: string; + tax_number?: string; + branch_name?: string; + branch_code?: string; + document_id?: string; + card_hash?: string; + card_number?: string; + exp_date?: string; + network?: string; + type?: string; + payee_name?: string; + payee_address?: { + address_street: string; + address_city: string; + address_subdivision: string; + address_country_code: string; + address_postal_code: string; + }; + bank_address?: { + address_street: string; + address_city: string; + address_subdivision: string; + address_country_code: string; + address_postal_code: string; + }; + installments?: { + amount: number; + date: number; + }; + interest?: { + cap: number; + apr: number; + accrued: number; + }; + correspondent_info?: { + address: string; + routing_num: string; + bank_name: string; + }; + match_info?: { + email_match: string; + phone_number_match: string; + name_match: string; + }; + biller_id?: string; + custody?: string; + risk?: string; + monthly_withdrawals_remaining?: number; + split_ratio?: number; + schedule?: string; + speeds?: string[]; + class?: string; + [index: string]: unknown; +} +export interface INodeDetailsExtra { + other: INodeDetailsExtraOther; +} +export interface INodeDetailsExtraOther { + access_token?: unknown; + micro_meta?: INodeDetailsMicroMeta; + updated_on?: unknown; +} +export interface INodeDetailsMicroMeta { + micro_attempts: number; + micro_sent_count: number; + skip_micro: boolean; +} +/** + * @todo fill this out with subnet details info + */ +export interface INodeDetailsSubnetInfo { + _id: string; + _links: object; +} +export interface IgenECashBarcodePayload { + amount: { + currency: string; + amount: number; + }; + retailer_id: number; +} diff --git a/types/interfaces/subnet.d.ts b/types/interfaces/subnet.d.ts new file mode 100644 index 0000000..40b3878 --- /dev/null +++ b/types/interfaces/subnet.d.ts @@ -0,0 +1,88 @@ +/** + * {@link [Subnet Object Details](https://docs.synapsefi.com/api-references/subnets/subnet-object-details)} + */ +export interface ISubnetDetailsObject { + _id: string; + user_id: string; + node_id: string; + client: { + id: string; + name: string; + }; + nickname: string; + account_class: string; + status: string; + status_code: string; + created_on: string; + updated_on: string; + supp_id: string; + agreements: { + type: string; + url: string; + }; + /** + * Additional Values for Cards + */ + card_number?: string; + cvc?: string; + pin?: string; + exp?: string; + card_style_id?: string; + wallet_style_id?: string; + preferences?: { + allow_foreign_transactions?: boolean; + daily_transaction_limit?: number | null; + daily_cash_limit?: number | null; + monthly_transaction_limit?: number | null; + monthly_cash_limit?: number | null; + }; + /** + * Additional Values for Account Numbers + */ + account_num?: string; + routing_num?: { + wire?: string; + ach?: string; + }; +} +export interface IGetSubnetsApiResponse { + error_code: string; + http_code: string; + limit: number; + page: number; + page_count: number; + subnets: ISubnetDetailsObject[]; + subnets_count: number; + success: boolean; +} +export interface IGetShipmentsApiResponse { + error_code: string; + http_code: string; + limit: number; + page: number; + page_count: number; + ships: IShipmentObject[]; + ship_count: number; + success: boolean; +} +export interface IShipmentObject { + _id: string; + card_style_id: string; + fee_node_id: string; + name: string; + secondary_label: string; + address: { + address_line_1: string; + address_city: string; + address_state: string; + address_zipcode: string; + address_country_code: string; + address_care_of: string; + }; + subnet_id: string; + delivery: string; + delivery_carrier: string; + tracking: string; + created_on: string; + status: string; +} diff --git a/types/interfaces/subscription.d.ts b/types/interfaces/subscription.d.ts new file mode 100644 index 0000000..dd176d8 --- /dev/null +++ b/types/interfaces/subscription.d.ts @@ -0,0 +1,24 @@ +export interface IGetSubscriptionsApiResponse { + error_code: string; + http_code: string; + limit: number; + page: number; + page_count: number; + subscriptions_count: number; + subscriptions: ISubscriptionObject[]; + success: boolean; +} +export interface ISubscriptionObject { + _id: string; + _links: { + self: { + href: string; + }; + }; + _v: number; + client_id: string; + is_active: boolean; + scope: TSubscriptionScope[]; + url: string; +} +export type TSubscriptionScope = "USERS|POST" | "USER|PATCH" | "USERS|PATCH" | "NODES|POST" | "NODE|PATCH" | "NODES|PATCH" | "NODE|DELETE" | "NODES|DELETE" | "TRANS|POST" | "TRANS|POST|JIT" | "TRAN|PATCH" | "TRANS|PATCH" | "TRAN|DELETE" | "TRANS|DELETE" | "SUBNETS|POST" | "SUBNET|PATCH"; diff --git a/types/interfaces/transaction.d.ts b/types/interfaces/transaction.d.ts new file mode 100644 index 0000000..066bbf4 --- /dev/null +++ b/types/interfaces/transaction.d.ts @@ -0,0 +1,263 @@ +export interface ITransactionDetailsObject { + amount: { + currency: string; + amount: number; + }; + client: { + id: string; + name: string; + }; + extra: ITransExtraObject; + fees: { + fee: number; + note: string; + to: { + id: string; + }; + }[]; + recent_status: number; + timeline: ITransactionTimelineObject[]; + from: ITransToFromObj; + to: ITransToFromObj; + _id: string; + _v: number; +} +export interface IGetTransactionsApiResponse { + error_code: string; + http_code: string; + limit: number; + page: number; + page_count: number; + success: boolean; + trans: ITransactionDetailsObject[]; + trans_count: number; +} +export interface ITransactionTimelineObject { + date: string; + note: string; + status: string; + status_id: string; +} +export interface ITransToFromObj { + id: null | string; + meta?: ITransMetaObj; + nickname: string; + type: string; + user: { + _id: string; + legal_names: string[]; + }; +} +/** + * @note THIS IS NOT COMPREHENSIVE - there are values here not present in the docs and values in the docs not present here + * {@link [docs](https://docs.synapsefi.com/api-references/transactions/transaction-object-details#interchange-meta-fields)} + */ +export interface ITransMetaObj { + account_num: string; + amount: string; + acquirer_reference_number: string | null; + address: { + city: string; + country: string; + state: string; + street: string; + zipcode: string; + }; + approval_code: string; + back_signiture: boolean; + card_acceptor_id: string; + check_back: string; + check_front: string; + check_number: string; + check_quality_bucket_num: string; + condition_code: null; + conversion_meta: { + settlement_currency: string; + transaction_currency: string; + settlement_currency_conversion_rate: number; + }; + enriched_info: { + category: string; + entity_id: string; + facilitator_id: string; + location_id: string; + status: string; + }; + fees: { + amount: number; + type: string; + }[]; + foreign_transaction: boolean; + front_signature: string; + fraud_score: { + reason: string; + score: number; + }; + is_check: boolean; + is_endorsed: boolean; + is_force_post: boolean; + is_recurring: boolean; + mcc: string; + merchant_category: string; + merchant_id: string; + merchant_logo: string; + merchant_name: string; + merchant_official_page: string; + merchant_phone_number: string; + merchant_subcategory: string; + mid: string; + name: string; + original_check_back: string; + original_check_front: string; + pan_entry_mode: string; + partial_approval_allowed: boolean; + pin_entry_mode: string; + presentment_info: { + card_presence: string; + cardholder_presence: string; + security_concern: string; + type: string; + }; + rebates: { + amount: number; + type: string; + }[]; + retrieval_reference_number: string; + revenues: ITransMetaRevenuesObj[]; + routing_number: string; + sub_amounts: { + amount: number; + type: string; + }[]; + subnet_id: string; + srn_type: string; + srn_address: string; + system_trace_audit_number: string; + terminal_id: string; + terminal_info: { + attendance: string; + card_input_capability: string; + card_retention_capability: string; + location: string; + operator: string; + type: string; + }; + type: string; +} +export interface ITransMetaRevenuesObj { + amount: number; + type: string; + meta: { + program: string; + cap: number; + fixed_rate: number; + variable_rate: number; + daily_adjusted_rate: number; + unadjusted_value: number; + }; +} +/** + * Synapse has an enrich endpoint that can return additional information about a merchant etc + * {@link [docs](https://docs.synapsefi.com/api-references/miscellaneous/enrichment-guide)} + */ +export interface IEnrichmentObj { + _id: string; + address: { + city: string; + country_code: string; + loc: number[]; + postal_code: string; + street1: string; + street2: string; + subdivision: string; + }; + analytics: unknown; + logo: string; + name: string; + official_page: string; + phone_number: { + country_code: string; + national_number: string; + }; + scope: string; +} +export interface ITransExtraObject { + created_on: number; + asset: String; + rate: number; + rate_limit: number; + supp_id: string; + group_id: string; + note: string; + encrypted_note: string; + process_on: number; + settlement_delay: number; + tracking_number: string; + same_day: boolean; + speed: string; + other: { + attachments: string[]; + chargeback_disputed: boolean; + dispute_meta: any; + is_provisional_credit: boolean; + parent_transaction_id: string; + }; + txp_meta: any; + interchange_meta: any; +} +export interface IDisputeTransactionPayload { + /** + * required dispute reason: INCORRECT_AMOUNT + */ + amount_debited: number; + /** + * required dispute reason: INCORRECT_AMOUNT|ATM + */ + amount_received: number; + /** + * required dispute reason: UNAUTHORIZED|CARD_LOST + */ + lost_date: number; + /** + * required dispute reason: UNAUTHORIZED|CARD_LOST + */ + how_lost: string; + /** + * required dispute reason: UNAUTHORIZED|CARD_IN_HAND|SHARED, UNAUTHORIZED|CARD_IN_HAND|NOT_SHARED + */ + last_use: string; + /** + * required dispute reason: UNAUTHORIZED|CARD_IN_HAND|SHARED + */ + people_allowed_use: string; + /** + * required dispute reason: CANCEL_RECURRING_PMT + */ + contact_date: number; + /** + * required dispute reason: CANCEL_RECURRING_PMT + */ + contact_method: string; + /** + * required dispute reason: CHARGED_TWICE|CREDIT_NOT_PROCESSED|DUPLICATE, CHARGED_TWICE|CREDIT_NOT_PROCESSED|PAID_BY_OTHER_MEANS + */ + trans_on_same_card: boolean; + /** + * required dispute reason: CHARGED_TWICE|CREDIT_NOT_PROCESSED|DUPLICATE, CHARGED_TWICE|CREDIT_NOT_PROCESSED|PAID_BY_OTHER_MEANS + */ + merch_given_attempt_to_resolve: boolean; + /** + * required dispute reason: CANCEL_RECURRING_PMT + */ + contact_name: string; + /** + * required dispute reason: CANCEL_RECURRING_PMT + */ + contact_response: string; +} +export interface IDisputeChargebackPayload { + /** + * required: Array of supporting docs converted into base 64 encoded strings + */ + docs: string[]; +} diff --git a/types/interfaces/user.d.ts b/types/interfaces/user.d.ts new file mode 100644 index 0000000..a44bc88 --- /dev/null +++ b/types/interfaces/user.d.ts @@ -0,0 +1,442 @@ +/** + * @description API response format for a GET call to `/users` by the client to fetch a list of users + */ +export interface IGetUsersResponse { + "error_code": string; + "http_code": string; + "limit": number; + "page": number; + "page_count": number; + "success": boolean; + "users": IUserObject[]; + "users_count": number; +} +/** + * @description Information that lives on a user object + */ +export interface IUserObject { + /** + * included in API response + */ + account_closure_date: number; + /** + * included in API response + */ + client: { + id: string; + name: string; + }; + /** + * optional, contains all the KYC information associated with the user profile. + */ + documents: IUserDocument[]; + emails: string[]; + extra: { + /** + * optional, CIP Tag associated with the user object. + */ + cip_tag: number; + /** + * optional, whether or not 2FA is enabled. defaults to `true`. + * WE STRONGLY RECOMMEND USING 2FA OR SOME FORM OF MFA WITHIN YOUR APPLICATION. + * {@link [read about OAuth](https://docs.synapsefi.com/api-references/oauth)} + */ + extra_security: boolean; + /** + * included in API response, Unix timestamp (in ms) value of when the user object was created. + */ + date_joined: number; + /** + * optional, if the user profile is a business, value is `true`. default is `false` + */ + is_business: boolean; + /** + * optional, Unix timestamp (in ms) value of when the user object was last updated. + */ + last_updated: number; + /** + * optional, 250 max character string + */ + public_note: null | string; + /** + * optional, supplemental ID + */ + supp_id: string | null; + }; + flag: string; + flag_code: unknown; + ips: string[]; + is_hidden: boolean; + /** + * required for `POST` call + */ + legal_names: string[]; + logins: { + email: string; + scope: string; + }[]; + permission: string; + permission_code: unknown; + /** + * required for `POST` call + */ + phone_numbers: string[]; + photos: unknown[]; + /** + * included in API response. Refresh token you will be using to OAuth the user. + */ + refresh_token: string; + /** + * Included in API response. Represents if the user is on a meaningful screenings list. Go to Possible Watchlists Values to learn more. + * {@link [Possible Watchlists Values](https://docs.synapsefi.com/api-references/users/user-object-details#possible-watchlists-values)} + */ + watchlists: string; + /** + * included in API response, Primary key of user object + */ + _id: string; + _links: unknown; + _v: number; + [index: string]: any; +} +export interface IUserDocument { + /** + * required, Address city of the business location or individual's residence. If the user wishes to receive mail elsewhere, you can add that as a MAILING_ADDRESS social document. Go to Social Document Schema to learn more. We recommend verifying your address to prevent failure. + * + * {@link [Social Document Schema](https://docs.synapsefi.com/api-references/users/user-object-details#social-document-schema)} + * {@link [verifying your address](https://beta-docs.synapsefi.com/api-references/miscellaneous/verify-address)} + */ + address_city: string; + /** + * required, ISO Alpha-2 formatted Address country code of the business location or individual's residence. + */ + address_country_code: string; + /** + * required, Address zip/postal code of the business location or individual's residence. + */ + address_postal_code: string; + /** + * required, Address street of the business location or individual's residence. + */ + address_street: string; + /** + * required, Address subdivision (state) of the business location or individual's residence. + */ + address_subdivision: string; + /** + * optional, Common name for the individual/entity. + */ + alias: string; + /** + * required if business base doc. + * @enum "MSB","LENDING","NON-US_OFFICE","NON-US_ACTIVITY","CRYPTO","PUBLIC","PRIVATE","REGISTERED_WITH_SEC","OTHER","NBFI-US","NBFI-FOREIGN","LISTED-US","LISTED-FOREIGN","NFP","BANK-US","BANK-FOREIGN","FUND" + */ + company_activity: string[]; + /** + * required, Day of entity formation for business or Birth date for individual. + */ + day: number; + /** + * optional, Desired scope for base document. + */ + desired_scope: string; + /** + * optional + */ + doc_option_key: string; + /** + * optional + */ + docs_key: string; + /** + * optional + */ + docs_title: string; + /** + * Included in API response. Included for business user's business base document. Possible values: VALID, INVALID, REVIEWING. Go to KYC, Risk and Compliance to learn more. + * {@link [KYC, Risk and Compliance](https://docs.synapsefi.com/intro-to-risk)} + */ + edd_status: string; + /** + * required, Email of the individual/entity associated with this base document. + */ + email: string; + /** + * required, Industry or profession of business or individual. Go to Allowed Entity Scopes response section to see all the possible values. + * + * {@link [Allowed Entity Scopes](https://docs.synapsefi.com/api-references/users/allowed-entity-scopes)} + */ + entity_scope: string; + /** + * required, Type of business or gender of the individual. Go to Allowed Entity Types response section to see all the possible values. + * + * {@link [ Allowed Entity Types](https://docs.synapsefi.com/api-references/users/allowed-entity-types)} + */ + entity_type: string; + /** + * required if individual base doc on business user. Allowed values: `CONTROLLING_PERSON`, `UBO`. + */ + entity_relationship: string; + /** + * required only to `PATCH` existing base document. Primary key of the base document. This value is a local primary key, meaning, it's only unique within a user object. Different user objects can have same base doc IDs. + */ + id: string; + /** + * Included in API response, Included for an individual's base document (either for business, joint or individual accounts). Value ranges from 0-1. Go to ID Score to learn more. + * + * {@link [ID Score](https://docs.synapsefi.com/product-guides/id-score)} + */ + id_score: number; + /** + * required, IP of the individual/entity associated with this base document. + */ + ip: string; + /** + * required, Month of entity formation for business or Birth month for individual. + */ + month: number; + /** + * required, Name of the individual/entity associated with this base document. + */ + name: string; + /** + * required if individual base doc on business user. Percentage of the business owned by the beneficial owner. + */ + ownership_percentage: number; + /** + * Included in API response. Permission scope of the base document. + */ + permission_scope: string; + /** + * required, Phone number of the individual/entity associated with this base document. + */ + phone_number: string; + /** + * Included in API response + */ + required_edd_docs: string[]; + /** + * optional, Physical documents linked to the base document. Go to Physical Document Schema to learn more. + * + * {@link [Physical Document Schema](https://docs.synapsefi.com/api-references/users/user-object-details#physical-document-schema)} + */ + physical_docs: IUserPhysicalDoc[]; + /** + * included in API response. This object contains all the sanctions screenings lists the user has been run against. This object is just a detailed response that decides the value of watchlists. Our recommendation is not to pay attention to this field but just the watchlists key instead. Go to Screenings Results Details to learn more. + * + * {@link [Screenings Results Details](https://docs.synapsefi.com/api-references/users/user-object-details#screenings-results-details)} + */ + screening_results: { + [index: string]: 'MATCH' | 'NO_MATCH' | 'FAILED' | 'PENDING' | 'FALSE_POSITIVE'; + }; + /** + * optional. Social documents linked to the base document. + * + * {@link [Social Documents Schema](https://docs.synapsefi.com/api-references/users/user-object-details#social-document-schema)} + */ + social_docs: IUserSocialDoc[]; + /** + * included in API response. see ID Score to learn more + * + * {@link [ID Score](https://docs.synapsefi.com/product-guides/id-score)} + */ + trust_level: 'low' | 'medium' | 'high'; + /** + * optional. Virtual Documents linked to the base document. + * + * {@link [Virtual Document Schema](https://docs.synapsefi.com/api-references/users/user-object-details#virtual-document-schema)} + */ + virtual_docs: IUserVirtualDoc[]; + /** + * included in API repsonse. Represents if the user is on a meaningful screenings list. Go to Possible Watchlists Values to learn more. + * + * {@link [Possible Watchlists Values](https://docs.synapsefi.com/api-references/users/user-object-details#possible-watchlists-values)} + */ + watchlists: 'PENDING' | 'SOFT_MATCH|PENDING_UPLOAD' | 'MATCH' | 'SOFT_MATCH' | 'NO_MATCH' | 'FALSE_POSITIVE'; + /** + * required. Year of entity formation for business or Birth year for individual. + */ + year: number; + [index: string]: any; +} +export interface IUserPhysicalDoc { + /** + * required, Type of physical document being submitted. Go to Allowed Document Types response section to see all the possible values. + * + * {@link [Allowed Document Types](https://docs.synapsefi.com/api-references/users/allowed-document-types)} + */ + document_type: string; + /** + * required. Value of the document. Physical documents must be encoded Base64 before being uploaded to our system. Please ensure that the image is clear, with all corners visible in case of a document with legible text. In case of videos, please ensure that the video is clear with ample light and audio is clear and without distortion or disturbance. + * + * In case of VIDEO_AUTHORIZATION, please ensure that the user's face is clearly visible and the audio is clear and states the user saying "I authorize account opening at ." + */ + document_value: string; + /** + * required if you wish to PATCH an existing virtual document. Primary key of the virtual document. This value is a local primary key, meaning, it's only unique within a base document. Different base documents can have same virtual document IDs. + */ + id: string; + /** + * Included in API response. If the document status is SUBMITTED|INVALID, invalid_reasons describes the reasons for why the document was marked as invalid. Go to Possible Invalid Reasons Values to learn more. + * + * {@link [Possible Invalid Reasons Values](https://docs.synapsefi.com/api-references/users/user-object-details#possible-invalid-reasons-values-for-physical-docs)} + */ + invalid_reasons: string[]; + /** + * included in API repsonse. Unix timestamp (in ms) value of when the virtual document was last updated. + */ + last_updated: number; + /** + * included in API response. Status of the virtual document. Go to Possible Sub-Document Status Values to learn more. + * + * {@link [Possible Sub-Document Status Values](https://docs.synapsefi.com/api-references/users/user-object-details#possible-sub-document-status-values)} + */ + status: string; + meta?: { + /** + * requirement depends. ISO Alpha-2 formatted state code of the issuing state of the physical document. Go to Allowed Document Types response section to see which physical documents require this field. This field will not be returned in any user responses. + * + * {@link [Allowed Document Types](https://docs.synapsefi.com/api-references/users/allowed-document-types)} + */ + state_code?: string; + /** + * requirement depends, ISO Alpha-2 formatted country code of the issuing country of the physical document. Go to Allowed Document Types response section to see which physical documents require this field. This field will not be returned in any user responses. + * + * {@link [Allowed Document Types](https://docs.synapsefi.com/api-references/users/allowed-document-types)} + */ + country_code?: string; + /** + * requirement depends. ID number associated with the physical document. Go to Allowed Document Types response section to see which physical documents require this field. This field will not be returned in any user responses. + * + * {@link [Allowed Document Types](https://docs.synapsefi.com/api-references/users/allowed-document-types)} + */ + id_number?: string; + }; + [index: string]: any; +} +export interface IUserVirtualDoc { + /** + * required, see response for Allowed Document Types to see possible values + * + * {@link [Allowed Document Types](https://docs.synapsefi.com/api-references/users/allowed-document-types)} + */ + document_type: string; + /** + * required, value of the document + */ + document_value: string; + /** + * required to `PATCH` existing document + */ + id: string; + /** + * included in API response. Unix timestamp (in ms) value of when the document was last updated. + */ + last_updated: number; + /** + * Included in API response. Status of the virtual document. Go to Possible Sub-Document Status Values to learn more. + * + * {@link [Possible Sub-Document Status Values](https://docs.synapsefi.com/api-references/users/user-object-details#possible-sub-document-status-values)} + */ + status: string; + meta?: { + /** + * requirement depends, ISO Alpha-2 formatted country code of the issuing country of the physical document. Go to Allowed Document Types response section to see which physical documents require this field. This field will not be returned in any user responses. + * + * {@link [Allowed Document Types](https://docs.synapsefi.com/api-references/users/allowed-document-types)} + */ + country_code?: string; + }; + [index: string]: any; +} +export interface IUserSocialDoc { + /** + * required, see response for Allowed Document Types to see possible values + * + * {@link [Allowed Document Types](https://docs.synapsefi.com/api-references/users/allowed-document-types)} + */ + document_type: string; + /** + * required, value of the document + */ + document_value: string; + /** + * required to `PATCH` existing document + */ + id: string; + /** + * included in API response. Unix timestamp (in ms) value of when the document was last updated. + */ + last_updated: number; + /** + * Included in API response. Status of the virtual document. Go to Possible Sub-Document Status Values to learn more. + * + * {@link [Possible Sub-Document Status Values](https://docs.synapsefi.com/api-references/users/user-object-details#possible-sub-document-status-values)} + */ + status: string; + info?: { + /** + * Included in API Response. Currently a response in MAILING_ADDRESS social document. Two reasons: invalid_address and address_has_incorrect_unit. + */ + invalid_reasons: string[]; + /** + * Included in API Response. ISO Alpha-2 formatted Address country code associated with the social document. Currently a response in MAILING_ADDRESS social document. + */ + address_country_code: string; + /** + * Included in API Response. Address zip or postal code associated with the social document. Currently a response in MAILING_ADDRESS social document. + */ + address_postal_code: string; + /** + * Included in API Response. Address city associated with the social document. Currently a response in MAILING_ADDRESS social document. + */ + address_city: string; + /** + * Included in API Response. Address street associated with the social document. Currently a response in MAILING_ADDRESS social document. + */ + address_street: string; + /** + * Included in API Response. Address subdivision (state) associated with the social document. Currently a response in MAILING_ADDRESS social document. + */ + address_subdivision: string; + /** + * Included in API Response. C/O name associated with the social document. Currently a response in MAILING_ADDRESS social document. + */ + address_care_of: string; + }; + meta?: { + /** + * requirement depends. Address zip or postal code associated with the social document. Currently a response in MAILING_ADDRESS social document. This field will not be returned in any user responses. + */ + address_postal_code?: string; + /** + * requirement depends. Address city associated with the social document. Currently a response in MAILING_ADDRESS social document. This field will not be returned in any user responses. + */ + address_city?: string; + /** + * requirement depends. Address street associated with the social document. Currently a response in MAILING_ADDRESS social document. This field will not be returned in any user responses. + */ + address_street?: string; + /** + * requirement depends. Address subdivision (state) associated with the social document. Currently a response in MAILING_ADDRESS social document. This field will not be returned in any user responses. + */ + address_subdivision?: string; + /** + * Optional. C/O name associated with the social document. Currently a response in MAILING_ADDRESS social document. This field will not be returned in any user responses. + */ + address_care_of?: string; + /** + * requirement depends, ISO Alpha-2 formatted country code of the issuing country of the physical document. Go to Allowed Document Types response section to see which physical documents require this field. This field will not be returned in any user responses. + * + * {@link [Allowed Document Types](https://docs.synapsefi.com/api-references/users/allowed-document-types)} + */ + country_code?: string; + /** + * requirement depends. ISO Alpha-2 formatted Address country code of the issuing state of the virtual document. Go to Allowed Document Types response section to see which social documents require this field. This field will not be returned in any user responses. + * + * {@link [Allowed Document Types](https://docs.synapsefi.com/api-references/users/allowed-document-types)} + */ + state_code?: string; + }; + [index: string]: any; +} diff --git a/types/lib/Client.d.ts b/types/lib/Client.d.ts new file mode 100644 index 0000000..c645730 --- /dev/null +++ b/types/lib/Client.d.ts @@ -0,0 +1,160 @@ +import { IDeliverabilityObject, IGetAtmLocationsResponse, IHeadersObject, IHeadersOptions, IQueryParams, IVerifiedRoutingNum } from '../interfaces/helpers'; +import { AxiosResponse } from 'axios'; +import { IGetUsersResponse, IUserObject } from '../interfaces/user'; +import User from './User'; +import { IDisputeChargebackPayload, IGetTransactionsApiResponse } from '../interfaces/transaction'; +import { IGetNodesApiResponse } from '../interfaces/node'; +import { IGetSubscriptionsApiResponse, ISubscriptionObject } from '../interfaces/subscription'; +declare class Client { + client_id: string; + client_secret: string; + fingerprint: string; + ip_address: string; + host: string; + isProduction: boolean; + headers: IHeadersObject; + _default_public_key_scopes: string[]; + _default_subscription_scopes: string[]; + constructor({ client_id, client_secret, fingerprint, ip_address, isProduction }: { + client_id: any; + client_secret: any; + fingerprint: any; + ip_address: any; + isProduction: any; + }); + /** + * @description POST call to create a new user. + * @param bodyParams payload with user details for create user call. + * @param ip_address ip address of the user + * @param options TODO + * @returns newly created user object instantiated with SynapseNode library + * + * {@link [User Object Details](https://docs.synapsefi.com/api-references/users/user-object-details)} + * {@link [Create User](https://docs.synapsefi.com/api-references/users/create-user)} + */ + createUser(bodyParams: Partial, ip_address: string, options?: IHeadersOptions | null): Promise; + /** + * @description gets a list of users based on query passed. + * @param queryParams parameters for GET call to fetch users + * @returns list of users based on query passed. + * + * {@link [View All Users](https://docs.synapsefi.com/api-references/users/view-all-users-paginated)} + */ + getAllUsers(queryParams?: IQueryParams): Promise>; + /** + * @description fetches and instanties a user object based on the passed user primary key. + * @param user_id primary key of the desired user to get + * @param options TODO + * @returns instantiated user object + * + * {@link [View User](https://docs.synapsefi.com/api-references/users/view-user)} + */ + getUser(user_id: string, options?: { + [index: string]: string; + } | null): Promise; + /** + * @description gest a list of transactions + * @param queryParams parameters for GET call to fetch list of transactions + * @returns list of transactions based on query passed + */ + getPlatformTransactions(queryParams?: IQueryParams): Promise>; + /** + * @description gest a list of nodes + * @param queryParams parameters for GET call to fetch list of nodes + * @returns list of nodes based on query passed + */ + getPlatformNodes(queryParams?: IQueryParams): Promise>; + /** + * @returns list of institutions + */ + getInstitutions(): Promise>; + issuePublicKey(scope?: string[], userId?: string | null): Promise>; + /** + * + * @param subscriptionUrl url destination for webhooks + * @param scope scopes on which to run the callback + * @param idempotency_key optional idempotency in headers + * @returns newly created + * + * {@link [Subscription Object Details](https://docs.synapsefi.com/api-references/subscriptions/create-subscription)} + * {@link [Create Subscription](https://docs.synapsefi.com/api-references/subscriptions/create-subscription)} + */ + createSubscription(subscriptionUrl: string, scope?: string[], idempotency_key?: string | null): Promise>; + /** + * @description gets a list of all the subscriptions + * @param queryParams Query params to view list of subsciptions + * @returns list of subscriptions + * + * {@link [View All Subscriptions](https://docs.synapsefi.com/api-references/subscriptions/view-all-subscriptions)} + */ + getAllSubscriptions(queryParams?: IQueryParams): Promise>; + /** + * @description fetch a single subscription by ID + * @param subscription_id primary key of subscription to fetch + * @returns subscription object details + */ + getSubscription(subscription_id: string): Promise>; + /** + * @description patch call to update specified subscription + * @param subscription_id primary key of subscription to update + * @param bodyParams subscription properties to update + * @returns updated scription object + */ + updateSubscription(subscription_id: string, bodyParams?: Partial): Promise>; + /** + * @description view all atms + * @param queryParams + * @returns + * + * {@link [View ATMs](https://docs.synapsefi.com/api-references/nodes/view-atms)} + */ + locateAtms(queryParams?: IQueryParams): Promise>; + /** + * + * @param bodyParams + * @returns deliverability details object + */ + verifyAddress(bodyParams?: any): Promise>; + /** + * @param bodyParams + * @returns information about the verified routing number + * + * {@link [Verify Routing Number](https://docs.synapsefi.com/api-references/miscellaneous/verify-routing-number)} + */ + verifyRoutingNumber(bodyParams?: { + routing_num?: string; + type?: string; + }): Promise>; + getCryptoQuotes(): Promise>; + getCryptoMarketData(queryParams?: IQueryParams): Promise>; + getWebhookLogs(): Promise>; + getTradeMarketData(queryParams?: IQueryParams): Promise>; + /** + * @description Only INTERCHANGE-US transactions that have been RETURNED within the last 14 days with return code of IR999 can be disputed. + * If dispute is won, the transaction will go back to SETTLED status. We recommend {@link [Subscribing to our webhooks](https://docs.synapsefi.com/api-references/subscriptions)} to be notified. + * @param transId Unique ID for transaction + * @param bodyParams Array of supporting docs converted into base 64 encoded strings + */ + disputeChargeback(transId: string, bodyParams: IDisputeChargebackPayload): Promise>; + /** + * @description {@link [Fetches allowed node types](https://docs.synapsefi.com/api-references/nodes/allowed-node-types)} + * @returns list of allowed node types + */ + getNodeTypes(): Promise>; + /** + * @description {@link [Fetches allowed user document types](https://docs.synapsefi.com/api-references/users/allowed-document-types)} + * @returns list of allowed user document types + */ + getUserDocumentTypes(): Promise>; + /** + * @description {@link [Fetches allowed user entity types](https://docs.synapsefi.com/api-references/users/allowed-entity-types)} + * @returns list of allowed user entity types + */ + getUserEntityTypes(): Promise>; + /** + * @description {@link [Fetches allowed user entity scopes](https://docs.synapsefi.com/api-references/users/allowed-entity-scopes)} + * @returns list of allowed user entity scopes + */ + getUserEntityScopes(): Promise>; +} +export default Client; diff --git a/types/lib/User.d.ts b/types/lib/User.d.ts new file mode 100644 index 0000000..fec23ba --- /dev/null +++ b/types/lib/User.d.ts @@ -0,0 +1,398 @@ +import { IHeadersObject, IQueryParams } from "../interfaces/helpers"; +import { AxiosResponse } from 'axios'; +import Client from './Client'; +import { IUserObject } from "../interfaces/user"; +import { IgenECashBarcodePayload, IGetNodesApiResponse, INodeDetailsObject } from "../interfaces/node"; +import { IDisputeTransactionPayload, IGetTransactionsApiResponse, ITransactionDetailsObject } from "../interfaces/transaction"; +import { IGetShipmentsApiResponse, IGetSubnetsApiResponse, IShipmentObject, ISubnetDetailsObject } from "../interfaces/subnet"; +declare class User { + id: string; + body: IUserObject; + host: string; + fingerprint: string; + ip_address: string; + oauth_key: string; + client: Client; + headers: IHeadersObject; + constructor({ data, headerObj, client }: { + data: any; + headerObj: any; + client: any; + }); + /** + * @description patch call to add KYC info for users + * @param bodyParams user object details to be updated + * @returns updated user object + * + * {@link [KYC FAQs](https://docs.synapsefi.com/api-references/users#kyc-faqs)} + */ + addUserKyc(bodyParams?: Partial): Promise>; + /** + * @description delete a base document by ID + * @param bodyParams specify which document id to delete, include `permission_scope` as `"DELETE_DOCUMENT"` + * @returns updated user object + * + * @todo refactor to take in a document id and abstract building the necessary body params + * + * {@link [Delete an existing document](https://docs.synapsefi.com/api-references/users/update-user#delete-an-existing-base-document)} + */ + deleteExistingDocument(bodyParams?: Partial): Promise>; + /** + * @description update a user object + * @param bodyParams user object properties to update + * @returns update user object details + * + * {@link [Update User](https://docs.synapsefi.com/api-references/users/update-user)} + */ + updateUser(bodyParams?: Partial): Promise>; + /** + * GET ALL USER DUPLICATES + * + * @returns Promise + * + * [Get User Duplicates Docs]{@link https://docs.synapsefi.com/api-references/users/manage-duplicates#example-request} + */ + getUserDuplicates(): Promise>; + /** + * SWAP DUPLICATE USER + * @param {String} swap_to_user_id required: User ID you'd like to swap the open status with + * + * @returns Promise + * + * [Swap Duplicate User Docs]{@link https://docs.synapsefi.com/api-references/users/manage-duplicates#example-request-1} + */ + swapDuplicateUsers(swap_to_user_id: any): Promise>; + /** + * RETRIEVE REFRESH TOKEN + */ + _grabRefreshToken(): Promise; + /** + * POST OAUTH USER + */ + _oauthUser(bodyParams?: {}): Promise; + /** + * @description creates a node for the user. + * @param bodyParams type is required, info and extra values are optional depending on type. + * @param idempotency_key optional idempotency key for headers + * @returns newly created node object + * + * {@link [Create Node](https://docs.synapsefi.com/api-references/nodes/create-node)} + */ + createNode(bodyParams?: {}, idempotency_key?: string | null): Promise>; + verifyAchMfa(access_token: any, mfa_answer: any, idempotency_key?: null): Promise>; + /** + * @description gets all user nodes + * @param queryParams parameters and filter for searching for user nodes + * @returns list of user's nodes + * + * {@link [View All User Nodes](https://docs.synapsefi.com/api-references/nodes/view-all-user-nodes)} + */ + getAllUserNodes(queryParams?: IQueryParams): Promise>; + /** + * @description fetch node details by suplied node ID + * @param node_id primary key for node + * @param queryParams query parameters + * @returns node details object + * + * {@link [View Node](https://docs.synapsefi.com/api-references/nodes/view-node)} + */ + getNode(node_id: string, queryParams?: IQueryParams): Promise>; + /** + * @description returns a list of user transactions + * @param queryParams filters and parameters for trans to fetch + * @returns list of trans + * + * {@link [View all user transactions](https://docs.synapsefi.com/api-references/transactions/view-all-user-transactions)} + */ + getUserTransactions(queryParams?: IQueryParams): Promise>; + /** + * + * GET TRIGGER DUMMY TRANSACTIONS + */ + triggerDummyTransactions(node_id: any, queryParams?: IQueryParams): Promise>; + /** + * @description UBO or Ultimate Beneficial Owner documents is used to declare who is the ultimate beneficial owner of a business or major shareholder. + * @param bodyParams see Generate UBO Doc for details + * @returns TODO + * + * {@link [Generate UBO Doc](https://docs.synapsefi.com/api-references/users/generate-ubo-doc)} + */ + generateUboForm(bodyParams: any): Promise>; + /** + * @description gets list of statement objects based on supplied user id + * @param queryParams + * @returns list of user statement objects + * + * {@link [Statement Object Details](https://docs.synapsefi.com/api-references/statements/statement-object-details)} + * {@link [View all user statements](https://docs.synapsefi.com/api-references/statements/view-all-user-statements)} + */ + getStatementsByUser(queryParams?: IQueryParams): Promise>; + /** + * @description gets list of statement objects base on passed node id + * @param queryParams + * @returns list of node statement objects + * + * {@link [Statement Object Details](https://docs.synapsefi.com/api-references/statements/statement-object-details)} + * {@link [View all node statements](https://docs.synapsefi.com/api-references/statements/view-all-node-statements)} + */ + getStatementsByNode(node_id: string, queryParams?: IQueryParams): Promise>; + /** + * @deprecated use `shipCard` instead + */ + shipCardNode(node_id: any, bodyParams: any): Promise>; + /** + * @deprecated + */ + resetCardNode(node_id: any): Promise>; + /** + * @description micro deposits used to verify ACH node + * @param node_id primary key of node + * @param bodyParams micro deposits + * @returns updated node object + * + * @todo refactor to take in the two micro deposit values and shape the payload in this method + * {@link [Verify Micro Deposits](https://docs.synapsefi.com/api-references/nodes/update-node#verify-micro-deposits)} + */ + verifyMicroDeposits(node_id: string, bodyParams: { + micro: [number, number]; + }): Promise>; + /** + * @description resends the micro deposits + * @param node_id primary key of node + * + * {@link [Resend Micro Deposits](https://docs.synapsefi.com/api-references/nodes/update-node#resend-micro-deposits)} + */ + reinitiateMicroDeposits(node_id: string): Promise>; + /** + * @description `PATCH` call to update node + * @param node_id primary key of node + * @param bodyParams node object properties to update + * @returns updated node object + */ + updateNode(node_id: string, bodyParams: Partial): Promise>; + /** + * @description sets `is_active` to false + * @param node_id primary key of node + * @returns inactive node object + */ + deleteNode(node_id: string): Promise>; + /** + * @deprecated use `pushToMobileWallet` instead + * {@link [Push to Wallet](https://docs.synapsefi.com/api-references/subnets/push-to-wallet)} + */ + generateApplePayToken(node_id: any, bodyParams: any): Promise>; + /** + * @param node_id primary key of node + * @param bodyParams payload includes object with amount and currency, as well as retailer id + * {@link [generate e-cash barcode](https://docs.synapsefi.com/api-references/nodes/generate-ecash-barcode)} + */ + generateECashBarcode(node_id: string, bodyParams: IgenECashBarcodePayload): Promise>; + /** + * @description `POST` call to create a transaction for a specified node + * @param node_id primary key of node + * @param bodyParams details for transaction to create + * @param idempotency_key optional idempotency key + * @returns newly created transaction object + * + * {@link [Create Transaction](https://docs.synapsefi.com/api-references/transactions/create-transaction)} + */ + createTransaction(node_id: string, bodyParams: Partial, idempotency_key?: null): Promise>; + /** + * + * @param {String} node_id required: id of node on which to create bulk transactions + * @param {Object} bodyParams required: body of post request, must have transactions key, which is an array of transaction objects + * @param {Array} bodyParams.transactions + * + * @returns Promise + * + * Idempotency keys can be provided for each transaction, inside each transaction object's `extra` key. + * + * e.g. `{ transactions: [{ extra: { idempotency_key: 'idemPotKeyStr' } }] }` + * + * [Batch Transaction Docs]{@link https://docs.synapsefi.com/api-references/transactions/create-batch-transactions} + * [Trans Object Details]{@link https://docs.synapsefi.com/api-references/transactions/transaction-object-details} + */ + createBatchTransactions(node_id: string, bodyParams: Partial[]): Promise>; + /** + * @description `GET` call for a single transaction + * @param node_id Primary key of node + * @param trans_id Primary key of transaction + * @returns Single Transaction object + * + * {@link [View Transaction](https://docs.synapsefi.com/api-references/transactions/view-transaction)} + */ + getTransaction(node_id: string, trans_id: string): Promise>; + /** + * @param node_id primary key of node + * @param queryParams filter & query parameters for get transactions call + * @returns list of transactions for a specified node + * + * {@link [View All Node transactions](https://docs.synapsefi.com/api-references/transactions/view-all-node-transactions)} + */ + getAllNodeTransactions(node_id: string, queryParams?: IQueryParams): Promise>; + /** + * @description To cancel a transaction en route to the recipient, the transaction must not have been batched already. For example, to cancel transactions between native Synapse accounts (ex: Deposit Accounts), they need to have status CREATED or QUEUED-BY-SYNAPSE.While a transaction leaving a Deposit Account, to an ACH-US account can be canceled with status CREATED, QUEUED-BY-SYNAPSE orPROCESSING-DEBIT (because outgoing ACH is batched during PROCESSING-CREDIT). + * You cannot cancel an already settled transaction, with the exception of Reversals for Interchange Pull transactions. + + * @param node_id primary key of the node + * @param trans_id primary key of the transaction + * @returns canceled transaction + * + * {@link [Cancel Transaction](https://docs.synapsefi.com/api-references/transactions/cancel-transaction)} + */ + deleteTransaction(node_id: string, trans_id: string): Promise>; + /** + * @description `PATCH` call to comment on the status of a transaction + * @param node_id primary key of node + * @param trans_id primary key of transaction + * @param bodyParams transaction details to update + * @returns updated transaction object + * + * @todo refactor to take string comment sintead and format payload here. Also, create sister methods for retry and execute trans + */ + commentOnStatus(node_id: string, trans_id: string, bodyParams: Partial): Promise>; + /** + * @description `PATCH` call to dispute a card related transaction + * @param node_id primary key of node + * @param trans_id primary key of transaction + * @param bodyParams dispute transaction payload, see docs for details + * + * @todo response typing + * + * {@link [Dispute Transaction](https://docs.synapsefi.com/api-references/transactions/dispute-transaction)} + */ + disputeCardTransaction(node_id: string, trans_id: string, bodyParams: IDisputeTransactionPayload): Promise>; + /** + * @description `GET` call to fetch subnets for specified node id + * @param node_id primary key of node + * @param queryParams query params & filter for fetching subnets + * @returns list of subnets + * + * {@link [View All Node Subnets](https://docs.synapsefi.com/api-references/subnets/view-all-node-subnets)} + */ + getAllSubnets(node_id: any, queryParams?: IQueryParams): Promise>; + /** + * @description `GET` call to view a single subnet + * @param node_id primary key of node + * @param subnet_id primary key of subnet + * @param queryParams query params for fetching subnet, for full dehydrate or not + * @returns sing subnet details + * + * {@link [View Subnet](https://docs.synapsefi.com/api-references/subnets/view-subnet)} + */ + getSubnet(node_id: string, subnet_id: string, queryParams?: IQueryParams): Promise>; + /** + * @description `POST` call to create a subnet for a specified node + * @param node_id primary key of node + * @param bodyParams + * @param idempotency_key optional idempotency key + * @returns newly created subnet + */ + createSubnet(node_id: string, bodyParams: { + nickname?: string; + account_class?: string; + bin?: string; + }, idempotency_key?: string | null): Promise>; + /** + * @description `PATCH` call to update subnet details + * @param node_id primary key of node + * @param subnet_id primary key of subnet + * @param bodyParams Subnet object properties to update + * @returns updated subnet object + * + * {@link [Update Subnet](https://docs.synapsefi.com/api-references/subnets/update-subnet)} + */ + updateSubnet(node_id: string, subnet_id: string, bodyParams?: Partial): Promise>; + /** + * @description `PATCH` call to update subnet details + * @param node_id primary key of node + * @param subnet_id primary key of subnet + * @param bodyParams Subnet object properties to update + * + * @todo typing + * + * {@link [Push to Wallet](https://docs.synapsefi.com/api-references/subnets/push-to-wallet)} + */ + pushToMobileWallet(node_id: string, subnet_id: string, bodyParams?: any): Promise>; + /** + * @description `POST` call to create a card shipment + * @param node_id Primary Key of node + * @param subnet_id primary key of subnet + * @param bodyParams + * @returns newly created subnet + * + * {@link [Create Shipment](https://docs.synapsefi.com/api-references/shipments/create-shipment)} + */ + shipCard(node_id: string, subnet_id: string, bodyParams?: Partial): Promise>; + /** + * GET ALL CARD SHIPMENTS + * @param {String} node_id required: id of node belonging to the subnet + * @param {String} subnet_id required: id of card subnet for the card shipments + * @param {Object} queryParams optional: body of post request, can contain page and per_page keys indicating the amount of card shipments returned + * + * @returns Promise + * + * + * [Get Card Shipment Docs]{@link https://docs.synapsefi.com/api-references/shipments/view-all-subnet-shipments} + */ + getAllCardShipments(node_id: string, subnet_id: string, queryParams?: IQueryParams): Promise>; + /** + * GET A SINGLE CARD SHIPMENT + * @param {String} node_id required: id of node belonging to the subnet + * @param {String} subnet_id required: id of card subnet for the card shipments + * @param {Object} shipment_id requred: id of card shipment + * + * @returns Promise + * + * + * [Get Card Shipment Docs]{@link https://docs.synapsefi.com/api-references/shipments/view-shipment} + */ + getCardShipment(node_id: string, subnet_id: string, shipment_id: string): Promise>; + /** + * DELETE A SINGLE CARD SHIPMENT + * @param {String} node_id required: id of node belonging to the subnet + * @param {String} subnet_id required: id of card subnet for the card shipments + * @param {Object} shipment_id requred: id of card shipment + * + * @returns Promise + * + * + * [Get Card Shipment Docs]{@link https://docs.synapsefi.com/api-references/shipments/cancel-shipment} + * + * @todo response typing + */ + deleteCardShipment(node_id: string, subnet_id: string, shipment_id: string): Promise>; + /** + * @description triggers new fingerprint registration flow. If you use this call with a registered and active fingerprint, then this will authenticate the user if the refresh token has not expired. + * @param fp device fingerprint sring + * + * {@link [OAuth docs](https://docs.synapsefi.com/api-references/oauth)} + * @todo reponse typing + */ + registerNewFingerprint(fp: string): Promise>; + /** + * @description part of MFA register new fingerprint flow, tells Synapse where to send MFA pin to + * @param fp device fingerprint string + * @param device phone number or email string for 2FA flow + * + * {@link [OAuth docs](https://docs.synapsefi.com/api-references/oauth)} + * @todo reponse typing + */ + supplyDevice2FA(fp: string, device: string): Promise>; + /** + * @description part of fingerprint registration MFA flow - used to verify validation pin sent + * @param fp device fingerprint string + * @param validation_pin validation pin string sent via text or email to 2FA device + * + * {@link [OAuth docs](https://docs.synapsefi.com/api-references/oauth)} + * @todo reponse typing + */ + verifyFingerprint2FA(fp: string, validation_pin: string): Promise>; + /** + * @description updates the IP address in the instatiated users headers property + * @param ip + * @returns updated headers object on instantiated user object + */ + updateIpAddress(ip: string): IHeadersObject; +} +export default User;