From ae4ae1b13a8a03473faf38afc0e098c7f0b95549 Mon Sep 17 00:00:00 2001 From: axshani Date: Sat, 5 Feb 2022 23:41:24 +0200 Subject: [PATCH 1/2] baseCard types --- types/cards.ts | 231 ++++++++++++------------------------------ types/transactions.ts | 2 +- 2 files changed, 65 insertions(+), 168 deletions(-) diff --git a/types/cards.ts b/types/cards.ts index 82deb64d..209b2ab0 100644 --- a/types/cards.ts +++ b/types/cards.ts @@ -1,103 +1,108 @@ -import { Address, FullName, Phone, Relationship } from "./common" +import { Address, FullName, Phone, Relationship, UnimplementedFields } from "./common" export type Card = IndividualDebitCard | BusinessDebitCard | IndividualVirtualDebitCard | BusinessVirtualDebitCard export type cardStatus = "Active" | "Inactive" | "Stolen" | "Lost" | "Frozen" | "ClosedByCustomer" | "SuspectedFraud" +// /** +// * Identifier of the card resource. +// */ +// id: string -export interface IndividualDebitCard { +// /** +// * Type of the card resource. For individual debit card the value is always individualDebitCard. +// */ +// type: "individualDebitCard" | "businessDebitCard" | "individualVirtualDebitCard" | "businessVirtualDebitCard" + +// attributes: { + +export type BaseCard = { /** * Identifier of the card resource. */ id: string /** - * Type of the card resource. For individual debit card the value is always individualDebitCard. + * Type of the card resource. */ - type: "individualDebitCard" + type: string /** * JSON object representing the card 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 - - /** - * Last 4 digits of the debit card. - */ - last4Digits: string + attributes: BaseCardAttributes - /** - * Card expiration date, formatted YYYY-MM, e.g "2020-05". - */ - expirationDate: string + /** + * Describes relationships between the card resource and other resources (account and customer). + */ + relationships: BaseCardRelationships +} - /** - * Optional. Shipping address, if specified. - */ - shippingAddress?: Address +export interface BaseCardAttributes extends UnimplementedFields { + /** + * Date only. The date the resource was created. + * RFC3339 format. For more information: https://en.wikipedia.org/wiki/ISO_8601#RFCs + */ + createdAt: string - /** - * Status of the card, one of: Active, Inactive, Stolen, Lost, Frozen, ClosedByCustomer, SuspectedFraud. - */ - status: cardStatus + /** + * Last 4 digits of the debit card. + */ + last4Digits: string - /** - * Optional. Card design, if specified. - */ - design?: string - } + /** + * Card expiration date, formatted YYYY-MM, e.g "2020-05". + */ + expirationDate: string /** - * Describes relationships between the card resource and other resources (account and customer). + * Status of the card, one of: Active, Inactive, Stolen, Lost, Frozen, ClosedByCustomer, SuspectedFraud. */ - relationships: { - /** - * The account the card belongs to. - */ - account: Relationship + status: cardStatus +} - /** - * The individual or business customer the card belongs to. +export interface BaseCardRelationships extends UnimplementedFields { + /** + * The account the card belongs to. */ - customer: Relationship - } -} + account: Relationship -export interface BusinessDebitCard { /** - * Identifier of the card resource. + * The individual or business customer the card belongs to. */ - id: string + customer: Relationship +} + + +export type IndividualDebitCard = BaseCard & { /** - * Type of the card resource. For Business debit card the value is always businessDebitCard. + * Type of the card resource. For individual debit card the value is always individualDebitCard. */ - type: "businessDebitCard" + type: "individualDebitCard" /** * JSON object representing the card data. */ attributes: { /** - * Date only. The date the resource was created. - * RFC3339 format. For more information: https://en.wikipedia.org/wiki/ISO_8601#RFCs + * Optional. Shipping address, if specified. */ - createdAt: string + shippingAddress?: Address /** - * Last 4 digits of the debit card. + * Optional. Card design, if specified. */ - last4Digits: string + design?: string + } +} - /** - * Card expiration date, formatted YYYY-MM, e.g "2020-05". - */ - expirationDate: string +export type BusinessDebitCard = BaseCard & { + type: "businessDebitCard" + /** + * JSON object representing the card data. + */ + attributes: { /** * Optional. Shipping address, if specified. */ @@ -144,112 +149,24 @@ export interface BusinessDebitCard { */ email: string - /** - * Status of the card, one of: Active, Inactive, Stolen, Lost, Frozen, ClosedByCustomer, SuspectedFraud. - */ - status: cardStatus - /** * Optional. Card design, if specified. */ design?: string } - - /** - * Describes relationships between the card resource and other resources (account and customer). - */ - relationships: { - /** - * Account the card belong to. - */ - account: Relationship - - /** - * Holder of the account. - */ - customer: Relationship - } } -export interface IndividualVirtualDebitCard { - /** - * Identifier of the card resource. - */ - id: string - - /** - * Type of the card resource. For Business debit card the value is always individualVirtualDebitCard. - */ +export type IndividualVirtualDebitCard = BaseCard & { type: "individualVirtualDebitCard" - - /** - * JSON object representing the card 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 - - /** - * Last 4 digits of the debit card. - */ - last4Digits: string - - /** - * Card expiration date, formatted YYYY-MM, e.g "2020-05". - */ - expirationDate: string - - /** - * Status of the card, one of: Active, Inactive, Stolen, Lost, Frozen, ClosedByCustomer, SuspectedFraud. - */ - status: cardStatus - } - - /** - * Describes relationships between the card resource and other resources (account and customer). - */ - relationships: { - /** - * The account the card belongs to. - */ - account: Relationship - - /** - * The individual or business customer the card belongs to. - */ - customer: Relationship - } } -export interface BusinessVirtualDebitCard { - /** - * Identifier of the card resource. - */ - id: string - - /** - * Type of the card resource. For Business debit card the value is always businessVirtualDebitCard. - */ +export type BusinessVirtualDebitCard = BaseCard & { type: "businessVirtualDebitCard" /** * JSON object representing the card 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 - - /** - * Last 4 digits of the debit card. - */ - last4Digits: string - /** * Card expiration date, formatted YYYY-MM, e.g "2020-05". */ @@ -295,26 +212,6 @@ export interface BusinessVirtualDebitCard { * Email address of the card holder. */ email: string - - /** - * Status of the card, one of: Active, Inactive, Stolen, Lost, Frozen, ClosedByCustomer, SuspectedFraud. - */ - status: cardStatus - } - - /** - * Describes relationships between the card resource and other resources (account and customer). - */ - relationships: { - /** - * Account the card belong to. - */ - account: Relationship - - /** - * Holder of the account. - */ - customer: Relationship } } diff --git a/types/transactions.ts b/types/transactions.ts index 91916281..619f36b2 100644 --- a/types/transactions.ts +++ b/types/transactions.ts @@ -6,7 +6,7 @@ export type Transaction = OriginatedAchTransaction | ReceivedAchTransaction | Re export type TransactionDirection = "Credit" | "Debit" -export interface BaseTransaction{ +export interface BaseTransaction { /** * Identifier of the transaction resource. */ From b2f398675b6ea24123c816234874832540c873a3 Mon Sep 17 00:00:00 2001 From: axshani Date: Thu, 24 Feb 2022 20:55:05 +0200 Subject: [PATCH 2/2] added BaseCreateCardRequestAttributes added attributes to cards --- types/cards.ts | 109 ++++++++++++++++++------------------------------- 1 file changed, 40 insertions(+), 69 deletions(-) diff --git a/types/cards.ts b/types/cards.ts index 209b2ab0..1bf02039 100644 --- a/types/cards.ts +++ b/types/cards.ts @@ -217,6 +217,23 @@ export type BusinessVirtualDebitCard = BaseCard & { export type CreateDebitCardRequest = CreateIndividualDebitCardRequest | CreateBusinessDebitCardRequest | CreateIndividualVirtualDebitCardRequest | CreateBusinessVirtualDebitCardRequest +export interface BaseCreateCardRequestAttributes extends UnimplementedFields { + /** + * See [Idempotency](https://developers.unit.co/#intro-idempotency). + */ + idempotencyKey?: string + + /** + * See [Tags](https://developers.unit.co/#tags). + */ + tags?: object + + /** + * Optional. See [Limits](https://docs.unit.co/cards/#card-limits) (cents). + */ + limits?: CardLimits +} + export interface CreateIndividualDebitCardRequest { type: "individualDebitCard" @@ -232,15 +249,15 @@ export interface CreateIndividualDebitCardRequest { design?: string /** - * See [Idempotency](https://developers.unit.co/#intro-idempotency). + * Optional, up to 21 characters. Use for a second cardholder name, company name, or other data to be embossed on a card. */ - idempotencyKey?: string + additionalEmbossedText?: string /** - * See [Tags](https://developers.unit.co/#tags). + * Optional, default is false. Sets the card as Digitally active. */ - tags?: object - } + digitallyActive?: boolean + } & BaseCreateCardRequestAttributes relationships: { /** @@ -254,27 +271,6 @@ export interface CreateBusinessDebitCardRequest { type: "businessDebitCard" attributes: { - /** - * Address to ship the card to. Optional, if not specified, the individual address is used. - */ - shippingAddress?: Address - - /** - * SSN of the card holder (numbers only). Either an SSN or a passport number is required. - */ - ssn?: string - - /** - * Passport number of the card holder. Either an SSN or a passport is required. - */ - passport?: string - - /** - * Required on passport only. Two letters representing the card holder nationality. (e.g. “US”). - * ISO31661 - Alpha2 format. For more information: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 - */ - nationality?: string - /** * Full name of the card holder. */ @@ -284,6 +280,11 @@ export interface CreateBusinessDebitCardRequest { * RFC3339 Date string Date of birth of the card holder (e.g. "2001-08-15"). */ dateOfBirth: string + + /** + * Address to ship the card to. Optional, if not specified, the individual address is used. + */ + shippingAddress?: Address /** * Address of the card holder. @@ -306,15 +307,15 @@ export interface CreateBusinessDebitCardRequest { design?: string /** - * See [Idempotency](https://developers.unit.co/#intro-idempotency). + * Optional, up to 21 characters. Use for a second cardholder name, company name, or other data to be embossed on a card. */ - idempotencyKey?: string + additionalEmbossedText?: string /** - * See [Tags](https://developers.unit.co/#tags). + * Optional, default is false. Sets the card as Digitally active. */ - tags?: object - } + digitallyActive?: boolean + } & BaseCreateCardRequestAttributes relationships: { /** @@ -327,23 +328,19 @@ export interface CreateBusinessDebitCardRequest { export interface CreateIndividualVirtualDebitCardRequest { type: "individualVirtualDebitCard" - attributes: { - /** - * See [Idempotency](https://developers.unit.co/#intro-idempotency). - */ - idempotencyKey?: string - - /** - * See [Tags](https://developers.unit.co/#tags). - */ - tags?: object - } + attributes: BaseCreateCardRequestAttributes relationships: { /** * Link to the account the card belongs to. Holder of the account must be an individual. */ account: Relationship + + /** + * Optional, Link to the customer the card belongs to. Mandatory if the account has more than one customer. + * Holder of the account must be an individual. + */ + customer?: Relationship } } @@ -351,22 +348,6 @@ export interface CreateBusinessVirtualDebitCardRequest { type: "businessVirtualDebitCard" attributes: { - /** - * SSN of the card holder (numbers only). Either an SSN or a passport number is required. - */ - ssn?: string - - /** - * Passport number of the card holder. Either an SSN or a passport is required. - */ - passport?: string - - /** - * Required on passport only. Two letters representing the card holder nationality. (e.g. “US”). - * ISO31661 - Alpha2 format. For more information: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 - */ - nationality?: string - /** * Full name of the card holder. */ @@ -391,17 +372,7 @@ export interface CreateBusinessVirtualDebitCardRequest { * Email address of the card holder. */ email: string - - /** - * See [Idempotency](https://developers.unit.co/#intro-idempotency). - */ - idempotencyKey?: string - - /** - * See [Tags](https://developers.unit.co/#tags). - */ - tags?: object - } + } & BaseCreateCardRequestAttributes relationships: { /**