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.
This commit is contained in:
Rish 2019-10-03 23:10:42 +05:30
parent 06e6e15cc5
commit 40fddac43c
3 changed files with 15 additions and 8 deletions

View File

@ -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'
});

View File

@ -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')
});

View File

@ -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
};
}
});