Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "method-node",
"version": "1.1.7",
"version": "1.1.8",
"description": "Node.js library for the Method API",
"main": "dist/index.ts",
"module": "dist/index.mjs",
Expand Down
40 changes: 40 additions & 0 deletions src/resources/Account/Attributes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Resource, { IResourceListOpts } from '../../resource';
import Configuration, { IResponse } from '../../configuration';
import type { IAccountAttributes } from './types';

export default class AccountAttributes extends Resource {
constructor(config: Configuration) {
super(config.addPath('attributes'));
}

/**
* Retrieves an Attributes record for an Account.
*
* @param acc_attr_id ID of the Attribute
* @returns Returns an Account’s Attribute object.
*/

async retrieve(acc_attr_id: string) {
return super._getWithId<IResponse<IAccountAttributes>>(acc_attr_id);
}

/**
* Retrieves a list of Attributes objects for an account.
*
* @returns Returns a list of Attributes objects.
*/

async list(opts?: IResourceListOpts) {
return super._list<IResponse<IAccountAttributes>>(opts);
}

/**
* Creates a new Attributes request to retrieve the Account’s attributes.
*
* @returns Returns an Account’s Attributes object.
*/

async create() {
return super._create<IResponse<IAccountAttributes>, {}>({});
}
};
30 changes: 30 additions & 0 deletions src/resources/Account/Products.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Resource from '../../resource';
import Configuration, { IResponse } from '../../configuration';
import type { IAccountProduct, IAccountProductListResponse } from './types';

export default class AccountProducts extends Resource {
constructor(config: Configuration) {
super(config.addPath('products'));
}

/**
* Retrieve an account's product.
*
* @param prd_id ID of the product.
* @returns Returns a Product object.
*/

async retrieve(prd_id: string) {
return super._getWithId<IResponse<IAccountProduct>>(prd_id);
}

/**
* Retrieve an account's product list.
*
* @returns Returns a map of Product names to Product objects for an Account.
*/

async list() {
return super._get<IResponse<IAccountProductListResponse>>();
}
};
6 changes: 6 additions & 0 deletions src/resources/Account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import Configuration, { IResponse } from '../../configuration';
import AccountCardBrand from './CardBrands';
import AccountPayoffs from './Payoffs';
import AccountUpdates from './Updates';
import AccountAttributes from './Attributes';
import AccountBalances from './Balances';
import AccountSensitive from './Sensitive';
import AccountTransactions from './Transactions';
import AccountSubscriptions from './Subscriptions';
import AccountVerificationSession from './VerificationSessions';
import AccountProducts from './Products';
import type {
IAccount,
IAccountListOpts,
Expand All @@ -23,8 +25,10 @@ export class AccountSubResources {
payoffs: AccountPayoffs;
sensitive: AccountSensitive;
subscriptions: AccountSubscriptions;
products: AccountProducts;
transactions: AccountTransactions;
updates: AccountUpdates;
attributes: AccountAttributes;
verificationSessions: AccountVerificationSession;

constructor(acc_id: string, config: Configuration) {
Expand All @@ -33,8 +37,10 @@ export class AccountSubResources {
this.payoffs = new AccountPayoffs(config.addPath(acc_id));
this.sensitive = new AccountSensitive(config.addPath(acc_id));
this.subscriptions = new AccountSubscriptions(config.addPath(acc_id));
this.products = new AccountProducts(config.addPath(acc_id));
this.transactions = new AccountTransactions(config.addPath(acc_id));
this.updates = new AccountUpdates(config.addPath(acc_id));
this.attributes = new AccountAttributes(config.addPath(acc_id));
this.verificationSessions = new AccountVerificationSession(config.addPath(acc_id));
}
};
Expand Down
60 changes: 60 additions & 0 deletions src/resources/Account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,42 @@ export const AccountProducts = {
card_brand: 'card_brand',
payoff: 'payoff',
update: 'update',
attribute: 'attribute',
transactions: 'transactions',
} as const;

export type TAccountProducts = keyof typeof AccountProducts;

export const AccountProductStatuses = {
unavailable: 'unavailable',
available: 'available',
restricted: 'restricted',
} as const;

export type TAccountProductStatuses = keyof typeof AccountProductStatuses;

export interface IAccountProduct {
id: string;
name: string;
status: TAccountProductStatuses;
status_error: IResourceError | null;
latest_request_id: string | null;
is_subscribable: boolean;
created_at: string;
updated_at: string;
};

export interface IAccountProductListResponse {
payment?: IAccountProduct;
balance?: IAccountProduct;
sensitive?: IAccountProduct;
card_brand?: IAccountProduct;
payoff?: IAccountProduct;
update?: IAccountProduct;
attribute?: IAccountProduct;
transactions?: IAccountProduct;
};

export const AccountSubscriptionTypes = {
transactions: 'transactions',
update: 'update',
Expand Down Expand Up @@ -597,6 +629,33 @@ export interface IAccountWithdrawConsentOpts {
reason: 'holder_withdrew_consent' | null;
};

export const AccountAttributeNames = {
usage_pattern: 'usage_pattern',
account_standing: 'account_standing',
delinquent_period: 'delinquent_period',
delinquent_outcome: 'delinquent_outcome',
delinquent_amount: 'delinquent_amount',
utilization: 'utilization',
};

export type TAccountAttributeNames = keyof typeof AccountAttributeNames;

export type TAccountAttributes = {
[K in TAccountAttributeNames]: {
value: any | null;
}
};

export interface IAccountAttributes {
id: string;
account_id: string;
status: TResourceStatus;
attributes: TAccountAttributes | null;
error: IResourceError | null;
created_at: string;
updated_at: string;
}

export interface IAccount {
id: string;
holder_id: string;
Expand All @@ -615,6 +674,7 @@ export interface IAccount {
payoff?: string | IAccountPayoff | null;
transactions?: string | IAccountTransaction[] | null;
update?: string | IAccountUpdate | null;
attribute?: string | IAccountAttributes | null;
latest_verification_session?: string | IAccountVerificationSession | null;
error: IResourceError | null;
created_at: string;
Expand Down
Loading