From 40fddac43cfe6933b32b62ad6264f65b3d12b6b9 Mon Sep 17 00:00:00 2001 From: Rish Date: Thu, 3 Oct 2019 23:10:42 +0530 Subject: [PATCH] Updated member model to use new subscriptions structure no issue Members API was updated to have new subscription structure, this updates model and its transformation to match it. --- ghost/admin/app/models/member-subscription.js | 15 ++++++++++----- ghost/admin/app/models/member.js | 2 +- ghost/admin/app/transforms/member-subscription.js | 6 ++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ghost/admin/app/models/member-subscription.js b/ghost/admin/app/models/member-subscription.js index 4b83d59b72..9dc53574ae 100644 --- a/ghost/admin/app/models/member-subscription.js +++ b/ghost/admin/app/models/member-subscription.js @@ -1,9 +1,14 @@ import EmberObject from '@ember/object'; export default EmberObject.extend({ - adapter: '', - amount: 0, - plan: '', - status: '', - validUntil: 0 + customer: 'customer_id', + subscription: 'subscription_id', + plan: 'plan_id', + status: 'subscription status', + name: 'plan nickname e.g. "Monthly"', + interval: 'how often plan charges e.g "month", "year"', + amount: 'amount in smallest denomination e.g. cents, so value for 5 dollars would be 500', + currency: 'e.g. usd', + last4: 'last four digits of card OR null', + validUntil: 'epoch timestamp of when current interval ends IN SECONDS' }); diff --git a/ghost/admin/app/models/member.js b/ghost/admin/app/models/member.js index e92f537fa1..094d8564c7 100644 --- a/ghost/admin/app/models/member.js +++ b/ghost/admin/app/models/member.js @@ -5,5 +5,5 @@ export default DS.Model.extend({ name: attr('string'), email: attr('string'), createdAt: attr('moment-utc'), - subscriptions: attr('member-subscription') + stripe: attr('member-subscription') }); diff --git a/ghost/admin/app/transforms/member-subscription.js b/ghost/admin/app/transforms/member-subscription.js index 83b373bee6..ea68575b6f 100644 --- a/ghost/admin/app/transforms/member-subscription.js +++ b/ghost/admin/app/transforms/member-subscription.js @@ -6,7 +6,7 @@ export default Transform.extend({ deserialize(serialized) { let subscriptions, subscriptionArray; - subscriptionArray = serialized || []; + subscriptionArray = serialized.subscriptions || []; subscriptions = subscriptionArray.map(itemDetails => MemberSubscription.create(itemDetails)); @@ -30,6 +30,8 @@ export default Transform.extend({ subscriptionArray = []; } - return subscriptionArray; + return { + subscriptions: subscriptionArray + }; } });