Skip to content
mrutid edited this page Jun 8, 2012 · 29 revisions

#Provision An HTTP request with content-type: application/json

##Entry Point: ###HTTP-POST:[3001] [host]/trans

####POST-DATA: The body must be a JSON with the data for provision The object must contain a payload, a priority (H or L) and a list ('queue') of objects with an 'id' property, for the target devices Optionally a callback, an expiration delay ('expirationDelay') or expiration time ('expirationDate') could be set (Both values in seconds)

Provision.json

{
"payload": "MESSAGE",
"priority":"H",
"callback":"http://foo.bar",
"queue":[
{"id":"Ax"},
{"id":"Bx"}
],
"expirationDelay": 360, //Seconds interval
//"expirationDate": UNIXTIMESTAMP 
}

###Response: The response is an object with an 'id' field with the id of the provisioned transaction. In case of error, the response will be a 400 and an object with a list of error messages in its "error" property

HTTP/1.1 200 OK content-type: application/json
{"ok":true, "data":"d84814f0-6776-11e1-a330-3324e9d100c2"}

HTTP/1.1 400 Bad Request content-type: application/json
{"errors":["undefined priority","undefined payload"]}

#Consumer Allows to retrieve the device messages, the id device must be append to the URL.

##Entry Point: ###HTTP-GET:[3001] [host]/queue/[id]

###GET PARAMS: "timeout": if the queue is empty , it will wait the value in seconds before returning an empty list ([]) or data arrived during the waiting period as soon as it arrives "max" : maximum number of mesages to retrieve. If there are more, they will be in te queue for later requests

###Response: The response is a list with the messages as strings. if there are no messages an empty list will be returned ([])

HTTP/1.1 200 OK content-type: application/json
{"ok":true, "data":["MSG ALTA prioridad 1","MSG BAJA prioridad 2"]}

#Transaction States Provide information about transaction's states (Pending, Delivered, Expired)

##Entry Point HTTP-GET:[3001] /trans/[transaction_id]/state Shows the state of the message on each queue of the transaction ###Response:

{"ok":true, "data":{"q1":"Pending","q2":"Delivered"}}

HTTP-GET:[3001] /trans/[transaction_id]/state/summary Shows number of messages on each state and the total count ###Response:

{"ok":true, "data":{"total_notifications":2,"Pending":1,"Delivered":1}}

HTTP-GET:[3001] /trans/[transaction_id]/state/Pending Show the queues of the transaction with the message wating to be delivered ###Response:

{"ok":true, "data":{"q1":"Pending"}}

HTTP-GET:[3001] /trans/[transaction_id]/state/Delivered Show the queues of the transaction with the messages having been delivered ###Response:

{"ok":true, "data":{"q2":"Delivered"}}

#Transaction info Get the metainformation related to a given transaction

##Entry point HTTP-GET:[3001] /trans/[transaction_id]

###Response Provision.json

{
    "ok": true,
    "data": {
        "expirationDate": "1339321787",
        "callback": "null",
        "priority": "H",
        "payload": "MESSAGE"
    }
}

#Get queue size Returns the size of a given queue

##EntryPoint HTTP-GET:[3001] /queue/[id]/size

###Response

{
    "ok": true,
    "data": "8"
}

#Set Payload Modify the current payload for a given transaction. This changes will apply to remaining consumed data

###Entry Point HTTP-POST:[3001] [host]/trans/[id]/payload ####POST-DATA: "New Message"

###Response:

{"ok":"true"}
{"errors":["Redis connection to localhost:6379 failed - connect ECONNREFUSED"]}

#Set Expire Date Modify the current ExpireDate (UNIXTIMESTAMP) for a given transaction.

###Entry Point HTTP-POST:[3001] [host]/trans/[id]/expirationDate ####POST-DATA: 1339158877

###Response:

{"ok":"true"}
{"errors":["Error: ERR value is not an integer or out of range"]}

#Delete Transaction Remove a given transaction. The behaviour will be the same as "EXPIRED" transaction. ###Entry Point HTTP-DELETE:[3001] [host]/trans/[id]

###Response:

{"ok":"true"}
{"errors":["Redis connection to localhost:6379 failed - connect ECONNREFUSED"]}
Clone this wiki locally