注意:此 API 的 v4.7 版本已发布!请参阅更新日志。仍暂时允许在链中提供与新冠肺炎 (COVID-19) 相关的帖子。

添加属性

借助属性,商家可以添加其他信息,例如无障碍选项和放置操作链接。

以下屏幕截图展示了 Google 搜索中属性显示方式的一个示例。“堂食”、“外卖”和“送餐”选项就是属性。其他属性包括顺序和菜单链接。

测试“商家信息操作”链接

列出属性

要查看主要类别和国家/地区的属性列表,可以请求 attributes.list。属性是动态的,应该经常进行检索。请参阅下一部分中展示的示例。

请求

HTTP
GET https://mybusiness.googleapis.com/v4/attributes?country=US&languageCode=EN&categoryId=gcid:restaurant

响应

以下部分响应会返回具有各种 AttributeValueType 值的属性。

{
    {
      "attributeId": "has_live_music",
      "valueType": "BOOL",
      "displayName": "Live music",
      "groupDisplayName": "Highlights",
      "valueMetadata": [
        {
          "value": true,
          "displayName": "Live music"
        }
      ],
      "displayStrings": {
        "uiText": "Live music",
        "standaloneText": "Has live music",
        "negativeText": "No live music"
      }
    },
    {
      "attributeId": "has_wheelchair_accessible_entrance",
      "valueType": "BOOL",
      "displayName": "Wheelchair accessible entrance",
      "groupDisplayName": "Accessibility",
      "valueMetadata": [
        {
          "value": true,
          "displayName": "Wheelchair accessible entrance"
        },
        {
          "value": false,
          "displayName": "No wheelchair accessible entrance"
        }
      ],
      "displayStrings": {
        "uiText": "Wheelchair accessible entrance",
        "standaloneText": "Has wheelchair accessible entrance",
        "negativeText": "No wheelchair accessible entrance"
      }
    },
    {
      "attributeId": "has_braille_menu",
      "valueType": "BOOL",
      "displayName": "Braille menu",
      "groupDisplayName": "Offerings",
      "valueMetadata": [
        {
          "value": true,
          "displayName": "Braille menu"
        }
      ],
      "displayStrings": {
        "uiText": "Braille menu",
        "standaloneText": "Has braille menu",
        "negativeText": "No braille menu"
      }
    },
    {
      "attributeId": "has_no_contact_delivery",
      "valueType": "BOOL",
      "displayName": "No-contact delivery",
      "groupDisplayName": "Offerings",
      "valueMetadata": [
        {
          "value": true,
          "displayName": "No-contact delivery"
        }
      ],
      "displayStrings": {
        "uiText": "No-contact delivery",
        "standaloneText": "Has no-contact delivery",
        "negativeText": "No no-contact delivery"
      }
    },
    {
      "attributeId": "welcomes_lgbtq",
      "valueType": "BOOL",
      "displayName": "LGBTQ friendly",
      "groupDisplayName": "Planning",
      "valueMetadata": [
        {
          "value": true,
          "displayName": "LGBTQ friendly"
        }
      ],
      "displayStrings": {
        "uiText": "LGBTQ friendly",
        "standaloneText": "LGBTQ friendly",
        "negativeText": "Not showing LGBT friendly"
      }
    },
    {
      "attributeId": "wi_fi",
      "valueType": "ENUM",
      "displayName": "Wi-Fi",
      "groupDisplayName": "Amenities",
      "valueMetadata": [
        {
          "value": "free_wi_fi",
          "displayName": "Free"
        },
        {
          "value": "paid_wi_fi",
          "displayName": "Paid"
        }
      ],
      "displayStrings": {
        "uiText": "Wi-Fi",
        "standaloneText": "Has Wi-Fi",
        "negativeText": "No Wi-Fi"
      }
    },
    {
      "attributeId": "pay_credit_card_types_accepted",
      "valueType": "REPEATED_ENUM",
      "displayName": "Credit cards",
      "groupDisplayName": "Payments",
      "isRepeatable": true,
      "valueMetadata": [
        {
          "value": "american_express",
          "displayName": "American Express"
        },
        {
          "value": "china_union_pay",
          "displayName": "China Union Pay"
        },
        {
          "value": "diners_club",
          "displayName": "Diners Club"
        },
        {
          "value": "discover",
          "displayName": "Discover"
        },
        {
          "value": "jcb",
          "displayName": "JCB"
        },
        {
          "value": "mastercard",
          "displayName": "MasterCard"
        },
        {
          "value": "visa",
          "displayName": "VISA"
        }
      ],
      "displayStrings": {
        "uiText": "Credit cards",
        "standaloneText": "Credit cards accepted",
        "negativeText": "Credit cards not accepted"
      }
    },
    {
      "attributeId": "url_menu",
      "valueType": "URL",
      "displayName": "Menu link",
      "groupDisplayName": "Place page URLs",
      "displayStrings": {
        "uiText": "Menu link",
        "standaloneText": "Menu link",
        "negativeText": "No online menu"
      }
    },
    {
      "attributeId": "url_reservations",
      "valueType": "URL",
      "displayName": "Reservations links",
      "groupDisplayName": "Place page URLs",
      "displayStrings": {
        "uiText": "Reservations links",
        "standaloneText": "Reservations links",
        "negativeText": "Table booking not available"
      }
    }
  ]
}

设置商家信息的属性

要使用 accounts.location.patch 设置属性,请使用 updateMask=attributes 添加查询参数,并使用您要更新的属性设置“attributeMask”参数。如果 attributeMask 中的属性不适用于相应营业地点,则会被忽略。要更新所有属性,请将 attributeMask 留空。

以下示例设置了商家信息的预留链接和送餐选项属性。

HTTP
PATCH
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}?updateMask=attributes&attributeMask=url_reservations,has_no_contact_delivery
{
  "attributes": [
        {
            "attributeId": "has_no_contact_delivery",
            "values": [ true ]
        },
        {
            "attributeId": "url_reservations",
            "urlValues": [
                {
                    "url": "www.abcreservations.com"
                }
            ]
        }
    ]
}