Skip to content

Commit a6cedac

Browse files
committed
updated Composer packages and applied Pint code style fixes, leaning more towards laravel preset
dropping support for PHP 8.1
1 parent d295915 commit a6cedac

File tree

13 files changed

+34
-170
lines changed

13 files changed

+34
-170
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# CHANGELOG
22

3-
## [0.4.x (Unreleased)](https://github.com/onlime/bexio-api-client/compare/0.3.1...main)
3+
## [0.5.x (unreleased)](https://github.com/onlime/bexio-api-client/compare/0.5.0...main)
4+
5+
## [0.5.0 (2023-09-27)](https://github.com/onlime/bexio-api-client/compare/0.4.1...0.5.0)
46

57
- Added Bexio company profile endpoint request methods to `Other` resource.
6-
- Drop PHP 8.0 support
8+
- Drop PHP 8.0/8.1 support
79
- Integrated laravel/pint as dev requirement for PHP style fixing
810

911
## [0.4.1 (2022-03-24)](https://github.com/onlime/bexio-api-client/compare/0.4.0...0.4.1)

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
}
2121
],
2222
"require": {
23-
"php": "^8.1",
23+
"php": "^8.2",
2424
"ext-json": "*",
2525
"jumbojett/openid-connect-php": "^0.9.10",
26-
"guzzlehttp/guzzle": "^7.5"
26+
"guzzlehttp/guzzle": "^7.8"
2727
},
2828
"require-dev": {
29-
"laravel/pint": "^1.2"
29+
"laravel/pint": "^1.13"
3030
},
3131
"suggest": {
3232
"onlime/laravel-bexio-api-client": "To use Laravel HTTP Client instead of Guzzle"

pint.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
{
22
"preset": "laravel",
33
"rules": {
4-
"braces": false,
54
"blank_line_before_statement": false,
6-
"class_definition": false,
75
"binary_operator_spaces": false,
8-
"concat_space": false,
9-
"no_unused_imports": false,
10-
"Laravel/laravel_phpdoc_alignment": false,
11-
"Laravel/laravel_phpdoc_separation": false,
6+
"phpdoc_separation": false,
127
"modernize_strpos": true
138
},
149
"exclude": [

src/Bexio/AbstractClient.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ public function getRefreshToken(): ?string
5454

5555
public function persistTokens(string $tokensFile): bool
5656
{
57-
return false !== file_put_contents($tokensFile, json_encode([
57+
return file_put_contents($tokensFile, json_encode([
5858
'accessToken' => $this->getAccessToken(),
5959
'refreshToken' => $this->getRefreshToken(),
60-
]));
60+
])) !== false;
6161
}
6262

6363
public function loadTokens(string $tokensFile)
6464
{
6565
if (! file_exists($tokensFile)) {
66-
throw new \Exception('Tokens file not found: ' . $tokensFile);
66+
throw new \Exception('Tokens file not found: '.$tokensFile);
6767
}
6868
$tokens = json_decode(file_get_contents($tokensFile));
6969

@@ -126,8 +126,8 @@ public function getFullApiUrl(string $path = '', array $query = []): string
126126
// prefix path with default API version if there was no version provided
127127
return implode('/', array_filter([
128128
self::API_URL,
129-
1 === preg_match('/\d\.\d\//', $path) ? '' : self::API_DEFAULT_VERSION,
130-
empty($query) ? $path : $path . '?' . http_build_query($query),
129+
preg_match('/\d\.\d\//', $path) === 1 ? '' : self::API_DEFAULT_VERSION,
130+
empty($query) ? $path : $path.'?'.http_build_query($query),
131131
]));
132132
}
133133

src/Bexio/Client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function request(
4141
) {
4242
$options = [
4343
'headers' => [
44-
'Authorization' => 'Bearer ' . $this->getAccessToken(),
44+
'Authorization' => 'Bearer '.$this->getAccessToken(),
4545
'Accept' => 'application/json',
4646
],
4747
'allow_redirects' => false,
@@ -51,7 +51,7 @@ protected function request(
5151
$options['query'] = $queryParams;
5252
}
5353

54-
if (! empty($data) && self::METHOD_GET !== $method) {
54+
if (! empty($data) && $method !== self::METHOD_GET) {
5555
$options['json'] = $data;
5656
}
5757

@@ -60,7 +60,7 @@ protected function request(
6060
} catch (ClientException $e) {
6161
// transform Guzzle ClientException into some more readable form, so that body content does not get truncated
6262
$body = json_decode($e->getResponse()->getBody()->getContents());
63-
throw new BexioClientException($body->message . ' ' . json_encode($body->errors), $body->error_code);
63+
throw new BexioClientException($body->message.' '.json_encode($body->errors), $body->error_code);
6464
}
6565

6666
return json_decode($response->getBody());

src/Bexio/Resource/AbstractDocumentPositions.php

Lines changed: 18 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -12,188 +12,146 @@ abstract class AbstractDocumentPositions extends Bexio
1212
protected $documentType = 'kb_foo'; // replace this in concrete class by kb_offer|kb_order|kb_invoice
1313

1414
/**
15-
* @param int $documentId
16-
* @param array $params
1715
* @return mixed
1816
*/
1917
public function listDefaultPositions(int $documentId, array $params = [])
2018
{
21-
return $this->client->get($this->documentType . "/$documentId/kb_position_custom", $params);
19+
return $this->client->get($this->documentType."/$documentId/kb_position_custom", $params);
2220
}
2321

2422
/**
25-
* @param int $documentId
26-
* @param int $itemId
2723
* @return mixed
2824
*/
2925
public function showDefaultPosition(int $documentId, int $itemId)
3026
{
31-
return $this->client->get($this->documentType . "/$documentId/kb_position_custom/$itemId");
27+
return $this->client->get($this->documentType."/$documentId/kb_position_custom/$itemId");
3228
}
3329

3430
/**
35-
* @param int $documentId
36-
* @param array $params
3731
* @return mixed
3832
*/
3933
public function createDefaultPosition(int $documentId, array $params = [])
4034
{
41-
return $this->client->post($this->documentType . "/$documentId/kb_position_custom", $params);
35+
return $this->client->post($this->documentType."/$documentId/kb_position_custom", $params);
4236
}
4337

4438
/**
45-
* @param int $documentId
46-
* @param int $itemId
47-
* @param array $params
4839
* @return mixed
4940
*/
5041
public function editDefaultPosition(int $documentId, int $itemId, array $params = [])
5142
{
52-
return $this->client->post($this->documentType . "/$documentId/kb_position_custom/$itemId", $params);
43+
return $this->client->post($this->documentType."/$documentId/kb_position_custom/$itemId", $params);
5344
}
5445

5546
/**
56-
* @param int $documentId
57-
* @param int $itemId
58-
* @param array $params
5947
* @return mixed
6048
*/
6149
public function overwriteDefaultPosition(int $documentId, int $itemId, array $params = [])
6250
{
63-
return $this->client->put($this->documentType . "/$documentId/kb_position_custom/$itemId", $params);
51+
return $this->client->put($this->documentType."/$documentId/kb_position_custom/$itemId", $params);
6452
}
6553

6654
/**
67-
* @param int $documentId
68-
* @param int $itemId
6955
* @return mixed
7056
*/
7157
public function deleteDefaultPosition(int $documentId, int $itemId)
7258
{
73-
return $this->client->delete($this->documentType . "/$documentId/kb_position_custom/$itemId");
59+
return $this->client->delete($this->documentType."/$documentId/kb_position_custom/$itemId");
7460
}
7561

7662
/**
77-
* @param int $documentId
78-
* @param array $params
7963
* @return mixed
8064
*/
8165
public function listItemPositions(int $documentId, array $params = [])
8266
{
83-
return $this->client->get($this->documentType . "/$documentId/kb_position_article", $params);
67+
return $this->client->get($this->documentType."/$documentId/kb_position_article", $params);
8468
}
8569

8670
/**
87-
* @param int $documentId
88-
* @param int $itemId
8971
* @return mixed
9072
*/
9173
public function showItemPosition(int $documentId, int $itemId)
9274
{
93-
return $this->client->get($this->documentType . "/$documentId/kb_position_article/$itemId");
75+
return $this->client->get($this->documentType."/$documentId/kb_position_article/$itemId");
9476
}
9577

9678
/**
97-
* @param int $documentId
98-
* @param array $params
9979
* @return mixed
10080
*/
10181
public function createItemPosition(int $documentId, array $params = [])
10282
{
103-
return $this->client->post($this->documentType . "/$documentId/kb_position_article", $params);
83+
return $this->client->post($this->documentType."/$documentId/kb_position_article", $params);
10484
}
10585

10686
/**
107-
* @param int $documentId
108-
* @param int $itemId
109-
* @param array $params
11087
* @return mixed
11188
*/
11289
public function editItemPosition(int $documentId, int $itemId, array $params = [])
11390
{
114-
return $this->client->post($this->documentType . "/$documentId/kb_position_article/$itemId", $params);
91+
return $this->client->post($this->documentType."/$documentId/kb_position_article/$itemId", $params);
11592
}
11693

11794
/**
118-
* @param int $documentId
119-
* @param int $itemId
120-
* @param array $params
12195
* @return mixed
12296
*/
12397
public function overwriteItemPosition(int $documentId, int $itemId, array $params = [])
12498
{
125-
return $this->client->put($this->documentType . "/$documentId/kb_position_article/$itemId", $params);
99+
return $this->client->put($this->documentType."/$documentId/kb_position_article/$itemId", $params);
126100
}
127101

128102
/**
129-
* @param int $documentId
130-
* @param int $itemId
131103
* @return mixed
132104
*/
133105
public function deleteItemPosition(int $documentId, int $itemId)
134106
{
135-
return $this->client->delete($this->documentType . "/$documentId/kb_position_article/$itemId");
107+
return $this->client->delete($this->documentType."/$documentId/kb_position_article/$itemId");
136108
}
137109

138110
/**
139-
* @param int $documentId
140-
* @param array $params
141111
* @return mixed
142112
*/
143113
public function listDiscountPositions(int $documentId, array $params = [])
144114
{
145-
return $this->client->get($this->documentType . "/$documentId/kb_position_discount", $params);
115+
return $this->client->get($this->documentType."/$documentId/kb_position_discount", $params);
146116
}
147117

148118
/**
149-
* @param int $documentId
150-
* @param int $itemId
151119
* @return mixed
152120
*/
153121
public function showDiscountPosition(int $documentId, int $itemId)
154122
{
155-
return $this->client->get($this->documentType . "/$documentId/kb_position_discount/$itemId");
123+
return $this->client->get($this->documentType."/$documentId/kb_position_discount/$itemId");
156124
}
157125

158126
/**
159-
* @param int $documentId
160-
* @param array $params
161127
* @return mixed
162128
*/
163129
public function createDiscountPosition(int $documentId, array $params = [])
164130
{
165-
return $this->client->post($this->documentType . "/$documentId/kb_position_discount", $params);
131+
return $this->client->post($this->documentType."/$documentId/kb_position_discount", $params);
166132
}
167133

168134
/**
169-
* @param int $documentId
170-
* @param int $itemId
171-
* @param array $params
172135
* @return mixed
173136
*/
174137
public function editDiscountPosition(int $documentId, int $itemId, array $params = [])
175138
{
176-
return $this->client->post($this->documentType . "/$documentId/kb_position_discount/$itemId", $params);
139+
return $this->client->post($this->documentType."/$documentId/kb_position_discount/$itemId", $params);
177140
}
178141

179142
/**
180-
* @param int $documentId
181-
* @param int $itemId
182-
* @param array $params
183143
* @return mixed
184144
*/
185145
public function overwriteDiscountPosition(int $documentId, int $itemId, array $params = [])
186146
{
187-
return $this->client->put($this->documentType . "/$documentId/kb_position_discount/$itemId", $params);
147+
return $this->client->put($this->documentType."/$documentId/kb_position_discount/$itemId", $params);
188148
}
189149

190150
/**
191-
* @param int $documentId
192-
* @param int $itemId
193151
* @return mixed
194152
*/
195153
public function deleteDiscountPosition(int $documentId, int $itemId)
196154
{
197-
return $this->client->delete($this->documentType . "/$documentId/kb_position_discount/$itemId");
155+
return $this->client->delete($this->documentType."/$documentId/kb_position_discount/$itemId");
198156
}
199157
}

src/Bexio/Resource/Accounting.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class Accounting extends Bexio
1212
/**
1313
* Fetch a list of accounts
1414
*
15-
* @param array $params
1615
* @return mixed
1716
*/
1817
public function getAccounts(array $params = [])
@@ -23,7 +22,6 @@ public function getAccounts(array $params = [])
2322
/**
2423
* Fetch a list of taxes
2524
*
26-
* @param array $params
2725
* @return mixed
2826
*/
2927
public function getTaxes(array $params = [])
@@ -34,7 +32,6 @@ public function getTaxes(array $params = [])
3432
/**
3533
* Fetch a list of currencies
3634
*
37-
* @param array $params
3835
* @return mixed
3936
*/
4037
public function getCurrencies(array $params = [])
@@ -45,7 +42,6 @@ public function getCurrencies(array $params = [])
4542
/**
4643
* Create new currency
4744
*
48-
* @param array $params
4945
* @return mixed
5046
*/
5147
public function createCurrency(array $params = [])
@@ -56,7 +52,6 @@ public function createCurrency(array $params = [])
5652
/**
5753
* Fetch a currency
5854
*
59-
* @param int $id
6055
* @return mixed
6156
*/
6257
public function getCurrency(int $id)
@@ -67,7 +62,6 @@ public function getCurrency(int $id)
6762
/**
6863
* Delete a currency
6964
*
70-
* @param int $id
7165
* @return mixed
7266
*/
7367
public function deleteCurrency(int $id)
@@ -78,8 +72,6 @@ public function deleteCurrency(int $id)
7872
/**
7973
* Update a currency
8074
*
81-
* @param int $id
82-
* @param array $params
8375
* @return mixed
8476
*/
8577
public function updateCurrency(int $id, array $params = [])

0 commit comments

Comments
 (0)