Tính năng cập nhật theo thời gian thực cho phép bạn đồng bộ hoá kho hàng ưu đãi với Google. Bạn có thể đẩy các bản cập nhật gia tăng gần như theo thời gian thực. Hệ thống của chúng tôi sẽ biên dịch các thay đổi từ Nguồn cấp dữ liệu + RTU để hiển thị thông tin mới nhất cho người dùng.
Điểm cuối API
Để đẩy hoặc xoá các bản cập nhật theo thời gian thực, hãy sử dụng các điểm cuối API REST sau:
Đẩy theo lô
- Hộp cát:
https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchPush - Sản xuất:
https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchPush
Xoá theo lô
- Hộp cát:
https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchDelete - Sản xuất:
https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchDelete
Để biết thêm thông tin về định nghĩa đối tượng JSON ưu đãi, hãy xem bài viết Ưu đãi. Để biết thêm thông tin chi tiết về các thuộc tính ưu đãi, hãy truy cập vào trang tham khảo về Ưu đãi.
Cách xác thực với API
Để kết nối với API, hãy tham khảo bài viết Xác thực bằng Mapsbooking API.
Các điểm hạn chế
Khi sử dụng API cập nhật theo thời gian thực, hãy lưu ý những điểm hạn chế sau:
- Chỉ protoRecord: API được định cấu hình để chỉ sử dụng
protoRecord(không phảidataRecord). - Hạn mức: Các API này có hạn mức là 1.500 yêu cầu mỗi phút cho mỗi tài khoản đối tác. Mỗi yêu cầu được giới hạn ở mức gửi 1.000 bản ghi để chèn hoặc xoá.
- Các hạn chế về việc liên kết thực thể: Đối với mỗi ưu đãi, đối tác có thể gửi bản cập nhật cho 1 mã nhận dạng thực thể. Nếu bạn muốn cập nhật cùng một ưu đãi trên nhiều mã thực thể, thì đối tác phải gửi 1 bản ghi cho mỗi
entityId.entityIdphải luôn là số ít cho mỗi bản ghi. - Ưu đãi tiện ích bổ sung: Do hạn chế về việc liên kết thực thể, các ưu đãi tiện ích bổ sung là
addOnOfferApplicableToAllEntitieskhông thực sự được hỗ trợ cho bản cập nhật RTU và không thể cập nhật theo cách này (chỉ thông qua nguồn cấp dữ liệu).
Ví dụ:
Ví dụ về cập nhật theo lô
Sau đây là ví dụ về cách đẩy bản cập nhật theo thời gian thực thông qua curl:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token --impersonate-service-account=test@myproject.gserviceaccount.com --scopes=https://www.googleapis.com/auth/mapsbooking)" \
-H "Content-Type: application/json" \
-d '{
"records": [
{
"generationTimestamp": {
"seconds": 100
},
"protoRecord": {
"@type": "type.googleapis.com/madden.ingestion.offer.Offer",
"offerId": "1",
"entityIds": [
"1234567890"
],
"addOnOfferApplicableToAllEntities": false,
"offerSource": "OFFER_SOURCE_AGGREGATOR",
"actionType": "ACTION_TYPE_FOOD_DELIVERY",
"offerModes": [
"OFFER_MODE_WALK_IN"
],
"offerCategory": "OFFER_CATEGORY_BASE_OFFER",
"tags": [
"OFFER_TAG_NEW_YEAR_SPECIAL"
],
"offerDetails": {
"offerDisplayText": "FLAT 10% off",
"offerSummaryText": "MONDAY TO FRIDAY",
"discountPercent": 10
},
"offerRestrictions": {
"combinableWithOtherOffers": true,
"inclusions": [
{
"description": "complementary drink"
},
{
"description": " starters"
}
],
"exclusions": [
{
"description": "taxes and Tips"
}
]
},
"validityPeriods": [
{
"timeOfDay": {
"timeWindows": [
{
"openTime": {
"hours": 10
},
"closeTime": {
"hours": 20
}
}
]
},
"validPeriod": {
"validFromTime": {
"seconds": 10
}
}
}
],
"offerUrl": "https://www.google.com/offer"
}
}
]
}' \
https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/20000123/feeds/google.offer/record:batchPush
Ví dụ về xoá theo lô
Sau đây là ví dụ về cách xoá một ưu đãi thông qua curl:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token --impersonate-service-account=test@myproject.gserviceaccount.com --scopes=https://www.googleapis.com/auth/mapsbooking)" \
-H "Content-Type: application/json" \
-d '{
"records": [
{
"deleteTime": {
"seconds": 150
},
"protoRecord": {
"@type": "type.googleapis.com/madden.ingestion.offer.Offer",
"offerId": "1",
"entityIds": [
"1234567890"
]
}
}
]
}' \
https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/20000123/feeds/google.offer/record:batchDelete