Closed
Bug 894591
Opened 12 years ago
Closed 12 years ago
API consumers should be able to reorder applications in a collection
Categories
(Marketplace Graveyard :: API, defect, P2)
Tracking
(Not tracked)
RESOLVED
FIXED
2013-08-13
People
(Reporter: chuck, Assigned: chuck)
References
Details
(Whiteboard: p=2 [qa+])
API consumers should be able to reorder applications in a collection at a unique endpoint.
This endpoint should be protected by the Apps:Collections permission created in bug 894425.
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → charmston
Comment 1•12 years ago
|
||
https://github.com/mozilla/flue/commit/e7f7311
Added Flue API endpoint:
curl -X POST 'http://localhost:5000/api/v1/rocketfuel/collections/<collection_slug>/reorder_app/' -d 'app=<app_id>&position=<position>'
P.S. It'd be nice to accept a JSON-formatted list of applications with their corresponding positions. Or we can create a separate "bulk" `reorder_app` API endpoint.
Assignee | ||
Comment 2•12 years ago
|
||
I was thinking that we'd only accept a bulk submission, and return a 400 if, e.g., all apps in the collection weren't represented in the body. We'll always have the data in the rocketfuel client, and it's a clean and explicit way to ensure that ordering collisions don't happen with a single request.
So if
GET /api/v1/rocketfuel/collections/80/
Returns the response body of:
{
"name": "Cee's Vans",
"description": "All the apps you need to purchase your next vehicle.",
"apps": [
"/api/v1/apps/app/100/",
"/api/v1/apps/app/200/",
"/api/v1/apps/app/300/",
"/api/v1/apps/app/400/"
}
}
Then you would submit this request body to swap the positions of the apps with PKs of 200 and 300:
POST /api/v1/rocketfuel/collections/80/reorder_apps/
{
100: 1,
200: 3,
300: 2,
400: 4
}
Comment 3•12 years ago
|
||
(In reply to Chuck Harmston [:chuck] from comment #2)
> I was thinking that we'd only accept a bulk submission, and return a 400 if,
> e.g., all apps in the collection weren't represented in the body. We'll
> always have the data in the rocketfuel client, and it's a clean and explicit
> way to ensure that ordering collisions don't happen with a single request.
The downside here is that if someone modifies the collection while someone else is reordering it, everything falls apart for the user reordering the collection and they get into a situation where they're in a bad state and there's no clear way to recover.
Assignee | ||
Comment 4•12 years ago
|
||
Yeah, this isn't ideal, but careful error catching on the side of the client could suggest this as a likely cause of the error. That seems more reasonable than the potentially unexpected or unpredictable results of concurrent editing.
Comment 5•12 years ago
|
||
(In reply to Chuck Harmston [:chuck] from comment #4)
> Yeah, this isn't ideal, but careful error catching on the side of the client
> could suggest this as a likely cause of the error. That seems more
> reasonable than the potentially unexpected or unpredictable results of
> concurrent editing.
If the error response contained the updated list of apps, that would be helpful.
Assignee | ||
Comment 6•12 years ago
|
||
Landed here: https://github.com/mozilla/zamboni/commit/7de9f51c2aab14b0bd1ca01773fa2f764ba76757
Docs: http://firefox-marketplace-api.readthedocs.org/en/latest/topics/rocketfuel.html#reorder-apps
STR:
1) Create a collection, using the steps here: http://firefox-marketplace-api.readthedocs.org/en/latest/topics/rocketfuel.html#post--api-v1-rocketfuel-collections-
2) Add multiple apps from a collection, using the steps here: http://firefox-marketplace-api.readthedocs.org/en/latest/topics/rocketfuel.html#post--api-v1-rocketfuel-collections-%28int-id%29-add_app-
3) Attempt to reorder the collection, using the steps here: http://firefox-marketplace-api.readthedocs.org/en/latest/topics/rocketfuel.html#reorder-apps
4) In a successful reproduction, the response from step 3 should return the apps in the new order indicated by the request from step 3.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: p=2 [qa+]
Target Milestone: --- → 2013-08-13
Assignee | ||
Comment 7•12 years ago
|
||
(Note: all requests will need to authenticate using steps 1-2 in the STR from bug 894456, comment 1)
You need to log in
before you can comment on or make changes to this bug.
Description
•