Fetching only shipped orders from orocommerce using API - orocommerce

I want to fetch orders with the internal status shipped from my orocommerce store what will be filter for that.In documentation I am not getting any help.
Thanks
Utpal Maity

Seems entity InternalStatus is disabled by default – https://github.com/oroinc/orocommerce/blob/master/src/Oro/Bundle/OrderBundle/Resources/config/oro/api.yml#L37.
If you change (overwrite in your api.yml) it to:
Extend\Entity\EV_Order_Internal_Status: ~
it will be available in API in relationships section:
"internal_status": ▿{
"data": {
"type": "orderinternalstatuses",
"id": "open"
}
}
}
as well as in filter. For other entities same configuration should be applied.
Please have a look at API documentation – https://github.com/laboro/dev/blob/f2a40c66127531287b4f0d5a35ed7800196be6ac/package/platform/src/Oro/Bundle/ApiBundle/Resources/doc/configuration.md

Related

How to limit Podio API output for complex item resources

Is it possible to limit API response from the POST /item/app/{app_id}/filter/ for a complex resources with a lot of fields set? I know there is fields param and it can be used with some predefined views, like items.view(micro), but this is not a solution for us. We need to explicitly define which fields should be returned, to have in the response only needed fields (optimize the output length as much as possible, but have all needed fields). Can we somehow achieve this by available for now API params or could Podio consider to introduce such functionality in the future API revisions?
You can specify the fields() decorator, to add desired fields to your view.
items.view(micro).fields(fields,created_on,last_edit_on)
Unfortunately I don't think it is possible to further filter the number of Podio Application's Fields returned under the REST response's fields field (ugh 😓).
I couldn't find a way to filter on the Fields defined by the user on the Application.
E.g.
[
{
"fields": [
{
"label": "My item field"
"field_id": 123456778,
"external_id": "my-item-field"
}
]
}
]
It's not possible to filter by my-item-field.
As I know, Rest Api doesn't allow you to limit (select) output fields. (As GraphQL can do)
So, while Podio is on Rest Api - you can't do that.

How to get reviews history

I'm using the Upsource API to get the revisions and reviews.
Does anyone know which method to use to get the reviews summary?
Review Summary
I've tried getReviewSummaryChanges, getReviewSummaryDiscussions, but I didn't get what I needed.
Thank you
You can try other methods as described in the documentation:
https://upsource.evolutiongaming.com/~api_doc/reference/index.html
Try POST with "getFeed" method to get complete set of changes happening to a review : including "addedRevisions":
https://upsource-host/~rpc/getFeed
{
"limit": 20,
"type": 2,
"projectId":"myproject",
"reviewId":"MYPROJECT-CR-123"
}

Asana integration with Slack

I am looking to implement a solution where when I create a project in Asana it will create a room in Slack with all the same members.I was planning on writing a script to run every couple of minutes to look for either new projects or changes in membership of current projects and then call out to slack to make the changes. This, however, would be a lot of chatter so I was hoping someone might know of and be able to recommend another way that will make these changes on an as needed basis.
It sounds like you have the best solution outlined for this use case.
In order to get a list of new projects in a workspaces you should query the projects endpoint and check for newly created projects based on the created_at field, using opt_fields field selector to have that returned in your query. I strongly suggest that you scope this query to a single workspace and use pagination.
GET 'https://api.asana.com/api/1.0/workspaces/5233820891524/projects?opt_fields=name,created_at&limit=2' | j
{
"data": [
{
"id": 23154287843671,
"created_at": "2014-12-31T18:35:49.695Z",
"name": "Ninja Things"
},
{
"id": 23154287843675,
"created_at": "2014-12-31T18:35:59.174Z",
"name": "Unicorns"
}
],
"next_page": {
"offset": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJib3JkZXJfcmFuayI6ImRTbm5ZaGNOOWFFIiwiaWF0IjoxNDM4ODE0MzY0LCJleHAiOjE0Mzg4MTUyNjR9.82zecHAT51-GSrL6FdcrRdMs45U7PZ3g-d4Zuo_B8UA",
"uri": "https://api.asana.com/api/1.0/workspaces/5233820891524/projects?limit=2&opt_output=json&opt_fields=name%2Ccreated_at&offset=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJib3JkZXJfcmFuayI6ImRTbm5ZaGNOOWFFIiwiaWF0IjoxNDM4ODE0MzY0LCJleHAiOjE0Mzg4MTUyNjR9.82zecHAT51-GSrL6FdcrRdMs45U7PZ3g-d4Zuo_B8UA",
"path": "/workspaces/5233820891524/projects?limit=2&opt_output=json&opt_fields=name%2Ccreated_at&offset=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJib3JkZXJfcmFuayI6ImRTbm5ZaGNOOWFFIiwiaWF0IjoxNDM4ODE0MzY0LCJleHAiOjE0Mzg4MTUyNjR9.82zecHAT51-GSrL6FdcrRdMs45U7PZ3g-d4Zuo_B8UA"
}
}
For new members of current projects you would need to query individual projects and check the memberships property.
I would have suggested using the Events api to check for new members but tested and determined that new members are not considered an event on the project, something that we will consider changing.

How to retrieve all products from a Smart Collection through Shopify API?

What's the best way to retrieve all products from a Smart Collection through Shopify API?
Thanks!
Update: API version 2020-04
See Codesmith's answer below. As of API version 2020-04, you can now use a smart collection id with the collections endpoint:
GET /admin/api/2020-04/collections/{collection_id}/products.json
See the Collection API docs for more info.
Pre-2020 solution
From the SmartCollection page in the Shopify API docs:
Smart Collections also use collects to connect a product to that smart collection.
And on the Collects page:
List only collects for a certain collection
GET /admin/collects.json?collection_id=841564295
HTTP/1.1 200 OK
{
"collects": [
{
"collection_id": 841564295,
"created_at": "2014-05-23T14:16:47-04:00",
"featured": false,
"id": 1071559648,
"product_id": 921728736,
"sort_value": "0000000001",
"updated_at": "2014-05-23T14:16:47-04:00",
"position": 1
},
...
]
}
The collects contain the product_ids for each of the products in the collection with the specified collection_id.
2020 Update,
For the latest API (2020-04 as of now), you can simply use the /collections/ endpoint, using the Smart Collection ID:
GET https://<shopname>.myshopify.com/admin/api/2020-04/collections/<smart collection id>/products.json
More details can be found in Shopify's Collection API Docs.

RESTfully handling sub-resources

I've been creating a RESTful application and am undecided over how I should handle requests that don't return all entities of a resource or return multiple resources (a GET /resource/all request). Please allow me a few moments to setup the situation (I'll try to generalize this as much as possible so it can apply to others besides me):
Let's say I'm creating a product API. For simplicity, let's say it returns JSON (after the proper accept headers are sent). Products can be accessed at /product/[id]. Products have reviews which can be accessed at /products/[id]/review/[id].
My first question lies in this sub-resource pattern. Since you may not always want the reviews when you GET a product, they are accessible by another URI. From what I read I should include the URI of the request that will return all review URI's for a product in the response for a product request. How should I go about this so that it abides to RESTful standards? Should it be a header like Reviews-URI: /product/123/review/all or should I include the URL in the response body like so:
{ 'name': 'Shamwow',
'price': '$14.99',
'reviews': '/product/123/review/all'
}
My second question is about how the /product/[id]/review/all request should function. I've heard that I should just send the URL's of all of the reviews and make the user GET each of them instead of packaging all of them into one request. How should I indicate this array of review URIs according to RESTful standards? Should I use a header or list the URIs in the response body like so:
{ 'reviews': [ '/product/123/review/1',
'/product/123/review/2',
'/product/123/review/3'
]
}
Your problem is you're not using Hypermedia. Hypermedia specifically has elements that hold links to other things.
You should consider HAL, as this is a Hypermedia content type that happens to also be in JSON.
Then you can leverage the links within HAL to provide references to your reviews.
As to your first question (header or body), definitely do not invent your own custom header. Some here will argue that you should use the Link header, but I think you'll find plenty of need for nested links and should keep them in the body.
How you indicate either the URI to the reviews/ resource, or the list of URI's within that, is entirely up to the media type you select to represent each resource. If you're using HTML, for example, you can use an anchor tag. If you're using plain JSON, which has no hypermedia syntax, you'll have to spend some time in the documentation for your API describing which values are URI's, either by nominating them with special keys, or wrapping them in special syntax like {"link": "reviews/123"}, or with a related schema document.
Take a look at Shoji, a JSON-based media type which was designed explicitly for this pattern of subresources.
The JSON Schema standard might help you here, in particular Hyper-Schemas.
It lets you define how to extract link URIs from your data, and what their "rel"s are - essentially turning your JSON data into hyper-media. So for your first bit of data, you might write a schema like:
{
"title": "Product",
"type": "object",
"properties": {...},
"links": [
{"rel": "reviews", "href": "{reviews}"}
]
}
The value of href is a URI Template - so for example, if your data included productId, then you could replace the value of href with "/product/{productId}/review/all".
For the second bit of example data (the list of reviews) you might have a schema like this:
{
"type": "object",
"properties": {
"reviews": {
"type": "array",
"items": {
"links": [
{"rel": "full", "href": "{$}"}
]
}
}
}
}
In the URI Template of href, the special value of {$} means "the value of the JSON node itself". So that Hyper-Schema specifies that each item in the reviews array should be replaced with the data at the specified URL (rel="full").