승인 필요
연락처를 업데이트합니다. 예를 참조하세요.
요청
HTTP 요청
PUT https://www.googleapis.com/mirror/v1/contacts/id
매개변수
매개변수 이름 | 값 | 설명 |
---|---|---|
경로 매개변수 | ||
id |
string |
연락처의 ID입니다. |
확인할 내용
이 요청을 처리하려면 다음 범위의 승인을 받아야 합니다(인증 및 승인 자세히 알아보기).
범위 |
---|
https://www.googleapis.com/auth/glass.timeline |
요청 본문
요청 본문에서는 다음과 같은 속성을 사용하여 Contacts 리소스를 제공합니다.
숙소 이름 | 값 | 설명 | 메모 |
---|---|---|---|
필수 속성 | |||
acceptCommands[].type |
string |
이 명령어에 해당하는 작업 유형입니다. 허용되는 값은 다음과 같습니다.
|
쓰기 가능 |
displayName |
string |
이 연락처에 표시할 이름입니다. | 쓰기 가능 |
id |
string |
이 연락처의 ID입니다. 애플리케이션에서 생성되고 불투명 토큰으로 처리됩니다. | 쓰기 가능 |
imageUrls[] |
list |
연락처에 표시할 이미지 URL 집합입니다. 대부분의 연락처는 하나의 이미지를 갖지만 '그룹' 연락처에는 최대 8개의 이미지 URL이 포함될 수 있으며, 해당 연락처의 크기가 조정되고 클라이언트에서 모자이크로 잘립니다. | 쓰기 가능 |
선택 속성 | |||
acceptCommands[] |
list |
연락처가 처리할 수 있는 음성 메뉴 명령어의 목록입니다. Glass에서는 음성 메뉴 명령어당 최대 3개의 연락처를 표시합니다. 이보다 더 많은 경우 특정 명령어에 priority 이 가장 높은 세 개의 연락처가 표시됩니다. |
쓰기 가능 |
acceptTypes[] |
list |
연락처에서 지원하는 MIME 유형 목록입니다. 수락 유형이 항목의 첨부파일 유형과 일치하는 경우 연락처가 사용자에게 표시됩니다. allowType을 지정하지 않으면 연락처가 모든 항목에 표시됩니다. | 쓰기 가능 |
phoneNumber |
string |
연락처의 기본 전화번호입니다. 국가 번호 및 지역 번호가 포함된 정규화된 전화번호 또는 지역 전화번호일 수 있습니다. | 쓰기 가능 |
priority |
unsigned integer |
연락처 목록에서 우선순위를 결정하는 연락처의 우선순위입니다. 우선순위가 높은 연락처는 우선순위가 낮은 연락처보다 먼저 표시됩니다. | 쓰기 가능 |
speakableName |
string |
이 연락처의 이름을 발음해야 합니다. 이 이름을 음성 명확성 메뉴의 일부로 사용해야 하는 경우 이 이름이 예상 발음으로 사용됩니다. 이 이름은 발음하기 어려운 문자가 있거나 표시 철자가 발음이 아닌 경우 연락처 이름에 유용합니다. | 쓰기 가능 |
type |
string |
이 연락처의 유형입니다. UI에서 정렬하는 데 사용됩니다. 허용되는 값은 다음과 같습니다.
|
쓰기 가능 |
응답
요청에 성공할 경우 이 메서드는 응답 본문에 Contacts 리소스를 반환합니다.
예
참고: 이 메서드에 제공되는 코드 예시가 지원되는 모든 프로그래밍 언어를 나타내는 것은 아닙니다. 지원되는 언어 목록은 클라이언트 라이브러리 페이지를 참조하세요.
자바
자바 클라이언트 라이브러리를 사용합니다.
import com.google.api.services.mirror.Mirror;
import com.google.api.services.mirror.model.Contact;
import java.io.IOException;
public class MyClass {
// ...
/**
* Rename an existing contact for the current user.
*
* @param service Authorized Mirror service.
* @param contactId ID of the contact to rename.
* @param newDisplayName New displayName for the contact.
* @return Patched contact on success, {@code null} otherwise.
*/
public static Contact renameContact(Mirror service, String contactId, String newDisplayName) {
try {
// Get the latest version of the contact from the API.
Contact contact = service.contacts().get(contactId).execute();
contact.setDisplayName(newDisplayName);
// Send an update request to the API.
return service. contacts().update(contactId, contact).execute();
} catch (IOException e) {
System.err.println("An error occurred: " + e);
return null;
}
}
// ...
}
.NET
.NET 클라이언트 라이브러리를 사용합니다.
using System; using Google.Apis.Mirror.v1; using Google.Apis.Mirror.v1.Data; public class MyClass { // ... /// <summary> /// Rename an existing contact for the current user. /// </summary> /// <param name='service'>Authorized Mirror service.</param> /// <param name='contactId'>ID of the contact to rename.</param> /// <param name='newDisplayName'> /// New displayName for the contact. /// </param> /// <returns> /// Updated contact on success, null otherwise. /// </returns> public static Contact RRenameContact(MirrorService service, String contactId, String newDisplayName) { try { Contact contact = service.Contacts.Get(contactId).Fetch(); contact.DisplayName = newDisplayName; return service.Contacts.Update(contact, contactId).Fetch(); } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); return null; } } // ... }
PHP
PHP 클라이언트 라이브러리를 사용합니다.
/** * Rename an existing contact for the current user. * * @param Google_MirrorService $service Authorized Mirror service. * @param string $contactId ID of the contact to rename. * @param string $newDisplayName New displayName for the contact. * @return Google_Contact Updated contact on success, null otherwise. */ function renameContact($service, $contactId, $newDisplayName) { try { $updatedContact = $service->contacts->get($contactId); $updatedContact->setDisplayName($newDisplayName); return $service->contacts->update($contactId, $updatedContact); } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); return null; } }
Python
Python 클라이언트 라이브러리를 사용합니다.
from apiclient import errors # ... def rename_contact(service, contact_id, new_display_name): """Rename an existing contact for the current user. Args: service: Authorized Mirror service. contact_id: ID of the contact to rename. new_display_name: New displayName for the contact. Returns: return Patched contact on success, None otherwise. """ try: # Get the latest version of the contact from the API. contact = service.contacts().get(contact_id).execute() contact['displayName'] = new_display_name return service. contacts().update( id=contact_id, body=contact).execute() except errors.HttpError, e: print 'An error occurred: %s' % error return None
Ruby
Ruby 클라이언트 라이브러리를 사용합니다.
## # Rename an existing contact for the current user. # # @param [Google::APIClient] client # Authorized client instance. # @param [String] contact_id # ID of the contact to rename. # @param [String] new_display_name # New displayName for the contact. # @return [Google::APIClient::Schema::Mirror::V1::Contact] # Updated contact on success, nil otherwise. def rename_contact(client, contact_id, new_display_name) mirror = client.discovered_api('mirror', 'v1') # Get the latest version of the contact from the API. result = client.execute( :api_method => mirror.contacts.get, :parameters => { 'id' => contact_id }) if result.success? contact = result.data contact.display_name = new_display_name result = client.execute( :api_method => mirror.contacts.update, :parameters => { 'id' => contact_id }, :body_object => contact) if result.success? return result.data end end puts "An error occurred: #{result.data['error']['message']}" end
Go
import (
"code.google.com/p/google-api-go-client/mirror/v1"
"fmt"
)
// RenameContact renames an existing contact for the current user.
func RenameContact(g *mirror.Service, contactId string,
newDisplayName string) (*mirror.Contact, error) {
s, err := g. Contacts.Get(contactId).Do()
if err != nil {
fmt.Printf("An error occurred: %v\n", err)
return nil, err
}
s.DisplayName = newDisplayName
r, err := g.Contacts.Patch(contactId, s).Do()
if err != nil {
fmt.Printf("An error occurred: %v\n", err)
return nil, err
}
return r, nil
}
원시 HTTP
클라이언트 라이브러리를 사용하지 않습니다.
PUT /mirror/v1/contacts/harold HTTP/1.1 Authorization: Bearer auth token Content-Type: application/json Content-Length: length { "displayName": "Harold Penguin", "imageUrls": ["https://developers.google.com/glass/images/harold.jpg"] }