Skip to content

Commit 0f5b2d7

Browse files
committed
WIP
1 parent 19743db commit 0f5b2d7

File tree

8 files changed

+30
-31
lines changed

8 files changed

+30
-31
lines changed

.github/workflows/laravel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Setup PHP
1212
uses: shivammathur/setup-php@v2
1313
with:
14-
php-version: '7.4'
14+
php-version: '8.0'
1515
- uses: actions/checkout@v2
1616
- name: Cache Dependencies
1717
uses: actions/cache@v1

.php_cs renamed to .php-cs-fixer.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010
->exclude($excluded_folders)
1111
->in(__DIR__);
1212

13-
return PhpCsFixer\Config::create()
13+
return (new PhpCsFixer\Config())
1414
->setRules([
15-
'@Symfony' => true,
16-
'binary_operator_spaces' => ['align_double_arrow' => true],
15+
'@Symfony' => true,
16+
'binary_operator_spaces' => [
17+
'operators' => [
18+
'=>' => 'align_single_space_minimal',
19+
],
20+
],
1721
'array_syntax' => ['syntax' => 'short'],
1822
'linebreak_after_opening_tag' => true,
1923
'not_operator_with_successor_space' => true,

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"keywords": ["laravel", "sendcloud", "soved", "shipping", "parcel"],
55
"type": "library",
66
"require": {
7-
"php": "^7.4|^8.0",
7+
"php": "^8.0",
88
"guzzlehttp/guzzle": "^7.0.1",
99
"illuminate/http": "^8.0",
1010
"illuminate/support": "^8.0"

readme.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
# Send parcels using the Sendcloud Shipping API
22

3-
⚠️ Work in progress!
4-
5-
Supported endpoints:
6-
- `GET` parcels
7-
- `GET` parcels/statuses
8-
- `GET` parcels/{id}
9-
- `POST` parcels
10-
- `POST` parcels/{id}/cancel
11-
- `GET` shipping_methods
12-
133
[![tests](https://github.com/sander3/laravel-sendcloud/workflows/Laravel/badge.svg)](https://github.com/sander3/laravel-sendcloud/actions?query=workflow%3ALaravel)
14-
[![codecov](https://codecov.io/gh/sander3/laravel-sendcloud/branch/master/graph/badge.svg)](https://codecov.io/gh/sander3/laravel-sendcloud)
154

165
## Requirements
176

18-
- PHP >= 7.4
7+
- PHP >= 8.0
198
- Laravel >= 8.0
209

2110
## Security Vulnerabilities
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Soved\Laravel\Sendcloud\Exceptions;
4+
5+
use Exception;
6+
7+
class ResponseException extends Exception
8+
{
9+
}

src/Exceptions/ValidationException.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ class ValidationException extends Exception
88
{
99
public array $missingKeys;
1010

11-
public function __construct(array $missingKeys)
12-
{
11+
public function __construct(
12+
public array $missingKeys
13+
) {
1314
parent::__construct('The given data was invalid.');
14-
15-
$this->missingKeys = $missingKeys;
1615
}
1716
}

src/Sendcloud.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Soved\Laravel\Sendcloud\Data\ParcelData;
77
use Soved\Laravel\Sendcloud\Data\SenderData;
88
use Soved\Laravel\Sendcloud\Contracts\SendcloudContract;
9+
use Soved\Laravel\Sendcloud\Exceptions\ResponseException;
910

1011
class Sendcloud implements SendcloudContract
1112
{
@@ -91,7 +92,13 @@ private function request(string $method, string $endpoint, array $data = [], boo
9192
$response->throw();
9293
}
9394

94-
return $response->json();
95+
$decoded = $response->json();
96+
97+
if (null === $decoded) {
98+
throw new ResponseException();
99+
}
100+
101+
return $decoded;
95102
}
96103

97104
private function getUrl(string $endpoint): string

src/SendcloudServiceProvider.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@
99

1010
class SendcloudServiceProvider extends ServiceProvider
1111
{
12-
/**
13-
* Bootstrap the application services.
14-
*
15-
* @return void
16-
*/
17-
public function boot()
18-
{
19-
}
20-
2112
/**
2213
* Register the application services.
2314
*

0 commit comments

Comments
 (0)