@@ -839,6 +839,26 @@ const createClient = (profile, userAgent, opt = {}) => {
839
839
return profile . parseSubscription ( ctx , res . details )
840
840
}
841
841
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
+
842
862
const subscribeToJourney = async ( userId , channelIds , journeyRefreshToken , opt = { } ) => {
843
863
if ( ! isNonEmptyString ( userId ) ) {
844
864
throw new TypeError ( 'userId must be a non-empty string' )
@@ -948,6 +968,8 @@ const createClient = (profile, userAgent, opt = {}) => {
948
968
client . createSubscriptionsUser = createSubscriptionsUser
949
969
client . subscriptions = subscriptions
950
970
client . subscription = subscription
971
+ client . disableSubscription = disableSubscription
972
+ client . enableSubscription = enableSubscription
951
973
client . subscribeToJourney = subscribeToJourney
952
974
client . unsubscribe = unsubscribe
953
975
}
0 commit comments