为费率方案设置限制通知

您正在查看 Apigee Edge 文档。
转到 Apigee X 文档
info

当开发者接近或达到其购买的按量分级或捆绑费率卡方案的特定限制时 ,您可以通过电子邮件通知他们。例如,如果开发者 购买了捆绑了 1,000 次调用的按量分级方案,那么当他们达到 800 次调用(使用率 80%)或在 API 调用上花费 500 美元时,您可以通知他们。

如需使用 API 为费率方案设置限制通知,请执行以下步骤:

  1. 自定义通知模板,该模板将用于 通知开发者。
  2. 配置通知条件和操作

自定义通知模板

以下示例展示了如何自定义将用于通知开发者的通知模板。如需了解详情,请参阅管理 通知模板(使用 API)

$ curl -H "Content-Type: application/json " -X POST -d \    
'{
    "name": "RATE_PLAN_LIMIT_TEMPLATE",
    "subject": "Nearing your rate plan limit",
    "htmlImage": "<p>Hi ${developer.name} - Wanted to let you know that you have used 800 API calls from your ${ratePlan.displayName} rate plan, which started on ${ratePlan.startDate} under the ${ratePlan.monetizationPackage.displayName} package and ${ratePlan.monetizationPackage.products.displayName} product. Just a friendly reminder that your API calls will be charged double after you cross 1000 calls. Thanks for using the API!</p>",
    "source": "Postman API call"
    }' \
"https://api.enterprise.apigee.com/v1/mint/organizations/myorg/notification-email-templates" \
    -u email:password

配置通知条件和操作

使用 API 配置通知条件和操作,如配置 通知条件和操作使用 API中所述。

如需触发费率方案限制的通知,请设置以下属性:

  • RATEPLAN - 要发送的通知类型。
  • PUBLISHED - 将此属性设置为 TRUE,以便在已发布的费率方案上触发通知。

然后,指定以下属性之一:

  • Transactions - 交易数量。例如,当开发者达到 800 笔交易时通知他们。 必须为整数值,且仅允许使用 > 和 = 运算符。
  • FeeExposure - 交易中累计的美元或积分金额。必须为 整数值,且仅允许使用 > 和 = 运算符。FeeExposure 不包含设置费、周期性费用或终止费金额。例如,当 API 交易的费用达到 500 美元时通知开发者 。FeeExposure 的计算 因税率而异。

以下载荷会在交易数量达到 800 时触发电子邮件通知:

$ curl -H "Content-Type:application/json" -X POST -d \
    '{
    "notificationCondition": [
      {
        "attribute": "RATEPLAN",
        "value": "{RATE_PLAN_ID}"
      },
      {
        "attribute": "PUBLISHED",
        "value": "TRUE"
      },
      {
        "attribute": "Transactions",
        "value": "= 800"
      }     
    ],
   "actions": [{
          "actionAttribute": "DEV_ID",
          "value": "ANY",
          "templateId": "{EMAIL_TEMPLATE_ID}"
        }]
  }' \
"https://api.enterprise.apigee.com/v1/mint/organizations/{org_name}/notification-conditions" \
    -u email:password