認証が必要です
インプレースの連絡先を更新します。 例を見る。
リクエスト
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 のセット。ほとんどの連絡先には 1 つの画像が含まれますが、「グループ」は 1 つだけです。連絡先には最大 8 つの画像の URL を含めることができます。この URL はクライアント上でサイズ変更され、モザイク状に切り抜かれます。 | 書き込み可能 |
| 省略可能なプロパティ | |||
acceptCommands[] |
list |
連絡先が処理できる音声コマンドのリスト。Glass には、音声メニュー コマンドごとに最大 3 件の連絡先が表示されます。それ以上ある場合は、その特定のコマンドに対して priority が最も高い 3 つの連絡先が表示されます。 |
書き込み可能 |
acceptTypes[] |
list |
連絡先がサポートする MIME タイプのリスト。連絡先の acceptTypes のいずれかがアイテムの添付ファイルのタイプと一致する場合、連絡先はユーザーに表示されます。receiveTypes が指定されていない場合は、すべての項目について連絡先が表示されます。 | 書き込み可能 |
phoneNumber |
string |
連絡先のメインの電話番号。国番号と市外局番を含む完全修飾番号、または地域番号を指定できます。 | 書き込み可能 |
priority |
unsigned integer |
連絡先の優先度。連絡先リスト内の順序を決定します。優先度が高い連絡先は、優先度の低い連絡先よりも前に表示されます。 | 書き込み可能 |
speakableName |
string |
発音するこの連絡先の名前。この連絡先の名前を音声による不確実性解消メニューの一部として読み上げる必要がある場合、この名前が想定される発音として使用されます。これは、発音できない文字が含まれている連絡先名や、表示されるスペルが音声的でない連絡先名に便利です。 | 書き込み可能 |
type |
string |
この連絡先のタイプ。これは UI の並べ替えに使用されます。使用できる値:
|
書き込み可能 |
レスポンス
成功すると、このメソッドはレスポンスの本文で Contacts リソースを返します。
例
注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。
Java
Java クライアント ライブラリを使用します。
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
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"] }