Get Next Order to Pull
The Get Next Order to Pull operation retrieves orders individually from Talk2Sync for insertion or update in the external system.
Before requesting the next order, the daemon must verify whether Talk2Sync has finished processing the previous transaction. This is controlled through the hasmore status.
1. Check Whether More Orders Are Available
First, query the order pull status:
GET https://api.talk2sync.com/api/adapters/custom/reverse/connection/{{your key}}/pull/orders/hasmore
The endpoint returns a status similar to:
{
"hasmore": "waiting"
}
or:
{
"hasmore": "ready"
}
waiting
The waiting state indicates that the server is still processing the previous transaction.
The daemon must wait and query the endpoint again until the status changes to ready.
ready
The ready state indicates that the daemon can request the next order.
2. Retrieve the Next Order
Once the hasmore status is ready, request the next order:
GET https://api.talk2sync.com/api/adapters/custom/reverse/connection/{{your key}}/pull/orders/next
The response contains the order that must be inserted or updated in the external system:
{
"order": {
"_id": "75554554546",
"orderid": "777777",
"last_updated": 1517360038797,
"status": "paid",
"dateCreated": "",
"dateClosed": "",
"total": {
"amount": 350,
"currency": "USD"
},
"orderItems": [
{
"id": "7778545",
"variation_id": "0",
"quantity": "1",
"unitPrice": "350",
"currencyId": "USD"
}
],
"buyer": {
"id": "4578889",
"email": "testbuyer@example.com",
"phone": "88888888",
"firstName": "John",
"lastName": "Doe"
}
}
}
The daemon can then process the returned order and report whether the storage operation succeeded or failed.
Process
Next Steps
- Review Pull Orders Page for the order download initialization process.
- Continue with Notify Order Storage Success to report a successful storage operation.
- Continue with Notify Order Storage Failure to report a failed storage operation.
- Review Set Finish Order Pulls to finalize the order download.