CreateLease 方法

对创建租借的支持是可选的。它适用于有兴趣实现此功能的合作伙伴。请先与操作中心联系以确定是否符合条件,然后再开始。

创建租借是创建租借支持的预订的第一步。 合作伙伴后端会验证请求的预约空档是否有效且可用。在内部,合作伙伴会为请求的空档创建一个临时保全,并将其设置为于 lease_expiration_time 自动过期。如果请求的租借时间过长,则允许后端修改 lease_expiration_time。创建的租借会被返回给客户端。然后,由客户端请求为租借创建一个预定。

如果由于任何业务逻辑错误而导致创建租借失败,则应在响应中填充该错误。如需了解详情,请参阅预订失败

请求

CreateLeaseRequest

返回值

CreateLeaseResponse

要求:

  • lease_id 必须由合作伙伴后端创建,并在 CreateLeaseResponse 中设置。
  • 必须在 CreateLeaseResponse 中设置 lease_expiration_time。
  • 如果在 CreateLeaseRequest 中指定了资源字段,则必须在 CreateLeaseResponse 中对其进行设置并使之与 CreateLeaseRequest 相匹配。
  • 必须对 CreateLeaseResponse 中的所有其他字段进行设置并使之与 CreateLeaseRequest 相匹配。

规范的 gRPC 错误代码

  • INVALID_ARGUMENT(商家 ID、服务 ID 或空档时间规范无效)
// Request to create a [ext.maps.booking.partner.v2.Lease] for a slot in the
// inventory.  The expiration time in the returned Lease may be modified by the
// backend, e.g. if the requested lease period is too long.
message CreateLeaseRequest {
  // The lease to be created with information about the appointment slot
  // (required)
  Lease lease = 1;
}

// Response for the [ext.maps.booking.partner.v2.CreateLease] RPC with the
// created [ext.maps.booking.partner.v2.Lease]
message CreateLeaseResponse {
  // The created [ext.maps.booking.partner.v2.Lease] (required)
  Lease lease = 1;

  // If creating a lease fails, this field should reflect the business logic
  // error (e.g., slot has become unavailable) and lease field is expected to be
  // unset. (required if failure occurs)
  BookingFailure booking_failure = 2;
}