Contacts: update

অনুমোদন প্রয়োজন

জায়গায় একটি পরিচিতি আপডেট করে। একটি উদাহরণ দেখুন

অনুরোধ

HTTP অনুরোধ

PUT https://www.googleapis.com/mirror/v1/contacts/id

পরামিতি

পরামিতি নাম মান বর্ণনা
পাথ প্যারামিটার
id string পরিচিতির আইডি।

অনুমোদন

এই অনুরোধের জন্য নিম্নলিখিত সুযোগের সাথে অনুমোদনের প্রয়োজন ( প্রমাণিকরণ এবং অনুমোদন সম্পর্কে আরও পড়ুন )।

ব্যাপ্তি
https://www.googleapis.com/auth/glass.timeline

শরীরের অনুরোধ

অনুরোধের অংশে, নিম্নলিখিত বৈশিষ্ট্য সহ একটি পরিচিতি সংস্থান সরবরাহ করুন:

সম্পত্তির নাম মান বর্ণনা মন্তব্য
প্রয়োজনীয় বৈশিষ্ট্য
acceptCommands[]. type string এই কমান্ডটি যে ধরনের অপারেশনের সাথে মিলে যায়। অনুমোদিত মান হল:
  • TAKE_A_NOTE - "Take a note" ভয়েস মেনু কমান্ড থেকে ব্যবহারকারীর বক্তৃতার প্রতিলিপি সহ একটি টাইমলাইন আইটেম শেয়ার করে।
  • POST_AN_UPDATE - "আপডেট পোস্ট করুন" ভয়েস মেনু কমান্ড থেকে ব্যবহারকারীর বক্তৃতার প্রতিলিপি সহ একটি টাইমলাইন আইটেম শেয়ার করে৷
লিখনযোগ্য
displayName string এই পরিচিতির জন্য প্রদর্শিত নাম। লিখনযোগ্য
id string এই পরিচিতির জন্য একটি আইডি। এটি অ্যাপ্লিকেশন দ্বারা উত্পন্ন হয় এবং একটি অস্বচ্ছ টোকেন হিসাবে বিবেচিত হয়৷ লিখনযোগ্য
imageUrls[] list একটি পরিচিতির জন্য প্রদর্শনের জন্য চিত্র URL এর সেট৷ বেশিরভাগ পরিচিতির একটি একক চিত্র থাকবে, তবে একটি "গ্রুপ" পরিচিতিতে 8টি পর্যন্ত চিত্র URL অন্তর্ভুক্ত থাকতে পারে এবং সেগুলিকে ক্লায়েন্টে একটি মোজাইক আকারে পুনরায় আকার দেওয়া হবে এবং ক্রপ করা হবে৷ লিখনযোগ্য
ঐচ্ছিক বৈশিষ্ট্য
acceptCommands[] list ভয়েস মেনু কমান্ডের একটি তালিকা যা একটি পরিচিতি পরিচালনা করতে পারে। গ্লাস প্রতিটি ভয়েস মেনু কমান্ডের জন্য তিনটি পরিচিতি দেখায়। যদি এর বেশি থাকে, তাহলে সেই নির্দিষ্ট কমান্ডের জন্য সর্বোচ্চ priority সহ তিনটি পরিচিতি দেখানো হয়। লিখনযোগ্য
acceptTypes[] list MIME প্রকারের একটি তালিকা যা একটি পরিচিতি সমর্থন করে৷ পরিচিতিটি ব্যবহারকারীকে দেখানো হবে যদি এর কোনো গ্রহণযোগ্য প্রকার আইটেমের সংযুক্তিগুলির যেকোনো প্রকারের সাথে মেলে। যদি কোনও গ্রহণযোগ্য প্রকার না দেওয়া হয়, তবে সমস্ত আইটেমের জন্য পরিচিতি দেখানো হবে। লিখনযোগ্য
phoneNumber string যোগাযোগের জন্য প্রাথমিক ফোন নম্বর। এটি একটি সম্পূর্ণ-যোগ্য নম্বর হতে পারে, দেশের কলিং কোড এবং এলাকা কোড বা একটি স্থানীয় নম্বর সহ। লিখনযোগ্য
priority unsigned integer পরিচিতির তালিকায় অর্ডার নির্ধারণের জন্য পরিচিতির অগ্রাধিকার। উচ্চ অগ্রাধিকারের পরিচিতিগুলিকে কম অগ্রাধিকারগুলির আগে দেখানো হবে৷ লিখনযোগ্য
speakableName string এই পরিচিতির নাম যেমন উচ্চারণ করা উচিত। যদি এই পরিচিতির নামটি একটি ভয়েস দ্ব্যর্থতা মেনুর অংশ হিসাবে উচ্চারিত হয় তবে এই নামটি প্রত্যাশিত উচ্চারণ হিসাবে ব্যবহৃত হয়৷ এটি উচ্চারণযোগ্য অক্ষর সহ পরিচিতি নামগুলির জন্য বা যার প্রদর্শনের বানান অন্যথায় ধ্বনিগত নয়। লিখনযোগ্য
type string এই পরিচিতির ধরন। এটি UI-তে সাজানোর জন্য ব্যবহৃত হয়। অনুমোদিত মান হল:
  • INDIVIDUAL - একক ব্যক্তির প্রতিনিধিত্ব করে। এটি ডিফল্ট।
  • GROUP - একক ব্যক্তির চেয়ে বেশি প্রতিনিধিত্ব করে।
লিখনযোগ্য

প্রতিক্রিয়া

সফল হলে, এই পদ্ধতিটি প্রতিক্রিয়া বডিতে একটি পরিচিতি সংস্থান প্রদান করে।

উদাহরণ

দ্রষ্টব্য: এই পদ্ধতির জন্য উপলব্ধ কোড উদাহরণগুলি সমস্ত সমর্থিত প্রোগ্রামিং ভাষার প্রতিনিধিত্ব করে না (সমর্থিত ভাষার তালিকার জন্য ক্লায়েন্ট লাইব্রেরি পৃষ্ঠা দেখুন)।

জাভা

জাভা ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

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;
    }
  }

  // ...
}

পিএইচপি

পিএইচপি ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

/**
 * 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;
  }
}

পাইথন

পাইথন ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

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

রুবি

রুবি ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

##
# 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"]
}