0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added the product name to member subscriptions

refs https://github.com/TryGhost/Team/issues/1141 da6a43bfcf

- Adds the `member.subscriptions.price.product.name` property to the member read endpoint
This commit is contained in:
Thibaut Patel 2022-03-10 10:10:50 +01:00 committed by Thibaut Patel
parent 3db963c540
commit 49d393c88f
4 changed files with 120 additions and 6 deletions

View file

@ -83,7 +83,7 @@
"@tryghost/logging": "2.0.4",
"@tryghost/magic-link": "1.0.20",
"@tryghost/member-events": "0.4.0",
"@tryghost/members-api": "5.1.1",
"@tryghost/members-api": "5.2.0",
"@tryghost/members-events-service": "0.3.1",
"@tryghost/members-importer": "0.5.3",
"@tryghost/members-offers": "0.10.8",

View file

@ -248,6 +248,83 @@ Object {
}
`;
exports[`Members API Can add a subscription 3: [body] 1`] = `
Object {
"members": Array [
Object {
"avatar_image": null,
"comped": false,
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
"email": "member1@test.com",
"email_count": 0,
"email_open_rate": null,
"email_opened_count": 0,
"geolocation": null,
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
"labels": Any<Array>,
"last_seen_at": null,
"name": "Mr Egg",
"note": null,
"products": Array [],
"status": "paid",
"subscribed": true,
"subscriptions": Array [
Object {
"cancel_at_period_end": false,
"cancellation_reason": null,
"current_period_end": Any<String>,
"customer": Object {
"email": "member1@test.com",
"id": "cus_123",
"name": null,
},
"default_payment_card_last4": null,
"id": "sub_123",
"offer": null,
"plan": Object {
"amount": 5000,
"currency": "USD",
"id": "173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730b12",
"interval": "month",
"nickname": "month",
},
"price": Object {
"amount": 5000,
"currency": "USD",
"id": "173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730b12",
"interval": "month",
"nickname": "Monthly",
"price_id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
"product": Object {
"id": "109c85c734fb9992e7bc30a26af66c22f5c94d8dc62e0a33cb797be902c06b2d",
"name": "Default Product",
"product_id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
},
"type": "recurring",
},
"start_date": Any<String>,
"status": "active",
},
],
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
},
],
}
`;
exports[`Members API Can add a subscription 4: [headers] 1`] = `
Object {
"access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "1391",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding",
"x-powered-by": "Express",
}
`;
exports[`Members API Can add and send a signup confirmation email 1: [body] 1`] = `
Object {
"members": Array [

View file

@ -734,6 +734,33 @@ describe('Members API', function () {
.matchHeaderSnapshot({
etag: anyEtag
});
// Check member read with a subscription
await agent
.get(`/members/${memberId}/`)
.expectStatus(200)
.matchBodySnapshot({
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: [{
start_date: anyString,
current_period_end: anyString,
price: {
price_id: anyObjectId,
product: {
product_id: anyObjectId
}
}
}]
})
})
.matchHeaderSnapshot({
etag: anyEtag
});
});
// Delete a member

View file

@ -2178,10 +2178,10 @@
"@tryghost/domain-events" "^0.1.8"
"@tryghost/member-events" "^0.4.0"
"@tryghost/members-api@5.1.1":
version "5.1.1"
resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-5.1.1.tgz#2d547f0104c46619a3f903a2ca1069eece1c6030"
integrity sha512-2utNMPfz9H7qddaD89PueRCWZx4Rr+v0QjrgLPbmjEZajEXrghETQch25RLkwE8AO1Cll2SNpoWbkMpijT1F4g==
"@tryghost/members-api@5.2.0":
version "5.2.0"
resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-5.2.0.tgz#71be571c8c143da06cb97d74aa522a9ed5fbded4"
integrity sha512-QhOyD3e/Tik/jPlPo/JHz1E+IYuX4t2GA4ThR7p7gzK56or8nacPwiBiJjxRNHDWLCso1J4Yu/x3A4t1AxlBtA==
dependencies:
"@nexes/nql" "^0.6.0"
"@tryghost/debug" "^0.1.2"
@ -2193,7 +2193,7 @@
"@tryghost/member-events" "^0.4.0"
"@tryghost/members-analytics-ingress" "^0.1.11"
"@tryghost/members-payments" "^0.1.10"
"@tryghost/members-stripe-service" "^0.8.4"
"@tryghost/members-stripe-service" "^0.9.0"
"@tryghost/tpl" "^0.1.2"
"@types/jsonwebtoken" "^8.5.1"
bluebird "^3.5.4"
@ -2285,6 +2285,16 @@
leaky-bucket "^2.2.0"
stripe "^8.174.0"
"@tryghost/members-stripe-service@^0.9.0":
version "0.9.0"
resolved "https://registry.yarnpkg.com/@tryghost/members-stripe-service/-/members-stripe-service-0.9.0.tgz#f70ffa3afbd9903f7af8819dcb30eee0a3303c0c"
integrity sha512-sSkYV5Uq2/daAx6+rzxECIARuucfzpYgXQsfpbXEvObMyldslctEiVIo9n/aO7nCB7a9YjdE/75REr/GbLQqdg==
dependencies:
"@tryghost/debug" "^0.1.4"
"@tryghost/errors" "1.2.4"
leaky-bucket "^2.2.0"
stripe "^8.174.0"
"@tryghost/metrics@1.0.6":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@tryghost/metrics/-/metrics-1.0.6.tgz#e01279f7d0a085bf967c40b66006479aa80708b8"