Is HTTParty clearing a variable in responses - ruby-on-rails

I found a weird case using httparty, in one of the API I do receive expected JSON object expect one key which has an empty value. This key's name is PaymentToken. Wondering if this is some configuration to hide / clear value of variables with Token / Payment in the name?
I was trying to reproduce the same issue on Postman, with exactly the same request and receiving the same structure of object with the same keys values + PaymentToken value is there.
Postman:
{
"ActionType": "RES",
"IsActive": false,
"BookingCode": null,
"PaymentToken": "/ON9lFhfw2VYR9BiIep/peByEOtPSmtI7t+vxbcHFtsJctezBgS3mwKcVxSNCzZqKHXi4qPh8pMPGRMJOU6+1ZhSQ=",
"Customer": null,
"Mode": 0
}
HTTParty:
{
"ActionType": "RES",
"IsActive": false,
"BookingCode": null,
"PaymentToken": "",
"Customer": null,
"Mode": 0
}
Has anyone experienced the same issue?

Related

Getting labels from Planner with Microsoft Graph API

Is it possible to get the labels and priority from a Microsoft Planner task with the Microsoft Graph API?
See screenshot below to have an idea:
Using next endpoint: https://graph.microsoft.com/v1.0/planner/plans/<plan-id>/tasks I get next data:
{
"#odata.etag": "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBBWCc=\"",
"planId": "r4g58er4grregrg7848",
"bucketId": "64g8df54hhktohk487",
"title": "Title of a task",
"orderHint": "545457845775LM",
"assigneePriority": "",
"percentComplete": 0,
"startDateTime": null,
"createdDateTime": "2022-01-07T13:58:14.5355148Z",
"dueDateTime": null,
"hasDescription": true,
"previewType": "description",
"completedDateTime": null,
"completedBy": null,
"referenceCount": 0,
"checklistItemCount": 1,
"activeChecklistItemCount": 3,
"conversationThreadId": null,
"id": "grejgopreg645647",
"createdBy": {
"user": {
"displayName": null,
"id": "74463467-d67d-4512-9086-c9e279dde6ae"
}
},
"appliedCategories": {
"category5": true
},
"assignments": {}
}
I've next comments on this JSON:
What is assigneePriority? When a priority is filled in, will always be an empty string.
What is appliedCategories? Can these categories being used for the labels? But what is category5?
While it's not the most straightforward answer, you can figure out what labels are assigned to a task. You'll need both the planid and taskid to get it.
The appliedCategories are actually the labels applied to a particular task. Their identifieres are just category##. To find the corresponding label name, you'll need to make a call to get the plan details.
Graph API URL: https://graph.microsoft.com/beta/planner/plans/{planid}/details
This will return a JSON object containing each of the categories and their descriptions. You can find more info here about the plannerPlanDetails type. Note: the v1.0 graph endpoint only returns the first 6 categories, while the beta version will return 25.
"categoryDescriptions": {
"category1": "Some name",
"category2": "Some other name",
"category3": "Another",
"category4": null,
...
"category25": null
}
Within the task details, appliedCategories object will contain any labels assigned to that task.
For the priority, you will find a priority property on the task object when using the beta version of the endpoint. It's an integer, but from my testing, the following are the corresponding priority titles
9 - Low
5 - Important
3 - Medium
1 - Urgent
You'll have to do some correlation on your own to match them up, but this is how you can get the information you're looking for.

Graph API: reportDate attribute not available in getEmailActivityCounts

I have been using the getEmailActivityCounts(Beta version) in graph api for the past 3 years.
But recently facing issues on retrieving the reportDate in the graph data when JSON export type is used. Without reportDate, we couldn't map on which date the metrics count had happened.
Any help would be appreciated.
Request : https://graph.microsoft.com/beta/reports/getEmailActivityCounts(period='D180')?$format=application/json
Response : {
"reportRefreshDate": "2022-01-19",
"send": 3,
"receive": 14,
"read": null,
"meetingCreated": 0,
"meetingInteracted": null,
"reportPeriod": "180"
},
{
"reportRefreshDate": "2022-01-19",
"send": 1,
"receive": 1,
"read": null,
"meetingCreated": 0,
"meetingInteracted": null,
"reportPeriod": "180"
}
Thanks in Advance,
Maerona Wynn

Data sample for JSON type provider with optional property

I am trying to use the JSON type provider to access StackOverflow / StackExchange data via the API. It works great, with one caveat. The API has a throttle, which is signaled by a field "backoff" that contains the number of seconds you are supposed to back off until your next request.
As a result, I can't just point the JSON TP to the url, because by default the backoff field is not present. This is how the response typically looks:
{
"items": [
{
"has_synonyms": true,
"user_id": 1144035,
"is_moderator_only": false,
"is_required": false,
"count": 7054,
"name": "sql"
},
{
"has_synonyms": true,
"user_id": 1144035,
"is_moderator_only": false,
"is_required": false,
"count": 16,
"name": "algorithm"
}
],
"has_more": true,
"quota_max": 10000,
"quota_remaining": 9693
}
I assumed what I needed to do was to supply a sample which contains both an example without backoff (as above), and one along the lines of this:
"has_more": true,
"quota_max": 10000,
"quota_remaining": 9693,
"backoff": 10
}
... so that I get a Backoff Option. However, I am not sure how to structure / prepare the sample to that effect. Help would be much appreciated!
JSON Type Provider has a property SampleIsList, set it to true.
There is a documentation section Parsing Twitter stream about it, JsonProvider please scroll down as there is no way to reference the section directly.
Your sample file should look like this
[{
...
"has_more": true,
"quota_max": 10000,
"quota_remaining": 9693
},{
...
"has_more": true,
"quota_max": 10000,
"quota_remaining": 9693,
"backoff": 10
}]

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

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

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

Resources