अनुमति देना ज़रूरी है
किसी संपर्क की जगह की जानकारी अपडेट करता है. उदाहरण देखें.
अनुरोध
एचटीटीपी अनुरोध
PUT https://www.googleapis.com/mirror/v1/contacts/id
पैरामीटर
पैरामीटर का नाम | मान | ब्यौरा |
---|---|---|
पाथ पैरामीटर | ||
id |
string |
संपर्क का आईडी. |
अनुमति देना
इस अनुरोध के लिए नीचे दिए गए दायरे के साथ अनुमति की ज़रूरत है (पुष्टि करने और अनुमति देने के बारे में ज़्यादा पढ़ें).
दायरा |
---|
https://www.googleapis.com/auth/glass.timeline |
अनुरोध का मुख्य भाग
अनुरोध के मुख्य हिस्से में, इन प्रॉपर्टी के साथ संपर्क संसाधन दें:
प्रॉपर्टी का नाम | मान | ब्यौरा | नोट |
---|---|---|---|
ज़रूरी प्रॉपर्टी | |||
acceptCommands[].type |
string |
इस निर्देश से जुड़ी कार्रवाई का टाइप. इन वैल्यू का इस्तेमाल किया जा सकता है:
|
लिखा जा सकता है |
displayName |
string |
इस संपर्क के लिए प्रदर्शित करने के लिए नाम. | लिखा जा सकता है |
id |
string |
इस संपर्क का आईडी. इसे ऐप्लिकेशन जनरेट करता है और इसे एक ऑपैक टोकन माना जाता है. | लिखा जा सकता है |
imageUrls[] |
list |
किसी संपर्क को दिखाने के लिए इमेज के यूआरएल का सेट. ज़्यादातर संपर्कों में एक इमेज होगी, लेकिन "ग्रुप" संपर्क में ज़्यादा से ज़्यादा आठ इमेज यूआरएल शामिल किए जा सकते हैं. साथ ही, क्लाइंट पर इमेज का साइज़ बदला जा सकता है और उन्हें मोज़ेक में काटा जा सकता है. | लिखा जा सकता है |
ज़रूरी नहीं प्रॉपर्टी | |||
acceptCommands[] |
list |
वॉइस मेन्यू के निर्देशों की सूची, जिसे कोई संपर्क मैनेज कर सकता है. Glass हर ध्वनि मेनू आदेश के लिए तीन संपर्क दिखाता है. अगर उसमें तीन से ज़्यादा संपर्क हैं, तो उस खास निर्देश के लिए सबसे ज़्यादा priority वाले तीन संपर्क दिखाए जाते हैं. |
लिखा जा सकता है |
acceptTypes[] |
list |
ऐसे MIME टाइप की सूची जिन्हें कोई संपर्क इस्तेमाल कर सकता है. अगर आइटम में मौजूद अटैचमेंट के किसी टाइप से, स्वीकार किए जाने वाले टाइप में से कोई एक टाइप मेल खाता है, तो उपयोगकर्ता को संपर्क दिखाया जाएगा. अगर acceptTypes की वैल्यू नहीं दी गई है, तो संपर्क जानकारी सभी आइटम के लिए दिखेगी. | लिखा जा सकता है |
phoneNumber |
string |
संपर्क का मुख्य फ़ोन नंबर. यह पूरी तरह से क्वालिफ़ाइड नंबर हो सकता है, जिसमें देश का कॉलिंग कोड और एरिया कोड शामिल हो. इसके अलावा, यह स्थानीय नंबर भी हो सकता है. | लिखा जा सकता है |
priority |
unsigned integer |
संपर्क की प्राथमिकता, ताकि संपर्कों की सूची में क्रम तय किया जा सके. ज़्यादा प्राथमिकता वाले संपर्कों को, कम प्राथमिकता वाले संपर्कों से पहले दिखाया जाएगा. | लिखा जा सकता है |
speakableName |
string |
इस संपर्क का नाम, जिसका उच्चारण करना है. अगर इस संपर्क का नाम, आवाज़ साफ़ तौर पर बताने वाले मेन्यू के हिस्से के तौर पर बोला जाना चाहिए, तो इस नाम का इस्तेमाल उच्चारण के मुताबिक किया जाएगा. यह सुविधा उन संपर्कों के नामों के लिए काम की है जिनमें ऐसे वर्ण हैं जिनका उच्चारण नहीं किया जा सकता या जिनकी डिसप्ले स्पेलिंग फ़ोनेटिक नहीं है. | लिखा जा सकता है |
type |
string |
इस संपर्क का प्रकार. इसका इस्तेमाल यूज़र इंटरफ़ेस (यूआई) में क्रम से लगाने के लिए किया जाता है. स्वीकृत मान हैं:
|
लिखा जा सकता है |
जवाब
अगर यह तरीका कामयाब होता है, तो जवाब के मुख्य हिस्से में संपर्कों का रिसॉर्स दिखता है.
उदाहरण
ध्यान दें: इस तरीके के लिए दिए गए कोड के उदाहरणों में इसके साथ काम करने वाली सभी प्रोग्रामिंग भाषाएं नहीं दिखाई गई हैं (इसके साथ काम करने वाली भाषाओं की सूची के लिए क्लाइंट लाइब्रेरी वाला पेज देखें).
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 क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
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 क्लाइंट लाइब्रेरी का इस्तेमाल किया जाता है.
/**
* 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 क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
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 क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
##
# 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
}
क्लाइंट लाइब्रेरी का इस्तेमाल नहीं करता.
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"]
}