From 6ec0bcb24d580a3083892088d4d8a5d5782f094a Mon Sep 17 00:00:00 2001 From: Drsdre Date: Mon, 30 Jan 2017 15:15:01 +0100 Subject: [PATCH] Add patchData function. Change context for update and edit to 'edit'. --- Client.php | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/Client.php b/Client.php index 7a4ce08..b7a1b28 100644 --- a/Client.php +++ b/Client.php @@ -184,7 +184,7 @@ public function getData( */ public function updateData( $entity_url, - $context = 'view', + $context = 'edit', array $data ) { // Set Set query data @@ -202,6 +202,35 @@ public function updateData( return $this; } + /** + * Update with entity url + * + * @param string $entity_url + * @param string $context view or edit + * @param array $data + * + * @return self + */ + public function patchData( + $entity_url, + $context = 'edit', + array $data + ) { + // Set Set query data + $data['context'] = $context; + + $this->request = + $this->createAuthenticatedRequest() + ->setMethod( 'patch' ) + ->setUrl( str_replace( $this->endpoint . '/', '', $entity_url ) )// Strip endpoint url from url param + ->setData( $data ) + ; + + $this->executeRequest(); + + return $this; + } + /** * Add data with entity url * @@ -242,7 +271,7 @@ public function addData( */ public function deleteData( $entity_url, - $context = 'view', + $context = 'edit', array $data ) { // Set context