From b865d002a918f82783c3117e615d322cbc13ac2d Mon Sep 17 00:00:00 2001 From: Rish Date: Wed, 20 May 2020 00:01:09 +0530 Subject: [PATCH] Added update subscription API refs https://github.com/TryGhost/members.js/issues/20 - Adds update subscription api for member - API allows updating plan for a particular subscription for logged-in member --- ghost/portal/src/utils/api.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ghost/portal/src/utils/api.js b/ghost/portal/src/utils/api.js index f28f6d89de..afa5adc6fa 100644 --- a/ghost/portal/src/utils/api.js +++ b/ghost/portal/src/utils/api.js @@ -170,6 +170,21 @@ function setupGhostApi() { }).catch(function (err) { throw err; }); + }, + async updateSubscription({subscriptionId, planName}) { + const identity = await api.member.identity(); + const url = endpointFor({type: 'members', resource: 'subscriptions'}) + subscriptionId + '/'; + return makeRequest({ + url, + method: 'PUT', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + identity: identity, + planName + }) + }); } };