Difference between revisions of "Setting the status of a job"

From MyMobileWorkers API
Jump to: navigation, search
(→‎Valid status transitions)
m (new url)
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
The status of a job can be changed remotely by placing requests against the API.
 +
 
== Summary ==
 
== Summary ==
 
{| border="1" class="wikitable"
 
{| border="1" class="wikitable"
Line 25: Line 27:
  
  
−
The status of a job can be changed remotely by placing requests against the API.
+
   
−
Please refer to the [[List_of_Job_Statuses]] when placing an API call. In addition if your My Mobile Workers account defines any custom statuses then the API can also be used to update jobs with these.   
+
−
 
+
−
In order to make a valid API request it must contain the following parameters
+
−
 
+
−
1. A MyMobileWorkers web API key
+
−
2. The job number that you wish to update the status of
+
−
3. The status you with to update the job to
+
−
 
+
−
The curl tool can be used to place requests against the API in order to test connectivity to the API.
+
−
Please substitute within the call <<YOUR_WEB_API_KEY>> and <<YOUR_JOB_NUMBER>> with values from your portal account
+
−
 
+
−
curl -X POST "<nowiki>https://live.mymobileworkers.com:8181/api/1/jobs/job/status/update?api_key=<<YOUR_WEB_API_KEY>>&job_number=<<YOUR_JOB_NUMBER>>&status=JOB_COMPLETED</nowiki>"
+
−
 
+
−
The above request will transition the status of a job to JOB_COMPLETED if the job presently has the status NEW.
+
−
 
+
−
Within the MyMobileWorkers system statuses have a status type. The type of a status dictates which status changes can be made through the API.
+
−
 
+
−
NEW -> JOB_COMPLETED type completed
+
−
NEW -> JOB_FAILED type completed
+
−
 
+
−
JOB_COMPLETED -> JOB_FAILED
+
−
JOB_FAILED -> JOB_COMPLETED
+
−
 
+
−
NEW -> custom completed type
+
−
 
+
−
custom completed type -> custom completed type
+
−
 
+
 
== Valid status transitions ==
 
== Valid status transitions ==
 
{| border="1" class="wikitable"
 
{| border="1" class="wikitable"
  
 
! Current status  
 
! Current status  
−
| colspan="2" | New status
+
| colspan="2" | Possible status
 +
|-
 +
! NEW
 +
| colspan="2" | JOB_COMPLETED
 +
|-
 +
! NEW
 +
| colspan="2" | JOB_FAILED
 +
|-
 +
! NEW
 +
| colspan="2" | CUSTOM_COMPLETED_TYPE
 +
|-
 +
! NEW
 +
| colspan="2" | CUSTOM_NEW_TYPE
 +
|-
 +
! JOB_COMPLETED
 +
| colspan="2" | JOB_FAILED
 +
|-
 +
! JOB_FAILED
 +
| colspan="2" | JOB_COMPLETED
 +
|-
 +
! CUSTOM_COMPLETED_TYPE
 +
| colspan="2" | CUSTOM_COMPLETED_TYPE
 
|-
 
|-
 
|}
 
|}
 +
 +
- CUSTOM_COMPLETED_TYPE statuses are defined within the web portal under the settings menu. They will always be defaulted to uppercase.
 +
 +
== Example success response ==
 +
<source lang="java">{"successful":[{"job_number":"123456"}]}</source>
 +
 +
== Example failure response ==
 +
<source lang="java">{"failed":[{"job_number":"123456","errors":[{"error_code":"STA001","error_message":"Invalid job status specified"}]}]}</source>
  
 
== Example curl request ==
 
== Example curl request ==
  
−
curl -X POST "<nowiki>https://live.mymobileworkers.com:8181/api/1/jobs/job/status/update?api_key=APIKEY&job_number=JOB_NUMBER&status=JOB_COMPLETED</nowiki>"
+
curl -X POST "<nowiki>https://api.mymobileworkers.com:8181/api/1/jobs/job/status/update?api_key=APIKEY&job_number=JOB_NUMBER&status=JOB_COMPLETED</nowiki>"
  
−
curl -X POST "<nowiki>https://live.mymobileworkers.com:8181/api/1/jobs/job/status/update?api_key=APIKEY&job_number=JOB_NUMBER&status=JOB_FAILED</nowiki>"
+
curl -X POST "<nowiki>https://api.mymobileworkers.com:8181/api/1/jobs/job/status/update?api_key=APIKEY&job_number=JOB_NUMBER&status=JOB_FAILED</nowiki>"

Latest revision as of 09:19, 21 October 2016

The status of a job can be changed remotely by placing requests against the API.

Contents

[edit] Summary

Update job status
URL https://:base_url/:api_path/:version/jobs//job/status/update?api_key=YOUR_KEY&&job_number=JOB_NUMBER&status=JOB_STATUS
Type POST
Params: api_key required
job_number required
status required
Response JSON


[edit] Valid status transitions

Current status Possible status
NEW JOB_COMPLETED
NEW JOB_FAILED
NEW CUSTOM_COMPLETED_TYPE
NEW CUSTOM_NEW_TYPE
JOB_COMPLETED JOB_FAILED
JOB_FAILED JOB_COMPLETED
CUSTOM_COMPLETED_TYPE CUSTOM_COMPLETED_TYPE

- CUSTOM_COMPLETED_TYPE statuses are defined within the web portal under the settings menu. They will always be defaulted to uppercase.

[edit] Example success response

{"successful":[{"job_number":"123456"}]}

[edit] Example failure response

{"failed":[{"job_number":"123456","errors":[{"error_code":"STA001","error_message":"Invalid job status specified"}]}]}

[edit] Example curl request

curl -X POST "https://api.mymobileworkers.com:8181/api/1/jobs/job/status/update?api_key=APIKEY&job_number=JOB_NUMBER&status=JOB_COMPLETED"

curl -X POST "https://api.mymobileworkers.com:8181/api/1/jobs/job/status/update?api_key=APIKEY&job_number=JOB_NUMBER&status=JOB_FAILED"

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox