Google API Update Product details - google-api

Is there a way to update a product unsing
https://www.googleapis.com/content/v2/SKU/products
or any other scope without inserting all details again in the JSON?
Untill know I understand that as soon I use INSERT and the conditions
"channel": "online",
"contentLanguage": "de",
"offerId": "12345",
"targetCountry": "de",
"condition": "new"
are the same as in one existing product it updates the product.
But I want to avaid to upload every Attribut again and I dont have these data in my Programm in this moment so I would have to GET them each time from Google.

It is possible to update with INSERT but the ID must not be the SKU itself it must contain the JSON ID string(like): "online:de:DE:12345"
So a JSON like:
{
"channel": "online",
"contentLanguage": "de",
"offerId": "online:de:DE:12345",
"targetCountry": "DE",
"price": {
"value": "99.00",
"currency": "EUR"
}
}
Will UPDATE the existing product.

Related

Get files from Sharepoint after doing a Filter on Array

The problem I am having is :
Sharepoint Get File Files (Properties Only) can only do one filter for ODATA, not a a second AND clause so I need to use Filter Array to make secondary filter work. And it does work....
But now I need to take my filtered array and somehow get the {FullPath} property and get the file content via passing a path and I get this error...
[ {
"#odata.etag": ""1"",
"ItemInternalId": "120",
"ID": 120,
"Modified": "2022-03-21T15:03:31Z",
"Editor": {
"#odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
"Claims": "i:0#.f|membership|dev#email.com",
"DisplayName": "Bob dole",
"Email": "dev#email.com",
"Picture": "https://company.sharepoint.us/sites/devtest/_layouts/15/UserPhoto.aspx?Size=L&AccountName=dev#email.com",
"Department": "Information Technology",
"JobTitle": "Senior Applications Developer II"
},
"Editor#Claims": "data",
"Created": "2022-03-21T15:03:31Z",
"Author": {
"#odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
"Claims": "i:0#.f|membership|dev#email.com",
"DisplayName": "Bob Dole",
"Email": "dev#email.com",
"Picture": "https://company.sharepoint.us/sites/devtest/_layouts/15/UserPhoto.aspx?Size=L&AccountName=dev#email.com",
"Department": "Information Technology",
"JobTitle": "Senior Applications Developer II"
},
"Author#Claims": "i:0#.f|membership|dev#email.com",
"OData__DisplayName": "",
"{Identifier}": "Shared%2bDocuments%252fSDS%252fFiles%252fA10_NICKEL%2bVANADIUM%2bPRODUCT_PIS-USA_French.pdf",
"{IsFolder}": false,
"{Thumbnail}": ...DATA,
"{Link}": "https://company.sharepoint.us/sites/devtest/Shared%20Documents/SDS/Files/A10_NICKEL%20VANADIUM%20PRODUCT_PIS-USA_French.pdf",
"{Name}": "A10_NICKEL VANADIUM PRODUCT_PIS-USA_French",
"{FilenameWithExtension}": "A10_NICKEL VANADIUM PRODUCT_PIS-USA_French.pdf",
"{Path}": "Shared Documents/SDS/Files/",
"{FullPath}": "Shared Documents/SDS/Files/A10_NICKEL VANADIUM PRODUCT_PIS-USA_French.pdf",
"{IsCheckedOut}": false,
"{VersionNumber}": "1.0" } ]
So from what I can see, I think it's what I thought. Even though you're filtering an array down to a single element, you need to treat it like an array.
I'm going to make an assumption that you're always going to retrieve a single item as a result of your filter step.
I created a variable (SharePoint Documents) to store your "filtered" array so I could then do the work to extract the {FullPath} property.
I then created variable that is initialised with the first (again, I'm making the assumption that your filter will only ever return a single element) and used this expression ...
variables('SharePoint Documents')?[0]['{FullPath}']
This is the result and you can use that in your next step to get the file content from SharePoint ...
If my assumption is wrong and you can have more than one then you'll need to throw it in a loop and do the same sort of thing ...
This is the expression contained within ...
items('For_Each_in_Array')['{FullPath}']
Result ...
I actually ended up doing this and it works.

How to patch property of list in nested object with condition for restful api

How should i design a Restful API for PATCH operation that support update some property in the a list with condition?
say i have following json model:
{
"key1": "value",
"key2": "value",
"list": [
{
"property": "someValue",
"toBePatched": "value"
},
{
"property": "otherValue",
"toBePatched": "value"
}
]
}
I need to patch the "toBePatched" property in the list when the "property" equals to "someValue". By looking at the json patch here, i think it is a good way to go, but i dont think the json pointer supports the query? how should i define a path that supports "/list/property=someValue/toBePatch"?
One stupid way to do it is to pass it as query parameter to the api, and have some logic around it, but i dont think thats a standard way to do it.
[
{ "op": "test", "path": "/list/0/property", "value": "someValue"},
{ "op": "test", "path": "/list/0/toBePatched", "value": "value"},
{ "op": "replace", "path": "/list/0/toBePatched", "value": "the-new-value"}
]
test is important, it lets you verify that the server hasn't change the part of the document that you are intending to change. See section 5 on Error Handling for details.

ElasticSearch URI Search null field

I need to create a query via URI to filter all data between two dates and also if this date field is null.
For example:
I have the field "creation_date" in some objects, however I want that in the resulting also does not appear the objects that the field does not have.
I tried something similar below:
http://localhost//elasticsearch/channels/channel/_search?q=channel.schedule.creation_date:[2018-06-19 TO 2018-12-22] OR channel.schedule.creation_date: NULL
As far as comparing the dates is OK, it works. The problem is to get the NULL values.
Edited
Source sample:
"_source": {
"channel": {
"activated": false,
"approved": false,
"content": "Jvjv",
"creation_date": "2018-06-21T13:06:10.000Z",
"facebookLink": "J jv",
"id": "Kvjvjv",
"instagramId": "Jvjv",
"name": "Kbkbkvk",
"ownerId": "sZtxdhiNbNY9sr2DtiCzlgJfsqb2",
"plan": 0,
"purpose": "Jvjv",
"recurrence": 1,
"segment": "Jvjvjv",
"twitterId": "Jvjv",
"youtubeId": "Jvj"
}
}
}
You can do this using the NOT(_exists_:field_name) constraint:
Can you try this ?
http://localhost//elasticsearch/channels/channel/_search?q=channel.schedule.creation_date:[2018-06-19 TO 2018-12-22] OR NOT(_exists_:channel.schedule.creation_date)

Sprind data jpa - How to handle selective fields posted by client to rest web service

I am handling request through Spring data rest using jpa. I have a domain class say user, in this domain class there is lots of fields and mappings. When client want to update user data, they have to submit whole json body as per domain class. In want to handle it so that client can update user information by sending selective fields only. What is the best approach for doing this please suggest.
Sample JSON OBJECT mapped to User domain class:
{
"id": 1,
"oauthClientDetails": {
"clientId": "8909241111",
"resourceIds": null,
"clientSecret": "secret",
"scope": "read",
"authorizedGrantTypes": "client_credentials",
"webServerRedirectUri": null,
"authorities": null,
"accessTokenValidity": 18000,
"refreshTokenValidity": null,
"additionalInformation": "{}",
"autoApprove": null
},
"deviceNo": "SMR01-4417-0002",
"deviceMasterType": {
"id": 1,
"name": "Single Phase",
"description": "Single phase meter",
"createdDate": "21-02-2018 10:11:03",
"updatedDate": "24-02-2018 10:11:03",
"statusMaster": {
"id": 2,
"name": "Active",
"createdDate": "21-02-2018 10:11:03",
"updatedDate": "21-02-2018 10:11:05",
"status": "1"
}
},
"societyName": "M G ROad",
"flatNo": "51",
"firstName": "rohit",
"lastName": "yadav",
"roleMaster": {
"id": 1,
"name": "Super user",
"description": "This role provides all application permissions.",
"createdDate": "23-02-2018 10:15:05",
"updatedDate": "23-02-2018 10:15:05",
"statusMaster": {
"id": 1,
"name": "De-Active",
"createdDate": "21-02-2018 10:11:03",
"updatedDate": "21-02-2018 10:11:05",
"status": "1"
}
},
"statusMaster": {
"id": 2,
"name": "Active",
"createdDate": "21-02-2018 10:11:03",
"updatedDate": "21-02-2018 10:11:05",
"status": "1"
},
"email": null,
"countryMaster": {
"id": 1,
"countryCode": "BOL",
"countryName": "Bolivia, Plurinational State of",
"callingCode": "591",
"createdDate": "21-02-2018 10:11:05",
"updatedDate": "21-02-2018 10:11:05"
},
"otp": "1234",
"otpVerification": null,
"alternateMobile": "8800488281",
"createdDate": "28-02-2018 11:15:05",
"updatedDate": "02-03-2018 10:15:05",
"clientID": null
}
You could partition your domain into sub domains, e.g.
Device contains (deviceNo) and DeviceMaster (deviceMasterType)
Role, Status, Country for roleMaster, statusMaster, countryMaster
with the root level elements such as email, updatedDate etc part of a base domain object such as Client.
your REST endpoints could then expose this domain structure to allow updating of partial information:
https://api.com/device
https://api.com/deviceMaster
https://api.com/role
https://api.com/status
https://api.com/country
https://api.com/client
and update the domain in parts. If a subdomain such as /device only needs the deviceNo updated, ignore the missing JSON fields when creating a domain object.
While it's good idea to break into sub-domain classes as suggested by #codebrane.
But even your sub-domain classes can have selective fields.
So you should first define which are optional and mandatory fields.
This first check should tell your clients what are the mandatory items they should send.
You should use Bean validations to achieve this as supported by whichever vendor database you are using.
And, it is unlikely that all items in your JSON are dependent, for example, a user's address or device information cannot be created without first saving the user.
If you put all of them in a single API then it will be hard for you to implement Single responsibility principle, rather not good as well.
In this scenario, you would correctly first save the user and then address, etc in a different API call.
Separate your dependent entities as separate domain objects which will help you in designing your REST APIs accordingly.
If you follow this approach then it helps you in giving the right responses to your clients as well. For e.g., an API which only takes address and fails for whatever reason will inform client that a single entity failed. If you had used Address, Contact, Device, etc all in one API then at server they can fail or pass independently and your API response will not be informative to the client.

freebase search api

How can I only return results which have a notable type?
IE when I have the default example:
https://www.googleapis.com/freebase/v1/search?query=nirvana&indent=true
It normally returns something like:
{
"mid": "/m/015k7",
"name": "Gautama Buddha",
"notable": {
"name": "Deity",
"id": "/religion/deity"
},
"lang": "en",
"score": 24.125902
}...
which is perfect, but sometimes it doesn't have a notable type and returns only:
{
"mid": "/m/01rkx5",
"name": "Mahayana Mahaparinirvana Sutra",
"lang": "en",
"score": 22.350945
},
How can i filter out all results except those that have a notable type?
I tried setting
filter = (all notable) but it expects (all notable:something)
any ideas?
Currently, its not possible to filter search results based on whether notable types exists. I've passed your suggestion on to the Freebase engineers and they'll considering whether to add this in a future release of the Search API.

Resources