From 6de1dbb77d09dede28c32f93e7f05421ae97ff70 Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Fri, 3 May 2024 10:14:30 +0200 Subject: [PATCH] Simplify client class. --- src/Client.php | 62 +++++++------------------------------------------ src/Gateway.php | 10 ++++---- 2 files changed, 14 insertions(+), 58 deletions(-) diff --git a/src/Client.php b/src/Client.php index 8912ba1..bc2d678 100644 --- a/src/Client.php +++ b/src/Client.php @@ -56,60 +56,16 @@ class Client { private $signing_key; /** - * Get the URL. - * - * @return string - */ - public function get_url() { - return $this->url; - } - - /** - * Set the action URL - * - * @param string $url URL. - * @return void - */ - public function set_url( $url ) { - $this->url = $url; - } - - /** - * Get refresh token. - * - * @return string - */ - public function get_refresh_token() { - return $this->refresh_token; - } - - /** - * Set refresh token. - * + * Construct client. + * + * @param string $url URL. * @param string $refresh_token Refresh token. - * @return void + * @param string $signing_key Signing key. */ - public function set_refresh_token( $refresh_token ) { + public function __construct( $url, $refresh_token, $signing_key ) { + $this->url = $url; $this->refresh_token = $refresh_token; - } - - /** - * Get signing key. - * - * @return string - */ - public function get_signing_key() { - return $this->signing_key; - } - - /** - * Set signing key. - * - * @param string $signing_key Signing key. - * @return void - */ - public function set_signing_key( $signing_key ) { - $this->signing_key = $signing_key; + $this->signing_key = $signing_key; } /** @@ -123,7 +79,7 @@ public function set_signing_key( $signing_key ) { * @throws \Exception Throws exception when Rabobank OmniKassa 2.0 response is not what we expect. */ private function request( $method, $endpoint, $token, $data = null ) { - $url = $this->get_url() . $endpoint; + $url = $this->url . $endpoint; /* * Arguments. @@ -203,7 +159,7 @@ private function request( $method, $endpoint, $token, $data = null ) { * @return object */ public function get_access_token_data() { - return $this->request( 'GET', 'gatekeeper/refresh', $this->get_refresh_token() ); + return $this->request( 'GET', 'gatekeeper/refresh', $this->refresh_token ); } /** diff --git a/src/Gateway.php b/src/Gateway.php index b2982fd..9f7eec8 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -63,11 +63,11 @@ public function __construct( Config $config ) { ]; // Client. - $this->client = new Client(); - - $this->client->set_url( $config->get_api_url() ); - $this->client->set_refresh_token( $config->refresh_token ); - $this->client->set_signing_key( $config->signing_key ); + $this->client = new Client( + $config->get_api_url(), + $config->refresh_token, + $config->signing_key + ); // Payment method iDEAL. $ideal_payment_method = new PaymentMethod( PaymentMethods::IDEAL );