diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f7014c3..a713055 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.11.0" + ".": "0.12.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 91752ae..df82cbc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 232 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-3309070d0c282e00842afa3021c80774f8e1f3a4517959927adfd9ffaa81c94c.yml -openapi_spec_hash: 57927271c019ee8ddd428afa8a57baaf +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-994727afca8b769c05b3531b0e560cfc71b7d2c45a49b54e09bbf73d0dbcaa1f.yml +openapi_spec_hash: bb1c55d7e08fb038a7383976bba226d1 config_hash: 27e44ed36b9c5617b580ead7231a594a diff --git a/CHANGELOG.md b/CHANGELOG.md index fe61a3b..a17f8bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.12.0 (2026-01-30) + +Full Changelog: [v0.11.0...v0.12.0](https://github.com/Increase/increase-php/compare/v0.11.0...v0.12.0) + +### Features + +* **api:** api update ([f9b9413](https://github.com/Increase/increase-php/commit/f9b9413669d9bcf6c8981b2ba3364ec18f155da8)) + ## 0.11.0 (2026-01-30) Full Changelog: [v0.10.0...v0.11.0](https://github.com/Increase/increase-php/compare/v0.10.0...v0.11.0) diff --git a/README.md b/README.md index e9098ee..a00fc60 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The REST API documentation can be found on [increase.com](https://increase.com/d ``` -composer require "increase/increase 0.11.0" +composer require "increase/increase 0.12.0" ``` diff --git a/src/AccountStatements/AccountStatement.php b/src/AccountStatements/AccountStatement.php index 893e918..16dd584 100644 --- a/src/AccountStatements/AccountStatement.php +++ b/src/AccountStatements/AccountStatement.php @@ -4,6 +4,7 @@ namespace Increase\AccountStatements; +use Increase\AccountStatements\AccountStatement\Loan; use Increase\AccountStatements\AccountStatement\Type; use Increase\Core\Attributes\Required; use Increase\Core\Concerns\SdkModel; @@ -12,12 +13,15 @@ /** * Account Statements are generated monthly for every active Account. You can access the statement's data via the API or retrieve a PDF with its details via its associated File. * + * @phpstan-import-type LoanShape from \Increase\AccountStatements\AccountStatement\Loan + * * @phpstan-type AccountStatementShape = array{ * id: string, * accountID: string, * createdAt: \DateTimeInterface, * endingBalance: int, * fileID: string, + * loan: null|Loan|LoanShape, * startingBalance: int, * statementPeriodEnd: \DateTimeInterface, * statementPeriodStart: \DateTimeInterface, @@ -59,6 +63,12 @@ final class AccountStatement implements BaseModel #[Required('file_id')] public string $fileID; + /** + * The loan balances. + */ + #[Required] + public ?Loan $loan; + /** * The Account's balance at the start of its statement period. */ @@ -96,6 +106,7 @@ final class AccountStatement implements BaseModel * createdAt: ..., * endingBalance: ..., * fileID: ..., + * loan: ..., * startingBalance: ..., * statementPeriodEnd: ..., * statementPeriodStart: ..., @@ -112,6 +123,7 @@ final class AccountStatement implements BaseModel * ->withCreatedAt(...) * ->withEndingBalance(...) * ->withFileID(...) + * ->withLoan(...) * ->withStartingBalance(...) * ->withStatementPeriodEnd(...) * ->withStatementPeriodStart(...) @@ -128,6 +140,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * + * @param Loan|LoanShape|null $loan * @param Type|value-of $type */ public static function with( @@ -136,6 +149,7 @@ public static function with( \DateTimeInterface $createdAt, int $endingBalance, string $fileID, + Loan|array|null $loan, int $startingBalance, \DateTimeInterface $statementPeriodEnd, \DateTimeInterface $statementPeriodStart, @@ -148,6 +162,7 @@ public static function with( $self['createdAt'] = $createdAt; $self['endingBalance'] = $endingBalance; $self['fileID'] = $fileID; + $self['loan'] = $loan; $self['startingBalance'] = $startingBalance; $self['statementPeriodEnd'] = $statementPeriodEnd; $self['statementPeriodStart'] = $statementPeriodStart; @@ -211,6 +226,19 @@ public function withFileID(string $fileID): self return $self; } + /** + * The loan balances. + * + * @param Loan|LoanShape|null $loan + */ + public function withLoan(Loan|array|null $loan): self + { + $self = clone $this; + $self['loan'] = $loan; + + return $self; + } + /** * The Account's balance at the start of its statement period. */ diff --git a/src/AccountStatements/AccountStatement/Loan.php b/src/AccountStatements/AccountStatement/Loan.php new file mode 100644 index 0000000..dc1f73b --- /dev/null +++ b/src/AccountStatements/AccountStatement/Loan.php @@ -0,0 +1,111 @@ + */ + use SdkModel; + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the loan payment is due. + */ + #[Required('due_at')] + public ?\DateTimeInterface $dueAt; + + /** + * The total amount due on the loan. + */ + #[Required('due_balance')] + public int $dueBalance; + + /** + * The amount past due on the loan. + */ + #[Required('past_due_balance')] + public int $pastDueBalance; + + /** + * `new Loan()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Loan::with(dueAt: ..., dueBalance: ..., pastDueBalance: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Loan)->withDueAt(...)->withDueBalance(...)->withPastDueBalance(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with( + ?\DateTimeInterface $dueAt, + int $dueBalance, + int $pastDueBalance + ): self { + $self = new self; + + $self['dueAt'] = $dueAt; + $self['dueBalance'] = $dueBalance; + $self['pastDueBalance'] = $pastDueBalance; + + return $self; + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the loan payment is due. + */ + public function withDueAt(?\DateTimeInterface $dueAt): self + { + $self = clone $this; + $self['dueAt'] = $dueAt; + + return $self; + } + + /** + * The total amount due on the loan. + */ + public function withDueBalance(int $dueBalance): self + { + $self = clone $this; + $self['dueBalance'] = $dueBalance; + + return $self; + } + + /** + * The amount past due on the loan. + */ + public function withPastDueBalance(int $pastDueBalance): self + { + $self = clone $this; + $self['pastDueBalance'] = $pastDueBalance; + + return $self; + } +} diff --git a/src/Accounts/Account.php b/src/Accounts/Account.php index de04447..780703f 100644 --- a/src/Accounts/Account.php +++ b/src/Accounts/Account.php @@ -6,6 +6,8 @@ use Increase\Accounts\Account\Bank; use Increase\Accounts\Account\Currency; +use Increase\Accounts\Account\Funding; +use Increase\Accounts\Account\Loan; use Increase\Accounts\Account\Status; use Increase\Accounts\Account\Type; use Increase\Core\Attributes\Required; @@ -15,6 +17,8 @@ /** * Accounts are your bank accounts with Increase. They store money, receive transfers, and send payments. They earn interest and have depository insurance. * + * @phpstan-import-type LoanShape from \Increase\Accounts\Account\Loan + * * @phpstan-type AccountShape = array{ * id: string, * accountRevenueRate: string|null, @@ -23,11 +27,13 @@ * createdAt: \DateTimeInterface, * currency: Currency|value-of, * entityID: string, + * funding: null|Funding|value-of, * idempotencyKey: string|null, * informationalEntityID: string|null, * interestAccrued: string, * interestAccruedAt: string|null, * interestRate: string, + * loan: null|Loan|LoanShape, * name: string, * programID: string, * status: Status|value-of, @@ -85,6 +91,14 @@ final class Account implements BaseModel #[Required('entity_id')] public string $entityID; + /** + * Whether the Account is funded by a loan or by deposits. + * + * @var value-of|null $funding + */ + #[Required(enum: Funding::class)] + public ?string $funding; + /** * The idempotency key you chose for this object. This value is unique across Increase and is used to ensure that a request is only processed once. Learn more about [idempotency](https://increase.com/documentation/idempotency-keys). */ @@ -115,6 +129,12 @@ final class Account implements BaseModel #[Required('interest_rate')] public string $interestRate; + /** + * The Account's loan-related information, if the Account is a loan account. + */ + #[Required] + public ?Loan $loan; + /** * The name you choose for the Account. */ @@ -156,11 +176,13 @@ final class Account implements BaseModel * createdAt: ..., * currency: ..., * entityID: ..., + * funding: ..., * idempotencyKey: ..., * informationalEntityID: ..., * interestAccrued: ..., * interestAccruedAt: ..., * interestRate: ..., + * loan: ..., * name: ..., * programID: ..., * status: ..., @@ -179,11 +201,13 @@ final class Account implements BaseModel * ->withCreatedAt(...) * ->withCurrency(...) * ->withEntityID(...) + * ->withFunding(...) * ->withIdempotencyKey(...) * ->withInformationalEntityID(...) * ->withInterestAccrued(...) * ->withInterestAccruedAt(...) * ->withInterestRate(...) + * ->withLoan(...) * ->withName(...) * ->withProgramID(...) * ->withStatus(...) @@ -202,6 +226,8 @@ public function __construct() * * @param Bank|value-of $bank * @param Currency|value-of $currency + * @param Funding|value-of|null $funding + * @param Loan|LoanShape|null $loan * @param Status|value-of $status * @param Type|value-of $type */ @@ -213,11 +239,13 @@ public static function with( \DateTimeInterface $createdAt, Currency|string $currency, string $entityID, + Funding|string|null $funding, ?string $idempotencyKey, ?string $informationalEntityID, string $interestAccrued, ?string $interestAccruedAt, string $interestRate, + Loan|array|null $loan, string $name, string $programID, Status|string $status, @@ -232,11 +260,13 @@ public static function with( $self['createdAt'] = $createdAt; $self['currency'] = $currency; $self['entityID'] = $entityID; + $self['funding'] = $funding; $self['idempotencyKey'] = $idempotencyKey; $self['informationalEntityID'] = $informationalEntityID; $self['interestAccrued'] = $interestAccrued; $self['interestAccruedAt'] = $interestAccruedAt; $self['interestRate'] = $interestRate; + $self['loan'] = $loan; $self['name'] = $name; $self['programID'] = $programID; $self['status'] = $status; @@ -326,6 +356,19 @@ public function withEntityID(string $entityID): self return $self; } + /** + * Whether the Account is funded by a loan or by deposits. + * + * @param Funding|value-of|null $funding + */ + public function withFunding(Funding|string|null $funding): self + { + $self = clone $this; + $self['funding'] = $funding; + + return $self; + } + /** * The idempotency key you chose for this object. This value is unique across Increase and is used to ensure that a request is only processed once. Learn more about [idempotency](https://increase.com/documentation/idempotency-keys). */ @@ -382,6 +425,19 @@ public function withInterestRate(string $interestRate): self return $self; } + /** + * The Account's loan-related information, if the Account is a loan account. + * + * @param Loan|LoanShape|null $loan + */ + public function withLoan(Loan|array|null $loan): self + { + $self = clone $this; + $self['loan'] = $loan; + + return $self; + } + /** * The name you choose for the Account. */ diff --git a/src/Accounts/Account/Funding.php b/src/Accounts/Account/Funding.php new file mode 100644 index 0000000..00bad75 --- /dev/null +++ b/src/Accounts/Account/Funding.php @@ -0,0 +1,15 @@ +, + * } + */ +final class Loan implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * The maximum amount of money that can be borrowed on the Account. + */ + #[Required('credit_limit')] + public int $creditLimit; + + /** + * The number of days after the statement date that the Account can be past due before being considered delinquent. + */ + #[Required('grace_period_days')] + public int $gracePeriodDays; + + /** + * The date on which the loan matures. + */ + #[Required('maturity_date')] + public ?string $maturityDate; + + /** + * The day of the month on which the loan statement is generated. + */ + #[Required('statement_day_of_month')] + public int $statementDayOfMonth; + + /** + * The type of payment for the loan. + * + * @var value-of $statementPaymentType + */ + #[Required('statement_payment_type', enum: StatementPaymentType::class)] + public string $statementPaymentType; + + /** + * `new Loan()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Loan::with( + * creditLimit: ..., + * gracePeriodDays: ..., + * maturityDate: ..., + * statementDayOfMonth: ..., + * statementPaymentType: ..., + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Loan) + * ->withCreditLimit(...) + * ->withGracePeriodDays(...) + * ->withMaturityDate(...) + * ->withStatementDayOfMonth(...) + * ->withStatementPaymentType(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param StatementPaymentType|value-of $statementPaymentType + */ + public static function with( + int $creditLimit, + int $gracePeriodDays, + ?string $maturityDate, + int $statementDayOfMonth, + StatementPaymentType|string $statementPaymentType, + ): self { + $self = new self; + + $self['creditLimit'] = $creditLimit; + $self['gracePeriodDays'] = $gracePeriodDays; + $self['maturityDate'] = $maturityDate; + $self['statementDayOfMonth'] = $statementDayOfMonth; + $self['statementPaymentType'] = $statementPaymentType; + + return $self; + } + + /** + * The maximum amount of money that can be borrowed on the Account. + */ + public function withCreditLimit(int $creditLimit): self + { + $self = clone $this; + $self['creditLimit'] = $creditLimit; + + return $self; + } + + /** + * The number of days after the statement date that the Account can be past due before being considered delinquent. + */ + public function withGracePeriodDays(int $gracePeriodDays): self + { + $self = clone $this; + $self['gracePeriodDays'] = $gracePeriodDays; + + return $self; + } + + /** + * The date on which the loan matures. + */ + public function withMaturityDate(?string $maturityDate): self + { + $self = clone $this; + $self['maturityDate'] = $maturityDate; + + return $self; + } + + /** + * The day of the month on which the loan statement is generated. + */ + public function withStatementDayOfMonth(int $statementDayOfMonth): self + { + $self = clone $this; + $self['statementDayOfMonth'] = $statementDayOfMonth; + + return $self; + } + + /** + * The type of payment for the loan. + * + * @param StatementPaymentType|value-of $statementPaymentType + */ + public function withStatementPaymentType( + StatementPaymentType|string $statementPaymentType + ): self { + $self = clone $this; + $self['statementPaymentType'] = $statementPaymentType; + + return $self; + } +} diff --git a/src/Accounts/Account/Loan/StatementPaymentType.php b/src/Accounts/Account/Loan/StatementPaymentType.php new file mode 100644 index 0000000..f89571d --- /dev/null +++ b/src/Accounts/Account/Loan/StatementPaymentType.php @@ -0,0 +1,15 @@ +, * informationalEntityID?: string|null, + * loan?: null|Loan|LoanShape, * programID?: string|null, * } */ @@ -40,12 +46,26 @@ final class AccountCreateParams implements BaseModel #[Optional('entity_id')] public ?string $entityID; + /** + * Whether the Account is funded by a loan or by deposits. + * + * @var value-of|null $funding + */ + #[Optional(enum: Funding::class)] + public ?string $funding; + /** * The identifier of an Entity that, while not owning the Account, is associated with its activity. This is generally the beneficiary of the funds. */ #[Optional('informational_entity_id')] public ?string $informationalEntityID; + /** + * The loan details for the account. + */ + #[Optional] + public ?Loan $loan; + /** * The identifier for the Program that this Account falls under. Required if you operate more than one Program. */ @@ -75,11 +95,16 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param Funding|value-of|null $funding + * @param Loan|LoanShape|null $loan */ public static function with( string $name, ?string $entityID = null, + Funding|string|null $funding = null, ?string $informationalEntityID = null, + Loan|array|null $loan = null, ?string $programID = null, ): self { $self = new self; @@ -87,7 +112,9 @@ public static function with( $self['name'] = $name; null !== $entityID && $self['entityID'] = $entityID; + null !== $funding && $self['funding'] = $funding; null !== $informationalEntityID && $self['informationalEntityID'] = $informationalEntityID; + null !== $loan && $self['loan'] = $loan; null !== $programID && $self['programID'] = $programID; return $self; @@ -115,6 +142,19 @@ public function withEntityID(string $entityID): self return $self; } + /** + * Whether the Account is funded by a loan or by deposits. + * + * @param Funding|value-of $funding + */ + public function withFunding(Funding|string $funding): self + { + $self = clone $this; + $self['funding'] = $funding; + + return $self; + } + /** * The identifier of an Entity that, while not owning the Account, is associated with its activity. This is generally the beneficiary of the funds. */ @@ -127,6 +167,19 @@ public function withInformationalEntityID( return $self; } + /** + * The loan details for the account. + * + * @param Loan|LoanShape $loan + */ + public function withLoan(Loan|array $loan): self + { + $self = clone $this; + $self['loan'] = $loan; + + return $self; + } + /** * The identifier for the Program that this Account falls under. Required if you operate more than one Program. */ diff --git a/src/Accounts/AccountCreateParams/Funding.php b/src/Accounts/AccountCreateParams/Funding.php new file mode 100644 index 0000000..fb3fd07 --- /dev/null +++ b/src/Accounts/AccountCreateParams/Funding.php @@ -0,0 +1,15 @@ +, + * maturityDate?: string|null, + * } + */ +final class Loan implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * The maximum amount of money that can be drawn from the Account. + */ + #[Required('credit_limit')] + public int $creditLimit; + + /** + * The number of days after the statement date that the Account can be past due before being considered delinquent. + */ + #[Required('grace_period_days')] + public int $gracePeriodDays; + + /** + * The day of the month on which the loan statement is generated. + */ + #[Required('statement_day_of_month')] + public int $statementDayOfMonth; + + /** + * The type of statement payment for the account. + * + * @var value-of $statementPaymentType + */ + #[Required('statement_payment_type', enum: StatementPaymentType::class)] + public string $statementPaymentType; + + /** + * The date on which the loan matures. + */ + #[Optional('maturity_date')] + public ?string $maturityDate; + + /** + * `new Loan()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Loan::with( + * creditLimit: ..., + * gracePeriodDays: ..., + * statementDayOfMonth: ..., + * statementPaymentType: ..., + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Loan) + * ->withCreditLimit(...) + * ->withGracePeriodDays(...) + * ->withStatementDayOfMonth(...) + * ->withStatementPaymentType(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param StatementPaymentType|value-of $statementPaymentType + */ + public static function with( + int $creditLimit, + int $gracePeriodDays, + int $statementDayOfMonth, + StatementPaymentType|string $statementPaymentType, + ?string $maturityDate = null, + ): self { + $self = new self; + + $self['creditLimit'] = $creditLimit; + $self['gracePeriodDays'] = $gracePeriodDays; + $self['statementDayOfMonth'] = $statementDayOfMonth; + $self['statementPaymentType'] = $statementPaymentType; + + null !== $maturityDate && $self['maturityDate'] = $maturityDate; + + return $self; + } + + /** + * The maximum amount of money that can be drawn from the Account. + */ + public function withCreditLimit(int $creditLimit): self + { + $self = clone $this; + $self['creditLimit'] = $creditLimit; + + return $self; + } + + /** + * The number of days after the statement date that the Account can be past due before being considered delinquent. + */ + public function withGracePeriodDays(int $gracePeriodDays): self + { + $self = clone $this; + $self['gracePeriodDays'] = $gracePeriodDays; + + return $self; + } + + /** + * The day of the month on which the loan statement is generated. + */ + public function withStatementDayOfMonth(int $statementDayOfMonth): self + { + $self = clone $this; + $self['statementDayOfMonth'] = $statementDayOfMonth; + + return $self; + } + + /** + * The type of statement payment for the account. + * + * @param StatementPaymentType|value-of $statementPaymentType + */ + public function withStatementPaymentType( + StatementPaymentType|string $statementPaymentType + ): self { + $self = clone $this; + $self['statementPaymentType'] = $statementPaymentType; + + return $self; + } + + /** + * The date on which the loan matures. + */ + public function withMaturityDate(string $maturityDate): self + { + $self = clone $this; + $self['maturityDate'] = $maturityDate; + + return $self; + } +} diff --git a/src/Accounts/AccountCreateParams/Loan/StatementPaymentType.php b/src/Accounts/AccountCreateParams/Loan/StatementPaymentType.php new file mode 100644 index 0000000..5f0556d --- /dev/null +++ b/src/Accounts/AccountCreateParams/Loan/StatementPaymentType.php @@ -0,0 +1,15 @@ + */ + use SdkModel; + + /** + * The maximum amount of money that can be drawn from the Account. + */ + #[Required('credit_limit')] + public int $creditLimit; + + /** + * `new Loan()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Loan::with(creditLimit: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Loan)->withCreditLimit(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(int $creditLimit): self + { + $self = new self; + + $self['creditLimit'] = $creditLimit; + + return $self; + } + + /** + * The maximum amount of money that can be drawn from the Account. + */ + public function withCreditLimit(int $creditLimit): self + { + $self = clone $this; + $self['creditLimit'] = $creditLimit; + + return $self; + } +} diff --git a/src/Accounts/BalanceLookup.php b/src/Accounts/BalanceLookup.php index f34f732..973d9d9 100644 --- a/src/Accounts/BalanceLookup.php +++ b/src/Accounts/BalanceLookup.php @@ -4,6 +4,7 @@ namespace Increase\Accounts; +use Increase\Accounts\BalanceLookup\Loan; use Increase\Accounts\BalanceLookup\Type; use Increase\Core\Attributes\Required; use Increase\Core\Concerns\SdkModel; @@ -12,10 +13,13 @@ /** * Represents a request to lookup the balance of an Account at a given point in time. * + * @phpstan-import-type LoanShape from \Increase\Accounts\BalanceLookup\Loan + * * @phpstan-type BalanceLookupShape = array{ * accountID: string, * availableBalance: int, * currentBalance: int, + * loan: null|Loan|LoanShape, * type: Type|value-of, * } */ @@ -42,6 +46,12 @@ final class BalanceLookup implements BaseModel #[Required('current_balance')] public int $currentBalance; + /** + * The loan balances for the Account. + */ + #[Required] + public ?Loan $loan; + /** * A constant representing the object's type. For this resource it will always be `balance_lookup`. * @@ -56,7 +66,11 @@ final class BalanceLookup implements BaseModel * To enforce required parameters use * ``` * BalanceLookup::with( - * accountID: ..., availableBalance: ..., currentBalance: ..., type: ... + * accountID: ..., + * availableBalance: ..., + * currentBalance: ..., + * loan: ..., + * type: ..., * ) * ``` * @@ -67,6 +81,7 @@ final class BalanceLookup implements BaseModel * ->withAccountID(...) * ->withAvailableBalance(...) * ->withCurrentBalance(...) + * ->withLoan(...) * ->withType(...) * ``` */ @@ -80,12 +95,14 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * + * @param Loan|LoanShape|null $loan * @param Type|value-of $type */ public static function with( string $accountID, int $availableBalance, int $currentBalance, + Loan|array|null $loan, Type|string $type, ): self { $self = new self; @@ -93,6 +110,7 @@ public static function with( $self['accountID'] = $accountID; $self['availableBalance'] = $availableBalance; $self['currentBalance'] = $currentBalance; + $self['loan'] = $loan; $self['type'] = $type; return $self; @@ -131,6 +149,19 @@ public function withCurrentBalance(int $currentBalance): self return $self; } + /** + * The loan balances for the Account. + * + * @param Loan|LoanShape|null $loan + */ + public function withLoan(Loan|array|null $loan): self + { + $self = clone $this; + $self['loan'] = $loan; + + return $self; + } + /** * A constant representing the object's type. For this resource it will always be `balance_lookup`. * diff --git a/src/Accounts/BalanceLookup/Loan.php b/src/Accounts/BalanceLookup/Loan.php new file mode 100644 index 0000000..ce00631 --- /dev/null +++ b/src/Accounts/BalanceLookup/Loan.php @@ -0,0 +1,111 @@ + */ + use SdkModel; + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the loan payment is due. + */ + #[Required('due_at')] + public ?\DateTimeInterface $dueAt; + + /** + * The total amount due on the loan. + */ + #[Required('due_balance')] + public int $dueBalance; + + /** + * The amount past due on the loan. + */ + #[Required('past_due_balance')] + public int $pastDueBalance; + + /** + * `new Loan()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Loan::with(dueAt: ..., dueBalance: ..., pastDueBalance: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Loan)->withDueAt(...)->withDueBalance(...)->withPastDueBalance(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with( + ?\DateTimeInterface $dueAt, + int $dueBalance, + int $pastDueBalance + ): self { + $self = new self; + + $self['dueAt'] = $dueAt; + $self['dueBalance'] = $dueBalance; + $self['pastDueBalance'] = $pastDueBalance; + + return $self; + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the loan payment is due. + */ + public function withDueAt(?\DateTimeInterface $dueAt): self + { + $self = clone $this; + $self['dueAt'] = $dueAt; + + return $self; + } + + /** + * The total amount due on the loan. + */ + public function withDueBalance(int $dueBalance): self + { + $self = clone $this; + $self['dueBalance'] = $dueBalance; + + return $self; + } + + /** + * The amount past due on the loan. + */ + public function withPastDueBalance(int $pastDueBalance): self + { + $self = clone $this; + $self['pastDueBalance'] = $pastDueBalance; + + return $self; + } +} diff --git a/src/Programs/Program.php b/src/Programs/Program.php index ef3c5c5..0cd909a 100644 --- a/src/Programs/Program.php +++ b/src/Programs/Program.php @@ -8,11 +8,14 @@ use Increase\Core\Concerns\SdkModel; use Increase\Core\Contracts\BaseModel; use Increase\Programs\Program\Bank; +use Increase\Programs\Program\Lending; use Increase\Programs\Program\Type; /** * Programs determine the compliance and commercial terms of Accounts. By default, you have a Commercial Banking program for managing your own funds. If you are lending or managing funds on behalf of your customers, or otherwise engaged in regulated activity, we will work together to create additional Programs for you. * + * @phpstan-import-type LendingShape from \Increase\Programs\Program\Lending + * * @phpstan-type ProgramShape = array{ * id: string, * bank: Bank|value-of, @@ -20,6 +23,7 @@ * createdAt: \DateTimeInterface, * defaultDigitalCardProfileID: string|null, * interestRate: string, + * lending: null|Lending|LendingShape, * name: string, * type: Type|value-of, * updatedAt: \DateTimeInterface, @@ -68,6 +72,12 @@ final class Program implements BaseModel #[Required('interest_rate')] public string $interestRate; + /** + * The lending details for the program. + */ + #[Required] + public ?Lending $lending; + /** * The name of the Program. */ @@ -100,6 +110,7 @@ final class Program implements BaseModel * createdAt: ..., * defaultDigitalCardProfileID: ..., * interestRate: ..., + * lending: ..., * name: ..., * type: ..., * updatedAt: ..., @@ -116,6 +127,7 @@ final class Program implements BaseModel * ->withCreatedAt(...) * ->withDefaultDigitalCardProfileID(...) * ->withInterestRate(...) + * ->withLending(...) * ->withName(...) * ->withType(...) * ->withUpdatedAt(...) @@ -132,6 +144,7 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param Bank|value-of $bank + * @param Lending|LendingShape|null $lending * @param Type|value-of $type */ public static function with( @@ -141,6 +154,7 @@ public static function with( \DateTimeInterface $createdAt, ?string $defaultDigitalCardProfileID, string $interestRate, + Lending|array|null $lending, string $name, Type|string $type, \DateTimeInterface $updatedAt, @@ -153,6 +167,7 @@ public static function with( $self['createdAt'] = $createdAt; $self['defaultDigitalCardProfileID'] = $defaultDigitalCardProfileID; $self['interestRate'] = $interestRate; + $self['lending'] = $lending; $self['name'] = $name; $self['type'] = $type; $self['updatedAt'] = $updatedAt; @@ -229,6 +244,19 @@ public function withInterestRate(string $interestRate): self return $self; } + /** + * The lending details for the program. + * + * @param Lending|LendingShape|null $lending + */ + public function withLending(Lending|array|null $lending): self + { + $self = clone $this; + $self['lending'] = $lending; + + return $self; + } + /** * The name of the Program. */ diff --git a/src/Programs/Program/Lending.php b/src/Programs/Program/Lending.php new file mode 100644 index 0000000..3ddf3c4 --- /dev/null +++ b/src/Programs/Program/Lending.php @@ -0,0 +1,71 @@ + */ + use SdkModel; + + /** + * The maximum extendable credit of the program. + */ + #[Required('maximum_extendable_credit')] + public int $maximumExtendableCredit; + + /** + * `new Lending()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Lending::with(maximumExtendableCredit: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Lending)->withMaximumExtendableCredit(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(int $maximumExtendableCredit): self + { + $self = new self; + + $self['maximumExtendableCredit'] = $maximumExtendableCredit; + + return $self; + } + + /** + * The maximum extendable credit of the program. + */ + public function withMaximumExtendableCredit( + int $maximumExtendableCredit + ): self { + $self = clone $this; + $self['maximumExtendableCredit'] = $maximumExtendableCredit; + + return $self; + } +} diff --git a/src/ServiceContracts/AccountsContract.php b/src/ServiceContracts/AccountsContract.php index 62e343f..e61e2d8 100644 --- a/src/ServiceContracts/AccountsContract.php +++ b/src/ServiceContracts/AccountsContract.php @@ -5,6 +5,8 @@ namespace Increase\ServiceContracts; use Increase\Accounts\Account; +use Increase\Accounts\AccountCreateParams\Funding; +use Increase\Accounts\AccountCreateParams\Loan; use Increase\Accounts\AccountListParams\CreatedAt; use Increase\Accounts\AccountListParams\Status; use Increase\Accounts\BalanceLookup; @@ -13,6 +15,8 @@ use Increase\RequestOptions; /** + * @phpstan-import-type LoanShape from \Increase\Accounts\AccountCreateParams\Loan + * @phpstan-import-type LoanShape from \Increase\Accounts\AccountUpdateParams\Loan as LoanShape1 * @phpstan-import-type CreatedAtShape from \Increase\Accounts\AccountListParams\CreatedAt * @phpstan-import-type StatusShape from \Increase\Accounts\AccountListParams\Status * @phpstan-import-type RequestOpts from \Increase\RequestOptions @@ -24,7 +28,9 @@ interface AccountsContract * * @param string $name the name you choose for the Account * @param string $entityID the identifier for the Entity that will own the Account + * @param Funding|value-of $funding whether the Account is funded by a loan or by deposits * @param string $informationalEntityID The identifier of an Entity that, while not owning the Account, is associated with its activity. This is generally the beneficiary of the funds. + * @param Loan|LoanShape $loan the loan details for the account * @param string $programID The identifier for the Program that this Account falls under. Required if you operate more than one Program. * @param RequestOpts|null $requestOptions * @@ -33,7 +39,9 @@ interface AccountsContract public function create( string $name, ?string $entityID = null, + Funding|string|null $funding = null, ?string $informationalEntityID = null, + Loan|array|null $loan = null, ?string $programID = null, RequestOptions|array|null $requestOptions = null, ): Account; @@ -55,6 +63,7 @@ public function retrieve( * @api * * @param string $accountID the identifier of the Account to update + * @param \Increase\Accounts\AccountUpdateParams\Loan|LoanShape1 $loan the loan details for the account * @param string $name the new name of the Account * @param RequestOpts|null $requestOptions * @@ -62,6 +71,7 @@ public function retrieve( */ public function update( string $accountID, + \Increase\Accounts\AccountUpdateParams\Loan|array|null $loan = null, ?string $name = null, RequestOptions|array|null $requestOptions = null, ): Account; diff --git a/src/ServiceContracts/Simulations/ProgramsContract.php b/src/ServiceContracts/Simulations/ProgramsContract.php index ae474aa..442de26 100644 --- a/src/ServiceContracts/Simulations/ProgramsContract.php +++ b/src/ServiceContracts/Simulations/ProgramsContract.php @@ -19,6 +19,7 @@ interface ProgramsContract * * @param string $name the name of the program being added * @param Bank|value-of $bank the bank for the program's accounts, defaults to First Internet Bank + * @param int $lendingMaximumExtendableCredit the maximum extendable credit of the program being added * @param string $reserveAccountID the identifier of the Account the Program should be added to is for * @param RequestOpts|null $requestOptions * @@ -27,6 +28,7 @@ interface ProgramsContract public function create( string $name, Bank|string|null $bank = null, + ?int $lendingMaximumExtendableCredit = null, ?string $reserveAccountID = null, RequestOptions|array|null $requestOptions = null, ): Program; diff --git a/src/Services/AccountsRawService.php b/src/Services/AccountsRawService.php index 0736103..3dd7828 100644 --- a/src/Services/AccountsRawService.php +++ b/src/Services/AccountsRawService.php @@ -7,6 +7,8 @@ use Increase\Accounts\Account; use Increase\Accounts\AccountBalanceParams; use Increase\Accounts\AccountCreateParams; +use Increase\Accounts\AccountCreateParams\Funding; +use Increase\Accounts\AccountCreateParams\Loan; use Increase\Accounts\AccountListParams; use Increase\Accounts\AccountListParams\CreatedAt; use Increase\Accounts\AccountListParams\Status; @@ -21,6 +23,8 @@ use Increase\ServiceContracts\AccountsRawContract; /** + * @phpstan-import-type LoanShape from \Increase\Accounts\AccountCreateParams\Loan + * @phpstan-import-type LoanShape from \Increase\Accounts\AccountUpdateParams\Loan as LoanShape1 * @phpstan-import-type CreatedAtShape from \Increase\Accounts\AccountListParams\CreatedAt * @phpstan-import-type StatusShape from \Increase\Accounts\AccountListParams\Status * @phpstan-import-type RequestOpts from \Increase\RequestOptions @@ -41,7 +45,9 @@ public function __construct(private Client $client) {} * @param array{ * name: string, * entityID?: string, + * funding?: Funding|value-of, * informationalEntityID?: string, + * loan?: Loan|LoanShape, * programID?: string, * }|AccountCreateParams $params * @param RequestOpts|null $requestOptions @@ -100,7 +106,9 @@ public function retrieve( * Update an Account * * @param string $accountID the identifier of the Account to update - * @param array{name?: string}|AccountUpdateParams $params + * @param array{ + * loan?: AccountUpdateParams\Loan|LoanShape1, name?: string + * }|AccountUpdateParams $params * @param RequestOpts|null $requestOptions * * @return BaseResponse diff --git a/src/Services/AccountsService.php b/src/Services/AccountsService.php index 8be1cb3..1f608cc 100644 --- a/src/Services/AccountsService.php +++ b/src/Services/AccountsService.php @@ -5,6 +5,8 @@ namespace Increase\Services; use Increase\Accounts\Account; +use Increase\Accounts\AccountCreateParams\Funding; +use Increase\Accounts\AccountCreateParams\Loan; use Increase\Accounts\AccountListParams\CreatedAt; use Increase\Accounts\AccountListParams\Status; use Increase\Accounts\BalanceLookup; @@ -16,6 +18,8 @@ use Increase\ServiceContracts\AccountsContract; /** + * @phpstan-import-type LoanShape from \Increase\Accounts\AccountCreateParams\Loan + * @phpstan-import-type LoanShape from \Increase\Accounts\AccountUpdateParams\Loan as LoanShape1 * @phpstan-import-type CreatedAtShape from \Increase\Accounts\AccountListParams\CreatedAt * @phpstan-import-type StatusShape from \Increase\Accounts\AccountListParams\Status * @phpstan-import-type RequestOpts from \Increase\RequestOptions @@ -42,7 +46,9 @@ public function __construct(private Client $client) * * @param string $name the name you choose for the Account * @param string $entityID the identifier for the Entity that will own the Account + * @param Funding|value-of $funding whether the Account is funded by a loan or by deposits * @param string $informationalEntityID The identifier of an Entity that, while not owning the Account, is associated with its activity. This is generally the beneficiary of the funds. + * @param Loan|LoanShape $loan the loan details for the account * @param string $programID The identifier for the Program that this Account falls under. Required if you operate more than one Program. * @param RequestOpts|null $requestOptions * @@ -51,7 +57,9 @@ public function __construct(private Client $client) public function create( string $name, ?string $entityID = null, + Funding|string|null $funding = null, ?string $informationalEntityID = null, + Loan|array|null $loan = null, ?string $programID = null, RequestOptions|array|null $requestOptions = null, ): Account { @@ -59,7 +67,9 @@ public function create( [ 'name' => $name, 'entityID' => $entityID, + 'funding' => $funding, 'informationalEntityID' => $informationalEntityID, + 'loan' => $loan, 'programID' => $programID, ], ); @@ -96,6 +106,7 @@ public function retrieve( * Update an Account * * @param string $accountID the identifier of the Account to update + * @param \Increase\Accounts\AccountUpdateParams\Loan|LoanShape1 $loan the loan details for the account * @param string $name the new name of the Account * @param RequestOpts|null $requestOptions * @@ -103,10 +114,11 @@ public function retrieve( */ public function update( string $accountID, + \Increase\Accounts\AccountUpdateParams\Loan|array|null $loan = null, ?string $name = null, RequestOptions|array|null $requestOptions = null, ): Account { - $params = Util::removeNulls(['name' => $name]); + $params = Util::removeNulls(['loan' => $loan, 'name' => $name]); // @phpstan-ignore-next-line argument.type $response = $this->raw->update($accountID, params: $params, requestOptions: $requestOptions); diff --git a/src/Services/Simulations/ProgramsRawService.php b/src/Services/Simulations/ProgramsRawService.php index 53c6b7b..7b2976b 100644 --- a/src/Services/Simulations/ProgramsRawService.php +++ b/src/Services/Simulations/ProgramsRawService.php @@ -30,7 +30,10 @@ public function __construct(private Client $client) {} * Simulates a [Program](#programs) being created in your group. By default, your group has one program called Commercial Banking. Note that when your group operates more than one program, `program_id` is a required field when creating accounts. * * @param array{ - * name: string, bank?: value-of, reserveAccountID?: string + * name: string, + * bank?: value-of, + * lendingMaximumExtendableCredit?: int, + * reserveAccountID?: string, * }|ProgramCreateParams $params * @param RequestOpts|null $requestOptions * diff --git a/src/Services/Simulations/ProgramsService.php b/src/Services/Simulations/ProgramsService.php index 19bb43d..78ff020 100644 --- a/src/Services/Simulations/ProgramsService.php +++ b/src/Services/Simulations/ProgramsService.php @@ -37,6 +37,7 @@ public function __construct(private Client $client) * * @param string $name the name of the program being added * @param Bank|value-of $bank the bank for the program's accounts, defaults to First Internet Bank + * @param int $lendingMaximumExtendableCredit the maximum extendable credit of the program being added * @param string $reserveAccountID the identifier of the Account the Program should be added to is for * @param RequestOpts|null $requestOptions * @@ -45,6 +46,7 @@ public function __construct(private Client $client) public function create( string $name, Bank|string|null $bank = null, + ?int $lendingMaximumExtendableCredit = null, ?string $reserveAccountID = null, RequestOptions|array|null $requestOptions = null, ): Program { @@ -52,6 +54,7 @@ public function create( [ 'name' => $name, 'bank' => $bank, + 'lendingMaximumExtendableCredit' => $lendingMaximumExtendableCredit, 'reserveAccountID' => $reserveAccountID, ], ); diff --git a/src/Simulations/Programs/ProgramCreateParams.php b/src/Simulations/Programs/ProgramCreateParams.php index 491da8e..dcec0fc 100644 --- a/src/Simulations/Programs/ProgramCreateParams.php +++ b/src/Simulations/Programs/ProgramCreateParams.php @@ -17,7 +17,10 @@ * @see Increase\Services\Simulations\ProgramsService::create() * * @phpstan-type ProgramCreateParamsShape = array{ - * name: string, bank?: null|Bank|value-of, reserveAccountID?: string|null + * name: string, + * bank?: null|Bank|value-of, + * lendingMaximumExtendableCredit?: int|null, + * reserveAccountID?: string|null, * } */ final class ProgramCreateParams implements BaseModel @@ -40,6 +43,12 @@ final class ProgramCreateParams implements BaseModel #[Optional(enum: Bank::class)] public ?string $bank; + /** + * The maximum extendable credit of the program being added. + */ + #[Optional('lending_maximum_extendable_credit')] + public ?int $lendingMaximumExtendableCredit; + /** * The identifier of the Account the Program should be added to is for. */ @@ -75,13 +84,15 @@ public function __construct() public static function with( string $name, Bank|string|null $bank = null, - ?string $reserveAccountID = null + ?int $lendingMaximumExtendableCredit = null, + ?string $reserveAccountID = null, ): self { $self = new self; $self['name'] = $name; null !== $bank && $self['bank'] = $bank; + null !== $lendingMaximumExtendableCredit && $self['lendingMaximumExtendableCredit'] = $lendingMaximumExtendableCredit; null !== $reserveAccountID && $self['reserveAccountID'] = $reserveAccountID; return $self; @@ -111,6 +122,18 @@ public function withBank(Bank|string $bank): self return $self; } + /** + * The maximum extendable credit of the program being added. + */ + public function withLendingMaximumExtendableCredit( + int $lendingMaximumExtendableCredit + ): self { + $self = clone $this; + $self['lendingMaximumExtendableCredit'] = $lendingMaximumExtendableCredit; + + return $self; + } + /** * The identifier of the Account the Program should be added to is for. */ diff --git a/src/Version.php b/src/Version.php index 3383acc..e80c30d 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace Increase; // x-release-please-start-version -const VERSION = '0.11.0'; +const VERSION = '0.12.0'; // x-release-please-end diff --git a/tests/Services/AccountsTest.php b/tests/Services/AccountsTest.php index dd6c57a..43a2cf7 100644 --- a/tests/Services/AccountsTest.php +++ b/tests/Services/AccountsTest.php @@ -43,7 +43,15 @@ public function testCreateWithOptionalParams(): void $result = $this->client->accounts->create( name: 'New Account!', entityID: 'entity_n8y8tnk2p9339ti393yi', + funding: 'loan', informationalEntityID: 'informational_entity_id', + loan: [ + 'creditLimit' => 0, + 'gracePeriodDays' => 0, + 'statementDayOfMonth' => 1, + 'statementPaymentType' => 'balance', + 'maturityDate' => '2019-12-27', + ], programID: 'program_i2v2os4mwza1oetokh9i', ); diff --git a/tests/Services/Simulations/ProgramsTest.php b/tests/Services/Simulations/ProgramsTest.php index e687c1e..ebed793 100644 --- a/tests/Services/Simulations/ProgramsTest.php +++ b/tests/Services/Simulations/ProgramsTest.php @@ -43,6 +43,7 @@ public function testCreateWithOptionalParams(): void $result = $this->client->simulations->programs->create( name: 'For Benefit Of', bank: 'blue_ridge_bank', + lendingMaximumExtendableCredit: 0, reserveAccountID: 'reserve_account_id', );