From 420680729d2fddd62d0e8b5d85b179b1a1687417 Mon Sep 17 00:00:00 2001 From: Michael Ossig Date: Fri, 16 May 2025 12:52:14 -0400 Subject: [PATCH] allows for either string or enroll payload when creating subscriptions --- package-lock.json | 4 ++-- package.json | 2 +- src/resources/Entity/Subscriptions.ts | 7 ++++++- test/resources/Entity.tests.ts | 8 ++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9157990..ed8b3fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "method-node", - "version": "1.1.14", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "method-node", - "version": "1.1.14", + "version": "1.2.0", "license": "ISC", "dependencies": { "axios": "^1.7.4", diff --git a/package.json b/package.json index 1aade2e..7b2ae0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "method-node", - "version": "1.1.14", + "version": "1.2.0", "description": "Node.js library for the Method API", "main": "dist/index.ts", "module": "dist/index.mjs", diff --git a/src/resources/Entity/Subscriptions.ts b/src/resources/Entity/Subscriptions.ts index dfc7b82..d98016c 100644 --- a/src/resources/Entity/Subscriptions.ts +++ b/src/resources/Entity/Subscriptions.ts @@ -43,7 +43,12 @@ export default class EntitySubscriptions extends Resource { * @returns Returns a map of Subscription name to either Subscription object or Error. */ - async create(opts: IEntitySubscriptionCreateOpts, requestConfig?: IRequestConfig) { + async create(opts: IEntitySubscriptionCreateOpts | TEntitySubscriptionNames, requestConfig?: IRequestConfig) { + if (typeof opts === 'string') { + opts = { + enroll: opts as TEntitySubscriptionNames, + }; + } return super._create, IEntitySubscriptionCreateOpts>(opts, requestConfig); } diff --git a/test/resources/Entity.tests.ts b/test/resources/Entity.tests.ts index 51f537a..f2c2664 100644 --- a/test/resources/Entity.tests.ts +++ b/test/resources/Entity.tests.ts @@ -966,9 +966,7 @@ describe('Entities - core methods tests', () => { it('should create a connect subscription for an entity', async () => { entities_create_connect_subscription_response = await client .entities(entities_create_response.id) - .subscriptions.create({ - enroll: 'connect' - }); + .subscriptions.create('connect'); const expect_connect_results: IEntitySubscription = { id: entities_create_connect_subscription_response.id, @@ -989,9 +987,7 @@ describe('Entities - core methods tests', () => { it('should create a credit_score subscription for an entity', async () => { entities_create_credit_score_subscription_response = await client .entities(entities_create_response.id) - .subscriptions.create({ - enroll: 'credit_score' - }); + .subscriptions.create('credit_score'); const expect_credit_score_results: IEntitySubscription = { id: entities_create_credit_score_subscription_response.id,