Now that the client is posting the full edit api call options with each contribution, it must be signed with the user access token and secret keys before being posted on to `https://test-commons.wikimedia.org/w/api.php`
The API options for each individual contribution can be found in the `api_options` key, e.g. `api_options = contribution["api_options"]`
This task covers **steps 2,3 and 6** in the diagram below.
Note: Steps 1, 4 and 5 are already complete. Howeve
=== Edit API call flow ===
{F29786515}
All edit API calls are made **one contribution at a time** and completely serially. In other words, each next API call needs to wait until the previous one has returned it's response.
For the **first** contribution in the array provided by the client in step 1, the `baserevid` is provided already as part of the `api_options`.
For **all subsequent** contributions, the `baserevid` will need to be added to the `api_options` using the response from the previous contribution. So the steps are as follows:
For each contribution in the array :
- Get the edit api options from `contribution["api_options"]`
- Add OAuth tokens/secrets to the same `api_options` object
- // ( Add `baserevid` to `api_options`, using value saved from the previous edit response. This is NOT needed for the FIRST contribution, as it's provided by the client )//
- Post using the final signed api_options to `https://test-commons.wikimedia.org/w/api.php`
- If edit successful:
- store the new "baserevid" from the response (this will be needed for the next contribution posted)
- Commit contribution to the database
- Repeat for next contribution...
Finally send the response to the client's initial contributions post request in STEP 1 from the diagram.
This must be done only once ALL responses have been received from contributions posted to to Commons, and they have been commited to the database