GetReader
GetReader
를 사용하면 게시자가 알려진 PPID가 있는 독자 중 한 명이 구독을 Google에 연결했는지 확인할 수 있습니다. 게시자는 GET
요청을 사용하여 특정 게시물 ID에 속한 PPID를 쿼리합니다.
요청
REST API: GET
요청
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid
클라이언트 라이브러리 (Node.js)
async function getReader(ppid) {
const publicationId = process.env.PUBLICATION_ID;
return await client.publications.readers.get({
name: `publications/${publicationId}/readers/${ppid}`,
});
};
응답
엔드포인트는 연결된 정기 결제의 created_time
가 포함된 JSON 본문이 있는 200을 반환하거나 게시물의 PPID를 찾을 수 없는 경우 오류를 반환합니다. 자세한 내용은 오류 섹션을 참고하세요.
{
"name": "publications/gtech-demo.appspot.com/readers/81112",
"create_time": "2022-04-19T04:53:40+00:00"
}
GetReaderEntitlements
GetReaderEntitlements
를 사용하면 게시자가 이전에 제공한 PPID의 사용 권한을 쿼리할 수 있습니다. 게시자는 GET 요청을 사용하여 PPID 및 게시물 ID를 제공하여 사용 권한을 요청합니다.
요청
REST API: GET
요청
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid/entitlements
클라이언트 라이브러리 (Node.js)
async function getReaderEntitlements(ppid) {
const publicationId = process.env.PUBLICATION_ID;
return await client.publications.readers.getEntitlements({
name: `publications/${publicationId}/readers/${ppid}/entitlements`
});
};
응답
요청이 성공하면 반환 형식은 UpdateReaderEntitlements
PATCH
요청으로 사용 권한을 저장하는 데 사용된 형식과 동일합니다.
{
"name": "publications/dailybugle.com/readers/6789/entitlements",
"entitlements": [
{
"product_id": "dailybugle.com:basic",
"subscription_token": "dnabhdufbwinkjanvejskenfw",
"detail": "This is our basic plan",
"expire_time": "2022-08-19T04:53:40+00:00"
},
{
"product_id": "dailybugle.com:premium",
"subscription_token": "wfwhddgdgnkhngfw",
"detail": "This is our premium plan",
"expire_time": "2022-07-19T04:53:40+00:00"
},
{
"product_id": "dailybugle.com:deluxe",
"subscription_token": "fefcbwinkjanvejfefw",
"detail": "This is our deluxe plan",
"expire_time": "2022-08-20T04:53:40+00:00"
}
]
}
사용 권한이 없지만 연결된 PPID가 있는 사용자의 경우 (예: 만료되어 삭제된 사용 권한) 사용 권한 요청은 표준 사용 권한 객체의 일부로 빈 사용 권한 배열을 반환합니다.
{
"name": "publications/dailybugle.com/readers/6789/entitlements",
"createTime": "2023-02-07T17:38:57.425577Z"
}
UpdateReaderEntitlements
UpdateReaderEntitlements
는 PPID를 기반으로 리더의 사용 권한을 생성하고 업데이트하는 데 사용됩니다.
이 샘플 페이로드는 The Daily Bugle의 세 가지 제품 ID(dailybugle.com:basic
, dailybugle.com:premium
, dailybugle.com:deluxe
)에 대한 PPID 6789
사용 권한을 리더에게 부여합니다. 이후 독자 6789
가 Google 검색 및 디스커버를 위해 Google 표시 경로를 사용하면 '구독 항목' 목록에 이러한 제품 ID로 태그된 dailybugle.com 기사의 관련 결과가 표시됩니다.
요청
REST API: PATCH
요청
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid/entitlements
요청 본문: entitlements
객체에 관한 자세한 내용은 용어집 페이지를 참고하세요.
{
entitlements : [{
product_id: `${publicationId}:basic`,
subscription_token: 'abc1234',
detail: 'This is our basic plan',
expire_time: '2025-10-21T03:05:08.200564Z'
}]
}
클라이언트 라이브러리 (Node.js)
async function updateReaderEntitlements(ppid) {
const publicationId = process.env.PUBLICATION_ID;
const requestBody = {
entitlements : [{
product_id: `${publicationId}:basic`,
subscription_token: 'abc1234',
detail: 'This is our basic plan',
expire_time: '2025-10-21T03:05:08.200564Z'
}]
};
return await client.publications.readers.updateEntitlements({
name: `publications/${publicationId}/readers/${ppid}/entitlements`,
requestBody
});
};
응답
PATCH 작업이 성공하면 저장된 entitlements
객체가 GetReaderEntitlements
와 동일한 형식으로 반환됩니다.
DeleteReader
DeleteReader
를 사용하면 게시자가 연결된 정기 결제를 수동으로 삭제할 수 있습니다.
게시자는 DELETE
요청을 사용하여 삭제할 게시물 ID의 PPID를 제출합니다.
DeleteReader
를 호출하기 전에 먼저 빈 배열({ "entitlements": [] }
)과 함께 UpdateReaderEntitlements
를 사용하여 사용 권한을 삭제하거나 사용 권한이 있는 리더를 삭제해야 하는 경우 선택적 force
매개변수를 true
로 설정해야 합니다.
force
매개변수의 기본값은 false
입니다.
요청
REST API: DELETE
요청
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid?force={boolean}
클라이언트 라이브러리 (Node.js)
async function deleteReader(ppid, forceDelete = false) {
const publicationId = process.env.PUBLICATION_ID;
return await client.publications.readers.delete({
name: `publications/${publicationId}/readers/${ppid}`
force: forceDelete
});
};
응답
삭제가 완료되면 빈 JSON 객체 {}
와 함께 200이 반환됩니다.
{}