Passed
Push — master ( 34ea0b...07bc23 )
by Dominic
02:47
created
src/Resources/Rate.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -4,28 +4,28 @@
 block discarded – undo
4 4
 
5 5
 class Rate extends Resource
6 6
 {
7
-    /**
8
-     * The enpoint for rate requests
9
-     * 
10
-     * @var string
11
-     */
12
-    const ENDPOINT = '/rate';
7
+	/**
8
+	 * The enpoint for rate requests
9
+	 * 
10
+	 * @var string
11
+	 */
12
+	const ENDPOINT = '/rate';
13 13
 
14
-    /**
15
-     * Get an exchange rate
16
-     * 
17
-     * @see https://revolut-engineering.github.io/api-docs/business-api/#exchanges-get-exchange-rates Official API documentation
18
-     * @param string $from 3-letter ISO base currency
19
-     * @param string $to 3-letter ISO target currency
20
-     * @param float $amount decimal amount, default is 1.00
21
-     * @return array The response body
22
-     * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
23
-     * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized
24
-     */
25
-    public function get(string $from, string $to, float $amount = 1)
26
-    {
27
-        return $this->client->get(self::ENDPOINT, [
28
-            'query' => compact('from', 'to', 'amount')
29
-        ]);
30
-    }
14
+	/**
15
+	 * Get an exchange rate
16
+	 * 
17
+	 * @see https://revolut-engineering.github.io/api-docs/business-api/#exchanges-get-exchange-rates Official API documentation
18
+	 * @param string $from 3-letter ISO base currency
19
+	 * @param string $to 3-letter ISO target currency
20
+	 * @param float $amount decimal amount, default is 1.00
21
+	 * @return array The response body
22
+	 * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
23
+	 * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized
24
+	 */
25
+	public function get(string $from, string $to, float $amount = 1)
26
+	{
27
+		return $this->client->get(self::ENDPOINT, [
28
+			'query' => compact('from', 'to', 'amount')
29
+		]);
30
+	}
31 31
 }
Please login to merge, or discard this patch.
src/Facades/Revolut.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@
 block discarded – undo
6 6
 
7 7
 class Revolut extends Facade
8 8
 {
9
-    /**
10
-     * Get the registered name of the component.
11
-     * 
12
-     * @return string
13
-     */
14
-    protected static function getFacadeAccessor()
15
-    {
16
-        return 'revolut';
17
-    }
9
+	/**
10
+	 * Get the registered name of the component.
11
+	 * 
12
+	 * @return string
13
+	 */
14
+	protected static function getFacadeAccessor()
15
+	{
16
+		return 'revolut';
17
+	}
18 18
 }
Please login to merge, or discard this patch.
src/Client.php 1 patch
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -20,191 +20,191 @@
 block discarded – undo
20 20
  */
21 21
 class Client
22 22
 {
23
-    /**
24
-     * The production URL
25
-     * 
26
-     * @var string
27
-     */
28
-    const PRODUCTION_URL = 'https://b2b.revolut.com';
29
-
30
-    /**
31
-     * The sandbox URL
32
-     * 
33
-     * @var string
34
-     */
35
-    const SANDBOX_URL = 'https://sandbox-b2b.revolut.com';
36
-
37
-    /**
38
-     * The API URI
39
-     * 
40
-     * @var string
41
-     */
42
-    const API_ENDPOINT = '/api';
43
-
44
-    /**
45
-     * The API version
46
-     * 
47
-     * @var string
48
-     */
49
-    const API_VERSION = '1.0';
50
-
51
-    /**
52
-     * The token manager
53
-     *
54
-     * @var \tbclla\Revolut\Auth\TokenManager
55
-     */
56
-    private $tokenManager;
57
-
58
-    /**
59
-     * the HTTP client
60
-     * 
61
-     * @var \tbclla\Revolut\Interfaces\MakesHttpRequests
62
-     */
63
-    private $httpClient;
64
-
65
-    /**
66
-     * The access token
67
-     * 
68
-     * @var \tbclla\Revolut\Auth\AccessToken
69
-     */
70
-    private $accessToken;
71
-
72
-    /**
73
-     * Create the client instance
74
-     * 
75
-     * @param \tbclla\Revolut\Auth\TokenManager $tokenManager
76
-     * @param \tbclla\Revolut\Interfaces\MakesHttpRequests $httpClient
77
-     * @return void
78
-     */
79
-    public function __construct(TokenManager $tokenManager, MakesHttpRequests $httpClient)
80
-    {
81
-        $this->tokenManager = $tokenManager;
82
-        $this->httpClient = $httpClient;
83
-    }
84
-
85
-    /**
86
-     * @param string $name
87
-     * @param mixed $arguments
88
-     * @return \tbclla\Revolut\Resources\Resource
89
-     * @throws \tbclla\Revolut\Exceptions\RevolutException
90
-     */
91
-    public function __call($name, $arguments)
92
-    {
93
-        $resource = __NAMESPACE__ . '\\Resources\\' . ucfirst($name);
94
-        if (!class_exists($resource)) {
95
-            throw new RevolutException($resource . ' is not a valid API resource');
96
-        }
97
-        return new $resource($this);
98
-    }
99
-
100
-    /**
101
-     * Set the access token
102
-     *
103
-     * @param \tbclla\Revolut\Auth\AccessToken $accessToken
104
-     * @return void
105
-     */
106
-    public function setAccessToken(AccessToken $accessToken): void
107
-    {
108
-        $this->accessToken = $accessToken;
109
-    }
110
-
111
-    /**
112
-     * Create and set a fresh access token
113
-     * 
114
-     * @return void
115
-     */
116
-    public function refreshAccessToken(): void
117
-    {
118
-        $this->setAccessToken($this->tokenManager->refreshAccessToken());
119
-    }
120
-
121
-    /**
122
-     * Get the base URI for all API requests
123
-     * 
124
-     * @param string $endpoint
125
-     * @return string
126
-     */
127
-    public static function buildUri(string $endpoint = '')
128
-    {
129
-        $url = config('revolut.sandbox', true) ? self::SANDBOX_URL : self::PRODUCTION_URL;
130
-
131
-        return $url . self::apiUri() . $endpoint;
132
-    }
23
+	/**
24
+	 * The production URL
25
+	 * 
26
+	 * @var string
27
+	 */
28
+	const PRODUCTION_URL = 'https://b2b.revolut.com';
29
+
30
+	/**
31
+	 * The sandbox URL
32
+	 * 
33
+	 * @var string
34
+	 */
35
+	const SANDBOX_URL = 'https://sandbox-b2b.revolut.com';
36
+
37
+	/**
38
+	 * The API URI
39
+	 * 
40
+	 * @var string
41
+	 */
42
+	const API_ENDPOINT = '/api';
43
+
44
+	/**
45
+	 * The API version
46
+	 * 
47
+	 * @var string
48
+	 */
49
+	const API_VERSION = '1.0';
50
+
51
+	/**
52
+	 * The token manager
53
+	 *
54
+	 * @var \tbclla\Revolut\Auth\TokenManager
55
+	 */
56
+	private $tokenManager;
57
+
58
+	/**
59
+	 * the HTTP client
60
+	 * 
61
+	 * @var \tbclla\Revolut\Interfaces\MakesHttpRequests
62
+	 */
63
+	private $httpClient;
64
+
65
+	/**
66
+	 * The access token
67
+	 * 
68
+	 * @var \tbclla\Revolut\Auth\AccessToken
69
+	 */
70
+	private $accessToken;
71
+
72
+	/**
73
+	 * Create the client instance
74
+	 * 
75
+	 * @param \tbclla\Revolut\Auth\TokenManager $tokenManager
76
+	 * @param \tbclla\Revolut\Interfaces\MakesHttpRequests $httpClient
77
+	 * @return void
78
+	 */
79
+	public function __construct(TokenManager $tokenManager, MakesHttpRequests $httpClient)
80
+	{
81
+		$this->tokenManager = $tokenManager;
82
+		$this->httpClient = $httpClient;
83
+	}
84
+
85
+	/**
86
+	 * @param string $name
87
+	 * @param mixed $arguments
88
+	 * @return \tbclla\Revolut\Resources\Resource
89
+	 * @throws \tbclla\Revolut\Exceptions\RevolutException
90
+	 */
91
+	public function __call($name, $arguments)
92
+	{
93
+		$resource = __NAMESPACE__ . '\\Resources\\' . ucfirst($name);
94
+		if (!class_exists($resource)) {
95
+			throw new RevolutException($resource . ' is not a valid API resource');
96
+		}
97
+		return new $resource($this);
98
+	}
99
+
100
+	/**
101
+	 * Set the access token
102
+	 *
103
+	 * @param \tbclla\Revolut\Auth\AccessToken $accessToken
104
+	 * @return void
105
+	 */
106
+	public function setAccessToken(AccessToken $accessToken): void
107
+	{
108
+		$this->accessToken = $accessToken;
109
+	}
110
+
111
+	/**
112
+	 * Create and set a fresh access token
113
+	 * 
114
+	 * @return void
115
+	 */
116
+	public function refreshAccessToken(): void
117
+	{
118
+		$this->setAccessToken($this->tokenManager->refreshAccessToken());
119
+	}
120
+
121
+	/**
122
+	 * Get the base URI for all API requests
123
+	 * 
124
+	 * @param string $endpoint
125
+	 * @return string
126
+	 */
127
+	public static function buildUri(string $endpoint = '')
128
+	{
129
+		$url = config('revolut.sandbox', true) ? self::SANDBOX_URL : self::PRODUCTION_URL;
130
+
131
+		return $url . self::apiUri() . $endpoint;
132
+	}
133 133
     
134
-    /**
135
-     * Get the URI for API requests
136
-     * 
137
-     * @return string
138
-     */
139
-    public static function apiUri()
140
-    {
141
-        return self::API_ENDPOINT . '/' . self::API_VERSION;
142
-    }
143
-
144
-    /**
145
-     * Perform a POST request against a specified endpoint
146
-     *
147
-     * @param string $endpoint
148
-     * @param array $options
149
-     * @return array The response body
150
-     * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
151
-     * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized
152
-     */
153
-    public function post(string $endpoint, array $options = [])
154
-    {
155
-        return $this->httpClient->post($this->buildUri($endpoint), $this->buildOptions($options));
156
-    }
157
-
158
-    /**
159
-     * Perform a GET request against a specified endpoint
160
-     *
161
-     * @param string $endpoint
162
-     * @return array The response body
163
-     * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
164
-     * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized
165
-     */
166
-    public function get(string $endpoint, array $options = [])
167
-    {
168
-        return $this->httpClient->get($this->buildUri($endpoint), $this->buildOptions($options));
169
-    }
170
-
171
-    /**
172
-     * Perform a DELETE request against a specified endpoint
173
-     *
174
-     * @param string $endpoint
175
-     * @return void
176
-     * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
177
-     * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized
178
-     */
179
-    public function delete(string $endpoint)
180
-    {
181
-        $this->httpClient->delete($this->buildUri($endpoint), $this->buildOptions());
182
-    }
183
-
184
-    /**
185
-     * Build the request options
186
-     * 
187
-     * @param array $options
188
-     * @return array
189
-     */
190
-    private function buildOptions(array $options = [])
191
-    {
192
-        if (!$this->accessToken) {
193
-            $this->setAccessToken($this->tokenManager->getAccessToken());
194
-        } else if ($this->accessToken->hasExpired()) {
195
-            $this->refreshAccessToken();
196
-        }
197
-
198
-        return array_merge($options, ['headers' => ['Authorization' => 'Bearer ' . $this->accessToken->value]]);
199
-    }
200
-
201
-    /**
202
-     * Generate a v4 UUID to use as a request ID
203
-     * 
204
-     * @return string
205
-     */
206
-    public static function generateRequestId()
207
-    {
208
-        return (string) Str::Uuid();
209
-    }
134
+	/**
135
+	 * Get the URI for API requests
136
+	 * 
137
+	 * @return string
138
+	 */
139
+	public static function apiUri()
140
+	{
141
+		return self::API_ENDPOINT . '/' . self::API_VERSION;
142
+	}
143
+
144
+	/**
145
+	 * Perform a POST request against a specified endpoint
146
+	 *
147
+	 * @param string $endpoint
148
+	 * @param array $options
149
+	 * @return array The response body
150
+	 * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
151
+	 * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized
152
+	 */
153
+	public function post(string $endpoint, array $options = [])
154
+	{
155
+		return $this->httpClient->post($this->buildUri($endpoint), $this->buildOptions($options));
156
+	}
157
+
158
+	/**
159
+	 * Perform a GET request against a specified endpoint
160
+	 *
161
+	 * @param string $endpoint
162
+	 * @return array The response body
163
+	 * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
164
+	 * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized
165
+	 */
166
+	public function get(string $endpoint, array $options = [])
167
+	{
168
+		return $this->httpClient->get($this->buildUri($endpoint), $this->buildOptions($options));
169
+	}
170
+
171
+	/**
172
+	 * Perform a DELETE request against a specified endpoint
173
+	 *
174
+	 * @param string $endpoint
175
+	 * @return void
176
+	 * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
177
+	 * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized
178
+	 */
179
+	public function delete(string $endpoint)
180
+	{
181
+		$this->httpClient->delete($this->buildUri($endpoint), $this->buildOptions());
182
+	}
183
+
184
+	/**
185
+	 * Build the request options
186
+	 * 
187
+	 * @param array $options
188
+	 * @return array
189
+	 */
190
+	private function buildOptions(array $options = [])
191
+	{
192
+		if (!$this->accessToken) {
193
+			$this->setAccessToken($this->tokenManager->getAccessToken());
194
+		} else if ($this->accessToken->hasExpired()) {
195
+			$this->refreshAccessToken();
196
+		}
197
+
198
+		return array_merge($options, ['headers' => ['Authorization' => 'Bearer ' . $this->accessToken->value]]);
199
+	}
200
+
201
+	/**
202
+	 * Generate a v4 UUID to use as a request ID
203
+	 * 
204
+	 * @return string
205
+	 */
206
+	public static function generateRequestId()
207
+	{
208
+		return (string) Str::Uuid();
209
+	}
210 210
 }
Please login to merge, or discard this patch.
src/database/migrations/2019_08_19_000000_create_revolut_tokens_table.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@
 block discarded – undo
6 6
 
7 7
 class CreateRevolutTokensTable extends Migration
8 8
 {
9
-    /**
10
-     * Run the migrations.
11
-     *
12
-     * @return void
13
-     */
14
-    public function up()
15
-    {
16
-        Schema::create(config('revolut.tokens.table_name'), function(Blueprint $table) {
17
-            $table->bigIncrements('id');
18
-            $table->string('type');
19
-            $table->mediumText('value');
20
-            $table->boolean('is_encrypted')->default(false);
21
-            $table->timestamp('expires_at')->nullable();
22
-            $table->timestamp('created_at')->useCurrent();
23
-        });
24
-    }
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create(config('revolut.tokens.table_name'), function(Blueprint $table) {
17
+			$table->bigIncrements('id');
18
+			$table->string('type');
19
+			$table->mediumText('value');
20
+			$table->boolean('is_encrypted')->default(false);
21
+			$table->timestamp('expires_at')->nullable();
22
+			$table->timestamp('created_at')->useCurrent();
23
+		});
24
+	}
25 25
 
26
-    /**
27
-     * Reverse the migrations.
28
-     *
29
-     * @return void
30
-     */
31
-    public function down()
32
-    {
33
-        Schema::dropIfExists(config('revolut.tokens.table_name'));
34
-    }
26
+	/**
27
+	 * Reverse the migrations.
28
+	 *
29
+	 * @return void
30
+	 */
31
+	public function down()
32
+	{
33
+		Schema::dropIfExists(config('revolut.tokens.table_name'));
34
+	}
35 35
 }
Please login to merge, or discard this patch.
src/Providers/RevolutServiceProvider.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -19,73 +19,73 @@
 block discarded – undo
19 19
 
20 20
 class RevolutServiceProvider extends ServiceProvider
21 21
 {
22
-    /**
23
-     * Register services.
24
-     *
25
-     * @return void
26
-     */
27
-    public function register()
28
-    {
29
-        $this->app->bind(CacheTokenRepository::class, function() {
30
-            return new CacheTokenRepository(
31
-                resolve(CacheFactory::class),
32
-                config('revolut.tokens.cache.driver')
33
-            );
34
-        });
22
+	/**
23
+	 * Register services.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function register()
28
+	{
29
+		$this->app->bind(CacheTokenRepository::class, function() {
30
+			return new CacheTokenRepository(
31
+				resolve(CacheFactory::class),
32
+				config('revolut.tokens.cache.driver')
33
+			);
34
+		});
35 35
 
36
-        $this->app->bind(TokenRepository::class, function() {
37
-            return config('revolut.tokens.store') === 'database'
38
-                ? new DatabaseTokenRepository
39
-                :  resolve(CacheTokenRepository::class);
40
-        });
36
+		$this->app->bind(TokenRepository::class, function() {
37
+			return config('revolut.tokens.store') === 'database'
38
+				? new DatabaseTokenRepository
39
+				:  resolve(CacheTokenRepository::class);
40
+		});
41 41
 
42
-        $this->app->bind(MakesHttpRequests::class, GuzzleHttpClient::class);
42
+		$this->app->bind(MakesHttpRequests::class, GuzzleHttpClient::class);
43 43
 
44
-        $this->app->bind(ClientAssertion::class, function() {
45
-            return new ClientAssertion(
46
-                config('revolut.client_id'),
47
-                config('revolut.private_key'),
48
-                config('revolut.redirect_uri')
49
-            );
50
-        });
44
+		$this->app->bind(ClientAssertion::class, function() {
45
+			return new ClientAssertion(
46
+				config('revolut.client_id'),
47
+				config('revolut.private_key'),
48
+				config('revolut.redirect_uri')
49
+			);
50
+		});
51 51
 
52
-        $this->app->bind(AuthorizationCodeRequest::class, function() {
53
-            return new AuthorizationCodeRequest(
54
-                config('revolut.client_id'),
55
-                config('revolut.redirect_uri'),
56
-                config('revolut.sandbox')
57
-            );
58
-        });
52
+		$this->app->bind(AuthorizationCodeRequest::class, function() {
53
+			return new AuthorizationCodeRequest(
54
+				config('revolut.client_id'),
55
+				config('revolut.redirect_uri'),
56
+				config('revolut.sandbox')
57
+			);
58
+		});
59 59
 
60
-        $this->app->singleton('revolut', function() {
61
-            return resolve(Client::class);
62
-        });
63
-    }
60
+		$this->app->singleton('revolut', function() {
61
+			return resolve(Client::class);
62
+		});
63
+	}
64 64
 
65
-    /**
66
-     * Bootstrap services.
67
-     *
68
-     * @return void
69
-     */
70
-    public function boot()
71
-    {
72
-        $this->publishes([
73
-            __DIR__ . '/../config/revolut.php' => config_path('revolut.php')
74
-        ]);
65
+	/**
66
+	 * Bootstrap services.
67
+	 *
68
+	 * @return void
69
+	 */
70
+	public function boot()
71
+	{
72
+		$this->publishes([
73
+			__DIR__ . '/../config/revolut.php' => config_path('revolut.php')
74
+		]);
75 75
 
76
-        if (config('revolut.tokens.store') === 'database') {
77
-            $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
78
-        }
76
+		if (config('revolut.tokens.store') === 'database') {
77
+			$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
78
+		}
79 79
         
80
-        $this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
80
+		$this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
81 81
 
82
-        if ($this->app->runningInConsole()) {
83
-            $this->commands([
84
-                JWTCommand::class,
85
-                CleanupCommand::class,
86
-                ResetCommand::class,
87
-                AuthorizeCommand::class,
88
-            ]);
89
-        }
90
-    }
82
+		if ($this->app->runningInConsole()) {
83
+			$this->commands([
84
+				JWTCommand::class,
85
+				CleanupCommand::class,
86
+				ResetCommand::class,
87
+				AuthorizeCommand::class,
88
+			]);
89
+		}
90
+	}
91 91
 }
Please login to merge, or discard this patch.
src/GuzzleHttpClient.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -9,51 +9,51 @@
 block discarded – undo
9 9
 
10 10
 class GuzzleHttpClient implements MakesHttpRequests
11 11
 {
12
-    /**
13
-     * @var \GuzzleHttp\Client
14
-     */
15
-    private $client;
16
-
17
-    /**
18
-     * @return void
19
-     */
20
-    public function __construct()
21
-    {
22
-        $this->client = new Client();
23
-    }
24
-
25
-    public function post(string $url, array $options = [])
26
-    {
27
-        return $this->send('POST', $url, $options);
28
-    }
29
-
30
-    public function get(string $url, array $options = [])
31
-    {
32
-        return $this->send('GET', $url, $options);
33
-    }
34
-
35
-    public function delete(string $url, array $options = []) : void
36
-    {
37
-        $this->send('DELETE', $url, $options);
38
-    }
39
-
40
-    /**
41
-     * Perform a request
42
-     * 
43
-     * @param string $method The request method
44
-     * @param string $url The request url
45
-     * @param array $options The request options
46
-     * @return array|null The response body
47
-     * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
48
-     */
49
-    private function send(string $method, string $url, array $options)
50
-    {
51
-        try {
52
-            $response = $this->client->request($method, $url, $options);
53
-        } catch (BadResponseException $e) {
54
-            throw new ApiException($e->getMessage(), $e->getCode(), $e);
55
-        }
56
-
57
-        return json_decode($response->getBody(), true);
58
-    }
12
+	/**
13
+	 * @var \GuzzleHttp\Client
14
+	 */
15
+	private $client;
16
+
17
+	/**
18
+	 * @return void
19
+	 */
20
+	public function __construct()
21
+	{
22
+		$this->client = new Client();
23
+	}
24
+
25
+	public function post(string $url, array $options = [])
26
+	{
27
+		return $this->send('POST', $url, $options);
28
+	}
29
+
30
+	public function get(string $url, array $options = [])
31
+	{
32
+		return $this->send('GET', $url, $options);
33
+	}
34
+
35
+	public function delete(string $url, array $options = []) : void
36
+	{
37
+		$this->send('DELETE', $url, $options);
38
+	}
39
+
40
+	/**
41
+	 * Perform a request
42
+	 * 
43
+	 * @param string $method The request method
44
+	 * @param string $url The request url
45
+	 * @param array $options The request options
46
+	 * @return array|null The response body
47
+	 * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
48
+	 */
49
+	private function send(string $method, string $url, array $options)
50
+	{
51
+		try {
52
+			$response = $this->client->request($method, $url, $options);
53
+		} catch (BadResponseException $e) {
54
+			throw new ApiException($e->getMessage(), $e->getCode(), $e);
55
+		}
56
+
57
+		return json_decode($response->getBody(), true);
58
+	}
59 59
 }
Please login to merge, or discard this patch.
src/Console/Commands/ResetCommand.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -7,32 +7,32 @@
 block discarded – undo
7 7
 
8 8
 class ResetCommand extends Command
9 9
 {
10
-    /**
11
-     * The name and signature of the console command.
12
-     *
13
-     * @var string
14
-     */
15
-    protected $signature = 'revolut:reset';
10
+	/**
11
+	 * The name and signature of the console command.
12
+	 *
13
+	 * @var string
14
+	 */
15
+	protected $signature = 'revolut:reset';
16 16
 
17
-    /**
18
-     * The console command description.
19
-     *
20
-     * @var string
21
-     */
22
-    protected $description = 'Truncate the Revolut tokens table';
17
+	/**
18
+	 * The console command description.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	protected $description = 'Truncate the Revolut tokens table';
23 23
 
24
-    /**
25
-     * Execute the console command.
26
-     *
27
-     * @return mixed
28
-     */
29
-    public function handle()
30
-    {
31
-        $table = config('.revolut.tokens.table_name');
24
+	/**
25
+	 * Execute the console command.
26
+	 *
27
+	 * @return mixed
28
+	 */
29
+	public function handle()
30
+	{
31
+		$table = config('.revolut.tokens.table_name');
32 32
 
33
-        if ($this->confirm('All Revolut tokens will be deleted permanently. Are you sure?')) {
34
-            DB::table($table)->truncate();
35
-            $this->info($table . ' table has been truncated.');
36
-        }
37
-    }
33
+		if ($this->confirm('All Revolut tokens will be deleted permanently. Are you sure?')) {
34
+			DB::table($table)->truncate();
35
+			$this->info($table . ' table has been truncated.');
36
+		}
37
+	}
38 38
 }
Please login to merge, or discard this patch.
src/Console/Commands/AuthorizeCommand.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -8,38 +8,38 @@
 block discarded – undo
8 8
 
9 9
 class AuthorizeCommand extends Command
10 10
 {
11
-    /**
12
-     * The name and signature of the console command.
13
-     *
14
-     * @var string
15
-     */
16
-    protected $signature = 'revolut:authorize {--redirect= : A destination to be redirected to after the authorization}';
17
-
18
-    /**
19
-     * The console command description.
20
-     *
21
-     * @var string
22
-     */
23
-    protected $description = 'Authorize API access for you app';
24
-
25
-    /**
26
-     * Execute the console command.
27
-     *
28
-     * @return mixed
29
-     */
30
-    public function handle()
31
-    {
32
-        $redirect = $this->option('redirect') ?? null;
33
-
34
-        if (!$route = config('revolut.auth_route.name')) {
35
-            $this->error('Route name invalid or missing');
36
-            $this->error('Check you configuration and verify that "auth_route.name" is valid');
37
-            return;
38
-        }
39
-
40
-        $url = route($route, ['after_success' => $redirect]);
41
-
42
-        $this->info('Follow the link to complete the authorization:');
43
-        $this->line('<fg=black;bg=yellow>' . $url . '</>');
44
-    }
11
+	/**
12
+	 * The name and signature of the console command.
13
+	 *
14
+	 * @var string
15
+	 */
16
+	protected $signature = 'revolut:authorize {--redirect= : A destination to be redirected to after the authorization}';
17
+
18
+	/**
19
+	 * The console command description.
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $description = 'Authorize API access for you app';
24
+
25
+	/**
26
+	 * Execute the console command.
27
+	 *
28
+	 * @return mixed
29
+	 */
30
+	public function handle()
31
+	{
32
+		$redirect = $this->option('redirect') ?? null;
33
+
34
+		if (!$route = config('revolut.auth_route.name')) {
35
+			$this->error('Route name invalid or missing');
36
+			$this->error('Check you configuration and verify that "auth_route.name" is valid');
37
+			return;
38
+		}
39
+
40
+		$url = route($route, ['after_success' => $redirect]);
41
+
42
+		$this->info('Follow the link to complete the authorization:');
43
+		$this->line('<fg=black;bg=yellow>' . $url . '</>');
44
+	}
45 45
 }
Please login to merge, or discard this patch.
src/Console/Commands/CleanupCommand.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -9,31 +9,31 @@
 block discarded – undo
9 9
 
10 10
 class CleanupCommand extends Command
11 11
 {
12
-    /**
13
-     * The name and signature of the console command.
14
-     *
15
-     * @var string
16
-     */
17
-    protected $signature = 'revolut:cleanup';
12
+	/**
13
+	 * The name and signature of the console command.
14
+	 *
15
+	 * @var string
16
+	 */
17
+	protected $signature = 'revolut:cleanup';
18 18
 
19
-    /**
20
-     * The console command description.
21
-     *
22
-     * @var string
23
-     */
24
-    protected $description = 'Delete all expired Revolut access tokens and refresh tokens.';
19
+	/**
20
+	 * The console command description.
21
+	 *
22
+	 * @var string
23
+	 */
24
+	protected $description = 'Delete all expired Revolut access tokens and refresh tokens.';
25 25
 
26
-    /**
27
-     * Execute the console command.
28
-     *
29
-     * @return mixed
30
-     */
31
-    public function handle()
32
-    {
33
-        $accessTokens = AccessToken::clearExpired();
34
-        $this->info('Deleted ' . $accessTokens . ' expired access ' . Str::plural('token', $accessTokens));
26
+	/**
27
+	 * Execute the console command.
28
+	 *
29
+	 * @return mixed
30
+	 */
31
+	public function handle()
32
+	{
33
+		$accessTokens = AccessToken::clearExpired();
34
+		$this->info('Deleted ' . $accessTokens . ' expired access ' . Str::plural('token', $accessTokens));
35 35
 
36
-        $refreshTokens = RefreshToken::clearExpired();
37
-        $this->info('Deleted ' . $refreshTokens . ' expired refresh ' . Str::plural('token', $refreshTokens));
38
-    }
36
+		$refreshTokens = RefreshToken::clearExpired();
37
+		$this->info('Deleted ' . $refreshTokens . ' expired refresh ' . Str::plural('token', $refreshTokens));
38
+	}
39 39
 }
Please login to merge, or discard this patch.