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

From MyMobileWorkers API
Jump to: navigation, search
m (new url)
 
(25 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.
 
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
+
== Summary ==
 +
{| border="1" class="wikitable"
  
−
1. A MyMobileWorkers web API key
+
! Update job status
−
2. The job number that you wish to update the status of
+
! colspan="2" |
−
3. The status you with to update the job to
+
|-
 +
! URL
 +
| colspan="2" |  https://:base_url/:api_path/:version/jobs//job/status/update?api_key=YOUR_KEY&&job_number=JOB_NUMBER&status=JOB_STATUS
 +
|-
 +
! Type
 +
| colspan="2" | POST
 +
|-
 +
! Params:
 +
| api_key || required
 +
|-
 +
!
 +
| job_number || required
 +
|-
 +
!
 +
| status || required
 +
|-
 +
! Response
 +
| colspan="2" | JSON
 +
|}
  
−
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>"
+
   
 +
== Valid status transitions ==
 +
{| border="1" class="wikitable"
  
−
The above request will transition the status of a job to JOB_COMPLETED if the job presently has the status NEW.
+
! Current 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
 +
|-
 +
|}
  
−
Within the MyMobileWorkers system statuses have a status type. The type of a status dictates which status changes can be made through the API.
+
- CUSTOM_COMPLETED_TYPE statuses are defined within the web portal under the settings menu. They will always be defaulted to uppercase.
  
−
NEW -> JOB_COMPLETED type completed
+
== Example success response ==
−
NEW -> JOB_FAILED type completed
+
<source lang="java">{"successful":[{"job_number":"123456"}]}</source>
  
−
JOB_COMPLETED -> JOB_FAILED
+
== Example failure response ==
−
JOB_FAILED -> JOB_COMPLETED
+
<source lang="java">{"failed":[{"job_number":"123456","errors":[{"error_code":"STA001","error_message":"Invalid job status specified"}]}]}</source>
  
−
NEW -> custom completed type
+
== Example curl request ==
  
−
custom completed type -> custom completed type
+
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://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