We have a simple Sales Order table consisting of a header and one or many line items (obviously this could be any model has-many models object). We can fetch an existing sales order with a simple API call such as:
https://api.domain.com/v1/sales-orders/1
<?xml version="1.0" encoding="UTF-8"?>
<response>
<id>1</id>
<code>QTE-200001</code>
<timestamp>1671926400</timestamp>
<customer_name>ACME Corporation</customer_name>
<value>260.00</value>
<sales_order_items>
<item>
<id>1</id>
<sales_order_id>1</sales_order_id>
<description>Widget</description>
<unit_price>90.00</unit_price>
<quantity>2.00</quantity>
<line_total>180.00</line_total>
</item>
<item>
<id>2</id>
<sales_order_id>1</sales_order_id>
<description>Doodah</description>
<unit_price>80.00</unit_price>
<quantity>1.00</quantity>
<line_total>80.00</line_total>
</item>
</sales_order_items>
</response>
The question is, how can we accept and process a POST API request in Yii for a new or existing sales order?