Skip to content

Commit 9711873

Browse files
feat(api): api update
1 parent 9a194bb commit 9711873

File tree

8 files changed

+225
-4
lines changed

8 files changed

+225
-4
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 232
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-8bcd1f04377ee8ae354a1cb3b1c214232c8b448a93c98502ea92b696bf0757bf.yml
3-
openapi_spec_hash: c338b176720c2dc69dd3f7db351ea8a5
4-
config_hash: d15ecbf4dc8a7a0ef99397d11b557444
1+
configured_endpoints: 233
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-1ed184e346fa8c739f7de410b940df9f160681dd818eed4ec1e48b40451007d0.yml
3+
openapi_spec_hash: 0bc3978204acc7949c98e1d098bf5e1c
4+
config_hash: ca482105d83c23b2986f1c9c441c4343

src/ServiceContracts/Simulations/CheckDepositsContract.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Increase\CheckDeposits\CheckDeposit;
88
use Increase\Core\Exceptions\APIException;
99
use Increase\RequestOptions;
10+
use Increase\Simulations\CheckDeposits\CheckDepositAdjustmentParams\Reason;
1011
use Increase\Simulations\CheckDeposits\CheckDepositSubmitParams\Scan;
1112

1213
/**
@@ -15,6 +16,23 @@
1516
*/
1617
interface CheckDepositsContract
1718
{
19+
/**
20+
* @api
21+
*
22+
* @param string $checkDepositID the identifier of the Check Deposit you wish to adjust
23+
* @param int $amount The adjustment amount in the minor unit of the Check Deposit's currency (e.g., cents). A negative amount means that the funds are being clawed back by the other bank and is a debit to your account. Defaults to the negative of the Check Deposit amount.
24+
* @param Reason|value-of<Reason> $reason The reason for the adjustment. Defaults to `non_conforming_item`, which is often used for a low quality image that the recipient wasn't able to handle.
25+
* @param RequestOpts|null $requestOptions
26+
*
27+
* @throws APIException
28+
*/
29+
public function adjustment(
30+
string $checkDepositID,
31+
?int $amount = null,
32+
Reason|string|null $reason = null,
33+
RequestOptions|array|null $requestOptions = null,
34+
): CheckDeposit;
35+
1836
/**
1937
* @api
2038
*

src/ServiceContracts/Simulations/CheckDepositsRawContract.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,31 @@
88
use Increase\Core\Contracts\BaseResponse;
99
use Increase\Core\Exceptions\APIException;
1010
use Increase\RequestOptions;
11+
use Increase\Simulations\CheckDeposits\CheckDepositAdjustmentParams;
1112
use Increase\Simulations\CheckDeposits\CheckDepositSubmitParams;
1213

1314
/**
1415
* @phpstan-import-type RequestOpts from \Increase\RequestOptions
1516
*/
1617
interface CheckDepositsRawContract
1718
{
19+
/**
20+
* @api
21+
*
22+
* @param string $checkDepositID the identifier of the Check Deposit you wish to adjust
23+
* @param array<string,mixed>|CheckDepositAdjustmentParams $params
24+
* @param RequestOpts|null $requestOptions
25+
*
26+
* @return BaseResponse<CheckDeposit>
27+
*
28+
* @throws APIException
29+
*/
30+
public function adjustment(
31+
string $checkDepositID,
32+
array|CheckDepositAdjustmentParams $params,
33+
RequestOptions|array|null $requestOptions = null,
34+
): BaseResponse;
35+
1836
/**
1937
* @api
2038
*

src/Services/Simulations/CheckDepositsRawService.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Increase\Core\Exceptions\APIException;
1111
use Increase\RequestOptions;
1212
use Increase\ServiceContracts\Simulations\CheckDepositsRawContract;
13+
use Increase\Simulations\CheckDeposits\CheckDepositAdjustmentParams;
14+
use Increase\Simulations\CheckDeposits\CheckDepositAdjustmentParams\Reason;
1315
use Increase\Simulations\CheckDeposits\CheckDepositSubmitParams;
1416
use Increase\Simulations\CheckDeposits\CheckDepositSubmitParams\Scan;
1517

@@ -25,6 +27,41 @@ final class CheckDepositsRawService implements CheckDepositsRawContract
2527
*/
2628
public function __construct(private Client $client) {}
2729

30+
/**
31+
* @api
32+
*
33+
* Simulates the creation of a [Check Deposit Adjustment](#check-deposit-adjustments) on a [Check Deposit](#check-deposits). This Check Deposit must first have a `status` of `submitted`.
34+
*
35+
* @param string $checkDepositID the identifier of the Check Deposit you wish to adjust
36+
* @param array{
37+
* amount?: int, reason?: value-of<Reason>
38+
* }|CheckDepositAdjustmentParams $params
39+
* @param RequestOpts|null $requestOptions
40+
*
41+
* @return BaseResponse<CheckDeposit>
42+
*
43+
* @throws APIException
44+
*/
45+
public function adjustment(
46+
string $checkDepositID,
47+
array|CheckDepositAdjustmentParams $params,
48+
RequestOptions|array|null $requestOptions = null,
49+
): BaseResponse {
50+
[$parsed, $options] = CheckDepositAdjustmentParams::parseRequest(
51+
$params,
52+
$requestOptions,
53+
);
54+
55+
// @phpstan-ignore-next-line return.type
56+
return $this->client->request(
57+
method: 'post',
58+
path: ['simulations/check_deposits/%1$s/adjustment', $checkDepositID],
59+
body: (object) $parsed,
60+
options: $options,
61+
convert: CheckDeposit::class,
62+
);
63+
}
64+
2865
/**
2966
* @api
3067
*

src/Services/Simulations/CheckDepositsService.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Increase\Core\Util;
1111
use Increase\RequestOptions;
1212
use Increase\ServiceContracts\Simulations\CheckDepositsContract;
13+
use Increase\Simulations\CheckDeposits\CheckDepositAdjustmentParams\Reason;
1314
use Increase\Simulations\CheckDeposits\CheckDepositSubmitParams\Scan;
1415

1516
/**
@@ -31,6 +32,32 @@ public function __construct(private Client $client)
3132
$this->raw = new CheckDepositsRawService($client);
3233
}
3334

35+
/**
36+
* @api
37+
*
38+
* Simulates the creation of a [Check Deposit Adjustment](#check-deposit-adjustments) on a [Check Deposit](#check-deposits). This Check Deposit must first have a `status` of `submitted`.
39+
*
40+
* @param string $checkDepositID the identifier of the Check Deposit you wish to adjust
41+
* @param int $amount The adjustment amount in the minor unit of the Check Deposit's currency (e.g., cents). A negative amount means that the funds are being clawed back by the other bank and is a debit to your account. Defaults to the negative of the Check Deposit amount.
42+
* @param Reason|value-of<Reason> $reason The reason for the adjustment. Defaults to `non_conforming_item`, which is often used for a low quality image that the recipient wasn't able to handle.
43+
* @param RequestOpts|null $requestOptions
44+
*
45+
* @throws APIException
46+
*/
47+
public function adjustment(
48+
string $checkDepositID,
49+
?int $amount = null,
50+
Reason|string|null $reason = null,
51+
RequestOptions|array|null $requestOptions = null,
52+
): CheckDeposit {
53+
$params = Util::removeNulls(['amount' => $amount, 'reason' => $reason]);
54+
55+
// @phpstan-ignore-next-line argument.type
56+
$response = $this->raw->adjustment($checkDepositID, params: $params, requestOptions: $requestOptions);
57+
58+
return $response->parse();
59+
}
60+
3461
/**
3562
* @api
3663
*
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Increase\Simulations\CheckDeposits;
6+
7+
use Increase\Core\Attributes\Optional;
8+
use Increase\Core\Concerns\SdkModel;
9+
use Increase\Core\Concerns\SdkParams;
10+
use Increase\Core\Contracts\BaseModel;
11+
use Increase\Simulations\CheckDeposits\CheckDepositAdjustmentParams\Reason;
12+
13+
/**
14+
* Simulates the creation of a [Check Deposit Adjustment](#check-deposit-adjustments) on a [Check Deposit](#check-deposits). This Check Deposit must first have a `status` of `submitted`.
15+
*
16+
* @see Increase\Services\Simulations\CheckDepositsService::adjustment()
17+
*
18+
* @phpstan-type CheckDepositAdjustmentParamsShape = array{
19+
* amount?: int|null, reason?: null|Reason|value-of<Reason>
20+
* }
21+
*/
22+
final class CheckDepositAdjustmentParams implements BaseModel
23+
{
24+
/** @use SdkModel<CheckDepositAdjustmentParamsShape> */
25+
use SdkModel;
26+
use SdkParams;
27+
28+
/**
29+
* The adjustment amount in the minor unit of the Check Deposit's currency (e.g., cents). A negative amount means that the funds are being clawed back by the other bank and is a debit to your account. Defaults to the negative of the Check Deposit amount.
30+
*/
31+
#[Optional]
32+
public ?int $amount;
33+
34+
/**
35+
* The reason for the adjustment. Defaults to `non_conforming_item`, which is often used for a low quality image that the recipient wasn't able to handle.
36+
*
37+
* @var value-of<Reason>|null $reason
38+
*/
39+
#[Optional(enum: Reason::class)]
40+
public ?string $reason;
41+
42+
public function __construct()
43+
{
44+
$this->initialize();
45+
}
46+
47+
/**
48+
* Construct an instance from the required parameters.
49+
*
50+
* You must use named parameters to construct any parameters with a default value.
51+
*
52+
* @param Reason|value-of<Reason>|null $reason
53+
*/
54+
public static function with(
55+
?int $amount = null,
56+
Reason|string|null $reason = null
57+
): self {
58+
$self = new self;
59+
60+
null !== $amount && $self['amount'] = $amount;
61+
null !== $reason && $self['reason'] = $reason;
62+
63+
return $self;
64+
}
65+
66+
/**
67+
* The adjustment amount in the minor unit of the Check Deposit's currency (e.g., cents). A negative amount means that the funds are being clawed back by the other bank and is a debit to your account. Defaults to the negative of the Check Deposit amount.
68+
*/
69+
public function withAmount(int $amount): self
70+
{
71+
$self = clone $this;
72+
$self['amount'] = $amount;
73+
74+
return $self;
75+
}
76+
77+
/**
78+
* The reason for the adjustment. Defaults to `non_conforming_item`, which is often used for a low quality image that the recipient wasn't able to handle.
79+
*
80+
* @param Reason|value-of<Reason> $reason
81+
*/
82+
public function withReason(Reason|string $reason): self
83+
{
84+
$self = clone $this;
85+
$self['reason'] = $reason;
86+
87+
return $self;
88+
}
89+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Increase\Simulations\CheckDeposits\CheckDepositAdjustmentParams;
6+
7+
/**
8+
* The reason for the adjustment. Defaults to `non_conforming_item`, which is often used for a low quality image that the recipient wasn't able to handle.
9+
*/
10+
enum Reason: string
11+
{
12+
case LATE_RETURN = 'late_return';
13+
14+
case WRONG_PAYEE_CREDIT = 'wrong_payee_credit';
15+
16+
case ADJUSTED_AMOUNT = 'adjusted_amount';
17+
18+
case NON_CONFORMING_ITEM = 'non_conforming_item';
19+
20+
case PAID = 'paid';
21+
}

tests/Services/Simulations/CheckDepositsTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ protected function setUp(): void
2727
$this->client = $client;
2828
}
2929

30+
#[Test]
31+
public function testAdjustment(): void
32+
{
33+
$result = $this->client->simulations->checkDeposits->adjustment(
34+
'check_deposit_f06n9gpg7sxn8t19lfc1'
35+
);
36+
37+
// @phpstan-ignore-next-line method.alreadyNarrowedType
38+
$this->assertInstanceOf(CheckDeposit::class, $result);
39+
}
40+
3041
#[Test]
3142
public function testReject(): void
3243
{

0 commit comments

Comments
 (0)