Google People API: search contacts in a specific group and contacts updated after a specific time - google-api

I am migrating our code from Google Contacts API to Google People API as Google Contacts API will be deprecated soon, but I noticed new People APIs are simple to compare with the old Contacts API.
For example, we have below code use the old Contacts API to search in a specific contact Group and were updated after a specific date by passing in the Group and StartDate parameters, but now we can't do the same query with new People API.
My question is in the new People API, is there any way we can search contacts in a specific Group and only get contacts that were updated after a specific date?
I saw one question which uses syncToken, but I think it is not a good solution for us.
Option to get the contact entries updated after a specific time NOT given in Google People API
GData.Contacts.ContactsFeed feed = service.Query(
new GData.Contacts.ContactsQuery("https://www.google.com/m8/feeds/contacts/default/full/")
{
OAuthRequestorId = employeeUserEmail,
Group = [contact group url],
NumberToRetrieve = FetchSize,
StartIndex = 1,
StartDate = [a date that only get contacts were modified after it],
});

I think they intentionally moved away from using a timestamp approach (give me all contacts updated since 1/1/2021) to a SyncToken approach.
The SyncToken eliminates any race-condition that might lead to loss of data.
For example if a contact was updated while a query was already in progress this leads to a race condition whether that contact would be included in the next query or not, which might cause the data changes to not get synced and next sync would be overridden.
So in case you're doing a fresh sync, or haven't synced for over 7 days, just get all the contacts of a group via: contactGroups.get.
If the last sync was less then 7 days ago, use a sync token to get just the updated contacts.
You could potentially get all contacts of a group, and then run a loop that filters via sources.updateTime but again, you're risking data loss.

Related

How do I get all products purchased by a user in the last month through the Kroger API?

I'd like to get a list of all the products an authenticated user purchased in the last month back from the Kroger API. Is there a way to do this (and how)?
I'm using Svelte + Node (not that the solution has to be Svelte/Node). I'm mostly looking for what API routes to hit, as it isn't clear to me from the documentation whether this is even possible.

Google Reports API for Meet attendance - strange conference_id

I'm trying to query attendance for a Google Meet conference created via Google Calendars API.
I've found that the conferenceId returned by Calendar API > Events > insert it's different from the one I can use to filter in Reports API.
conferenceId from Calendar API --> ["conferenceId"]=>string(12) "xxx-xxxx-xxx"
conferenceId from Reports API{"name": "conference_id", "value": "xxxxxxx_12234XXXXXxxxxXX56"}
Does anyone knows why?
How can I query attendance based on the data returned by Calendar API > Events > insert ?
Steps to reprocuduce:
Insert calendar events (be sure to add conferenceData structure to create also the Meet conference):
https://developers.google.com/calendar/api/v3/reference/events/insert
Use the conference
List activities from Report API and check the conference_id: https://developers.google.com/admin-sdk/reports/reference/rest/v1/activities/list
It seems that the conferenceId from the Calendar event object is different from the conference_id in the Reports (note that the name is different). The activities.list output also has another field called meeting_code, it's also under items.events.parameters:
{
"name": "meeting_code",
"value": "ASDFASFFGJ"
}
This one matches the conferenceId in a calendar event, except that it's without dashes and capitalized, so for the example "conferenceId": "asd-fasf-fgj" in a Calendar Event object you'll find "meeting_code": "ASDFASFFGJ" in the activity reports. So you can just remove the dashes and capitalize the conferenceId to match it to its corresponding meeting_code.
As to why this discrepancy exists, my guess after reading the definition of the Meet activity events is that it tracks different "conference sessions" within the same meeting code. For example, if you join the meeting asd-fasf-fgj it will create a new conference_id until everyone leaves the meeting. Then if the same meeting code is used again a different conference_id will be created to track the new session and so on.
I did some cursory testing and the logs do create a different conference_id every time I joined the same Meeting code. I didn't have multiple accounts to test so I'm not sure if two users can have matching IDs, but I may be close. I couldn't find any in-depth documentation so it would require more testing to figure out exactly how it works.
Either way, to address your immediate concern, you should be able to match the Event's conferenceId with the Report's meeting_code to track the attendance.
Reference:
Meet Activity log definition

Laravel payment multi subscriptions

I am working on a SAAS project where users can create various projects. With each project, they can choose from 5 different plans. Each plan has its own costs per month. Hotjar is a kind of equal concept.
Now I want to arrange the subscription with Stripe. The problem with that was that a user can have a maximum x subscription, which of course was a shame. Then I decided to take 1 subscription that has several plans. But now I have a dilemma, to update the subscription you have to change the number via SubscriptionItem. Then you have to save yourself which plan has which SubscriptionItem_id for which user. That is quite a detour and can cause many problems.
Someone is a better way with Stripe or another payment software.
You don't necessarily need to store the subscritpion_item IDs, you can look it up via the subscription_item list API. All you need to do is store the subscription_id for your customers, and based on that ID you can retrieve the list of subscription_items:
\Stripe\Stripe::setApiKey("sk_test_9GavlLpfiKewqeCBXvRvmVgd");
\Stripe\SubscriptionItem::all(["subscription" => "sub_EQlPGjVj4o5luH"]);
Then you can handle the data part of the returned JSON object and update / delete / etc these subscription items.
If you only have the customer_id handy, then you can use the subscription list API (with status as well on the GET params) to retrieve the list of active subscriptions.

Credit usage when Google Places API does not return Place ID

I'm looking to store Google Place ID for several different places (millions of records). I have purchased a premium plan usage.
Will Google deduct my credits for those records which don't have a Place ID (or Place ID is not returned) ?
Maps API Credits are deducted based on the number of requests made to the Places API, not the values or fields like Place ID, returned within those requests. Credits will be consumed anytime the request doesn't return an error so if you're getting some results (or ZERO_RESULTS), credits are being consumed.
As a Google Maps API Premium Plan customer, feel free to contact the support team for these sort of questions.

Solving the location-based app data problem

I'm trying to build a very simple location-based app and I have all of these services at my disposal (Foursquare API, SimpleGeo, Google Places, etc). All seem to provide me a list of venues (bars, coffee shops, stores, etc) near a given longitude latitude. This is great but once the users see the venues, they will be able to write reviews about each venue (for example). Now, what do I do with this data?
User ID (users for my app)
Venue Name (retrieved from Foursquare API)
Longitude, Latitude
Foursquare Venue ID
Review
Do I store this in my database? What happens if the venue name changes on the Foursquare servers? If I don't store this in my database, I'd have to do a lookup to retrieve the venue name and details every single time I want to return a list of reviews in the area. Can someone offer some advice on how to conceptually design a venue-based location app. Thanks.
Store the essential 3rd party info in your database but treat it as a cache. Have a background task that checks for updates every few minutes, days, or weeks depending on the likelyhood & severity of changes. In between updates the user may get stale data but hey, that's life... at least they got it fast. In doing your updates, don't update everything at once or you'll run quickly into API throttling limits.

Resources