I'm using the Google Shopping API to try to retrieve products that have an "order" of magnitud of a certain number, or approximation to this. For example If I would to select products that are between th $40 - $60 price range : $50 +/- $10. What should I add in the URL search string?
I know I can rank by price like this (according to the API):
GET https://www.googleapis.com/shopping/search/v1/public/products?key=key&country=US&q=%22mp3+player%22%7Cipod&rankBy=price%3Adescending
Nevermind, the correct way to do this was using flask and jinja2 along with ajax. One has to be aware of using JSON and how it maps correctly to its equivalent python objects, when using the google shopping API main 'items' objects :
"product": {
"googleId": "9243781955569725518",
"author": {
"name": "CompUPlus.com",
"accountId": "1209120"
},
"creationTime": "2010-03-04T09:51:45.000Z",
"modificationTime": "2010-11-25T09:24:08.000Z",
"language": "en",
"country": "US",
"title": "Logitech Squeezebox Radio, black",
"description": "Logitech Squeezebox Radio brings a world of free Internet radio subscription
services and your personal digital music collection to any space in your home
over your Wi-Fi network.",
"link": "http://www.compuplus.com/Radios/LOGITECH-Squeezebox-Radio-BLK-930-1115160.html",
"gtin": "00097855063601",
"gtins": [
"00097855063601"
],
"brand": "Logitech",
"mpn": "930-000101",
"condition": "new",
"images": [
{ "link": "http://content.etilize.com/300/1014430207.jpg" }
]
"inventories": [
{
"channel": "online",
"availability": "inStock",
"currency": "usd",
"price": 183.19
}
],
}
Related
This is a continuation of my other question:
My first question
What I am trying to accomplish:
User enters a mention
My web service creates an adaptive card form with custom data (same schema)
presents the card to my user
user enters some data
Submit sends this form data to my web service for processing
Here is the card (the result of the 1st http) I am sending in reply to mention
$var = '{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2",
"msTeams": {
"width": "full"
},
"body": [
{
"type": "TextBlock",
"text": "Adaptive Card Example",
"wrap": true,
"size": "large",
"weight": "bolder",
"id": "title"
},
{
"type": "Input.Text",
"placeholder": "Provide your thoughts",
"separator": true,
"isMultiline": true,
"id": "thoughts"
},
{
"type": "ActionSet",
"separator": true,
"actions": [
{
"type": "Action.Submit",
"title": "Submit",
"style": "positive",
"id": "submit"
}
]
}
]
}
';
How do i get to the value of input.text with the id of thoughts? everything i see, it ends up blank.
I am not sure what else you need to help, i can edit/post anything else.
*EDIT
this is my dynamic dropdown.
You should be able to make use of the dynamic content presented to you that is taken directly from your adaptive card definition ...
If the dynamic property doesn't exist, the easiest way to get the result is to simply refer to it using an expression ...
body('Post_adaptive_card_and_wait_for_a_response')?['data']?['thoughts']
... you could do the work to fully qualify the dynamic properties but in this case, it seems like overkill.
This is the output after I completed the card in my Teams channel ...
I am trying to get some info about errors of my desktop app from Microsoft Store analytics API. This is the response that I get from API:
{
"Value": [
{
"date": "2021-05-27",
"applicationId": "myid",
"applicationName": "myapp",
"failureName": "MOAPPLICATION_HANG_cfffffff_0EB8BD08.myapp!HANG_QUIESCE",
"eventType": "hang",
"deviceCount": 1423.0,
"eventCount": 1244.41342561402
},
{
"date": "2021-05-25",
"applicationId": "myid",
"applicationName": "myapp",
"failureName": "MOAPPLICATION_HANG_cfffffff_0EB8BD08.myapp!HANG_QUIESCE",
"eventType": "hang",
"deviceCount": 1468.0,
"eventCount": 1242.87238240919
},
{
"date": "2021-05-26",
"applicationId": "myid",
"applicationName": "myapp",
"failureName": "MOAPPLICATION_HANG_cfffffff_0EB8BD08.myapp!HANG_QUIESCE",
"eventType": "hang",
"deviceCount": 1480.0,
"eventCount": 1297.92338878456
}
],
"TotalCount": 3
}
Among other things, I want to know how many errors of each type were in specified period. I hoped that field eventCount would represent this info but as I can see it's not an integer in my case. Also in Microsoft docs I can see the same thing in example.
I got two questions:
Which metric eventCount field represents?
How can I get number of errors using this API?
There used to be sitemaps functionality but it got deprecated. Taxonomies are suggested as a replacement but when I request items from the API, the taxonomy elements lack the hierarchical structure. How do I search for an item that represents a parent page in website structure? Thank you.
You can still do that with Delivery API. First, you need to create and and organize your taxonomy group the same way you would organize your sitemap. Consider following sitemap as an example:
Home
About
Our team
Management
Contact us
Mission&Values
This is what the taxonomies would look like in Kentico Cloud:
Models for your items need to be created with taxonomy element, that would serve as a sitemap location selector. When you retrieve this element from the item, it will give you a list of terms that the item is associated with. If you tick two terms with the item (Contact us, Our team), this is what the element would look like in the API:
{
"item": {
"system": {
"id": "8a9e7010-c79b-41c5-a0bc-4f20c9c233b8",
"name": "Example item - contact form",
"codename": "example_item___contact_form",
"language": "default",
"type": "example_content_model",
"sitemap_locations": [],
"last_modified": "2019-05-13T08:20:50.3173519Z"
},
"elements": {
"sitemap": {
"type": "taxonomy",
"name": "Sitemap",
"taxonomy_group": "sitemap",
"value": [
{
"name": "Contact Us",
"codename": "contact_us"
},
{
"name": "Our team",
"codename": "our_team"
}
]
}
}
},
"modular_content": {}
}
As you can see you get information about taxonomy group codename and a flat list of name and codename pairs of each ticked term. To get the hierarchical structure, you need to make second call to retrieve the taxonomy group, which will yield following:
{
"system": {
"id": "0b4e3da2-8699-4b4d-961c-1fe912c91570",
"name": "Sitemap",
"codename": "sitemap",
"last_modified": "2019-05-13T08:01:34.6109452Z"
},
"terms": [
{
"name": "Home",
"codename": "home",
"terms": []
},
{
"name": "About",
"codename": "about",
"terms": [
{
"name": "Our team",
"codename": "our_team",
"terms": [
{
"name": "Management",
"codename": "management",
"terms": []
},
{
"name": "Contact Us",
"codename": "contact_us",
"terms": []
}
]
},
{
"name": "Mission & Values",
"codename": "mission___values",
"terms": []
}
]
}
]
}
Which reflects needed hierarchy. You can compare the codenames you got from your item to the position of the taxonomy term in your group - to get the parent taxonomy term just get the parent JSON node. If you need to figure out the parent item itself, you can call Delivery API again and use one of the array filters to get all the items marked with the parent sitemap location.
I have a spring-boot based micro-service generated using JHipster.
I am using keycloak as my Auth Server. I could enable Role-based & scope based authorization on my resources(apis).
Now the requirement is: based on the role of the client, I need to restrict the information to send in the response (either mask the attributes or nullify them).
eg:
consider the following api to get the person's profile
/api/person/{id}
{
"name": {
"firstName": "Jack",
"lastName": "Sparrow"
},
"gender": "MALE",
"emails": {
"details": [
{
"emailId": "jack.sparrow#gmail.com"
}
]
},
"phones": {
"details": [
{
"phoneNumber": "1234567890",
"countryCode": "+1"
}
]
},
"addresses": {
"details": [
{
"addressLine1": "aaaaaaaa",
"addressLine2": "bbbbbbb",
"city": "cccccc",
"state": "ddddd",
"country": "South Africa",
"postalCode": "987654"
}
]
},
"photo": "string",
"nationality": "South Africa",
"countryOfResidence": "string",
"active": true,
"createdAt": 1537431339569,
"modifiedAt": 1537436600693,
"createdBy": "admin",
"modifiedBy": "admin"
}
Now, when a person with BASIC role calls this API, the requirement is to show only basic information like:
- name, gender
If he has INTERMEDIATE role then we can send something more than basic but not full information. eg: name, gender, photo, nationality
If he has ADMIN role then we can send the complete information.
Can anyone please let me know What is the best approach to achieve this.
-- Thanks in advance :)
Consider there is a action card response from the MS bot & it looks as follows in skype:
When this similar response comes in the REST APIs i.e using Direct Line APIs. The following is the relevant part of JSON response.
{
"id": "1t90Ym3PEry|000000000000000014",
"conversationId": "1t90Ym3PEry",
"created": "2016-12-06T09:34:55.6280699Z",
"from": "rich3cards",
"images": [
"https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Seattlenighttimequeenanne.jpg/320px-Seattlenighttimequeenanne.jpg"
],
"attachments": [],
"eTag": "W/\"datetime'2016-12-06T09%3A34%3A54.94083Z'\""
},
{
"id": "1t90Ym3PEry|000000000000000014",
"conversationId": "1t90Ym3PEry",
"created": "2016-12-06T09:34:55.6280699Z",
"from": "rich3cards",
"text": "Hero Card\n\nSpace Needle\n\nThe <b>Space Needle</b> is an observation tower in Seattle, Washington, a landmark of the Pacific Northwest, and an icon of Seattle.\n\n(Current Weather) action?weather=Seattle, WA",
"images": [],
"attachments": [],
"eTag": "W/\"datetime'2016-12-06T09%3A34%3A54.94083Z'\""
}
Now, the question is about how do we parse this json to get the button data [(Current Weather) action?weather=Seattle, WA"] out of the text attribute? Is the only way is patter match ?
Has anyone faced or know solution, please put some light here too ;)
Update: If its different channel like skype/webchat/etc.. the JSON response looks very proper to consume, following is the sample JSON.
{
"type": "message",
"id": "5AdoK89rtSc|000000000000000018",
"timestamp": "2016-12-06T09:53:20.4777291Z",
"channelId": "webchat",
"from": {
"id": "rich3cards",
"name": "RichCards"
},
"conversation": {
"id": "5AdoK89rtSc"
},
"attachments": [
{
"contentType": "application/vnd.microsoft.card.hero",
"content": {
"title": "Hero Card",
"subtitle": "Space Needle",
"text": "The <b>Space Needle</b> is an observation tower in Seattle, Washington, a landmark of the Pacific Northwest, and an icon of Seattle.",
"images": [
{
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Seattlenighttimequeenanne.jpg/320px-Seattlenighttimequeenanne.jpg"
}
],
"buttons": [
{
"type": "postBack",
"value": "action?weather=Seattle, WA",
"title": "Current Weather"
}
]
}
}
]
As mentioned in the comments, you are using DirectLine v1.1. Unfortunately, v1.1 doesn't support attachments/cards and so there isn't a good way to understand/parse the card.
You might want to consider moving to DirectLine v3 which has full support for attachments.
Alternatively, if you want to support Cards, you might have to do something custom as shown in the DirectLine sample. There, the bot is sending the hero card through the ChannelData field and the client is parsing that accordingly. However, you might have to add the logic to detect who is talking to the bot so you send the cards as ChannelData only if the caller is DirectLine and not one of the other clients (such as skype)