Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question (People API) : is it still possible to manage labels (groups) using People API ? #7942

Open
AndroidDeveloperLB opened this issue May 5, 2021 · 1 comment
Labels
priority: p4 type: question Request for information or clarification. Not an issue.

Comments

@AndroidDeveloperLB
Copy link

Previously, we used to have something like this to create the labels (AKA groups) :

    @WorkerThread
    private fun createContactGroup(): ContactGroupEntry? {
        // Create the entry to insert
        try {
            val newGroup = ContactGroupEntry()
            newGroup.title = PlainTextConstruct(GROUP_NAME)
            val additionalInfo = ExtendedProperty()
            additionalInfo.name = "Temporary contacts group"
            newGroup.addExtendedProperty(additionalInfo)
            val postUrl = URL("https://www.google.com/m8/feeds/groups/default/full")
            val group = contactsService.insert(postUrl, newGroup)
            return group
        } catch (ex: Exception) {
            return null
        }
    }

And later when you wish to set it to some contacts, you could do something like that:

    @WorkerThread
    private fun addContactsToPeopleAPI(contactsToInsert: List<ContactEntry>,
        group: ContactGroupEntry): Boolean {
        try {
            val requestFeed = ContactFeed()
            contactsToInsert.forEach { contactEntry: ContactEntry ->
                contactEntry.addUserDefinedField(
                    UserDefinedField("someKey","someValue"))
                contactEntry.addGroupMembershipInfo(GroupMembershipInfo(false, group.id))
                BatchUtils.setBatchId(contactEntry, "create")
                BatchUtils.setBatchOperationType(contactEntry, BatchOperationType.INSERT)
                requestFeed.entries.add(contactEntry)
            }
            // Submit the batch request to the server.
            val responseFeed =
                contactsService.batch(URL(BATCH_URL), requestFeed)
        } catch (ex: java.lang.Exception) {
            return false
        }
        return true
    }

I could also remove contacts from a label and delete a label, and still I had to use getFeed(), ContactFeed, batch , etc...

But now with People API all I get is instances of Person, which is nothing similar to ContactEntry , and I can't find similar classes to replace those that are used here.

Is it still possible to do as I did before?
The docs say that People API does support writing (here) :

Note: For read and write access to users' contacts, use the People API, which provides both contact and profile information using JSON instead of the older GData protocol.

but when going there, this is the only thing I see that's similar to what I had:
https://developers.google.com/people/v1/other-contacts#copy-an-other-contact-to-mycontacts-group

@Neenu1995 Neenu1995 added the type: question Request for information or clarification. Not an issue. label May 5, 2021
@AndroidDeveloperLB
Copy link
Author

It seems that in general it is possible to manage them, but not to copy from other-contacts to them:
https://developers.google.com/people/api/rest/v1/contactGroups.members/modify

The only system contact groups that can have members added are contactGroups/myContacts and contactGroups/starred. Other system contact groups are deprecated and can only have contacts removed.

So, why can't I do this anymore?
And is there a way to at least call copyOtherContactToMyContactsGroup (here) in a batch way instead of one after another ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p4 type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants