您可以使用 Directory API 以编程方式管理客户。 借助此 API 中的方法,您可以更新 G Suite 网域上的联系信息,并更改实例的主域名。
检索客户
如需检索现有客户,请使用以下 GET
HTTP 请求,并包含向请求授权中所述的授权令牌。customerKey
可以是唯一的 customerId,也可以是 my_customer
,用于指示当前客户。
GET https://admin.googleapis.com/admin/directory/v1/customers/customerKey
成功的响应将返回 HTTP 200 状态代码。除了状态代码之外,JSON 响应还包含客户信息:
{
"etag": "\"spqlTgq5LGeoin0BH1d0f4rpI98/LnbnRK_ZWu_omowg36CZgTKECrY\"",
"kind": "admin#directory#customer",
"alternateEmail": "marty.mcfly@gmail.com",
"id": "C03xgje4y",
"customerDomain": "amatchmadeinspace.com",
"postalAddress": {
"organizationName": "A Match Made in Space, LLC",
"countryCode": "US"
},
"customerCreationTime": "2015-10-21T20:42:35.224Z"
}
更新现有客户
如需更新现有客户,请使用以下 PUT
HTTP 请求,并包含向请求授权中所述的授权令牌。customerKey
可以是客户的唯一客户 ID,也可以是 my_customer
以表示当前客户。
PUT https://admin.googleapis.com/admin/directory/v1/customers/customerKey
成功的响应将返回 HTTP 200 状态代码。除了状态代码之外,JSON 响应还包含最近更新的客户信息:
{
"alternateEmail": "marty.mcfly@gmail.com",
"customerDomain": "amatchmadeinspace.com",
"language": "EN",
"postalAddress": {
"organizationName": "A Match Made in Space, LLC",
"phoneNumber": "+15558675309"
}
}
成功的响应将返回 HTTP 200 状态代码。除了状态代码之外,JSON 响应还包含客户信息:
{
"etag": "\"spqlTgq5LGeoin0BH1d0f4rpI98/LnbnRK_ZWu_omowg36CZgTKECrY\"",
"kind": "admin#directory#customer",
"alternateEmail": "marty.mcfly@gmail.com",
"id": "C03xgje4y",
"customerDomain": "amatchmadeinspace.com",
"postalAddress": {
"organizationName": "A Match Made in Space, LLC",
"phoneNumber": "+15558675309"
},
"customerCreationTime": "2015-10-21T20:42:35.224Z"
}
更改客户的主域名
如需更改客户的主域名,请使用以下 PUT
HTTP 请求,并包含向请求授权中所述的授权令牌。customerKey
必须是唯一的 customerId,即 my_customer
。
PUT https://admin.googleapis.com/admin/directory/v1/customers/customerKey
JSON 请求正文必须包含新的 customerDomain
值:
{
"alternateEmail": "marty.mcfly@gmail.com",
"customerDomain": "fluxcapacitor.com",
"language": "EN",
"postalAddress": {
"organizationName": "A Match Made in Space, LLC",
"phoneNumber": "+15558675309"
}
}
成功的响应将返回 HTTP 200 状态代码。除了状态代码之外,JSON 响应还包含客户信息:
{
"etag": "\"spqlTgq5LGeoin0BH1d0f4rpI98/LnbnRK_ZWu_omowg36CZgTKECrY\"",
"kind": "admin#directory#customer",
"alternateEmail": "marty.mcfly@gmail.com",
"id": "C03xgje4y",
"customerDomain": "fluxcapacitor.com",
"postalAddress": {
"organizationName": "A Match Made in Space, LLC",
"phoneNumber": "+15558675309"
},
"customerCreationTime": "2015-10-21T20:42:35.224Z"
}