Message parameter doesn't allow html, so tried to use message_tags parameter in this format - ios

Message parameter doesn't allow html, so tried to use message_tags parameter in this format, but with real values(format from here http://developers.facebook.com/blog/post/592/):
{
"19": [
{
"id": 101961456910,
"name": "Marmot",
"offset": 19,
"length": 6
}
],
"0": [
{
"id": 1207059,
"name": "Dhiren Patel",
"offset": 0,
"length": 12
}
]
}
and no result. Tried different values, there are no errors, but no result.

The message_tags parameter isn't one you can set via the API.
Did you find documentation suggesting otherwise? invalid parameters are for the most part silently ignored when you make a POST request

Related

OpenAPI field validation precedence

Let's imagine I have a schema with 2 properties:
"properties": {
"name": {
"type": "string",
"minLength": 2,
"pattern": "<some unmatchable pattern>",
"x-constraints": "Capitalized(required = true)"
},
"petType": {
"type": "string",
"minLength": 2,
"pattern": "<some unmatchable pattern>",
"x-constraints": "Capitalized(required = true)"
}
}
What will happen if I send an invalid field? Is there any written in stone precedence of validation order? I.e. can a dependent service be sure it will always get the "Wrong length" error if name="a", even though other constraints don't match?
I tried official documentation but had no luck. Tests seem to return different error messages, but not sure if not due to the nature of test itself.

Fitbit API: Not returning the steps for a time range on a date

I am using the Fitbit endpoint in iOS app to fetch the steps as below:
https://api.fitbit.com/1/user/-/activities/steps/date/2019-07-01/1d/15min/time/12:00/12:15.json
This is to fetch the steps on a date for some time interval but it returns the array of some activities like Yoga, Walking, Winter activities etc. but not returning the steps count for the time interval. Can anyone please tell me how can I fetch the data for the same?
It returns the result as:
"categories": [
{
"activities": [
{
"accessLevel": "PUBLIC",
"activityLevels": [
{
"id": 3016,
"maxSpeedMPH": -1,
"mets": 8.5,
"minSpeedMPH": -1,
"name": "6 - 8 inch step"
},
{
"id": 3017,
"maxSpeedMPH": -1,
"mets": 10,
"minSpeedMPH": -1,
"name": "10 - 12 inch step"
}
],
"hasSpeed": false,
"id": 90004,
"name": "Aerobic step"
},
{
"accessLevel": "PUBLIC",
"hasSpeed": false,
"id": 3015,
"mets": 6.5,
"name": "Aerobic, general"
},
I found the reason behind Fitbit returning such data. It is just because the intraday data fetch requires the review from Fitbit or we can use the "personal" application type to get the data.

Dealing with json responses that may change (not all keys included every time, new keys could be added)

I need some pointers here.
I'm talking to an API that returns data based on specific parameters. I have been taking that response and flattening/editing it to fit my model and then saving into the database. Everything was working great until today that I started testing the live endpoint (no dummy data) and as it turns out, the format of the response changes.
For example, if a data set does not have a record, rather than including the value as nil, some responses are not including that key at all. This is breaking my logic to flatten and edit since now I'd need to check that every single field exists before I do anything.
Here are 2 snippets of what it can look like
Sample 1 - (No shared)
{
"request_info": {
"city_id": 76211,
"currency": "usd",
"req_type": "geom"
},
"data": {
"rental_counts": {
"counts": {
"private": {
"1": 17,
"2": 3,
"all": 20
},
"entire": {
"0": 2,
"1": 8,
"2": 11,
"3": 16,
"4": 14,
"5": 6,
"all": 57
}
},
}
}
}
Sample 2 (includes Shared)
{
"request_info": {
"city_id": 76211,
"currency": "usd",
"req_type": "geom"
},
"data": {
"rental_counts": {
"counts": {
"private": {
"1": 17,
"2": 3,
"all": 20
},
"entire": {
"0": 2,
"1": 8,
"2": 11,
"3": 16,
"4": 14,
"5": 6,
"all": 57
},
"shared": {
"0": 2,
"1": 8,
"all": 10
}
},
}
}
}
The changes I believe can happen at any level and for any key (parent or child). I'm sure I'm not the first one to run into something like this. What is the best way to manage it? Is there some method or gem that would help with parsing json and getting it into a standardized model whether the data keys are there or not?
I had been looking at Roar but still don't quite understand how it works very well. Is this something Roar could handle or would the json object need to be pre-defined and not dynamic?
I found a simpler solution than roar or deserializers. Ruby's slice method allows you to only select pre defined keys and ignore all others. I'm calling this method after flattening my hash but before using active record to import.

Siri shortcuts rounding number in "Get Contents of URL" POST

I am trying to create a iOS 12 Shortcut based on the Gautrain API.
I want to do a POST to the URL https://api.gautrain.co.za/transport-api/api/0/journey/create with the following payload:
{
"geometry": {
"coordinates": [
[
28.23794,
-25.74762
],
[
28.05693,
-26.10858
]
],
"type": "MultiPoint"
},
"profile": "ClosestToTime",
"maxItineraries": 3,
"timeType": "DepartAfter",
"only": {
"agencies": [
"edObkk6o-0WN3tNZBLqKPg"
]
}
}
I have entered all these details into a "Get Contents of URL" block. For the elements of the "coordinates" arrays I have used "Number".
The problem is that when I track what my phone is sending via mitmproxy, it sends all the information correctly, but the coordinates have been rounded to integers:
{
"geometry": {
"coordinates": [
[
28,
-25
],
[
28,
-26
]
],
"type": "MultiPoint"
},
"maxItineraries": 1,
"only": {
"agencies": [
"edObkk6o-0WN3tNZBLqKPg"
]
},
"profile": "ClosestToTime",
"timeType": "DepartAfter"
}
For this reason, the request is not giving the desired results.
I have a feeling this may be a bug, but is there something I am missing where I can tell Shortcuts to use the full set of digits?
I have found the problem. Since I am in South Africa, the numbers are expected to have commas instead of periods for decimals. I would have loved some feedback in the field that this wasn't a valid number instead of just silently ignoring the decimal.
The solution therefore was to change the "28.23794" in the entry box to "28,23794".
I might also link to postman-echo.com as an excellent tool for debugging these kinds of requests.

Importing relationships with Core Data and Magical Record

I am getting JSON data from a webservice and try to store that in Core Data with Magical Record. I read the great post (and only documentation?) "Importing data made easy" by Saul Mora but I still do not really understand what I need to do to get all data in my entities.
Here is the JSON the web service returns:
{
"ApiVersion": 4,
"AvailableFileSystemLibraries": [
{
"Id": 10,
"Name": "Movie Shares",
"Version": "0.5.4.0"
},
{
"Id": 11,
"Name": "Picture Shares",
"Version": "0.5.4.0"
},
{
"Id": 5,
"Name": "Shares",
"Version": "0.5.4.0"
},
{
"Id": 9,
"Name": "Music Shares",
"Version": "0.5.4.0"
}
],
"AvailableMovieLibraries": [
{
"Id": 3,
"Name": "Moving Pictures",
"Version": "0.5.4.0"
},
{
"Id": 7,
"Name": "MyVideo",
"Version": "0.5.4.0"
}
],
"AvailableMusicLibraries": [
{
"Id": 4,
"Name": "MyMusic",
"Version": "0.5.4.0"
}
],
"AvailablePictureLibraries": [
{
"Id": 8,
"Name": "Picture Shares",
"Version": "0.5.4.0"
}
],
"AvailableTvShowLibraries": [
{
"Id": 6,
"Name": "MP-TVSeries",
"Version": "0.5.4.0"
}
],
"DefaultFileSystemLibrary": 5,
"DefaultMovieLibrary": 3,
"DefaultMusicLibrary": 4,
"DefaultPictureLibrary": 0,
"DefaultTvShowLibrary": 6,
"ServiceVersion": "0.5.4"
}
The entities I want to store that data in look like this:
There is also a Server entity with a 1:1 relationship to ServerInfo.
What I want to do:
Store basic data (ApiVersion, ...) in ServerInfo. This I already got to work.
Store each object in AvailableXYLibraries in BackendLibrary (1:n relationship from ServerInfo).
Set type based on the XY part of AvailableXYLibraries, for example "movie" for AvailableMovieLibraries.
Set defaultLibrary to true if this library is referenced by DefaultXYLibrary.
Set providerId to servername + LibraryId as there are multiple servers that can have BackendLibraries with the same numeric ID.
Is this possible with Magical Record? I guess I need to implement some of the import hooks and set some user info keys, but everything I read doesn't really tell me where to set what user info key or implement which method where and how.
I hope this made sense and that you can give me some hints :) Thanks!
The structure of this data is quite a bit different from your Core Data model. What you'll most likely have to do is iterate a bit on the dictionary. That is, there are various collections of library data, eg. FileSystemLibraries, AvailableMovieLibraries, etc. You'll have to get the array out of those keys, and then map your entities as I described in the article. In order to launch the process, you'll have to call
[BackendLibrary importFromArray:arrayFromDownloadedDictionary];
where the arrayFromDownloadedDictionary is each array in the example dictionary you've posted. Once you give the array to MagicalRecord, and provided the proper field mapping, MagicalRecord will then import and create all the entities for you at that point.
Make sure you map "Id" to BackendLibary.id, "Name" to BackendLibrary.name, and "Version" to BackendLibrary.version

Resources