Saf-t PT Suportado

InvoiceXpress API

purchase_orders.change-state

Changes the state of a purchase order.

Possible state transitions:

  • draft to final – finalized
  • draft to deleted – deleted
  • final to second_copy – second_copy
  • final to accepted – accepted
  • final to refused – refused
  • final to canceled – canceled
  • second_copy to canceled – canceled
  • accepted to refused – refused
  • accepted to completed – completed
  • refused to canceled – canceled
  • refused to accepted – accepted

Any other transitions will fail.

When canceling an purchase order you must specify a reason.

You call this method by submitting a HTTP PUT request to the following URL :

https://:screen-name.invoicexpress.net/purchase_orders/:purchase-order-id/change-state.xml

Example xml to be submitted:

<?xml version="1.0" encoding="UTF-8"?>
<purchase_order>
 <state>canceled</state>
 <message>Canceled due to amount of money</message>
</purchase_order>

<purchase_order>
 <state>finalized</state>
</purchase_order>

Parameters

Parameters are the data you will pass with the call.

api_key

Your secret identifier. You find your API Key under Account Overview in the Account section.
Rules: Required

purchase-order-id

Id of the purchase_order to change state.
Rules: Required

state

State which the purchase order will be changed to. Options are:

  • finalized
  • second_copy
  • canceled
  • accepted
  • rejected
  • deleted

Rules: Required

message

Reason for cancelling the purchase_order.
Rules: Required when state is “canceled”, otherwise ignored.

Return Values

This is the result that will be passed back to you.

Success

HTTP: 200 OK

Error

HTTP: 401 Access denied
The API Key parameter is missing or is incorrectly entered.
HTTP: 404 Not Found
No purchase_order matches the :purchase-order-id supplied.
HTTP: 422 Unprocessable Entity
Some of the parameters were incorrect.

Possible errors:

<?xml version="1.0" encoding="UTF-8"?>
<errors>
 <error>No content type or wrongly specified.</error>
</errors>
<?xml version="1.0" encoding="UTF-8"?>
<errors>
 <error>Invalid state</error>
</errors>
<?xml version="1.0" encoding="UTF-8"?>
<errors>
 <error>Cancel message can't be blank</error>
</errors>