mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 19:48:50 +03:00
a47b61c1d4
refs https://github.com/TryGhost/Team/issues/1141 Showing canceled subscriptions provide a more complete picture of the activity of a member. - Given there is no `member.product` object when a subscription is canceled, use the `member.subscriptions.price.product` objects instead of `member.products`. - applied boy-scout rule for linter errors and and code formatting - removed `multipleTiers` flag conditionals as it's now GA - set up subscriptions as a separate mirage resource so they are easier to work with - updated `PUT /members/:id/` endpoint to match real API's complimentary subscription behaviour - modified mirage member serializer to match API output Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk> Co-authored-by: Peter Zimon <peter.zimon@gmail.com>
28 lines
741 B
JavaScript
28 lines
741 B
JavaScript
import BaseSerializer from './application';
|
|
import {underscore} from '@ember/string';
|
|
|
|
export default BaseSerializer.extend({
|
|
embed: true,
|
|
|
|
include(/*request*/) {
|
|
let includes = [];
|
|
|
|
includes.push('product');
|
|
|
|
return includes;
|
|
},
|
|
|
|
keyForEmbeddedRelationship(relationshipName) {
|
|
if (relationshipName === 'product') {
|
|
return 'tier';
|
|
}
|
|
|
|
return underscore(relationshipName);
|
|
}
|
|
|
|
// NOTE: serialize() is not called for embedded records, serialization happens
|
|
// on the primary resource, in this case `member`
|
|
// TODO: extract subscription serialization and call it here too if we start
|
|
// to treat subscriptions as their own non-embedded resource
|
|
});
|