diff --git a/package-lock.json b/package-lock.json index 5a54bfac..782c71c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,16 @@ { "name": "@unit-finance/unit-node-sdk", - "version": "0.8.10", + "version": "0.8.15", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@unit-finance/unit-node-sdk", - "version": "0.8.10", + "version": "0.8.15", "license": "MPLv2", "dependencies": { - "axios": "^0.21.2" + "axios": "^0.21.2", + "crypto": "^1.0.1" }, "devDependencies": { "@types/node": "^15.0.2", @@ -479,6 +480,12 @@ "node": ">= 8" } }, + "node_modules/crypto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz", + "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==", + "deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in." + }, "node_modules/debug": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", @@ -1903,6 +1910,11 @@ "which": "^2.0.1" } }, + "crypto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz", + "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==" + }, "debug": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", diff --git a/package.json b/package.json index 1308d176..b5f3bfee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@unit-finance/unit-node-sdk", - "version": "0.8.10", + "version": "0.8.15", "description": "", "main": "dist/unit.js", "types": "dist/unit.d.ts", @@ -29,6 +29,7 @@ "typescript": "^4.2.4" }, "dependencies": { - "axios": "^0.21.2" + "axios": "^0.21.2", + "crypto": "^1.0.1" } } diff --git a/resources/account.ts b/resources/account.ts index 06e63510..7de792e1 100644 --- a/resources/account.ts +++ b/resources/account.ts @@ -1,6 +1,6 @@ import { Include, UnitResponse, UnitConfig } from "../types/common" import { Customer } from "../types/customer" -import { CreateAccountRequest, Account, PatchAccountRequest, AccountLimits } from "../types/account" +import { CreateAccountRequest, Account, PatchAccountRequest, AccountLimits, AccountDepositProduct, CloseAccountRequest } from "../types/account" import { BaseResource } from "./baseResource" export class Accounts extends BaseResource { @@ -13,8 +13,8 @@ export class Accounts extends BaseResource { return this.httpPost>("", { data: request }) } - public async closeAccount(accountId: string): Promise> { - return this.httpPost>(`/${accountId}/close`) + public async closeAccount(request: CloseAccountRequest): Promise> { + return this.httpPost>(`/${request.accountId}/close`, request.to_json()) } public async reopenAccount(accountId: string): Promise> { @@ -42,13 +42,17 @@ export class Accounts extends BaseResource { return this.httpGet & Include>("", { params: parameters }) } - public async update(request: PatchAccountRequest) : Promise> { - return this.httpPatch>(`/${request.accountId}`,{data: request.data}) + public async update(request: PatchAccountRequest): Promise> { + return this.httpPatch>(`/${request.accountId}`, { data: request.data }) } - public async limits(accountId: string) : Promise> { + public async limits(accountId: string): Promise> { return this.httpGet>(`/${accountId}/limits`) } + + public async getAvailableDepositProducts(accountId: string): Promise> { + return this.httpGet>(`/${accountId}/deposit-products`) + } } export interface AccountListParams { diff --git a/resources/atmLocations.ts b/resources/atmLocations.ts new file mode 100644 index 00000000..d6d0312e --- /dev/null +++ b/resources/atmLocations.ts @@ -0,0 +1,28 @@ +import { AtmLocation } from "../types/atmLocation" +import { UnitResponse, UnitConfig, Coordinates, Address } from "../types/common" +import { BaseResource } from "./baseResource" + +export class AtmLocations extends BaseResource { + + constructor(token: string, basePath: string, config?: UnitConfig) { + super(token, basePath + "/atm-locations", config) + } + + public async list(params?: AtmLocationListParams): Promise> { + const parameters = { + ...(params?.coordinates && { "filter[coordinates]": params.coordinates }), + ...(params?.address && { "filter[address]": params.address }), + ...(params?.postalCode && { "filter[postalCode]": params.postalCode }), + ...(params?.searchRadius && { "filter[searchRadius]": params.searchRadius }) + } + + return this.httpGet>("", { params: parameters }) + } +} + +export interface AtmLocationListParams { + coordinates?: Coordinates + address?: Address + postalCode?: string + searchRadius?: number +} \ No newline at end of file diff --git a/resources/billPays.ts b/resources/billPays.ts new file mode 100644 index 00000000..7d288520 --- /dev/null +++ b/resources/billPays.ts @@ -0,0 +1,14 @@ +import { Biller, GetBillerParams } from "../types/billPay" +import { UnitConfig, UnitResponse } from "../types/common" +import { BaseResource } from "./baseResource" + +export class BillPays extends BaseResource { + + constructor(token: string, basePath: string, config?: UnitConfig) { + super(token, basePath + "/payments/billpay/billers", config) + } + + public async get(params: GetBillerParams): Promise> { + return await this.httpGet>("", {params: params}) + } +} \ No newline at end of file diff --git a/resources/cards.ts b/resources/cards.ts index ba73061b..e4d730b2 100644 --- a/resources/cards.ts +++ b/resources/cards.ts @@ -1,4 +1,4 @@ -import { Card, CreateDebitCardRequest, ReplaceCardRequest } from "../types/cards" +import { Card, CardLimits, CreateDebitCardRequest, PinStatus, ReplaceCardRequest } from "../types/cards" import { Include, UnitConfig, UnitResponse } from "../types/common" import { Customer } from "../types/customer" import { Account } from "../types/account" @@ -14,33 +14,28 @@ export class Cards extends BaseResource { return await this.httpPost>("", { data: request }) } - public async reportStolen(id: number): Promise> { + public async reportStolen(id: string): Promise> { const path = `/${id}/report-stolen` return await this.httpPost>(path) } public async reportLost(id: string): Promise> { - const path = `/${id}/report-lost` - return await this.httpPost>(path) + return await this.httpPost>(`/${id}/report-lost`) } public async closeCard(id: string): Promise> { - const path = `/${id}/close` - return await this.httpPost>(path) + return await this.httpPost>(`/${id}/close`) } public async freeze(id: string): Promise> { - const path = `/${id}/freeze` - return await this.httpPost>(path) + return await this.httpPost>(`/${id}/freeze`) } public async unfreeze(id: string): Promise> { - const path = `/${id}/unfreeze` - return await this.httpPost>(path) + return await this.httpPost>(`/${id}/unfreeze`) } public async replace(request: ReplaceCardRequest): Promise> { - const path = `/${request.id}/replace` const data = { type: "replaceCard", attributes: { @@ -48,7 +43,7 @@ export class Cards extends BaseResource { } } - return await this.httpPost>(path, { data }) + return await this.httpPost>(`/${request.id}/replace`, { data }) } /** @@ -57,9 +52,7 @@ export class Cards extends BaseResource { * Related resources include: customer, account. See [Getting Related Resources](https://developers.unit.co/#intro-getting-related-resources). */ public async get(id: string, include = ""): Promise> { - const path = `/${id}?include=${include}` - - return await this.httpGet & Include>(path) + return await this.httpGet & Include>(`/${id}?include=${include}`) } public async list(params?: CardListParams): Promise & Include> { @@ -73,6 +66,16 @@ export class Cards extends BaseResource { return this.httpGet & Include>("", { params: parameters }) } + + public async getPinStatus(id: string): Promise> { + const path = `/${id}/secure-data/pin/status` + + return await this.httpGet>(path) + } + + public async limits(id: string) : Promise> { + return this.httpGet>(`/${id}/limits`) + } } export interface CardListParams { diff --git a/resources/counterparty.ts b/resources/counterparty.ts index 86a6b0f5..378ebbda 100644 --- a/resources/counterparty.ts +++ b/resources/counterparty.ts @@ -1,5 +1,5 @@ import { UnitConfig, UnitResponse } from "../types/common" -import { AchCounterparty, CreateCounterpartyRequest, PatchCounterpartyRequest } from "../types/counterparty" +import { AchCounterparty, CounterpartyBalance, CreateCounterpartyRequest, PatchCounterpartyRequest } from "../types/counterparty" import { BaseResource } from "./baseResource" export class Counterparties extends BaseResource { @@ -33,6 +33,10 @@ export class Counterparties extends BaseResource { public async update(id: string, request: PatchCounterpartyRequest): Promise> { return this.httpPatch>>(`/${id}`, { data: request }) } + + public async getBalance(id: string): Promise> { + return this.httpGet>>(`/${id}/balance`) + } } export interface CounterpartyListParams { diff --git a/resources/index.ts b/resources/index.ts index 95d701e8..63460490 100644 --- a/resources/index.ts +++ b/resources/index.ts @@ -16,4 +16,5 @@ export * from "./returns" export * from "./statements" export * from "./transactions" export * from "./webhooks" +export * from "./billPays" diff --git a/resources/institutions.ts b/resources/institutions.ts new file mode 100644 index 00000000..b43ce09e --- /dev/null +++ b/resources/institutions.ts @@ -0,0 +1,14 @@ +import { UnitResponse, UnitConfig } from "../types/common" +import { Institution } from "../types/institution" +import { BaseResource } from "./baseResource" + +export class Institutions extends BaseResource { + + constructor(token: string, basePath: string, config?: UnitConfig) { + super(token, basePath + "/institutions", config) + } + + public async get(routingNumber: string): Promise> { + return this.httpGet>(`/${routingNumber}`) + } +} \ No newline at end of file diff --git a/resources/payments.ts b/resources/payments.ts index 9a897256..892e5c2a 100644 --- a/resources/payments.ts +++ b/resources/payments.ts @@ -1,7 +1,7 @@ import { Account } from "../types/account" import { Include, UnitConfig, UnitResponse } from "../types/common" import { Customer } from "../types/customer" -import { AchPayment, CreatePaymentRequest, PatchPaymentRequest, Payment } from "../types/payments" +import { CreatePaymentRequest, PatchPaymentRequest, Payment } from "../types/payments" import { Transaction } from "../types/transactions" import { BaseResource } from "./baseResource" @@ -10,8 +10,8 @@ export class Payments extends BaseResource { super(token, basePath + "/payments", config) } - public async create(request: CreatePaymentRequest) : Promise> { - return this.httpPost>("",{data: request}) + public async create(request: CreatePaymentRequest) : Promise> { + return this.httpPost>("",{data: request}) } public async update(id: string, request: PatchPaymentRequest) : Promise> { @@ -22,12 +22,12 @@ export class Payments extends BaseResource { * Optional. A comma-separated list of related resources to include in the response. * Related resources include: customer, account, transaction. See Getting Related Resources */ - public async get(id: string, include?: string) : Promise>> { + public async get(id: string, include?: string) : Promise>> { const params = {include : include ? `include=${include}` : ""} - return this.httpGet>>(`/${id}`,{params}) + return this.httpGet>>(`/${id}`,{params}) } - public async list(params?: PaymentListParams) : Promise>> { + public async list(params?: PaymentListParams) : Promise>> { const parameters = { "page[limit]": (params?.limit ? params.limit : 100), "page[offset]": (params?.offset ? params.offset : 0), @@ -38,7 +38,7 @@ export class Payments extends BaseResource { "include": params?.include ? params.include : "" } - return this.httpGet>>("", {params: parameters}) + return this.httpGet>>("", {params: parameters}) } } diff --git a/resources/webhooks.ts b/resources/webhooks.ts index 104bb252..6065682a 100644 --- a/resources/webhooks.ts +++ b/resources/webhooks.ts @@ -1,6 +1,7 @@ import { UnitConfig, UnitResponse } from "../types/common" import { CreateWebhookRequest, PatchWebhookRequest, Webhook } from "../types/webhooks" import { BaseResource } from "./baseResource" +import crypto from "crypto" export class Webhooks extends BaseResource { constructor(token: string, basePath: string, config?: UnitConfig) { @@ -35,6 +36,12 @@ export class Webhooks extends BaseResource { public async disable(id: string): Promise> { return this.httpPost>(`/${id}/disable`) } + + public verify(signature: string, secret: string, payload: any) { + const hmac = crypto.createHmac("sha1", secret) + hmac.update(JSON.stringify(payload)) + return hmac.digest("base64") == signature + } } export interface WebhookListParams { diff --git a/types/account.ts b/types/account.ts index c16cdb69..c4ecaf9d 100644 --- a/types/account.ts +++ b/types/account.ts @@ -119,9 +119,16 @@ export interface CreateDepositAccountRequest { */ relationships: { /** - * The customer. + * The customer the deposit account belongs to. The customer is either a business or an individual. + * You must provide exactly one of customer or customers */ - customer: Relationship + customer?: Relationship + + /** + * The list of customers the deposit account belongs to. Each of the customers is an individual customer and at least one must be over 18 years old. + * You must provide exactly one of customer or customers + */ + customers?: Relationship[] } } export interface CreateBatchAccountRequest { @@ -203,7 +210,8 @@ export interface PatchDepositAccountRequest { data: { type: "depositAccount" attributes: { - tags: object + tags?: object + depositProduct?: string } } } @@ -222,4 +230,36 @@ export interface BatchAccount { relationships: { org: Relationship } -} \ No newline at end of file +} + +export interface AccountDepositProduct { + type: "accountDepositProduct" + attributes: { + name: string + } +} + +type CloseReason = "ByCustomer" | "Fraud" + +export class CloseAccountRequest { + public accountId: string + public reason: CloseReason + + constructor(accountId: string, reason: CloseReason = "ByCustomer") { + this.accountId = accountId + this.reason = reason + } + + public to_json(): any { + const data: any = { + "data": { + "type": "accountClose", + "attributes": { + "reason": this.reason + } + } + } + + return data + } +} diff --git a/types/application.ts b/types/application.ts index ed0fa9c5..0fa7897c 100644 --- a/types/application.ts +++ b/types/application.ts @@ -1,4 +1,4 @@ -import { Address, BeneficialOwner, BusinessContact, FullName, Officer, Phone, State, Relationship } from "./common" +import { Address, BeneficialOwner, BusinessContact, FullName, Officer, Phone, State, Relationship, DeviceFingerprint } from "./common" export type ApplicationStatus = "AwaitingDocuments" | //Certain documents are required for the process to continue. You may upload them via Upload Document. @@ -39,6 +39,11 @@ export interface BaseApplication { * Optional. The created Customer in case of approved application. */ customer?: Relationship + + /** + * Optional. The Application Form used to create the application. + */ + applicationForm?: Relationship } } @@ -380,6 +385,11 @@ export interface CreateIndividualApplicationRequest { * See [Idempotency.](https://developers.unit.co/#intro-idempotency) */ idempotencyKey?: string + + /** + * Optional. A list of device fingerprints for fraud and risk prevention [See Device Fingerprints](https://developers.unit.co/applications/#device-fingerprints). + */ + deviceFingerprints?: DeviceFingerprint[] } } @@ -456,6 +466,11 @@ export interface CreateBusinessApplicationRequest { * See [Idempotency.](https://developers.unit.co/#intro-idempotency) */ idempotencyKey?: string + + /** + * Optional. A list of device fingerprints for fraud and risk prevention [See Device Fingerprints](https://developers.unit.co/applications/#device-fingerprints). + */ + deviceFingerprints?: DeviceFingerprint[] } } @@ -465,4 +480,4 @@ export interface UploadDocumentRequest { isBackSide?: boolean file: Buffer fileType: "jpeg" | "png" | "pdf" -} +} \ No newline at end of file diff --git a/types/applicationForm.ts b/types/applicationForm.ts index b815dd58..9fe1cf47 100644 --- a/types/applicationForm.ts +++ b/types/applicationForm.ts @@ -26,14 +26,14 @@ export interface CreateApplicationFormRequest { * Optional. Array of Individual, Business or SoleProprietorship. Restrict the available application type for this specific application. */ allowedApplicationTypes?: Array<"Individual" | "SoleProprietorship" | "Business"> - }, + } relationships?: { /** * See [Create an Application Form from an existing Application](https://developers.unit.co/application-forms/#create-an-application-form-from-an-existing-application) */ application?: { data: { - type: "application", + type: "application" id: string } } diff --git a/types/atmLocation.ts b/types/atmLocation.ts new file mode 100644 index 00000000..1aaac537 --- /dev/null +++ b/types/atmLocation.ts @@ -0,0 +1,48 @@ +import { Coordinates } from "." + +export interface AtmLocation { + /** + * Type of the ATM location resource. The value is always atmLocation. + */ + type: "atmLocation" + + /** + * JSON object representing the ATM location data. + */ + attributes: { + /** + * Name of the ATM network. + */ + network: string + + /** + * Name of the ATM's location. + */ + locationName: string + + /** + * Coordinates (latitude, longitude) of the ATM. + */ + coordinates: Coordinates + + /** + * Address of the ATM. + */ + address: string + + /** + * Distance to the ATM (in miles). + */ + distance: number + + /** + * Indicates if the ATM is surcharge free. + */ + surchargeFree: boolean + + /** + * Indicates if the ATM accepts deposits. + */ + acceptDeposits: boolean + } +} \ No newline at end of file diff --git a/types/billPay.ts b/types/billPay.ts new file mode 100644 index 00000000..e9d8ad00 --- /dev/null +++ b/types/billPay.ts @@ -0,0 +1,38 @@ +export interface Biller { + /** + * Type of the biller resource. The value is always biller. + */ + type: "biller" + + /** + * Identifier of the biller resource. + */ + id: string + + /** + * JSON object representing the biller data. + */ + attributes: { + /** + * Name of the biller. + */ + name: string + + /** + * The category this biller is belong to. + */ + category: string + } +} + +export interface GetBillerParams { + /** + * Optional. Determine the results page number. + */ + page?: number + + /** + * Filter the name of the biller (full or partial). + */ + name: string +} diff --git a/types/cards.ts b/types/cards.ts index 48d2dd84..82deb64d 100644 --- a/types/cards.ts +++ b/types/cards.ts @@ -411,12 +411,12 @@ export interface CreateBusinessDebitCardRequest { /** * See [Idempotency](https://developers.unit.co/#intro-idempotency). */ - idempotencyKey: string + idempotencyKey?: string /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } relationships: { @@ -434,12 +434,12 @@ export interface CreateIndividualVirtualDebitCardRequest { /** * See [Idempotency](https://developers.unit.co/#intro-idempotency). */ - idempotencyKey: string + idempotencyKey?: string /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } relationships: { @@ -498,12 +498,12 @@ export interface CreateBusinessVirtualDebitCardRequest { /** * See [Idempotency](https://developers.unit.co/#intro-idempotency). */ - idempotencyKey: string + idempotencyKey?: string /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } relationships: { @@ -519,4 +519,33 @@ export interface ReplaceCardRequest { shippingAddress?: Address } +export interface PinStatus { + type: "pinStatus" + + attributes: { + status: "Set" | "NotSet" + } +} + +export interface CardLimits { + type: "limits" + attributes: { + limits: { + dailyWithdrawal: number + dailyPurchase: number + monthlyWithdrawal: number + monthlyPurchase: number + } + dailyTotals: { + withdrawals: number + deposits: number + purchases: number + } + monthlyTotals: { + withdrawals: number + deposits: number + purchases: number + } + } +} diff --git a/types/common.ts b/types/common.ts index 24f1d0d8..6eb87e73 100644 --- a/types/common.ts +++ b/types/common.ts @@ -290,6 +290,21 @@ export interface Statement { */ export type Relationship = { data: { type: string; id: string; }; } +/** + * More about [DeviceFingerprint](https://developers.unit.co/types#devicefingerprint) + */ +export interface DeviceFingerprint { + /** + * Provider of the device fingerprint fraud and risk prevention. The value is always iovation + */ + provider: string + + /** + * The device fingerprint blackbox value. + */ + value: string +} + export interface UnitResponse { data: T } diff --git a/types/counterparty.ts b/types/counterparty.ts index 3d1412b0..62b4d6f2 100644 --- a/types/counterparty.ts +++ b/types/counterparty.ts @@ -146,10 +146,52 @@ export interface PatchCounterpartyRequest { * Plaid integration token * See Plaid processor token */ - plaidProcessorToken: string + plaidProcessorToken: string /** * Optional, default to false. Verify the name of the counterparty, if the name verification fails the request will fail with code field set to NameVerificationFailed. */ verifyName?: boolean +} + +export interface CounterpartyBalance { + /** + * Identifier of the Counterparty. + */ + id: string + + /** + * Type of the balance. for counterparty balance the value is always counterpartyBalance. + */ + type: "counterpartyBalance" + + /** + * JSON object representing the counterparty balance resource. + */ + attributes: { + /** + * The current balance amount (in cents) of the counterparty. + */ + balance: number + + /** + * Optional. The available balance amount (in cents) of the counterparty. + */ + available?: number + } + + /** + * Describes relationships between the counterparty balance and the customer and counterparty. + */ + relationships: { + /** + * The customer the counterparty belongs to. + */ + counterparty: Relationship + + /** + * The customer the counterparty belongs to. + */ + customer: Relationship + } } \ No newline at end of file diff --git a/types/index.ts b/types/index.ts index 92ef7bcb..1f8e1873 100644 --- a/types/index.ts +++ b/types/index.ts @@ -15,3 +15,4 @@ export * from "./payments" export * from "./returns" export * from "./transactions" export * from "./webhooks" +export * from "./billPay" diff --git a/types/institution.ts b/types/institution.ts new file mode 100644 index 00000000..1ed92c91 --- /dev/null +++ b/types/institution.ts @@ -0,0 +1,38 @@ +import { Address } from "./common" + +export interface Institution { + /** + * Type of the institution resource. The value is always institution. + */ + type: "institution" + + /** + * JSON object representing the institution data. + */ + attributes: { + /** + * Routing number of the institution. Valid 9-digit ABA routing transit number. + */ + routingNumber: string + + /** + * Name of the institution. + */ + name: string + + /** + * Optional. Address of the institution. + */ + address?: Address + + /** + * Is FedACH participant. + */ + isACHSupported: boolean + + /** + * Is Fedwire participant. + */ + isWireSupported: boolean + } +} \ No newline at end of file diff --git a/types/transactions.ts b/types/transactions.ts index 0258c84d..893fb9dd 100644 --- a/types/transactions.ts +++ b/types/transactions.ts @@ -2,7 +2,7 @@ import { Address, Coordinates, Counterparty, Relationship } from "./common" export type Transaction = OriginatedAchTransaction | ReceivedAchTransaction | ReturnedAchTransaction | ReturnedReceivedAchTransaction | DishonoredAchTransaction | BookTransaction | PurchaseTransaction | AtmTransaction | FeeTransaction | CardReversalTransaction | CardTransaction | WireTransaction | - ReleaseTransaction | AdjustmentTransaction | InterestTransaction | DisputeTransaction + ReleaseTransaction | AdjustmentTransaction | InterestTransaction | DisputeTransaction | CheckDepositTransaction | ReturnedCheckDepositTransaction export interface OriginatedAchTransaction { /** @@ -59,7 +59,7 @@ export interface OriginatedAchTransaction { * See [Tags](https://developers.unit.co/#tags). * Inherited from the payment tags (see [Tag Inheritance](https://developers.unit.co/#tag-inheritance)). */ - tags: object + tags?: object } /** @@ -158,7 +158,7 @@ export interface ReceivedAchTransaction { * See [Tags](https://developers.unit.co/#tags). * Inherited from the payment tags (see [Tag Inheritance](https://developers.unit.co/#tag-inheritance)). */ - tags: object + tags?: object } /** @@ -242,7 +242,7 @@ export interface ReturnedAchTransaction { * See [Tags](https://developers.unit.co/#tags). * Inherited from the payment tags (see [Tag Inheritance](https://developers.unit.co/#tag-inheritance)). */ - tags: object + tags?: object } /** @@ -321,7 +321,7 @@ export interface ReturnedReceivedAchTransaction { * See [Tags](https://developers.unit.co/#tags). * Inherited from the payment tags (see [Tag Inheritance](https://developers.unit.co/#tag-inheritance)). */ - tags: object + tags?: object } /** @@ -420,7 +420,7 @@ export interface DishonoredAchTransaction { * See [Tags](https://developers.unit.co/#tags). * Inherited from the payment tags (see [Tag Inheritance](https://developers.unit.co/#tag-inheritance)). */ - tags: object + tags?: object } /** @@ -481,9 +481,10 @@ export interface BookTransaction { counterparty: Counterparty /** - * The ACH Trace Number. - */ - traceNumber: number + * See [Tags](https://developers.unit.co/#tags). + * Inherited from the payment tags (see [Tag Inheritance](https://developers.unit.co/#tag-inheritance)). + */ + tags?: object } /** @@ -496,9 +497,14 @@ export interface BookTransaction { account: Relationship /** - * The customer the deposit account belongs to. The customer is either a business or a individual. + * The Customer the deposit account belongs to. This relationship is only available if the account belongs to a single customer, business or individual. */ - customer: Relationship + customer?: Relationship + + /** + * The list of Customers the deposit account belongs to. This relationship is only available if the account belongs to multiple individual customers. + */ + customers?: Relationship[] /** * The account of the counterparty. @@ -509,13 +515,12 @@ export interface BookTransaction { * The counterparty customer. */ counterpartyCustomer: Relationship - } - /** - * See [Tags](https://developers.unit.co/#tags). - * Inherited from the payment tags (see [Tag Inheritance](https://developers.unit.co/#tag-inheritance)). - */ - tags: object + /** + * The payment belonging to this transaction + */ + payment: Relationship + } } export interface PurchaseTransaction { @@ -599,10 +604,25 @@ export interface PurchaseTransaction { */ recurring: boolean + /** + * Optional. The interchange share for this transaction. Calculated at the end of each day, see the transaction.updated event. + */ + interchange?: number + + /** + * Indicates whether the transaction was created over an electronic network (primarily the internet). + */ + ecommerce: boolean + + /** + * Indicates whether the card was present when the transaction was created. + */ + cardPresent: boolean + /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } /** @@ -695,7 +715,7 @@ export interface AtmTransaction { /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } /** @@ -763,7 +783,7 @@ export interface FeeTransaction { /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } /** @@ -836,7 +856,7 @@ export interface CardReversalTransaction { /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } /** @@ -909,7 +929,7 @@ export interface CardTransaction { /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } /** @@ -992,7 +1012,7 @@ export interface WireTransaction { /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } /** @@ -1079,7 +1099,7 @@ export interface ReleaseTransaction { /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } /** @@ -1142,7 +1162,7 @@ export interface AdjustmentTransaction { /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } /** @@ -1200,7 +1220,7 @@ export interface InterestTransaction { /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } /** @@ -1268,7 +1288,7 @@ export interface DisputeTransaction { /** * See [Tags](https://developers.unit.co/#tags). */ - tags: object + tags?: object } /** @@ -1285,4 +1305,155 @@ export interface DisputeTransaction { */ customer: Relationship } +} + +export interface CheckDepositTransaction { + /** + * Identifier of the transaction resource. + */ + id: string + + /** + * Type of the transaction resource. The value is always checkDepositTransaction. + */ + type: "checkDepositTransaction" + + /** + * JSON object representing the transaction data. + */ + attributes: { + /** + * Date only. The date the resource was created. + * RFC3339 format. For more information: https://en.wikipedia.org/wiki/ISO_8601#RFCs + */ + createdAt: string + + /** + * The direction in which the funds flow. Common to all transaction types. + */ + direction: "Credit" | "Debit" + + /** + * The amount (cents) of the transaction. Common to all transaction types. + */ + amount: number + + /** + * The account balance (cents) after the transaction. Common to all transaction types. + */ + balance: number + + /** + * Summary of the transaction. Common to all transaction types. + */ + summary: string + + /** + * See [Tags](https://developers.unit.co/#tags). + */ + tags?: object + } + + /** + * Describes relationships between the transaction resource and other resources (account, customer, checkDeposi). + */ + relationships: { + /** + * The Deposit Account of the customer. + */ + account: Relationship + + /** + * The Customer the deposit account belongs to. This relationship is only available if the account belongs to a single customer, business or individual. + */ + customer?: Relationship + + /** + * The list of Customers the deposit account belongs to. This relationship is only available if the account belongs to multiple individual customers. + */ + customers?: Relationship[] + + /** + * The Check Deposit the transaction is related to. + */ + checkDeposit: Relationship + } +} + +export interface ReturnedCheckDepositTransaction { + /** + * Identifier of the transaction resource. + */ + id: string + + /** + * Type of the transaction resource. The value is always returnedCheckDepositTransaction. + */ + type: "returnedCheckDepositTransaction" + + /** + * JSON object representing the transaction data. + */ + attributes: { + /** + * Date only. The date the resource was created. + * RFC3339 format. For more information: https://en.wikipedia.org/wiki/ISO_8601#RFCs + */ + createdAt: string + + /** + * The direction in which the funds flow. Common to all transaction types. + */ + direction: "Credit" | "Debit" + + /** + * The amount (cents) of the transaction. Common to all transaction types. + */ + amount: number + + /** + * The account balance (cents) after the transaction. Common to all transaction types. + */ + balance: number + + /** + * Summary of the transaction. Common to all transaction types. + */ + summary: string + + /** + * The reason for the transaction return. + */ + reason: string + + /** + * See [Tags](https://developers.unit.co/#tags). + */ + tags?: object + } + + /** + * Describes relationships between the transaction resource and other resources (account, customer, checkDeposi). + */ + relationships: { + /** + * The Deposit Account of the customer. + */ + account: Relationship + + /** + * The Customer the deposit account belongs to. This relationship is only available if the account belongs to a single customer, business or individual. + */ + customer?: Relationship + + /** + * The list of Customers the deposit account belongs to. This relationship is only available if the account belongs to multiple individual customers. + */ + customers?: Relationship[] + + /** + * The Check Deposit the transaction is related to. + */ + checkDeposit: Relationship + } } \ No newline at end of file diff --git a/unit.ts b/unit.ts index 9b6b8dd6..9bc5355c 100644 --- a/unit.ts +++ b/unit.ts @@ -18,6 +18,9 @@ import { Statments } from "./resources/statements" import { Returns } from "./resources/returns" import { ApplicationForms } from "./resources/applicationForm" import { AccountsEndOfDay } from "./resources/accountEndOfDay" +import { BillPays } from "./resources" +import { Institutions } from "./resources/institutions" +import { AtmLocations } from "./resources/atmLocations" export class Unit { public applications: Applications @@ -39,6 +42,9 @@ export class Unit { public events: Events public applicationForms: ApplicationForms public returns: Returns + public billPays: BillPays + public institutions: Institutions + public atmLocations: AtmLocations constructor(token: string, basePath: string, config?: UnitConfig) { // remove all trailing slashes from user-provided basePath @@ -62,6 +68,9 @@ export class Unit { this.statements = new Statments(token, basePath, config) this.applicationForms = new ApplicationForms(token, basePath, config) this.returns = new Returns(token, basePath, config) + this.billPays = new BillPays(token, basePath, config) + this.institutions = new Institutions(token, basePath, config) + this.atmLocations = new AtmLocations(token, basePath, config) this.helpers = helpers }