Skip to content

Commit 3f2b1c1

Browse files
authored
Merge pull request #1 from Increase/release-please--branches--main--changes--next
release: 0.1.0
2 parents 333652a + f60dddf commit 3f2b1c1

File tree

7 files changed

+87
-84
lines changed

7 files changed

+87
-84
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Publish Packagist
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
publish:
7+
name: publish
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Publish to Packagist
14+
run: |-
15+
curl --fail-with-body -X POST -H 'Content-Type: application/json' "https://packagist.org/api/update-package?username=${PACKAGIST_USERNAME}&apiToken=${PACKAGIST_SAFE_KEY}" -d '{"repository":"https://www.github.com/Increase/increase-php"}'
16+
env:
17+
PACKAGIST_USERNAME: ${{ secrets.INCREASE_PACKAGIST_USERNAME || secrets.PACKAGIST_USERNAME }}
18+
PACKAGIST_SAFE_KEY: ${{ secrets.INCREASE_PACKAGIST_SAFE_KEY || secrets.PACKAGIST_SAFE_KEY }}

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.0.1"
2+
".": "0.1.0"
33
}

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 232
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-a559a6a1a1f3781fad8db5bcb96c40b69a78b952d659395840accce782098e0c.yml
33
openapi_spec_hash: 2ae62041468e5cf6fe653d65b1b7a58a
4-
config_hash: 0d242469421d4c22a6010e671c6b2346
4+
config_hash: 27e44ed36b9c5617b580ead7231a594a

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
## 0.1.0 (2026-01-16)
4+
5+
Full Changelog: [v0.0.1...v0.1.0](https://github.com/Increase/increase-php/compare/v0.0.1...v0.1.0)
6+
7+
### Features
8+
9+
* **api:** api update ([0e9fe78](https://github.com/Increase/increase-php/commit/0e9fe7828945a11716c726911c20415a1477950d))
10+
* **api:** api update ([333652a](https://github.com/Increase/increase-php/commit/333652a3de344cdd790655076fb95f2e1ea55ae2))
11+
12+
13+
### Chores
14+
15+
* fix invalid exception class checks ([8ea143a](https://github.com/Increase/increase-php/commit/8ea143ad19e98508771c178bff858448b5046c71))

README.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,10 @@ The REST API documentation can be found on [increase.com](https://increase.com/d
88

99
## Installation
1010

11-
To use this package, install via Composer by adding the following to your application's `composer.json`:
12-
1311
<!-- x-release-please-start-version -->
1412

15-
```json
16-
{
17-
"repositories": [
18-
{
19-
"type": "vcs",
20-
"url": "git@github.com:Increase/increase-php.git"
21-
}
22-
],
23-
"require": {
24-
"increase/increase": "dev-main"
25-
}
26-
}
13+
```
14+
composer require "increase/increase 0.1.0"
2715
```
2816

2917
<!-- x-release-please-end -->

src/Core/Exceptions/APIStatusException.php

Lines changed: 49 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,81 +6,63 @@
66
use Psr\Http\Message\RequestInterface;
77
use Psr\Http\Message\ResponseInterface;
88

9-
/**
10-
*
11-
*
12-
*/
139
class APIStatusException extends APIException
1410
{
15-
/** @var string */
16-
protected const DESC = 'Increase API Status Error';
11+
/** @var string */
12+
protected const DESC = 'Increase API Status Error';
1713

18-
/** @var int|null $status */
19-
public ?int $status;
14+
public ?int $status;
2015

21-
/**
22-
* @param RequestInterface $request
23-
* @param ResponseInterface $response
24-
* @param string $message
25-
*
26-
* @return self
27-
*/
28-
public static function from(
29-
RequestInterface $request, ResponseInterface $response, string $message = ''
30-
): self {
31-
$status = $response->getStatusCode();
32-
$STAINLESS_FIXME_key = Util::dig($body, 'type')
16+
public function __construct(
17+
public RequestInterface $request,
18+
ResponseInterface $response,
19+
?\Throwable $previous = null,
20+
string $message = '',
21+
) {
22+
$this->response = $response;
23+
$this->status = $response->getStatusCode();
3324

34-
$cls = match (true)
35-
{
25+
$summary = Util::prettyEncodeJson(['status' => $this->status, 'body' => Util::decodeJson($response->getBody())]);
3626

37-
$status === null && $key === InvalidParametersError::type => InvalidParametersError::class,
38-
$status === null && $key === MalformedRequestError::type => MalformedRequestError::class,
39-
$status === null && $key === InvalidAPIKeyError::type => InvalidAPIKeyError::class,
40-
$status === null && $key === EnvironmentMismatchError::type => EnvironmentMismatchError::class,
41-
$status === null && $key === InsufficientPermissionsError::type => InsufficientPermissionsError::class,
42-
$status === null && $key === PrivateFeatureError::type => PrivateFeatureError::class,
43-
$status === null && $key === APIMethodNotFoundError::type => APIMethodNotFoundError::class,
44-
$status === null && $key === ObjectNotFoundError::type => ObjectNotFoundError::class,
45-
$status === null && $key === IdempotencyKeyAlreadyUsedError::type => IdempotencyKeyAlreadyUsedError::class,
46-
$status === null && $key === InvalidOperationError::type => InvalidOperationError::class,
47-
$status === null && $key === RateLimitedError::type => RateLimitedError::class,
48-
$status >= 500 && $key === InternalServerException::type => InternalServerException::class,
49-
$status === 400 => BadRequestException::class,
50-
$status === 401 => AuthenticationException::class,
51-
$status === 403 => PermissionDeniedException::class,
52-
$status === 404 => NotFoundException::class,
53-
$status === 409 => ConflictException::class,
54-
$status === 422 => UnprocessableEntityException::class,
55-
$status === 429 => RateLimitException::class,
56-
default => APIStatusException::class
27+
if ('' != $message) {
28+
$summary .= $message.PHP_EOL.$summary;
29+
}
5730

58-
};
59-
60-
return new $cls(request: $request, response: $response, message: $message);
61-
}
31+
parent::__construct(request: $request, message: $summary, previous: $previous);
32+
}
6233

63-
/**
64-
* @param RequestInterface $request
65-
* @param \Throwable|null $previous
66-
* @param ResponseInterface $response
67-
* @param string $message
68-
*/
69-
function __construct(
70-
public RequestInterface $request,
71-
ResponseInterface $response,
72-
?\Throwable $previous = null,
73-
string $message = '',
74-
) {
75-
$this->response = $response;
76-
$this->status = $response->getStatusCode();
34+
public static function from(
35+
RequestInterface $request,
36+
ResponseInterface $response,
37+
string $message = ''
38+
): self {
39+
$status = $response->getStatusCode();
40+
$body = Util::decodeJson($response->getBody());
41+
$key = Util::dig($body, 'type');
7742

78-
$summary = Util::prettyEncodeJson(['status' => $this->status, 'body' => Util::decodeJson($response->getBody())]);
43+
$cls = match (true) {
44+
400 === $status && InvalidParametersError::type === $key => InvalidParametersError::class,
45+
400 === $status && MalformedRequestError::type === $key => MalformedRequestError::class,
46+
401 === $status && InvalidAPIKeyError::type === $key => InvalidAPIKeyError::class,
47+
403 === $status && EnvironmentMismatchError::type === $key => EnvironmentMismatchError::class,
48+
403 === $status && InsufficientPermissionsError::type === $key => InsufficientPermissionsError::class,
49+
403 === $status && PrivateFeatureError::type === $key => PrivateFeatureError::class,
50+
404 === $status && APIMethodNotFoundError::type === $key => APIMethodNotFoundError::class,
51+
404 === $status && ObjectNotFoundError::type === $key => ObjectNotFoundError::class,
52+
409 === $status && IdempotencyKeyAlreadyUsedError::type === $key => IdempotencyKeyAlreadyUsedError::class,
53+
409 === $status && InvalidOperationError::type === $key => InvalidOperationError::class,
54+
429 === $status && RateLimitedError::type === $key => RateLimitedError::class,
55+
$status >= 500 && InternalServerException::type === $key => InternalServerException::class,
56+
400 === $status => BadRequestException::class,
57+
401 === $status => AuthenticationException::class,
58+
403 === $status => PermissionDeniedException::class,
59+
404 === $status => NotFoundException::class,
60+
409 === $status => ConflictException::class,
61+
422 === $status => UnprocessableEntityException::class,
62+
429 === $status => RateLimitException::class,
63+
default => APIStatusException::class
64+
};
7965

80-
if ('' != $message) {
81-
$summary .= $message . PHP_EOL . $summary;
66+
return new $cls(request: $request, response: $response, message: $message);
8267
}
83-
84-
parent::__construct(request: $request, message: $summary, previous: $previous);
85-
}
86-
}
68+
}

src/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
namespace Increase;
66

77
// x-release-please-start-version
8-
const VERSION = '0.0.1';
8+
const VERSION = '0.1.0';
99
// x-release-please-end

0 commit comments

Comments
 (0)