คุณใช้ Directory API เพื่อจัดการลูกค้าแบบเป็นโปรแกรมได้ เมธอดใน API นี้ช่วยให้คุณอัปเดตข้อมูลติดต่อในโดเมน G Suite รวมถึงเปลี่ยนโดเมนหลักสำหรับอินสแตนซ์ได้
เรียกข้อมูลลูกค้า
หากต้องการเรียกข้อมูลลูกค้าเดิม ให้ใช้คำขอ HTTP GET
ต่อไปนี้และรวมโทเค็นการให้สิทธิ์ที่อธิบายไว้ในการให้สิทธิ์คำขอ customerKey
อาจเป็นรหัสลูกค้าที่ไม่ซ้ำกัน หรือ 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"
}
อัปเดตลูกค้าเดิม
หากต้องการอัปเดตลูกค้าเดิม ให้ใช้คำขอ HTTP PUT
ต่อไปนี้และรวมโทเค็นการให้สิทธิ์ที่อธิบายไว้ในการให้สิทธิ์คำขอ customerKey
อาจเป็นรหัสลูกค้าที่ไม่ซ้ำกันของลูกค้า หรือ 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"
}
การเปลี่ยนชื่อโดเมนหลักของลูกค้า
หากต้องการเปลี่ยนโดเมนหลักของลูกค้า ให้ใช้คำขอ HTTP PUT
ต่อไปนี้และรวมโทเค็นการให้สิทธิ์ที่อธิบายไว้ในการให้สิทธิ์คำขอ
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"
}