diff --git a/src/Components/Operations/Delete.php b/src/Components/Operations/Delete.php new file mode 100755 index 0000000..abf3e8a --- /dev/null +++ b/src/Components/Operations/Delete.php @@ -0,0 +1,51 @@ +getClient()->delete($this->deleteUri($id)); + } catch (ClientException $previous) { + $e = new ApiException((string)$previous->getResponse()->getBody()); + $e->exception = $previous; + throw $e; + } + + return $response; + } + + /** + * @param $id + * + * @return string + */ + protected function deleteUri($id) + { + return 'v1/' . $this->getMethod() . '/' . $id; + } + +} \ No newline at end of file diff --git a/src/Components/Operations/Update.php b/src/Components/Operations/Update.php new file mode 100755 index 0000000..20d9144 --- /dev/null +++ b/src/Components/Operations/Update.php @@ -0,0 +1,53 @@ +getClient() + ->put($this->updateUri(), ['json' => $this->getModel()]); + } catch (ClientException $previous) { + $e = new ApiException((string)$previous->getResponse()->getBody()); + $e->exception = $previous; + throw $e; + } + return $response; + } + + /** + * @param $id + * + * @return string + */ + protected function updateUri() + { + return 'v1/' . $this->getMethod(); + } + +} \ No newline at end of file diff --git a/src/Models/Order.php b/src/Models/Order.php index c02bbcf..d7f06d9 100644 --- a/src/Models/Order.php +++ b/src/Models/Order.php @@ -4,9 +4,11 @@ use Afosto\ShopCtrl\Components\Model; use Afosto\ShopCtrl\Components\Operations\Create; +use Afosto\ShopCtrl\Components\Operations\Delete; use Afosto\ShopCtrl\Components\Operations\Find; use Afosto\ShopCtrl\Components\Operations\FindAll; use Afosto\ShopCtrl\Components\App; +use Afosto\ShopCtrl\Components\Operations\Update; /** * @property boolean $recalculateTotalsOnSave Gets or sets a value indicating whether we should recalculate the totals. @@ -63,7 +65,7 @@ class Order extends Model { const REVIEW_DISABLE_INVITE = -3; - use Find, FindAll, Create; + use Find, FindAll, Create, Update, Delete; public function getMap() { @@ -193,4 +195,8 @@ protected function createUri() return $this->findAllUri(); } + protected function updateUri() + { + return 'v1/Orders'; + } }