From 3163e7306549f906251afd54825a9ec23263040b Mon Sep 17 00:00:00 2001 From: Drsdre Date: Tue, 30 May 2017 22:56:45 +0200 Subject: [PATCH] Add $request_data parameter to getData(). Renamed $data to $update_data in putData(), patchData() and postData(). --- Client.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Client.php b/Client.php index 6a720df..d67e8f1 100644 --- a/Client.php +++ b/Client.php @@ -144,6 +144,7 @@ public function init() { * @param string $context view or edit * @param int|null $page * @param int $page_length + * @param array $request_data * * @return self */ @@ -151,23 +152,22 @@ public function getData( $entity_url, $context = 'view', $page = null, - $page_length = 10 + $page_length = 10, + array $request_data = [] ) { // Set query data - $data = [ - 'context' => $context, - 'per_page' => $page_length, - ]; + $request_data['context'] = $context; + $request_data['per_page'] = $page_length; if ( ! is_null( $page ) ) { - $data['page'] = $page; + $request_data['page'] = $page; } $this->request = $this->createAuthenticatedRequest() ->setMethod( 'get' ) ->setUrl( str_replace( $this->endpoint . '/', '', $entity_url ) )// Strip endpoint url from url param - ->setData( $data ) + ->setData( $request_data ) ; $this->executeRequest(); @@ -180,23 +180,23 @@ public function getData( * * @param string $entity_url * @param string $context view or edit - * @param array $data + * @param array $update_data * * @return self */ public function putData( $entity_url, $context = 'edit', - array $data + array $update_data ) { // Set Set query data - $data['context'] = $context; + $update_data['context'] = $context; $this->request = $this->createAuthenticatedRequest() ->setMethod( 'put' ) ->setUrl( str_replace( $this->endpoint . '/', '', $entity_url ) )// Strip endpoint url from url param - ->setData( $data ) + ->setData( $update_data ) ; $this->executeRequest(); @@ -209,23 +209,23 @@ public function putData( * * @param string $entity_url * @param string $context view or edit - * @param array $data + * @param array $update_data * * @return self */ public function patchData( $entity_url, $context = 'edit', - array $data + array $update_data ) { // Set Set query data - $data['context'] = $context; + $update_data['context'] = $context; $this->request = $this->createAuthenticatedRequest() ->setMethod( 'patch' ) ->setUrl( str_replace( $this->endpoint . '/', '', $entity_url ) )// Strip endpoint url from url param - ->setData( $data ) + ->setData( $update_data ) ; $this->executeRequest(); @@ -238,23 +238,23 @@ public function patchData( * * @param string $entity_url * @param string $context view or edit - * @param array $data + * @param array $update_data * * @return self */ public function postData( $entity_url, $context = 'view', - array $data + array $update_data ) { // Set context - $data['context'] = $context; + $update_data['context'] = $context; $this->request = $this->createAuthenticatedRequest() ->setMethod( 'post' ) ->setUrl( str_replace( $this->endpoint . '/', '', $entity_url ) )// Strip endpoint url from url param - ->setData( $data ) + ->setData( $update_data ) ; $this->executeRequest();