mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-01 23:37:43 +03:00
Added new offers endpoint on members API
refs https://github.com/TryGhost/Team/issues/1138 Portal offer urls use offer id to load offer details UI and stripe checkout in frontend. This endpoint allows portal to fetch offer details from offer id to create Portal UI with relevant details for potential members.
This commit is contained in:
parent
b286142a6b
commit
7270baa99c
@ -1,6 +1,7 @@
|
||||
const _ = require('lodash');
|
||||
const logging = require('@tryghost/logging');
|
||||
const membersService = require('./service');
|
||||
const offersService = require('../offers/service');
|
||||
const urlUtils = require('../../../shared/url-utils');
|
||||
const ghostVersion = require('@tryghost/version');
|
||||
const settingsCache = require('../../../shared/settings-cache');
|
||||
@ -58,6 +59,14 @@ const getMemberData = async function (req, res) {
|
||||
}
|
||||
};
|
||||
|
||||
const getOfferData = async function (req, res) {
|
||||
const offerId = req.params.id;
|
||||
const offer = await offersService.api.getOffer({id: offerId});
|
||||
return res.json({
|
||||
offers: [offer]
|
||||
});
|
||||
};
|
||||
|
||||
const updateMemberData = async function (req, res) {
|
||||
try {
|
||||
const data = _.pick(req.body, 'name', 'subscribed');
|
||||
@ -222,6 +231,7 @@ module.exports = {
|
||||
createSessionFromMagicLink,
|
||||
getIdentityToken,
|
||||
getMemberData,
|
||||
getOfferData,
|
||||
updateMemberData,
|
||||
getMemberSiteData,
|
||||
deleteSession,
|
||||
|
@ -37,6 +37,7 @@ module.exports = function setupMembersApp() {
|
||||
membersApp.put('/api/member', bodyParser.json({limit: '1mb'}), middleware.updateMemberData);
|
||||
membersApp.post('/api/member/email', bodyParser.json({limit: '1mb'}), (req, res) => membersService.api.middleware.updateEmailAddress(req, res));
|
||||
membersApp.get('/api/session', middleware.getIdentityToken);
|
||||
membersApp.get('/api/offers/:id', labs.enabledMiddleware('offers'), middleware.getOfferData);
|
||||
membersApp.delete('/api/session', middleware.deleteSession);
|
||||
membersApp.get('/api/site', middleware.getMemberSiteData);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user