Skip to content

Commit 829abdb

Browse files
committed
{disable,enabled}Subscription() [todo]
1 parent c048a24 commit 829abdb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

index.js

+22
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,26 @@ const createClient = (profile, userAgent, opt = {}) => {
839839
return profile.parseSubscription(ctx, res.details)
840840
}
841841

842+
const _setSubscriptionStatus = async (status, userId, subscriptionId, opt = {}) => {
843+
if (!isNonEmptyString(userId)) {
844+
throw new TypeError('userId must be a non-empty string')
845+
}
846+
if (subscriptionId === null || subscriptionId === undefined) {
847+
throw new TypeError('missing subscriptionId')
848+
}
849+
return await profile.request({profile, opt}, userAgent, {
850+
meth: 'SubscrStatus',
851+
req: {
852+
userId,
853+
subscrId: subscriptionId,
854+
status,
855+
},
856+
})
857+
}
858+
// todo: these fail repeatedly with a 504 Gateway Timeout 🤡
859+
const disableSubscription = _setSubscriptionStatus.bind(null, 'EXPIRED')
860+
const enableSubscription = _setSubscriptionStatus.bind(null, 'ACTIVE')
861+
842862
const subscribeToJourney = async (userId, channelIds, journeyRefreshToken, opt = {}) => {
843863
if (!isNonEmptyString(userId)) {
844864
throw new TypeError('userId must be a non-empty string')
@@ -948,6 +968,8 @@ const createClient = (profile, userAgent, opt = {}) => {
948968
client.createSubscriptionsUser = createSubscriptionsUser
949969
client.subscriptions = subscriptions
950970
client.subscription = subscription
971+
client.disableSubscription = disableSubscription
972+
client.enableSubscription = enableSubscription
951973
client.subscribeToJourney = subscribeToJourney
952974
client.unsubscribe = unsubscribe
953975
}

0 commit comments

Comments
 (0)