How to create a segmented push using OneSignal - push-notification

Here's the thing, I have two types of users, The Workers and Clients.. The workers can be at "n" categories as they want and what I'm trying to do is, when the client send a PUSH to a specific Category, every worker that was registered there must receive the notification.
I was trying to use the Tag approach by doing this :
"app_id": "APP_ID",
"tags": {
"first_name": "Jon",
"last_name": "Smith",
"level": "99",
"amount_spent": "6000",
"account_type": "VIP",
"key_to_delete": "\"\""
}
But, instead of having different properties, it must be the same Key (Category) so the service could recognize the category itself, something like : Reference
"app_id": "APP_ID",
"tags": {
"Category": "IT",
"Category": "Painter",
}
And if I try to create a tag with the same name, it just updates the value.

Related

How can we differentiate between a secondary and shared calendar in Google Calendar API response

I have a query with respect to the Calendar List API for Google Calendar:
https://developers.google.com/calendar/api/v3/reference/calendarList/list
We have a scenario where user1 has shared his calendar with user2 with Make Changes and Manage Sharing permission.
Now if we invoke the list calendar API on user2, we receive a response as below:
{
"kind": "calendar#calendarListEntry",
"etag": "\"<redacted>\"",
"id": "user1#gmail.com",
"summary": "user1#gmail.com",
"timeZone": "Asia/Kolkata",
"colorId": "4",
"backgroundColor": "#fa573c",
"foregroundColor": "#000000",
"accessRole": "owner",
"defaultReminders": [],
"conferenceProperties": {
"allowedConferenceSolutionTypes": [
"hangoutsMeet"
]
}
}
We can see that the access role above for the user1's calendar is owner and the primary value is absent(false).
Now if user2 has a secondary calendar we again see something similar in the listcalendar API response:
{
"kind": "calendar#calendarListEntry",
"etag": "\"<redacted>\"",
"id": "<redacted>#group.calendar.google.com",
"summary": "Secondary Calendar",
"timeZone": "Asia/Kolkata",
"colorId": "1",
"backgroundColor": "#ac725e",
"foregroundColor": "#000000",
"selected": true,
"accessRole": "owner",
"defaultReminders": [],
"conferenceProperties": {
"allowedConferenceSolutionTypes": [
"hangoutsMeet"
]
}
}
Access role above for the secondary calendar is owner and the primary value is absent(false).
So how can we differentiate between a secondary and shared calendar for user2? We require the same for some specific processing in our application.
As discussed in the comments there does not seem to be a clear way to differentiate the secondary calendars, except for the id and the appearance of the primary field.
Without having a database to control it, it does not seem to be possible to differentiate between a secondary calendar and a shared calendar, except for the calendar id.
You can use this template to explain your case to Google and ask to always have a field where you specify the calendar owner or another element that allows you to identify it.

Deeplinking into a telegram bot

I have a simple use case. When a user clicks the link below,
T.me/MycompanynameBot?start=Microsoft
I want to show him 3 inline buttons corresponding to 3 Telegram channels within Microsoft. Is this possible?
The key is the bot must be able to retrieve the parameters from the URL.
Thank you.
Yes it's possible to retrieve bot parameter via answerCallbackQuery
Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via #Botfather and accept the terms. Otherwise, you may use links like:
t.me/your_bot?start=XXXX
that open your bot with a parameter.
Here is an example I made for you :
{
"ok": true,
"result": [{
"update_id": 89590932,
"message": {
"message_id": 5978,
"from": {
"id": 223110107,
"is_bot": false,
"first_name": "Ğąme",
"last_name": "Ǿver!",
"username": "GameO7er",
"language_code": "en"
},
"chat": {
"id": 223110107,
"first_name": "Ğąme",
"last_name": "Ǿver!",
"username": "GameO7er",
"type": "private"
},
"date": 1579094448,
"text": "/start Microsoft",
"entities": [{
"offset": 0,
"length": 6,
"type": "bot_command"
}]
}
}]
}
As you can see type=bot_command so you can parse the message if (type == "bot_command") and get text and substring /start from the original text or what ever you want to do.
In many cases I detect users with the parameters for example when I wanna to know who invited this user to bot I share the link in this format:
t.me/NameBot?start=ReferUserID
for example :
t.me/NameBot?start=223110107
is my ID and I can see how many user I've invited to the bot.
Hope be useful.

How to handle Polymorphic endpoints on Pact?

I have an app where I can search for Books and Movies. These 2 entities have different properties, so their JSON structures are different.
I also have a GET /favorites endpoint which should return both Books and Movies.
GET /favorites
{
"favorites": [
{
"type": "book",
"title": "Foo",
"author": "John"
},
{
"type": "movie",
"name": "Bar",
"producers": [
{
"firstName": "Mary"
}
]
}
]
}
I searched for for docs on this case but I can't find anything. How can I write a Pact contract for this use case?
I would write two separate test cases for this, and use Provider States to differentiate the two payloads.
For example:
When there are books
When there are movies
Or something to that effect. See [1] for related background on this.
[1] https://docs.pact.io/faq#why-is-there-no-support-for-specifying-optional-attributes

Does the RingCentral Call Log API Return a "Missed" Value?

In the RingCentral Online Account Portal (https://service.ringcentral.com) and endpoint apps, the call log display shows whether a call was Inbound, Outbound or Missed.
In looking at the API Reference for the Call Log API, it seems that it only sends back Inbound or Outbound for "Direction". Does the developer Call Log API return a "Missed" value? Is there another way to get this information via the Call Log API?
Ref: https://developer.ringcentral.com/api-docs/latest/index.html#!#RefCallLog.html
This question appears to be in reference to the Online Account Portal UI's "Type" column as shown in this screenshot:
The web UI's "Type" column shows Inbound, Outbound or Missed. This can be generated by using the response properties for both direction and result.
direction API response property will be Inbound or Outbound
result API response property is an enumerated value that includes Missed and other values including Voicemail which is the example screenshot. A full list is available in the link below:
Ref: https://developer.ringcentral.com/api-docs/latest/index.html#!#ResultStatusValues
Here is an example response:
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/call-log?view=Simple&showBlocked=true&withRecording=false&dateFrom=2018-08-27T06:18:00.000Z&page=1&perPage=100",
"records": [
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/call-log/22222222?view=Simple",
"id": "22222222",
"sessionId": "33333333",
"startTime": "2018-08-27T17:38:12.634Z",
"duration": 27,
"type": "Voice",
"direction": "Inbound",
"action": "Phone Call",
"result": "Missed",
"to": {
"phoneNumber": "+16505550101"
},
"from": {
"phoneNumber": "+16505550102",
"name": "LOS ALTOS CA",
"location": "Los Altos, CA"
}
}
],
...
}
Please read this blog to find out more information you can find from the call log.

Get the latest document based on a document's property in Azure Cosmos DB

Let's say that I have a Cosmos DB collection with the SQL API that contains a list of messages that people have sent that give their current mood and a timestamp of when the message has been received. People can send messages whenever they want.
In my collection I have something that looks like this:
[
{
"PersonName": "John",
"CurrentMood": "Moody",
"TimeStamp": "2012-04-23T18:25:43.511Z",
"id": "25123829-1745-0a09-5436-9cf8bdcc95e3"
},
{
"PersonName": "Jim",
"CurrentMood": "Happy",
"TimeStamp": "2012-05-23T17:25:43.511Z",
"id": "6feb7b41-4b85-164e-dcd4-4e078872c5e2"
},
{
"PersonName": "John",
"CurrentMood": "Moody",
"TimeStamp": "2012-05-23T18:25:43.511Z",
"id": "b021a4a5-ee92-282c-0fe0-b5d6c27019af"
},
{
"PersonName": "Don",
"CurrentMood": "Sad",
"TimeStamp": "2012-03-23T18:25:43.511Z",
"id": "ee72cb36-4304-06e5-ed7c-1d0ff890de48"
}
]
I would like to send a query that gets the "current" mood of all the user who sent a message (the latest message received for all person).
It's relatively easy to do for each particular user, by combining TOP 1 and ORDER BY
SELECT TOP 1 *
FROM C
WHERE C.PersonName = "John"
ORDER BY C.TimeStamp
But I feel like looping through all my users and running the query for each might be very wasteful in resource and become expensive quickly, but I can't find a way that will work.
To note that I will quickly have a lot of persons who will send a lot of messages.
The common pattern for this is to have two collections, one that stores documents for (user, timestamp -> mood), then a downstream processor using Azure Functions or the Change feed API directly that computes the (user -> latest mood)
[Mood Time series Collection] ==> Lambda ==> [Latest Mood Collection]
And the Latest Mood Collection will look something like this for the data stream above. You then use this for your lookups (which are now key lookups).
{
"PersonName": "Jim",
"LatestMood": "Happy",
"LatestTimeStamp": "2012-05-23T17:25:43.511Z",
"id": "6feb7b41-4b85-164e-dcd4-4e078872c5e2"
},
{
"PersonName": "John",
"LatestMood": "Moody",
"LatestTimeStamp": "2012-05-23T18:25:43.511Z",
"id": "b021a4a5-ee92-282c-0fe0-b5d6c27019af"
},
{
"PersonName": "Don",
"LatestMood": "Sad",
"LatestTimeStamp": "2012-03-23T18:25:43.511Z",
"id": "ee72cb36-4304-06e5-ed7c-1d0ff890de48"
}

Resources