Skip to content

Commit

Permalink
Simplify client class.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed May 3, 2024
1 parent efd0014 commit 6de1dbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 58 deletions.
62 changes: 9 additions & 53 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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.
Expand Down Expand Up @@ -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 );
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 6de1dbb

Please sign in to comment.