From 1d0875553acb62a33f0831dca1cf5934b47cdcda Mon Sep 17 00:00:00 2001 From: cb-alish Date: Thu, 30 Jul 2026 14:37:39 +0530 Subject: [PATCH] Releasing v4.25.0 --- CHANGELOG.md | 58 +++++ VERSION | 2 +- src/Actions/AlertActions.php | 1 + .../Contracts/AlertActionsInterface.php | 1 + .../Contracts/CouponActionsInterface.php | 2 +- .../Contracts/CreditUnitActionsInterface.php | 109 +++++++++ .../Contracts/EntitlementActionsInterface.php | 6 +- .../Contracts/EstimateActionsInterface.php | 1 + .../Contracts/ExportActionsInterface.php | 10 +- .../Contracts/GrantBlockActionsInterface.php | 3 + .../Contracts/InvoiceActionsInterface.php | 6 +- .../Contracts/ItemActionsInterface.php | 2 +- .../Contracts/ItemFamilyActionsInterface.php | 2 +- .../Contracts/ItemPriceActionsInterface.php | 2 +- .../LedgerOperationActionsInterface.php | 23 +- .../Contracts/MeterActionsInterface.php | 2 +- .../PriceVariantActionsInterface.php | 2 +- .../Contracts/RampActionsInterface.php | 4 +- .../SubscriptionActionsInterface.php | 1 + src/Actions/CouponActions.php | 2 +- src/Actions/CreditUnitActions.php | 219 ++++++++++++++++++ src/Actions/EntitlementActions.php | 6 +- src/Actions/EstimateActions.php | 1 + src/Actions/ExportActions.php | 10 +- src/Actions/GrantBlockActions.php | 3 + src/Actions/InvoiceActions.php | 6 +- src/Actions/ItemActions.php | 2 +- src/Actions/ItemFamilyActions.php | 2 +- src/Actions/ItemPriceActions.php | 2 +- src/Actions/LedgerOperationActions.php | 45 +++- src/Actions/MeterActions.php | 2 +- src/Actions/PriceVariantActions.php | 2 +- src/Actions/RampActions.php | 4 +- src/Actions/SubscriptionActions.php | 1 + src/ChargebeeClient.php | 6 + src/Enums/EnabledEvents.php | 4 + src/Enums/EventType.php | 4 + src/Enums/PaymentMethod.php | 4 + src/Enums/PaymentMethodType.php | 4 + src/Enums/Type.php | 9 + src/Resources/Alert/Alert.php | 33 +-- src/Resources/Content/Content.php | 30 ++- src/Resources/CreditUnit/CreditUnit.php | 158 +++++++++++++ src/Resources/CreditUnit/Enums/Status.php | 14 ++ .../GrantBlock/Enums/GrantSource.php | 2 + src/Resources/GrantBlock/GrantBlock.php | 70 ++++-- .../LedgerAccountBalance.php | 22 +- .../LedgerEntry/Enums/AccountType.php | 14 ++ src/Resources/LedgerEntry/Enums/UnitType.php | 13 ++ src/Resources/LedgerEntry/LedgerEntry.php | 202 ++++++++++++++++ .../LedgerOperation/LedgerOperation.php | 64 ++--- .../PaymentIntent/Enums/PaymentMethodType.php | 4 + .../ArchiveCreditUnitResponse.php | 45 ++++ .../CreateCreditUnitResponse.php | 45 ++++ .../ListCreditUnitResponse.php | 54 +++++ .../ListCreditUnitResponseListObject.php | 14 ++ .../ReactivateCreditUnitResponse.php | 45 ++++ .../UpdateCreditUnitResponse.php | 45 ++++ .../AllocateLedgerOperationResponse.php | 102 ++++++++ .../AuthorizeLedgerOperationResponse.php | 44 +++- ...reAuthorizationLedgerOperationResponse.php | 44 +++- .../CaptureLedgerOperationResponse.php | 44 +++- ...seAuthorizationLedgerOperationResponse.php | 44 +++- src/Version.php | 2 +- 64 files changed, 1606 insertions(+), 123 deletions(-) create mode 100644 src/Actions/Contracts/CreditUnitActionsInterface.php create mode 100644 src/Actions/CreditUnitActions.php create mode 100644 src/Resources/CreditUnit/CreditUnit.php create mode 100644 src/Resources/CreditUnit/Enums/Status.php create mode 100644 src/Resources/LedgerEntry/Enums/AccountType.php create mode 100644 src/Resources/LedgerEntry/Enums/UnitType.php create mode 100644 src/Resources/LedgerEntry/LedgerEntry.php create mode 100644 src/Responses/CreditUnitResponse/ArchiveCreditUnitResponse.php create mode 100644 src/Responses/CreditUnitResponse/CreateCreditUnitResponse.php create mode 100644 src/Responses/CreditUnitResponse/ListCreditUnitResponse.php create mode 100644 src/Responses/CreditUnitResponse/ListCreditUnitResponseListObject.php create mode 100644 src/Responses/CreditUnitResponse/ReactivateCreditUnitResponse.php create mode 100644 src/Responses/CreditUnitResponse/UpdateCreditUnitResponse.php create mode 100644 src/Responses/LedgerOperationResponse/AllocateLedgerOperationResponse.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 25ca82b4..940e9885 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,61 @@ +### v4.25.0 (2026-07-30) +* * * +### New Resources: +- [`CreditUnit`](https://apidocs.chargebee.com/docs/api/credit_units) has been added. +- [`LedgerEntry`](https://apidocs.chargebee.com/docs/api/ledger_entries) has been added. + + +### New Actions: +- [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) has been added to [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). + + +### New Attributes: +- [`unit_id`](https://apidocs.chargebee.com/docs/api/alerts/alert-object#unit_id) has been added to [`Alert`](https://apidocs.chargebee.com/docs/api/alerts). +- [`subscription_id`](https://apidocs.chargebee.com/docs/api/grant_blocks/grant-block-object#subscription_id) has been added to [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks). +- [`modified_at`](https://apidocs.chargebee.com/docs/api/grant_blocks/grant-block-object#modified_at) has been added to [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks). +- [`resource_version`](https://apidocs.chargebee.com/docs/api/grant_blocks/grant-block-object#resource_version) has been added to [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks). +- [`created_at`](https://apidocs.chargebee.com/docs/api/ledger_account_balances/ledger-account-balance-object#created_at) has been added to [`LedgerAccountBalance`](https://apidocs.chargebee.com/docs/api/ledger_account_balances). +- [`resource_version`](https://apidocs.chargebee.com/docs/api/ledger_account_balances/ledger-account-balance-object#resource_version) has been added to [`LedgerAccountBalance`](https://apidocs.chargebee.com/docs/api/ledger_account_balances). + + +### New Parameters: +- [`account_type`](https://apidocs.chargebee.com/docs/api/grant_blocks/list-grant-blocks#account_type) has been added as query parameter to [`list_grant_blocks`](https://apidocs.chargebee.com/docs/api/grant_blocks/list-grant-blocks) in [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks). +- [`unit_id`](https://apidocs.chargebee.com/docs/api/alerts/create-an-alert#unit_id) has been added as request body parameter to [`create_an_alert`](https://apidocs.chargebee.com/docs/api/alerts/create-an-alert) in [`Alert`](https://apidocs.chargebee.com/docs/api/alerts). +- [`include_cancellation_day_in_billing`](https://apidocs.chargebee.com/docs/api/estimates/cancel-subscription-for-items-estimate#include_cancellation_day_in_billing) has been added as request body parameter to [`cancel_subscription_for_items_estimate`](https://apidocs.chargebee.com/docs/api/estimates/cancel-subscription-for-items-estimate) in [`Estimate`](https://apidocs.chargebee.com/docs/api/estimates). +- [`subscription_id`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate#subscription_id) has been added as request body parameter to [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). +- [`unit_id`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate#unit_id) has been added as request body parameter to [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). +- [`amount`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate#amount) has been added as request body parameter to [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). +- [`expires_at`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate#expires_at) has been added as request body parameter to [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). +- [`metadata`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate#metadata) has been added as request body parameter to [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). +- [`include_cancellation_day_in_billing`](https://apidocs.chargebee.com/docs/api/subscriptions/cancel-subscription-for-items#include_cancellation_day_in_billing) has been added as request body parameter to [`cancel_subscription_for_items`](https://apidocs.chargebee.com/docs/api/subscriptions/cancel-subscription-for-items) in [`Subscription`](https://apidocs.chargebee.com/docs/api/subscriptions). + + +### New Events: +- [`grant_blocks_created`](https://apidocs.chargebee.com/docs/api/events/webhook/grant_blocks_created) has been added. +- [`ledger_updated`](https://apidocs.chargebee.com/docs/api/events/webhook/ledger_updated) has been added. +- [`ledger_account_balance_updated`](https://apidocs.chargebee.com/docs/api/events/webhook/ledger_account_balance_updated) has been added. +- [`grant_blocks_updated`](https://apidocs.chargebee.com/docs/api/events/webhook/grant_blocks_updated) has been added. + + +### New Enums: +- `ledger_account_balance_updated`, `grant_blocks_created`, `grant_blocks_updated`, and `ledger_updated` have been added as new values enum `EventType`. +- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values enum `PaymentMethod`. +- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values enum `PaymentMethodType`. +- `dana`, `touch_n_go`, `tamara`, `qpay`, `credit_balance_dropped`, `credit`, `debit`, `hold`, and `unhold` have been added as new values enum `Type`. +- `active` and `archived` have been added as new values to enum attribute [`status`](https://apidocs.chargebee.com/docs/api/credit_units/credit-unit-object#status) in [`CreditUnit`](https://apidocs.chargebee.com/docs/api/credit_units). +- `grant_renewal` and `subscription_renewed` have been added as new values to enum attribute [`grant_source`](https://apidocs.chargebee.com/docs/api/grant_blocks/grant-block-object#grant_source) in [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks). +- `provisioned` and `overdraft` have been added as new values to enum attribute [`account_type`](https://apidocs.chargebee.com/docs/api/ledger_entries/ledger-entry-object#account_type) in [`LedgerEntry`](https://apidocs.chargebee.com/docs/api/ledger_entries). +- `credit_unit` has been added as a new value to enum attribute [`unit_type`](https://apidocs.chargebee.com/docs/api/ledger_entries/ledger-entry-object#unit_type) in [`LedgerEntry`](https://apidocs.chargebee.com/docs/api/ledger_entries). +- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values to enum attribute [`payment_method_type`](https://apidocs.chargebee.com/docs/api/payment_intents/payment-intent-object#payment_method_type) in [`PaymentIntent`](https://apidocs.chargebee.com/docs/api/payment_intents). +- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values to enum attribute [`active_payment_attempt.payment_method_type`](https://apidocs.chargebee.com/docs/api/payment_intents/payment-intent-object#active_payment_attempt_payment_method_type) in [`PaymentIntent`](https://apidocs.chargebee.com/docs/api/payment_intents). +- `archived` and `active` have been added as new values to enum query parameter `status.in` in [`list_credit_units`](https://apidocs.chargebee.com/docs/api/credit_units/list-credit-units) of [`CreditUnit`](https://apidocs.chargebee.com/docs/api/credit_units). +- `archived` and `active` have been added as new values to enum query parameter `status.is` in [`list_credit_units`](https://apidocs.chargebee.com/docs/api/credit_units/list-credit-units) of [`CreditUnit`](https://apidocs.chargebee.com/docs/api/credit_units). +- `provisioned` and `overdraft` have been added as new values to enum query parameter `account_type.is` in [`list_grant_blocks`](https://apidocs.chargebee.com/docs/api/grant_blocks/list-grant-blocks) of [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks). +- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values to enum request body parameter `payment_method_type` in [`update_a_payment_intent`](https://apidocs.chargebee.com/docs/api/payment_intents/update-a-payment-intent) of [`PaymentIntent`](https://apidocs.chargebee.com/docs/api/payment_intents). +- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values to enum request body parameter `payment_method_type` in [`create_a_payment_intent`](https://apidocs.chargebee.com/docs/api/payment_intents/create-a-payment-intent) of [`PaymentIntent`](https://apidocs.chargebee.com/docs/api/payment_intents). + + + ### v4.24.0 (2026-07-21) * * * ### New Resources: diff --git a/VERSION b/VERSION index 252fdf2c..4d9fbcf2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.24.0 +4.25.0 diff --git a/src/Actions/AlertActions.php b/src/Actions/AlertActions.php index 290e1e06..342d275c 100644 --- a/src/Actions/AlertActions.php +++ b/src/Actions/AlertActions.php @@ -241,6 +241,7 @@ public function all(array $params = [], array $headers = []): ListAlertResponse * description?: string, * metered_feature_id?: string, * currency_code?: string, + * unit_id?: string, * subscription_id?: string, * meta?: string, * } $params Description of the parameters diff --git a/src/Actions/Contracts/AlertActionsInterface.php b/src/Actions/Contracts/AlertActionsInterface.php index 31a21b44..f924fc52 100644 --- a/src/Actions/Contracts/AlertActionsInterface.php +++ b/src/Actions/Contracts/AlertActionsInterface.php @@ -133,6 +133,7 @@ public function all(array $params = [], array $headers = []): ListAlertResponse; * description?: string, * metered_feature_id?: string, * currency_code?: string, + * unit_id?: string, * subscription_id?: string, * meta?: string, * } $params Description of the parameters diff --git a/src/Actions/Contracts/CouponActionsInterface.php b/src/Actions/Contracts/CouponActionsInterface.php index 96c89dbb..79ac6006 100644 --- a/src/Actions/Contracts/CouponActionsInterface.php +++ b/src/Actions/Contracts/CouponActionsInterface.php @@ -86,8 +86,8 @@ * not_in?: mixed, * }, * applicable_item_price_ids?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * } $params Description of the parameters * diff --git a/src/Actions/Contracts/CreditUnitActionsInterface.php b/src/Actions/Contracts/CreditUnitActionsInterface.php new file mode 100644 index 00000000..c421db6a --- /dev/null +++ b/src/Actions/Contracts/CreditUnitActionsInterface.php @@ -0,0 +1,109 @@ + $headers + * @return ListCreditUnitResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function all(array $params = [], array $headers = []): ListCreditUnitResponse; + + /** + * @see https://apidocs.chargebee.com/docs/api/credit_units/create-a-credit-unit?lang=php-v4 + * @param array{ + * id?: string, + * name?: string, + * is_unlimited?: bool, + * overdraft_amount?: string, + * external_name?: string, + * } $params Description of the parameters + * + * @param array $headers + * @return CreateCreditUnitResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function create(array $params, array $headers = []): CreateCreditUnitResponse; + + /** + * @see https://apidocs.chargebee.com/docs/api/credit_units/archive-a-credit-unit?lang=php-v4 + * + * @param string $id + * @param array $headers + * @return ArchiveCreditUnitResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function archive(string $id, array $headers = []): ArchiveCreditUnitResponse; + + /** + * @see https://apidocs.chargebee.com/docs/api/credit_units/update-a-credit-unit?lang=php-v4 + * @param array{ + * name?: string, + * external_name?: string, + * } $params Description of the parameters + * @param string $id + * @param array $headers + * @return UpdateCreditUnitResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function update(string $id, array $params = [], array $headers = []): UpdateCreditUnitResponse; + + /** + * @see https://apidocs.chargebee.com/docs/api/credit_units/reactivate-a-credit-unit?lang=php-v4 + * + * @param string $id + * @param array $headers + * @return ReactivateCreditUnitResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function reactivate(string $id, array $headers = []): ReactivateCreditUnitResponse; + +} +?> \ No newline at end of file diff --git a/src/Actions/Contracts/EntitlementActionsInterface.php b/src/Actions/Contracts/EntitlementActionsInterface.php index 398ae8ba..a0f27658 100644 --- a/src/Actions/Contracts/EntitlementActionsInterface.php +++ b/src/Actions/Contracts/EntitlementActionsInterface.php @@ -18,16 +18,16 @@ * limit?: int, * offset?: string, * feature_id?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * entity_type?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * entity_id?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * include_drafts?: bool, * embed?: string, diff --git a/src/Actions/Contracts/EstimateActionsInterface.php b/src/Actions/Contracts/EstimateActionsInterface.php index 02b5d573..fb2331e4 100644 --- a/src/Actions/Contracts/EstimateActionsInterface.php +++ b/src/Actions/Contracts/EstimateActionsInterface.php @@ -200,6 +200,7 @@ public function paymentSchedules(array $params, array $headers = []): PaymentSch * unit_price_in_decimal?: string, * service_period_days?: int, * }>, + * include_cancellation_day_in_billing?: bool, * cancel_reason_code?: string, * } $params Description of the parameters * @param string $id diff --git a/src/Actions/Contracts/ExportActionsInterface.php b/src/Actions/Contracts/ExportActionsInterface.php index 89789eb9..1b86222f 100644 --- a/src/Actions/Contracts/ExportActionsInterface.php +++ b/src/Actions/Contracts/ExportActionsInterface.php @@ -395,8 +395,8 @@ public function differentialPrices(array $params = [], array $headers = []): Dif * }, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, @@ -602,8 +602,8 @@ public function retrieve(string $id, array $headers = []): RetrieveExportRespons * }, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, @@ -693,8 +693,8 @@ public function priceVariants(array $params = [], array $headers = []): PriceVar * }, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, @@ -1602,8 +1602,8 @@ public function creditNotes(array $params = [], array $headers = []): CreditNote * not_in?: mixed, * }, * applicable_item_price_ids?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * } $params Description of the parameters * @@ -1862,8 +1862,8 @@ public function orders(array $params = [], array $headers = []): OrdersExportRes * not_in?: mixed, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, diff --git a/src/Actions/Contracts/GrantBlockActionsInterface.php b/src/Actions/Contracts/GrantBlockActionsInterface.php index 7bfc4c5a..a9379314 100644 --- a/src/Actions/Contracts/GrantBlockActionsInterface.php +++ b/src/Actions/Contracts/GrantBlockActionsInterface.php @@ -22,6 +22,9 @@ * unit_id?: array{ * is?: mixed, * }, + * account_type?: array{ + * is?: mixed, + * }, * effective_from?: array{ * after?: mixed, * before?: mixed, diff --git a/src/Actions/Contracts/InvoiceActionsInterface.php b/src/Actions/Contracts/InvoiceActionsInterface.php index d0324008..12496a82 100644 --- a/src/Actions/Contracts/InvoiceActionsInterface.php +++ b/src/Actions/Contracts/InvoiceActionsInterface.php @@ -1244,13 +1244,13 @@ public function removeTaxWithheld(string $id, array $params, array $headers = [] * offset?: string, * payment_reference_number?: array{ * number?: array{ - * is?: string, - * in?: string, + * in?: string, + * is?: string, * }, * }, * id?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * } $params Description of the parameters * diff --git a/src/Actions/Contracts/ItemActionsInterface.php b/src/Actions/Contracts/ItemActionsInterface.php index f150d119..be97d2d7 100644 --- a/src/Actions/Contracts/ItemActionsInterface.php +++ b/src/Actions/Contracts/ItemActionsInterface.php @@ -96,8 +96,8 @@ * not_in?: mixed, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, diff --git a/src/Actions/Contracts/ItemFamilyActionsInterface.php b/src/Actions/Contracts/ItemFamilyActionsInterface.php index 56bb02c2..281a920c 100644 --- a/src/Actions/Contracts/ItemFamilyActionsInterface.php +++ b/src/Actions/Contracts/ItemFamilyActionsInterface.php @@ -53,8 +53,8 @@ public function delete(string $id, array $headers = []): DeleteItemFamilyRespons * between?: mixed, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, diff --git a/src/Actions/Contracts/ItemPriceActionsInterface.php b/src/Actions/Contracts/ItemPriceActionsInterface.php index 80e86b7d..747fd076 100644 --- a/src/Actions/Contracts/ItemPriceActionsInterface.php +++ b/src/Actions/Contracts/ItemPriceActionsInterface.php @@ -248,8 +248,8 @@ public function findApplicableItems(string $id, array $params = [], array $heade * between?: mixed, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, diff --git a/src/Actions/Contracts/LedgerOperationActionsInterface.php b/src/Actions/Contracts/LedgerOperationActionsInterface.php index a44dfd24..b6113808 100644 --- a/src/Actions/Contracts/LedgerOperationActionsInterface.php +++ b/src/Actions/Contracts/LedgerOperationActionsInterface.php @@ -4,6 +4,7 @@ use Chargebee\Responses\LedgerOperationResponse\CaptureLedgerOperationResponse; use Chargebee\Responses\LedgerOperationResponse\CaptureAuthorizationLedgerOperationResponse; use Chargebee\Responses\LedgerOperationResponse\RetrieveLedgerOperationLedgerOperationResponse; +use Chargebee\Responses\LedgerOperationResponse\AllocateLedgerOperationResponse; use Chargebee\Responses\LedgerOperationResponse\ReleaseAuthorizationLedgerOperationResponse; use Chargebee\Responses\LedgerOperationResponse\ListLedgerOperationsLedgerOperationResponse; use Chargebee\Responses\LedgerOperationResponse\AuthorizeLedgerOperationResponse; @@ -56,6 +57,26 @@ public function releaseAuthorization(array $params, array $headers = []): Releas */ public function capture(array $params, array $headers = []): CaptureLedgerOperationResponse; + /** + * @see https://apidocs.chargebee.com/docs/api/ledger_operations/allocate?lang=php-v4 + * @param array{ + * subscription_id?: string, + * unit_id?: string, + * amount?: string, + * expires_at?: int, + * metadata?: mixed, + * } $params Description of the parameters + * + * @param array $headers + * @return AllocateLedgerOperationResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function allocate(array $params, array $headers = []): AllocateLedgerOperationResponse; + /** * @see https://apidocs.chargebee.com/docs/api/ledger_operations/authorize?lang=php-v4 * @param array{ @@ -96,8 +117,8 @@ public function authorize(array $params, array $headers = []): AuthorizeLedgerOp * between?: mixed, * }, * type?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * sort_by?: array{ * asc?: string, diff --git a/src/Actions/Contracts/MeterActionsInterface.php b/src/Actions/Contracts/MeterActionsInterface.php index 7c0fdfdc..9c14370c 100644 --- a/src/Actions/Contracts/MeterActionsInterface.php +++ b/src/Actions/Contracts/MeterActionsInterface.php @@ -17,8 +17,8 @@ * limit?: int, * offset?: string, * name?: array{ - * is?: mixed, * starts_with?: mixed, + * is?: mixed, * }, * sort_by?: array{ * asc?: string, diff --git a/src/Actions/Contracts/PriceVariantActionsInterface.php b/src/Actions/Contracts/PriceVariantActionsInterface.php index 61a2947f..b28c0e11 100644 --- a/src/Actions/Contracts/PriceVariantActionsInterface.php +++ b/src/Actions/Contracts/PriceVariantActionsInterface.php @@ -67,8 +67,8 @@ public function delete(string $id, array $headers = []): DeletePriceVariantRespo * between?: mixed, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, diff --git a/src/Actions/Contracts/RampActionsInterface.php b/src/Actions/Contracts/RampActionsInterface.php index 1df8df1c..99798c48 100644 --- a/src/Actions/Contracts/RampActionsInterface.php +++ b/src/Actions/Contracts/RampActionsInterface.php @@ -111,12 +111,12 @@ public function createForSubscription(string $id, array $params, array $headers * offset?: string, * include_deleted?: bool, * status?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * subscription_id?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * effective_from?: array{ * after?: mixed, diff --git a/src/Actions/Contracts/SubscriptionActionsInterface.php b/src/Actions/Contracts/SubscriptionActionsInterface.php index 5975c2b0..c54bf5ff 100644 --- a/src/Actions/Contracts/SubscriptionActionsInterface.php +++ b/src/Actions/Contracts/SubscriptionActionsInterface.php @@ -318,6 +318,7 @@ public function resume(string $id, array $params = [], array $headers = []): Res * unit_price_in_decimal?: string, * service_period_days?: int, * }>, + * include_cancellation_day_in_billing?: bool, * cancel_reason_code?: string, * decommissioned?: bool, * } $params Description of the parameters diff --git a/src/Actions/CouponActions.php b/src/Actions/CouponActions.php index 75e7d556..6bdeda1a 100644 --- a/src/Actions/CouponActions.php +++ b/src/Actions/CouponActions.php @@ -99,8 +99,8 @@ public function __construct(HttpClientFactory $httpClientFactory, Environment $e * not_in?: mixed, * }, * applicable_item_price_ids?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * } $params Description of the parameters * diff --git a/src/Actions/CreditUnitActions.php b/src/Actions/CreditUnitActions.php new file mode 100644 index 00000000..0220eb0e --- /dev/null +++ b/src/Actions/CreditUnitActions.php @@ -0,0 +1,219 @@ +httpClientFactory = $httpClientFactory; + $this->env = $env; + } + + /** + * @see https://apidocs.chargebee.com/docs/api/credit_units/list-credit-units?lang=php-v4 + * @param array{ + * limit?: int, + * offset?: string, + * status?: array{ + * in?: mixed, + * is?: mixed, + * }, + * id?: array{ + * in?: mixed, + * is?: mixed, + * }, + * } $params Description of the parameters + * + * @param array $headers + * @return ListCreditUnitResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function all(array $params = [], array $headers = []): ListCreditUnitResponse + { + $jsonKeys = [ + ]; + $payload = ChargebeePayload::builder() + ->withEnvironment($this->env) + ->withHttpMethod("get") + ->withUriPaths(["credit_units"]) + ->withParamEncoder(new ListParamEncoder()) + ->withSubDomain(null) + ->withJsonKeys($jsonKeys) + ->withHeaders($headers) + ->withParams($params) + ->withTelemetryResource("creditUnit") + ->withTelemetryOperation("list") + ->build(); + $apiRequester = new APIRequester($this->httpClientFactory, $this->env); + $respObject = $apiRequester->makeRequest($payload); + return ListCreditUnitResponse::from($respObject->data, $respObject->headers); + } + + /** + * @see https://apidocs.chargebee.com/docs/api/credit_units/create-a-credit-unit?lang=php-v4 + * @param array{ + * id?: string, + * name?: string, + * is_unlimited?: bool, + * overdraft_amount?: string, + * external_name?: string, + * } $params Description of the parameters + * + * @param array $headers + * @return CreateCreditUnitResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function create(array $params, array $headers = []): CreateCreditUnitResponse + { + $jsonKeys = [ + ]; + $payload = ChargebeePayload::builder() + ->withEnvironment($this->env) + ->withHttpMethod("post") + ->withUriPaths(["credit_units"]) + ->withParamEncoder( new URLFormEncoder()) + ->withSubDomain(null) + ->withJsonKeys($jsonKeys) + ->withHeaders($headers) + ->withParams($params) + ->withIdempotent(true) + ->withTelemetryResource("creditUnit") + ->withTelemetryOperation("create") + ->build(); + $apiRequester = new APIRequester($this->httpClientFactory, $this->env); + $respObject = $apiRequester->makeRequest($payload); + return CreateCreditUnitResponse::from($respObject->data, $respObject->headers); + } + + /** + * @see https://apidocs.chargebee.com/docs/api/credit_units/archive-a-credit-unit?lang=php-v4 + * + * @param string $id + * @param array $headers + * @return ArchiveCreditUnitResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function archive(string $id, array $headers = []): ArchiveCreditUnitResponse + { + $jsonKeys = [ + ]; + $payload = ChargebeePayload::builder() + ->withEnvironment($this->env) + ->withHttpMethod("post") + ->withUriPaths(["credit_units",$id,"archive_command"]) + ->withParamEncoder( new URLFormEncoder()) + ->withSubDomain(null) + ->withJsonKeys($jsonKeys) + ->withHeaders($headers) + ->withIdempotent(true) + ->withTelemetryResource("creditUnit") + ->withTelemetryOperation("archive") + ->build(); + $apiRequester = new APIRequester($this->httpClientFactory, $this->env); + $respObject = $apiRequester->makeRequest($payload); + return ArchiveCreditUnitResponse::from($respObject->data, $respObject->headers); + } + + /** + * @see https://apidocs.chargebee.com/docs/api/credit_units/update-a-credit-unit?lang=php-v4 + * @param array{ + * name?: string, + * external_name?: string, + * } $params Description of the parameters + * @param string $id + * @param array $headers + * @return UpdateCreditUnitResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function update(string $id, array $params = [], array $headers = []): UpdateCreditUnitResponse + { + $jsonKeys = [ + ]; + $payload = ChargebeePayload::builder() + ->withEnvironment($this->env) + ->withHttpMethod("post") + ->withUriPaths(["credit_units",$id]) + ->withParamEncoder( new URLFormEncoder()) + ->withSubDomain(null) + ->withJsonKeys($jsonKeys) + ->withHeaders($headers) + ->withParams($params) + ->withIdempotent(true) + ->withTelemetryResource("creditUnit") + ->withTelemetryOperation("update") + ->build(); + $apiRequester = new APIRequester($this->httpClientFactory, $this->env); + $respObject = $apiRequester->makeRequest($payload); + return UpdateCreditUnitResponse::from($respObject->data, $respObject->headers); + } + + /** + * @see https://apidocs.chargebee.com/docs/api/credit_units/reactivate-a-credit-unit?lang=php-v4 + * + * @param string $id + * @param array $headers + * @return ReactivateCreditUnitResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function reactivate(string $id, array $headers = []): ReactivateCreditUnitResponse + { + $jsonKeys = [ + ]; + $payload = ChargebeePayload::builder() + ->withEnvironment($this->env) + ->withHttpMethod("post") + ->withUriPaths(["credit_units",$id,"reactivate_command"]) + ->withParamEncoder( new URLFormEncoder()) + ->withSubDomain(null) + ->withJsonKeys($jsonKeys) + ->withHeaders($headers) + ->withIdempotent(true) + ->withTelemetryResource("creditUnit") + ->withTelemetryOperation("reactivate") + ->build(); + $apiRequester = new APIRequester($this->httpClientFactory, $this->env); + $respObject = $apiRequester->makeRequest($payload); + return ReactivateCreditUnitResponse::from($respObject->data, $respObject->headers); + } + +} +?> \ No newline at end of file diff --git a/src/Actions/EntitlementActions.php b/src/Actions/EntitlementActions.php index ac18aadc..d83d96c2 100644 --- a/src/Actions/EntitlementActions.php +++ b/src/Actions/EntitlementActions.php @@ -31,16 +31,16 @@ public function __construct(HttpClientFactory $httpClientFactory, Environment $e * limit?: int, * offset?: string, * feature_id?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * entity_type?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * entity_id?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * include_drafts?: bool, * embed?: string, diff --git a/src/Actions/EstimateActions.php b/src/Actions/EstimateActions.php index 5136e869..67d1d0f0 100644 --- a/src/Actions/EstimateActions.php +++ b/src/Actions/EstimateActions.php @@ -272,6 +272,7 @@ public function paymentSchedules(array $params, array $headers = []): PaymentSch * unit_price_in_decimal?: string, * service_period_days?: int, * }>, + * include_cancellation_day_in_billing?: bool, * cancel_reason_code?: string, * } $params Description of the parameters * @param string $id diff --git a/src/Actions/ExportActions.php b/src/Actions/ExportActions.php index 9dddaad4..78cda91f 100644 --- a/src/Actions/ExportActions.php +++ b/src/Actions/ExportActions.php @@ -487,8 +487,8 @@ public function differentialPrices(array $params = [], array $headers = []): Dif * }, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, @@ -752,8 +752,8 @@ public function retrieve(string $id, array $headers = []): RetrieveExportRespons * }, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, @@ -863,8 +863,8 @@ public function priceVariants(array $params = [], array $headers = []): PriceVar * }, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, @@ -1852,8 +1852,8 @@ public function creditNotes(array $params = [], array $headers = []): CreditNote * not_in?: mixed, * }, * applicable_item_price_ids?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * } $params Description of the parameters * @@ -2152,8 +2152,8 @@ public function orders(array $params = [], array $headers = []): OrdersExportRes * not_in?: mixed, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, diff --git a/src/Actions/GrantBlockActions.php b/src/Actions/GrantBlockActions.php index 85ba1720..8dd9e66d 100644 --- a/src/Actions/GrantBlockActions.php +++ b/src/Actions/GrantBlockActions.php @@ -35,6 +35,9 @@ public function __construct(HttpClientFactory $httpClientFactory, Environment $e * unit_id?: array{ * is?: mixed, * }, + * account_type?: array{ + * is?: mixed, + * }, * effective_from?: array{ * after?: mixed, * before?: mixed, diff --git a/src/Actions/InvoiceActions.php b/src/Actions/InvoiceActions.php index 52146297..c1023e6c 100644 --- a/src/Actions/InvoiceActions.php +++ b/src/Actions/InvoiceActions.php @@ -1834,13 +1834,13 @@ public function removeTaxWithheld(string $id, array $params, array $headers = [] * offset?: string, * payment_reference_number?: array{ * number?: array{ - * is?: string, - * in?: string, + * in?: string, + * is?: string, * }, * }, * id?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * } $params Description of the parameters * diff --git a/src/Actions/ItemActions.php b/src/Actions/ItemActions.php index 9a2821db..2e459e5a 100644 --- a/src/Actions/ItemActions.php +++ b/src/Actions/ItemActions.php @@ -109,8 +109,8 @@ public function __construct(HttpClientFactory $httpClientFactory, Environment $e * not_in?: mixed, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, diff --git a/src/Actions/ItemFamilyActions.php b/src/Actions/ItemFamilyActions.php index 7619d591..b2f019e0 100644 --- a/src/Actions/ItemFamilyActions.php +++ b/src/Actions/ItemFamilyActions.php @@ -85,8 +85,8 @@ public function delete(string $id, array $headers = []): DeleteItemFamilyRespons * between?: mixed, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, diff --git a/src/Actions/ItemPriceActions.php b/src/Actions/ItemPriceActions.php index 0195f4c2..f563f943 100644 --- a/src/Actions/ItemPriceActions.php +++ b/src/Actions/ItemPriceActions.php @@ -357,8 +357,8 @@ public function findApplicableItems(string $id, array $params = [], array $heade * between?: mixed, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, diff --git a/src/Actions/LedgerOperationActions.php b/src/Actions/LedgerOperationActions.php index 4adeae1a..35ec570c 100644 --- a/src/Actions/LedgerOperationActions.php +++ b/src/Actions/LedgerOperationActions.php @@ -4,6 +4,7 @@ use Chargebee\Responses\LedgerOperationResponse\CaptureLedgerOperationResponse; use Chargebee\Responses\LedgerOperationResponse\CaptureAuthorizationLedgerOperationResponse; use Chargebee\Responses\LedgerOperationResponse\RetrieveLedgerOperationLedgerOperationResponse; +use Chargebee\Responses\LedgerOperationResponse\AllocateLedgerOperationResponse; use Chargebee\Responses\LedgerOperationResponse\ReleaseAuthorizationLedgerOperationResponse; use Chargebee\Responses\LedgerOperationResponse\ListLedgerOperationsLedgerOperationResponse; use Chargebee\Actions\Contracts\LedgerOperationActionsInterface; @@ -114,6 +115,48 @@ public function capture(array $params, array $headers = []): CaptureLedgerOperat return CaptureLedgerOperationResponse::from($respObject->data, $respObject->headers); } + /** + * @see https://apidocs.chargebee.com/docs/api/ledger_operations/allocate?lang=php-v4 + * @param array{ + * subscription_id?: string, + * unit_id?: string, + * amount?: string, + * expires_at?: int, + * metadata?: mixed, + * } $params Description of the parameters + * + * @param array $headers + * @return AllocateLedgerOperationResponse + * @throws PaymentException + * @throws OperationFailedException + * @throws APIError + * @throws InvalidRequestException + * @throws Exception + */ + public function allocate(array $params, array $headers = []): AllocateLedgerOperationResponse + { + $jsonKeys = [ + "metadata" => 0, + ]; + $payload = ChargebeePayload::builder() + ->withEnvironment($this->env) + ->withHttpMethod("post") + ->withUriPaths(["ledger_operations","allocate"]) + ->withParamEncoder( new JsonParamEncoder()) + ->withSubDomain(null) + ->withJsonKeys($jsonKeys) + ->withHeaderOverride("Content-Type", "application/json") + ->withHeaders($headers) + ->withParams($params) + ->withIdempotent(false) + ->withTelemetryResource("ledgerOperation") + ->withTelemetryOperation("allocate") + ->build(); + $apiRequester = new APIRequester($this->httpClientFactory, $this->env); + $respObject = $apiRequester->makeRequest($payload); + return AllocateLedgerOperationResponse::from($respObject->data, $respObject->headers); + } + /** * @see https://apidocs.chargebee.com/docs/api/ledger_operations/authorize?lang=php-v4 * @param array{ @@ -176,8 +219,8 @@ public function authorize(array $params, array $headers = []): AuthorizeLedgerOp * between?: mixed, * }, * type?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * sort_by?: array{ * asc?: string, diff --git a/src/Actions/MeterActions.php b/src/Actions/MeterActions.php index 5bd549c4..83f0acc8 100644 --- a/src/Actions/MeterActions.php +++ b/src/Actions/MeterActions.php @@ -30,8 +30,8 @@ public function __construct(HttpClientFactory $httpClientFactory, Environment $e * limit?: int, * offset?: string, * name?: array{ - * is?: mixed, * starts_with?: mixed, + * is?: mixed, * }, * sort_by?: array{ * asc?: string, diff --git a/src/Actions/PriceVariantActions.php b/src/Actions/PriceVariantActions.php index c89292c8..b3715575 100644 --- a/src/Actions/PriceVariantActions.php +++ b/src/Actions/PriceVariantActions.php @@ -99,8 +99,8 @@ public function delete(string $id, array $headers = []): DeletePriceVariantRespo * between?: mixed, * }, * business_entity_id?: array{ - * is_present?: mixed, * is?: mixed, + * is_present?: mixed, * }, * include_site_level_resources?: array{ * is?: mixed, diff --git a/src/Actions/RampActions.php b/src/Actions/RampActions.php index 897af978..b932522d 100644 --- a/src/Actions/RampActions.php +++ b/src/Actions/RampActions.php @@ -162,12 +162,12 @@ public function createForSubscription(string $id, array $params, array $headers * offset?: string, * include_deleted?: bool, * status?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * subscription_id?: array{ - * is?: mixed, * in?: mixed, + * is?: mixed, * }, * effective_from?: array{ * after?: mixed, diff --git a/src/Actions/SubscriptionActions.php b/src/Actions/SubscriptionActions.php index 79a8a51e..ec1dd8c2 100644 --- a/src/Actions/SubscriptionActions.php +++ b/src/Actions/SubscriptionActions.php @@ -414,6 +414,7 @@ public function resume(string $id, array $params = [], array $headers = []): Res * unit_price_in_decimal?: string, * service_period_days?: int, * }>, + * include_cancellation_day_in_billing?: bool, * cancel_reason_code?: string, * decommissioned?: bool, * } $params Description of the parameters diff --git a/src/ChargebeeClient.php b/src/ChargebeeClient.php index 20a42700..c2bf088a 100644 --- a/src/ChargebeeClient.php +++ b/src/ChargebeeClient.php @@ -26,6 +26,8 @@ use Chargebee\Actions\CouponSetActions; use Chargebee\Actions\Contracts\CreditNoteActionsInterface; use Chargebee\Actions\CreditNoteActions; +use Chargebee\Actions\Contracts\CreditUnitActionsInterface; +use Chargebee\Actions\CreditUnitActions; use Chargebee\Actions\Contracts\CurrencyActionsInterface; use Chargebee\Actions\CurrencyActions; use Chargebee\Actions\Contracts\CustomerActionsInterface; @@ -277,6 +279,10 @@ public function creditNote() :CreditNoteActionsInterface { return new CreditNoteActions($this->httpClientFactory, $this->env); } + public function creditUnit() :CreditUnitActionsInterface { + return new CreditUnitActions($this->httpClientFactory, $this->env); + } + public function currency() :CurrencyActionsInterface { return new CurrencyActions($this->httpClientFactory, $this->env); } diff --git a/src/Enums/EnabledEvents.php b/src/Enums/EnabledEvents.php index 0c036e00..0826060b 100644 --- a/src/Enums/EnabledEvents.php +++ b/src/Enums/EnabledEvents.php @@ -226,6 +226,10 @@ enum EnabledEvents : string { case ALERT_STATUS_CHANGED = "alert_status_changed"; case OMNICHANNEL_SUBSCRIPTION_ITEM_UPDATED = "omnichannel_subscription_item_updated"; case OMNICHANNEL_SUBSCRIPTION_ITEM_RECOVERED = "omnichannel_subscription_item_recovered"; + case LEDGER_ACCOUNT_BALANCE_UPDATED = "ledger_account_balance_updated"; + case GRANT_BLOCKS_CREATED = "grant_blocks_created"; + case GRANT_BLOCKS_UPDATED = "grant_blocks_updated"; + case LEDGER_UPDATED = "ledger_updated"; case PLAN_CREATED = "plan_created"; case PLAN_UPDATED = "plan_updated"; case PLAN_DELETED = "plan_deleted"; diff --git a/src/Enums/EventType.php b/src/Enums/EventType.php index 66ae7b85..bb9b3c29 100644 --- a/src/Enums/EventType.php +++ b/src/Enums/EventType.php @@ -217,6 +217,10 @@ enum EventType : string { case ALERT_STATUS_CHANGED = "alert_status_changed"; case OMNICHANNEL_SUBSCRIPTION_ITEM_UPDATED = "omnichannel_subscription_item_updated"; case OMNICHANNEL_SUBSCRIPTION_ITEM_RECOVERED = "omnichannel_subscription_item_recovered"; + case LEDGER_ACCOUNT_BALANCE_UPDATED = "ledger_account_balance_updated"; + case GRANT_BLOCKS_CREATED = "grant_blocks_created"; + case GRANT_BLOCKS_UPDATED = "grant_blocks_updated"; + case LEDGER_UPDATED = "ledger_updated"; case PLAN_CREATED = "plan_created"; case PLAN_UPDATED = "plan_updated"; case PLAN_DELETED = "plan_deleted"; diff --git a/src/Enums/PaymentMethod.php b/src/Enums/PaymentMethod.php index 98ce89d3..65b2b305 100644 --- a/src/Enums/PaymentMethod.php +++ b/src/Enums/PaymentMethod.php @@ -8,6 +8,10 @@ enum PaymentMethod : string { case BANK_TRANSFER = "bank_transfer"; case OTHER = "other"; case CUSTOM = "custom"; + case DANA = "dana"; + case TOUCH_N_GO = "touch_n_go"; + case TAMARA = "tamara"; + case QPAY = "qpay"; case CHARGEBACK = "chargeback"; case CARD = "card"; case AMAZON_PAYMENTS = "amazon_payments"; diff --git a/src/Enums/PaymentMethodType.php b/src/Enums/PaymentMethodType.php index e7faa076..e6863e1b 100644 --- a/src/Enums/PaymentMethodType.php +++ b/src/Enums/PaymentMethodType.php @@ -53,6 +53,10 @@ enum PaymentMethodType : string { case PAYNOW = "paynow"; case BIZUM = "bizum"; case PROMPTPAY = "promptpay"; + case DANA = "dana"; + case TOUCH_N_GO = "touch_n_go"; + case TAMARA = "tamara"; + case QPAY = "qpay"; case UNKNOWN = "unknown"; public static function tryFromValue(string $value): self { diff --git a/src/Enums/Type.php b/src/Enums/Type.php index 727257c1..8361d894 100644 --- a/src/Enums/Type.php +++ b/src/Enums/Type.php @@ -53,6 +53,10 @@ enum Type : string { case PAYNOW = "paynow"; case BIZUM = "bizum"; case PROMPTPAY = "promptpay"; + case DANA = "dana"; + case TOUCH_N_GO = "touch_n_go"; + case TAMARA = "tamara"; + case QPAY = "qpay"; case FREE_TRIAL = "free_trial"; case PAY_UP_FRONT = "pay_up_front"; case PAY_AS_YOU_GO = "pay_as_you_go"; @@ -60,6 +64,11 @@ enum Type : string { case COMPOUND = "compound"; case USAGE_EXCEEDED = "usage_exceeded"; case SPEND_EXCEEDED = "spend_exceeded"; + case CREDIT_BALANCE_DROPPED = "credit_balance_dropped"; + case CREDIT = "credit"; + case DEBIT = "debit"; + case HOLD = "hold"; + case UNHOLD = "unhold"; case UNKNOWN = "unknown"; public static function tryFromValue(string $value): self { diff --git a/src/Resources/Alert/Alert.php b/src/Resources/Alert/Alert.php index 4302a059..27a1fb98 100644 --- a/src/Resources/Alert/Alert.php +++ b/src/Resources/Alert/Alert.php @@ -33,6 +33,12 @@ class Alert { */ public ?string $currency_code; + /** + * + * @var ?string $unit_id + */ + public ?string $unit_id; + /** * * @var ?string $subscription_id @@ -59,9 +65,9 @@ class Alert { /** * - * @var ?array $threshold + * @var ?Threshold $threshold */ - public ?array $threshold; + public ?Threshold $threshold; /** * @@ -84,7 +90,7 @@ class Alert { /** * @var array $knownFields */ - protected static array $knownFields = [ "id" , "name" , "description" , "metered_feature_id" , "currency_code" , "subscription_id" , "meta" , "created_at" , "updated_at" , "threshold" , "filter_conditions" ]; + protected static array $knownFields = [ "id" , "name" , "description" , "metered_feature_id" , "currency_code" , "unit_id" , "subscription_id" , "meta" , "created_at" , "updated_at" , "threshold" , "filter_conditions" ]; /** * dynamic properties for resources @@ -98,11 +104,12 @@ private function __construct( ?string $description, ?string $metered_feature_id, ?string $currency_code, + ?string $unit_id, ?string $subscription_id, ?string $meta, ?int $created_at, ?int $updated_at, - ?array $threshold, + ?Threshold $threshold, ?array $filter_conditions, ?\Chargebee\Enums\Type $type, ?\Chargebee\Resources\Alert\Enums\Status $status, @@ -113,6 +120,7 @@ private function __construct( $this->description = $description; $this->metered_feature_id = $metered_feature_id; $this->currency_code = $currency_code; + $this->unit_id = $unit_id; $this->subscription_id = $subscription_id; $this->meta = $meta; $this->created_at = $created_at; @@ -125,10 +133,6 @@ private function __construct( public static function from(array $resourceAttributes): self { - $threshold = array_map(fn (array $result): Threshold => Threshold::from( - $result - ), $resourceAttributes['threshold'] ?? []); - $filter_conditions = array_map(fn (array $result): FilterCondition => FilterCondition::from( $result ), $resourceAttributes['filter_conditions'] ?? []); @@ -138,11 +142,12 @@ public static function from(array $resourceAttributes): self $resourceAttributes['description'] ?? null, $resourceAttributes['metered_feature_id'] ?? null, $resourceAttributes['currency_code'] ?? null, + $resourceAttributes['unit_id'] ?? null, $resourceAttributes['subscription_id'] ?? null, $resourceAttributes['meta'] ?? null, $resourceAttributes['created_at'] ?? null, $resourceAttributes['updated_at'] ?? null, - $threshold, + isset($resourceAttributes['threshold']) ? Threshold::from($resourceAttributes['threshold']) : null, $filter_conditions, @@ -163,6 +168,7 @@ public function toArray(): array 'description' => $this->description, 'metered_feature_id' => $this->metered_feature_id, 'currency_code' => $this->currency_code, + 'unit_id' => $this->unit_id, 'subscription_id' => $this->subscription_id, 'meta' => $this->meta, 'created_at' => $this->created_at, @@ -179,13 +185,10 @@ public function toArray(): array }); - - if($this->threshold !== []){ - $data['threshold'] = array_map( - fn (Threshold $threshold): array => $threshold->toArray(), - $this->threshold - ); + if($this->threshold instanceof Threshold){ + $data['threshold'] = $this->threshold->toArray(); } + if($this->filter_conditions !== []){ $data['filter_conditions'] = array_map( fn (FilterCondition $filter_conditions): array => $filter_conditions->toArray(), diff --git a/src/Resources/Content/Content.php b/src/Resources/Content/Content.php index 20e51457..05cee5bf 100644 --- a/src/Resources/Content/Content.php +++ b/src/Resources/Content/Content.php @@ -26,6 +26,7 @@ use Chargebee\Resources\CpqQuoteSignature\CpqQuoteSignature; use Chargebee\Resources\CreditNote\CreditNote; use Chargebee\Resources\CreditNoteEstimate\CreditNoteEstimate; +use Chargebee\Resources\CreditUnit\CreditUnit; use Chargebee\Resources\Currency\Currency; use Chargebee\Resources\Customer\Customer; use Chargebee\Resources\CustomerEntitlement\CustomerEntitlement; @@ -57,6 +58,7 @@ use Chargebee\Resources\ItemFamily\ItemFamily; use Chargebee\Resources\ItemPrice\ItemPrice; use Chargebee\Resources\LedgerAccountBalance\LedgerAccountBalance; +use Chargebee\Resources\LedgerEntry\LedgerEntry; use Chargebee\Resources\LedgerOperation\LedgerOperation; use Chargebee\Resources\Metadata\Metadata; use Chargebee\Resources\Meter\Meter; @@ -268,6 +270,12 @@ class Content { */ public ?CreditNoteEstimate $creditnoteestimate; + /** + * + * @var ?CreditUnit $creditunit + */ + public ?CreditUnit $creditunit; + /** * * @var ?Currency $currency @@ -454,6 +462,12 @@ class Content { */ public ?LedgerAccountBalance $ledgeraccountbalance; + /** + * + * @var ?LedgerEntry $ledgerentry + */ + public ?LedgerEntry $ledgerentry; + /** * * @var ?LedgerOperation $ledgeroperation @@ -811,7 +825,7 @@ class Content { /** * @var array $knownFields */ - protected static array $knownFields = [ "addon" , "address" , "advance_invoice_schedule" , "alert" , "alert_status" , "async_response" , "async_response_list" , "attached_item" , "attribute" , "billing_configuration" , "brand" , "business_entity" , "business_entity_transfer" , "card" , "column_definition" , "comment" , "configuration" , "contact" , "contract_term" , "coupon" , "coupon_code" , "coupon_set" , "cpq_quote_signature" , "credit_note" , "credit_note_estimate" , "currency" , "customer" , "customer_entitlement" , "differential_price" , "discount" , "download" , "einvoice" , "entitlement" , "entitlement_override" , "estimate" , "event" , "export" , "feature" , "filter_condition" , "gateway_error_detail" , "gift" , "grant_block" , "hierarchy" , "hosted_page" , "impacted_customer" , "impacted_item" , "impacted_item_price" , "impacted_subscription" , "in_app_subscription" , "invoice" , "invoice_estimate" , "item" , "item_entitlement" , "item_family" , "item_price" , "ledger_account_balance" , "ledger_operation" , "metadata" , "meter" , "metered_feature" , "non_subscription" , "offer_event" , "offer_fulfillment" , "omnichannel_one_time_order" , "omnichannel_one_time_order_item" , "omnichannel_subscription" , "omnichannel_subscription_item" , "omnichannel_subscription_item_offer" , "omnichannel_subscription_item_scheduled_change" , "omnichannel_transaction" , "order" , "payment_intent" , "payment_reference_number" , "payment_schedule" , "payment_schedule_estimate" , "payment_schedule_scheme" , "payment_source" , "payment_voucher" , "personalized_offer" , "plan" , "portal_session" , "price_variant" , "pricing_page_session" , "promotional_credit" , "promotional_grant" , "purchase" , "quote" , "quote_line_group" , "quoted_charge" , "quoted_delta_ramp" , "quoted_ramp" , "quoted_subscription" , "ramp" , "recorded_purchase" , "resource_migration" , "rule" , "site_migration_detail" , "subscription" , "subscription_entitlement" , "subscription_entitlements_created_detail" , "subscription_entitlements_updated_detail" , "subscription_estimate" , "tax_withheld" , "third_party_payment_method" , "time_machine" , "token" , "transaction" , "unbilled_charge" , "usage" , "usage_charge" , "usage_event" , "usage_file" , "usage_summary" , "virtual_bank_account" , "webhook_endpoint" ]; + protected static array $knownFields = [ "addon" , "address" , "advance_invoice_schedule" , "alert" , "alert_status" , "async_response" , "async_response_list" , "attached_item" , "attribute" , "billing_configuration" , "brand" , "business_entity" , "business_entity_transfer" , "card" , "column_definition" , "comment" , "configuration" , "contact" , "contract_term" , "coupon" , "coupon_code" , "coupon_set" , "cpq_quote_signature" , "credit_note" , "credit_note_estimate" , "credit_unit" , "currency" , "customer" , "customer_entitlement" , "differential_price" , "discount" , "download" , "einvoice" , "entitlement" , "entitlement_override" , "estimate" , "event" , "export" , "feature" , "filter_condition" , "gateway_error_detail" , "gift" , "grant_block" , "hierarchy" , "hosted_page" , "impacted_customer" , "impacted_item" , "impacted_item_price" , "impacted_subscription" , "in_app_subscription" , "invoice" , "invoice_estimate" , "item" , "item_entitlement" , "item_family" , "item_price" , "ledger_account_balance" , "ledger_entry" , "ledger_operation" , "metadata" , "meter" , "metered_feature" , "non_subscription" , "offer_event" , "offer_fulfillment" , "omnichannel_one_time_order" , "omnichannel_one_time_order_item" , "omnichannel_subscription" , "omnichannel_subscription_item" , "omnichannel_subscription_item_offer" , "omnichannel_subscription_item_scheduled_change" , "omnichannel_transaction" , "order" , "payment_intent" , "payment_reference_number" , "payment_schedule" , "payment_schedule_estimate" , "payment_schedule_scheme" , "payment_source" , "payment_voucher" , "personalized_offer" , "plan" , "portal_session" , "price_variant" , "pricing_page_session" , "promotional_credit" , "promotional_grant" , "purchase" , "quote" , "quote_line_group" , "quoted_charge" , "quoted_delta_ramp" , "quoted_ramp" , "quoted_subscription" , "ramp" , "recorded_purchase" , "resource_migration" , "rule" , "site_migration_detail" , "subscription" , "subscription_entitlement" , "subscription_entitlements_created_detail" , "subscription_entitlements_updated_detail" , "subscription_estimate" , "tax_withheld" , "third_party_payment_method" , "time_machine" , "token" , "transaction" , "unbilled_charge" , "usage" , "usage_charge" , "usage_event" , "usage_file" , "usage_summary" , "virtual_bank_account" , "webhook_endpoint" ]; /** * dynamic properties for resources @@ -845,6 +859,7 @@ private function __construct( ?CpqQuoteSignature $cpqquotesignature, ?CreditNote $creditnote, ?CreditNoteEstimate $creditnoteestimate, + ?CreditUnit $creditunit, ?Currency $currency, ?Customer $customer, ?CustomerEntitlement $customerentitlement, @@ -876,6 +891,7 @@ private function __construct( ?ItemFamily $itemfamily, ?ItemPrice $itemprice, ?LedgerAccountBalance $ledgeraccountbalance, + ?LedgerEntry $ledgerentry, ?LedgerOperation $ledgeroperation, ?Metadata $metadata, ?Meter $meter, @@ -962,6 +978,7 @@ private function __construct( $this->cpqquotesignature = $cpqquotesignature; $this->creditnote = $creditnote; $this->creditnoteestimate = $creditnoteestimate; + $this->creditunit = $creditunit; $this->currency = $currency; $this->customer = $customer; $this->customerentitlement = $customerentitlement; @@ -993,6 +1010,7 @@ private function __construct( $this->itemfamily = $itemfamily; $this->itemprice = $itemprice; $this->ledgeraccountbalance = $ledgeraccountbalance; + $this->ledgerentry = $ledgerentry; $this->ledgeroperation = $ledgeroperation; $this->metadata = $metadata; $this->meter = $meter; @@ -1081,6 +1099,7 @@ public static function from(array $resourceAttributes): self isset($resourceAttributes['cpq_quote_signature']) ? CpqQuoteSignature::from($resourceAttributes['cpq_quote_signature']) : null, isset($resourceAttributes['credit_note']) ? CreditNote::from($resourceAttributes['credit_note']) : null, isset($resourceAttributes['credit_note_estimate']) ? CreditNoteEstimate::from($resourceAttributes['credit_note_estimate']) : null, + isset($resourceAttributes['credit_unit']) ? CreditUnit::from($resourceAttributes['credit_unit']) : null, isset($resourceAttributes['currency']) ? Currency::from($resourceAttributes['currency']) : null, isset($resourceAttributes['customer']) ? Customer::from($resourceAttributes['customer']) : null, isset($resourceAttributes['customer_entitlement']) ? CustomerEntitlement::from($resourceAttributes['customer_entitlement']) : null, @@ -1112,6 +1131,7 @@ public static function from(array $resourceAttributes): self isset($resourceAttributes['item_family']) ? ItemFamily::from($resourceAttributes['item_family']) : null, isset($resourceAttributes['item_price']) ? ItemPrice::from($resourceAttributes['item_price']) : null, isset($resourceAttributes['ledger_account_balance']) ? LedgerAccountBalance::from($resourceAttributes['ledger_account_balance']) : null, + isset($resourceAttributes['ledger_entry']) ? LedgerEntry::from($resourceAttributes['ledger_entry']) : null, isset($resourceAttributes['ledger_operation']) ? LedgerOperation::from($resourceAttributes['ledger_operation']) : null, isset($resourceAttributes['metadata']) ? Metadata::from($resourceAttributes['metadata']) : null, isset($resourceAttributes['meter']) ? Meter::from($resourceAttributes['meter']) : null, @@ -1294,6 +1314,8 @@ public function toArray(): array + + @@ -1377,6 +1399,9 @@ public function toArray(): array if($this->creditnoteestimate instanceof CreditNoteEstimate){ $data['credit_note_estimate'] = $this->creditnoteestimate->toArray(); } + if($this->creditunit instanceof CreditUnit){ + $data['credit_unit'] = $this->creditunit->toArray(); + } if($this->currency instanceof Currency){ $data['currency'] = $this->currency->toArray(); } @@ -1470,6 +1495,9 @@ public function toArray(): array if($this->ledgeraccountbalance instanceof LedgerAccountBalance){ $data['ledger_account_balance'] = $this->ledgeraccountbalance->toArray(); } + if($this->ledgerentry instanceof LedgerEntry){ + $data['ledger_entry'] = $this->ledgerentry->toArray(); + } if($this->ledgeroperation instanceof LedgerOperation){ $data['ledger_operation'] = $this->ledgeroperation->toArray(); } diff --git a/src/Resources/CreditUnit/CreditUnit.php b/src/Resources/CreditUnit/CreditUnit.php new file mode 100644 index 00000000..f0655054 --- /dev/null +++ b/src/Resources/CreditUnit/CreditUnit.php @@ -0,0 +1,158 @@ + $knownFields + */ + protected static array $knownFields = [ "id" , "name" , "external_name" , "resource_version" , "updated_at" , "created_at" , "created_by" , "updated_by" , "is_unlimited" , "overdraft_amount" ]; + + /** + * dynamic properties for resources + * @var array $_data; + */ + protected $_data = []; + + private function __construct( + ?string $id, + ?string $name, + ?string $external_name, + ?int $resource_version, + ?int $updated_at, + ?int $created_at, + ?string $created_by, + ?string $updated_by, + ?bool $is_unlimited, + ?string $overdraft_amount, + ?\Chargebee\Resources\CreditUnit\Enums\Status $status, + ) + { + $this->id = $id; + $this->name = $name; + $this->external_name = $external_name; + $this->resource_version = $resource_version; + $this->updated_at = $updated_at; + $this->created_at = $created_at; + $this->created_by = $created_by; + $this->updated_by = $updated_by; + $this->is_unlimited = $is_unlimited; + $this->overdraft_amount = $overdraft_amount; + $this->status = $status; + } + + public static function from(array $resourceAttributes): self + { + $returnData = new self( $resourceAttributes['id'] ?? null, + $resourceAttributes['name'] ?? null, + $resourceAttributes['external_name'] ?? null, + $resourceAttributes['resource_version'] ?? null, + $resourceAttributes['updated_at'] ?? null, + $resourceAttributes['created_at'] ?? null, + $resourceAttributes['created_by'] ?? null, + $resourceAttributes['updated_by'] ?? null, + $resourceAttributes['is_unlimited'] ?? null, + $resourceAttributes['overdraft_amount'] ?? null, + + + isset($resourceAttributes['status']) ? \Chargebee\Resources\CreditUnit\Enums\Status::tryFromValue($resourceAttributes['status']) : null, + + ); + + return $returnData; + } + + public function toArray(): array + { + + $data = array_filter(['id' => $this->id, + 'name' => $this->name, + 'external_name' => $this->external_name, + 'resource_version' => $this->resource_version, + 'updated_at' => $this->updated_at, + 'created_at' => $this->created_at, + 'created_by' => $this->created_by, + 'updated_by' => $this->updated_by, + 'is_unlimited' => $this->is_unlimited, + 'overdraft_amount' => $this->overdraft_amount, + + 'status' => $this->status?->value, + + ], function ($value) { + return $value !== null; + }); + + + + + + return $data; + } +} +?> \ No newline at end of file diff --git a/src/Resources/CreditUnit/Enums/Status.php b/src/Resources/CreditUnit/Enums/Status.php new file mode 100644 index 00000000..c5bf0f2a --- /dev/null +++ b/src/Resources/CreditUnit/Enums/Status.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/src/Resources/GrantBlock/Enums/GrantSource.php b/src/Resources/GrantBlock/Enums/GrantSource.php index 10aa32fd..72d0fc21 100644 --- a/src/Resources/GrantBlock/Enums/GrantSource.php +++ b/src/Resources/GrantBlock/Enums/GrantSource.php @@ -8,6 +8,8 @@ enum GrantSource : string { case TOP_UP = "top_up"; case PROMOTIONAL_GRANTS = "promotional_grants"; case ROLLOVER = "rollover"; + case GRANT_RENEWAL = "grant_renewal"; + case SUBSCRIPTION_RENEWED = "subscription_renewed"; case UNKNOWN = "unknown"; public static function tryFromValue(string $value): self { diff --git a/src/Resources/GrantBlock/GrantBlock.php b/src/Resources/GrantBlock/GrantBlock.php index e1bd8a4a..5f85fc9f 100644 --- a/src/Resources/GrantBlock/GrantBlock.php +++ b/src/Resources/GrantBlock/GrantBlock.php @@ -9,6 +9,18 @@ class GrantBlock { */ public ?string $id; + /** + * + * @var ?string $subscription_id + */ + public ?string $subscription_id; + + /** + * + * @var ?string $unit_id + */ + public ?string $unit_id; + /** * * @var ?string $granted_amount @@ -77,27 +89,27 @@ class GrantBlock { /** * - * @var ?string $unit_id + * @var ?int $modified_at */ - public ?string $unit_id; + public ?int $modified_at; /** * - * @var mixed $metadata + * @var ?int $resource_version */ - public mixed $metadata; + public ?int $resource_version; /** * - * @var ?\Chargebee\Enums\Status $status + * @var mixed $metadata */ - public ?\Chargebee\Enums\Status $status; + public mixed $metadata; /** * - * @var ?\Chargebee\Resources\GrantBlock\Enums\GrantSource $grant_source + * @var ?\Chargebee\Enums\Status $status */ - public ?\Chargebee\Resources\GrantBlock\Enums\GrantSource $grant_source; + public ?\Chargebee\Enums\Status $status; /** * @@ -111,10 +123,16 @@ class GrantBlock { */ public ?\Chargebee\Resources\GrantBlock\Enums\UnitType $unit_type; + /** + * + * @var ?\Chargebee\Resources\GrantBlock\Enums\GrantSource $grant_source + */ + public ?\Chargebee\Resources\GrantBlock\Enums\GrantSource $grant_source; + /** * @var array $knownFields */ - protected static array $knownFields = [ "id" , "granted_amount" , "effective_from" , "expires_at" , "balance" , "hold_amount" , "used_amount" , "expired_amount" , "rolled_over_amount" , "voided_amount" , "origin_grant_block_id" , "created_at" , "unit_id" , "metadata" ]; + protected static array $knownFields = [ "id" , "subscription_id" , "unit_id" , "granted_amount" , "effective_from" , "expires_at" , "balance" , "hold_amount" , "used_amount" , "expired_amount" , "rolled_over_amount" , "voided_amount" , "origin_grant_block_id" , "created_at" , "modified_at" , "resource_version" , "metadata" ]; /** * dynamic properties for resources @@ -124,6 +142,8 @@ class GrantBlock { private function __construct( ?string $id, + ?string $subscription_id, + ?string $unit_id, ?string $granted_amount, ?int $effective_from, ?int $expires_at, @@ -135,15 +155,18 @@ private function __construct( ?string $voided_amount, ?string $origin_grant_block_id, ?int $created_at, - ?string $unit_id, + ?int $modified_at, + ?int $resource_version, mixed $metadata, ?\Chargebee\Enums\Status $status, - ?\Chargebee\Resources\GrantBlock\Enums\GrantSource $grant_source, ?\Chargebee\Resources\GrantBlock\Enums\AccountType $account_type, ?\Chargebee\Resources\GrantBlock\Enums\UnitType $unit_type, + ?\Chargebee\Resources\GrantBlock\Enums\GrantSource $grant_source, ) { $this->id = $id; + $this->subscription_id = $subscription_id; + $this->unit_id = $unit_id; $this->granted_amount = $granted_amount; $this->effective_from = $effective_from; $this->expires_at = $expires_at; @@ -155,17 +178,20 @@ private function __construct( $this->voided_amount = $voided_amount; $this->origin_grant_block_id = $origin_grant_block_id; $this->created_at = $created_at; - $this->unit_id = $unit_id; + $this->modified_at = $modified_at; + $this->resource_version = $resource_version; $this->metadata = $metadata; $this->status = $status; - $this->grant_source = $grant_source; $this->account_type = $account_type; - $this->unit_type = $unit_type; + $this->unit_type = $unit_type; + $this->grant_source = $grant_source; } public static function from(array $resourceAttributes): self { $returnData = new self( $resourceAttributes['id'] ?? null, + $resourceAttributes['subscription_id'] ?? null, + $resourceAttributes['unit_id'] ?? null, $resourceAttributes['granted_amount'] ?? null, $resourceAttributes['effective_from'] ?? null, $resourceAttributes['expires_at'] ?? null, @@ -177,17 +203,18 @@ public static function from(array $resourceAttributes): self $resourceAttributes['voided_amount'] ?? null, $resourceAttributes['origin_grant_block_id'] ?? null, $resourceAttributes['created_at'] ?? null, - $resourceAttributes['unit_id'] ?? null, + $resourceAttributes['modified_at'] ?? null, + $resourceAttributes['resource_version'] ?? null, $resourceAttributes['metadata'] ?? null, isset($resourceAttributes['status']) ? \Chargebee\Enums\Status::tryFromValue($resourceAttributes['status']) : null, - isset($resourceAttributes['grant_source']) ? \Chargebee\Resources\GrantBlock\Enums\GrantSource::tryFromValue($resourceAttributes['grant_source']) : null, - isset($resourceAttributes['account_type']) ? \Chargebee\Resources\GrantBlock\Enums\AccountType::tryFromValue($resourceAttributes['account_type']) : null, isset($resourceAttributes['unit_type']) ? \Chargebee\Resources\GrantBlock\Enums\UnitType::tryFromValue($resourceAttributes['unit_type']) : null, + + isset($resourceAttributes['grant_source']) ? \Chargebee\Resources\GrantBlock\Enums\GrantSource::tryFromValue($resourceAttributes['grant_source']) : null, ); @@ -198,6 +225,8 @@ public function toArray(): array { $data = array_filter(['id' => $this->id, + 'subscription_id' => $this->subscription_id, + 'unit_id' => $this->unit_id, 'granted_amount' => $this->granted_amount, 'effective_from' => $this->effective_from, 'expires_at' => $this->expires_at, @@ -209,17 +238,18 @@ public function toArray(): array 'voided_amount' => $this->voided_amount, 'origin_grant_block_id' => $this->origin_grant_block_id, 'created_at' => $this->created_at, - 'unit_id' => $this->unit_id, + 'modified_at' => $this->modified_at, + 'resource_version' => $this->resource_version, 'metadata' => $this->metadata, 'status' => $this->status?->value, - 'grant_source' => $this->grant_source?->value, - 'account_type' => $this->account_type?->value, 'unit_type' => $this->unit_type?->value, + 'grant_source' => $this->grant_source?->value, + ], function ($value) { return $value !== null; }); diff --git a/src/Resources/LedgerAccountBalance/LedgerAccountBalance.php b/src/Resources/LedgerAccountBalance/LedgerAccountBalance.php index 162d7c0d..758bb5a0 100644 --- a/src/Resources/LedgerAccountBalance/LedgerAccountBalance.php +++ b/src/Resources/LedgerAccountBalance/LedgerAccountBalance.php @@ -15,12 +15,24 @@ class LedgerAccountBalance { */ public ?string $unit_id; + /** + * + * @var ?int $created_at + */ + public ?int $created_at; + /** * * @var ?int $modified_at */ public ?int $modified_at; + /** + * + * @var ?int $resource_version + */ + public ?int $resource_version; + /** * * @var ?ProvisionedBalance $provisioned_balance @@ -42,7 +54,7 @@ class LedgerAccountBalance { /** * @var array $knownFields */ - protected static array $knownFields = [ "subscription_id" , "unit_id" , "modified_at" , "provisioned_balance" , "overdraft_balance" ]; + protected static array $knownFields = [ "subscription_id" , "unit_id" , "created_at" , "modified_at" , "resource_version" , "provisioned_balance" , "overdraft_balance" ]; /** * dynamic properties for resources @@ -53,7 +65,9 @@ class LedgerAccountBalance { private function __construct( ?string $subscription_id, ?string $unit_id, + ?int $created_at, ?int $modified_at, + ?int $resource_version, ?ProvisionedBalance $provisioned_balance, ?OverdraftBalance $overdraft_balance, ?\Chargebee\Resources\LedgerAccountBalance\Enums\UnitType $unit_type, @@ -61,7 +75,9 @@ private function __construct( { $this->subscription_id = $subscription_id; $this->unit_id = $unit_id; + $this->created_at = $created_at; $this->modified_at = $modified_at; + $this->resource_version = $resource_version; $this->provisioned_balance = $provisioned_balance; $this->overdraft_balance = $overdraft_balance; $this->unit_type = $unit_type; @@ -71,7 +87,9 @@ public static function from(array $resourceAttributes): self { $returnData = new self( $resourceAttributes['subscription_id'] ?? null, $resourceAttributes['unit_id'] ?? null, + $resourceAttributes['created_at'] ?? null, $resourceAttributes['modified_at'] ?? null, + $resourceAttributes['resource_version'] ?? null, isset($resourceAttributes['provisioned_balance']) ? ProvisionedBalance::from($resourceAttributes['provisioned_balance']) : null, isset($resourceAttributes['overdraft_balance']) ? OverdraftBalance::from($resourceAttributes['overdraft_balance']) : null, @@ -88,7 +106,9 @@ public function toArray(): array $data = array_filter(['subscription_id' => $this->subscription_id, 'unit_id' => $this->unit_id, + 'created_at' => $this->created_at, 'modified_at' => $this->modified_at, + 'resource_version' => $this->resource_version, diff --git a/src/Resources/LedgerEntry/Enums/AccountType.php b/src/Resources/LedgerEntry/Enums/AccountType.php new file mode 100644 index 00000000..d9204a23 --- /dev/null +++ b/src/Resources/LedgerEntry/Enums/AccountType.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/src/Resources/LedgerEntry/Enums/UnitType.php b/src/Resources/LedgerEntry/Enums/UnitType.php new file mode 100644 index 00000000..3e1cf064 --- /dev/null +++ b/src/Resources/LedgerEntry/Enums/UnitType.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/src/Resources/LedgerEntry/LedgerEntry.php b/src/Resources/LedgerEntry/LedgerEntry.php new file mode 100644 index 00000000..a6e4c843 --- /dev/null +++ b/src/Resources/LedgerEntry/LedgerEntry.php @@ -0,0 +1,202 @@ + $knownFields + */ + protected static array $knownFields = [ "id" , "subscription_id" , "unit_id" , "amount" , "grant_block_start_balance" , "grant_block_end_balance" , "account_start_balance" , "account_end_balance" , "ledger_operation_id" , "grant_block_id" , "created_at" , "modified_at" ]; + + /** + * dynamic properties for resources + * @var array $_data; + */ + protected $_data = []; + + private function __construct( + ?string $id, + ?string $subscription_id, + ?string $unit_id, + ?string $amount, + ?string $grant_block_start_balance, + ?string $grant_block_end_balance, + ?string $account_start_balance, + ?string $account_end_balance, + ?string $ledger_operation_id, + ?string $grant_block_id, + ?int $created_at, + ?int $modified_at, + ?\Chargebee\Enums\Type $type, + ?\Chargebee\Resources\LedgerEntry\Enums\AccountType $account_type, + ?\Chargebee\Resources\LedgerEntry\Enums\UnitType $unit_type, + ) + { + $this->id = $id; + $this->subscription_id = $subscription_id; + $this->unit_id = $unit_id; + $this->amount = $amount; + $this->grant_block_start_balance = $grant_block_start_balance; + $this->grant_block_end_balance = $grant_block_end_balance; + $this->account_start_balance = $account_start_balance; + $this->account_end_balance = $account_end_balance; + $this->ledger_operation_id = $ledger_operation_id; + $this->grant_block_id = $grant_block_id; + $this->created_at = $created_at; + $this->modified_at = $modified_at; + $this->type = $type; + $this->account_type = $account_type; + $this->unit_type = $unit_type; + } + + public static function from(array $resourceAttributes): self + { + $returnData = new self( $resourceAttributes['id'] ?? null, + $resourceAttributes['subscription_id'] ?? null, + $resourceAttributes['unit_id'] ?? null, + $resourceAttributes['amount'] ?? null, + $resourceAttributes['grant_block_start_balance'] ?? null, + $resourceAttributes['grant_block_end_balance'] ?? null, + $resourceAttributes['account_start_balance'] ?? null, + $resourceAttributes['account_end_balance'] ?? null, + $resourceAttributes['ledger_operation_id'] ?? null, + $resourceAttributes['grant_block_id'] ?? null, + $resourceAttributes['created_at'] ?? null, + $resourceAttributes['modified_at'] ?? null, + + + isset($resourceAttributes['type']) ? \Chargebee\Enums\Type::tryFromValue($resourceAttributes['type']) : null, + + isset($resourceAttributes['account_type']) ? \Chargebee\Resources\LedgerEntry\Enums\AccountType::tryFromValue($resourceAttributes['account_type']) : null, + + isset($resourceAttributes['unit_type']) ? \Chargebee\Resources\LedgerEntry\Enums\UnitType::tryFromValue($resourceAttributes['unit_type']) : null, + + ); + + return $returnData; + } + + public function toArray(): array + { + + $data = array_filter(['id' => $this->id, + 'subscription_id' => $this->subscription_id, + 'unit_id' => $this->unit_id, + 'amount' => $this->amount, + 'grant_block_start_balance' => $this->grant_block_start_balance, + 'grant_block_end_balance' => $this->grant_block_end_balance, + 'account_start_balance' => $this->account_start_balance, + 'account_end_balance' => $this->account_end_balance, + 'ledger_operation_id' => $this->ledger_operation_id, + 'grant_block_id' => $this->grant_block_id, + 'created_at' => $this->created_at, + 'modified_at' => $this->modified_at, + + 'type' => $this->type?->value, + + 'account_type' => $this->account_type?->value, + + 'unit_type' => $this->unit_type?->value, + + ], function ($value) { + return $value !== null; + }); + + + + + + return $data; + } +} +?> \ No newline at end of file diff --git a/src/Resources/LedgerOperation/LedgerOperation.php b/src/Resources/LedgerOperation/LedgerOperation.php index fe867dd4..2b415f3a 100644 --- a/src/Resources/LedgerOperation/LedgerOperation.php +++ b/src/Resources/LedgerOperation/LedgerOperation.php @@ -9,6 +9,18 @@ class LedgerOperation { */ public ?string $id; + /** + * + * @var ?string $subscription_id + */ + public ?string $subscription_id; + + /** + * + * @var ?string $unit_id + */ + public ?string $unit_id; + /** * * @var ?string $amount @@ -69,18 +81,6 @@ class LedgerOperation { */ public ?int $modified_at; - /** - * - * @var ?string $subscription_id - */ - public ?string $subscription_id; - - /** - * - * @var ?string $unit_id - */ - public ?string $unit_id; - /** * * @var mixed $metadata @@ -89,20 +89,20 @@ class LedgerOperation { /** * - * @var ?\Chargebee\Resources\LedgerOperation\Enums\Type $type + * @var ?\Chargebee\Resources\LedgerOperation\Enums\UnitType $unit_type */ - public ?\Chargebee\Resources\LedgerOperation\Enums\Type $type; + public ?\Chargebee\Resources\LedgerOperation\Enums\UnitType $unit_type; /** * - * @var ?\Chargebee\Resources\LedgerOperation\Enums\UnitType $unit_type + * @var ?\Chargebee\Resources\LedgerOperation\Enums\Type $type */ - public ?\Chargebee\Resources\LedgerOperation\Enums\UnitType $unit_type; + public ?\Chargebee\Resources\LedgerOperation\Enums\Type $type; /** * @var array $knownFields */ - protected static array $knownFields = [ "id" , "amount" , "provisioned_start_balance" , "provisioned_end_balance" , "overdraft_start_balance" , "overdraft_end_balance" , "parent_ledger_operation_id" , "ledger_operation_timestamp" , "auto_release_timestamp" , "created_at" , "modified_at" , "subscription_id" , "unit_id" , "metadata" ]; + protected static array $knownFields = [ "id" , "subscription_id" , "unit_id" , "amount" , "provisioned_start_balance" , "provisioned_end_balance" , "overdraft_start_balance" , "overdraft_end_balance" , "parent_ledger_operation_id" , "ledger_operation_timestamp" , "auto_release_timestamp" , "created_at" , "modified_at" , "metadata" ]; /** * dynamic properties for resources @@ -112,6 +112,8 @@ class LedgerOperation { private function __construct( ?string $id, + ?string $subscription_id, + ?string $unit_id, ?string $amount, ?string $provisioned_start_balance, ?string $provisioned_end_balance, @@ -122,14 +124,14 @@ private function __construct( ?int $auto_release_timestamp, ?int $created_at, ?int $modified_at, - ?string $subscription_id, - ?string $unit_id, mixed $metadata, - ?\Chargebee\Resources\LedgerOperation\Enums\Type $type, ?\Chargebee\Resources\LedgerOperation\Enums\UnitType $unit_type, + ?\Chargebee\Resources\LedgerOperation\Enums\Type $type, ) { $this->id = $id; + $this->subscription_id = $subscription_id; + $this->unit_id = $unit_id; $this->amount = $amount; $this->provisioned_start_balance = $provisioned_start_balance; $this->provisioned_end_balance = $provisioned_end_balance; @@ -140,16 +142,16 @@ private function __construct( $this->auto_release_timestamp = $auto_release_timestamp; $this->created_at = $created_at; $this->modified_at = $modified_at; - $this->subscription_id = $subscription_id; - $this->unit_id = $unit_id; $this->metadata = $metadata; - $this->type = $type; - $this->unit_type = $unit_type; + $this->unit_type = $unit_type; + $this->type = $type; } public static function from(array $resourceAttributes): self { $returnData = new self( $resourceAttributes['id'] ?? null, + $resourceAttributes['subscription_id'] ?? null, + $resourceAttributes['unit_id'] ?? null, $resourceAttributes['amount'] ?? null, $resourceAttributes['provisioned_start_balance'] ?? null, $resourceAttributes['provisioned_end_balance'] ?? null, @@ -160,14 +162,12 @@ public static function from(array $resourceAttributes): self $resourceAttributes['auto_release_timestamp'] ?? null, $resourceAttributes['created_at'] ?? null, $resourceAttributes['modified_at'] ?? null, - $resourceAttributes['subscription_id'] ?? null, - $resourceAttributes['unit_id'] ?? null, $resourceAttributes['metadata'] ?? null, - isset($resourceAttributes['type']) ? \Chargebee\Resources\LedgerOperation\Enums\Type::tryFromValue($resourceAttributes['type']) : null, - isset($resourceAttributes['unit_type']) ? \Chargebee\Resources\LedgerOperation\Enums\UnitType::tryFromValue($resourceAttributes['unit_type']) : null, + + isset($resourceAttributes['type']) ? \Chargebee\Resources\LedgerOperation\Enums\Type::tryFromValue($resourceAttributes['type']) : null, ); @@ -178,6 +178,8 @@ public function toArray(): array { $data = array_filter(['id' => $this->id, + 'subscription_id' => $this->subscription_id, + 'unit_id' => $this->unit_id, 'amount' => $this->amount, 'provisioned_start_balance' => $this->provisioned_start_balance, 'provisioned_end_balance' => $this->provisioned_end_balance, @@ -188,14 +190,12 @@ public function toArray(): array 'auto_release_timestamp' => $this->auto_release_timestamp, 'created_at' => $this->created_at, 'modified_at' => $this->modified_at, - 'subscription_id' => $this->subscription_id, - 'unit_id' => $this->unit_id, 'metadata' => $this->metadata, - 'type' => $this->type?->value, - 'unit_type' => $this->unit_type?->value, + 'type' => $this->type?->value, + ], function ($value) { return $value !== null; }); diff --git a/src/Resources/PaymentIntent/Enums/PaymentMethodType.php b/src/Resources/PaymentIntent/Enums/PaymentMethodType.php index c0e652d5..d829500b 100644 --- a/src/Resources/PaymentIntent/Enums/PaymentMethodType.php +++ b/src/Resources/PaymentIntent/Enums/PaymentMethodType.php @@ -51,6 +51,10 @@ enum PaymentMethodType : string { case PAYNOW = "paynow"; case BIZUM = "bizum"; case PROMPTPAY = "promptpay"; + case DANA = "dana"; + case TOUCH_N_GO = "touch_n_go"; + case TAMARA = "tamara"; + case QPAY = "qpay"; case UNKNOWN = "unknown"; public static function tryFromValue(string $value): self { diff --git a/src/Responses/CreditUnitResponse/ArchiveCreditUnitResponse.php b/src/Responses/CreditUnitResponse/ArchiveCreditUnitResponse.php new file mode 100644 index 00000000..5fcab4fb --- /dev/null +++ b/src/Responses/CreditUnitResponse/ArchiveCreditUnitResponse.php @@ -0,0 +1,45 @@ +credit_unit = $credit_unit; + + } + public static function from(array $resourceAttributes, array $headers = []): self + { + return new self( + isset($resourceAttributes['credit_unit']) ? CreditUnit::from($resourceAttributes['credit_unit']) : null, + $headers, $resourceAttributes); + } + + public function toArray(): array + { + $data = array_filter([ + ]); + + if($this->credit_unit instanceof CreditUnit){ + $data['credit_unit'] = $this->credit_unit->toArray(); + } + + return $data; + } +} +?> \ No newline at end of file diff --git a/src/Responses/CreditUnitResponse/CreateCreditUnitResponse.php b/src/Responses/CreditUnitResponse/CreateCreditUnitResponse.php new file mode 100644 index 00000000..833f7c4b --- /dev/null +++ b/src/Responses/CreditUnitResponse/CreateCreditUnitResponse.php @@ -0,0 +1,45 @@ +credit_unit = $credit_unit; + + } + public static function from(array $resourceAttributes, array $headers = []): self + { + return new self( + isset($resourceAttributes['credit_unit']) ? CreditUnit::from($resourceAttributes['credit_unit']) : null, + $headers, $resourceAttributes); + } + + public function toArray(): array + { + $data = array_filter([ + ]); + + if($this->credit_unit instanceof CreditUnit){ + $data['credit_unit'] = $this->credit_unit->toArray(); + } + + return $data; + } +} +?> \ No newline at end of file diff --git a/src/Responses/CreditUnitResponse/ListCreditUnitResponse.php b/src/Responses/CreditUnitResponse/ListCreditUnitResponse.php new file mode 100644 index 00000000..0ae0afcd --- /dev/null +++ b/src/Responses/CreditUnitResponse/ListCreditUnitResponse.php @@ -0,0 +1,54 @@ + $list + */ + public array $list; + + /** + * + * @var ?string $next_offset + */ + public ?string $next_offset; + + + private function __construct( + array $list, + ?string $next_offset, + array $responseHeaders=[], + array $rawResponse=[] + ) + { + parent::__construct($responseHeaders, $rawResponse); + $this->list = $list; + $this->next_offset = $next_offset; + + } + public static function from(array $resourceAttributes, array $headers = []): self + { + $list = array_map(function (array $result): ListCreditUnitResponseListObject { + return new ListCreditUnitResponseListObject( + isset($result['credit_unit']) ? CreditUnit::from($result['credit_unit']) : null, + );}, $resourceAttributes['list'] ?? []); + + return new self($list, + $resourceAttributes['next_offset'] ?? null, $headers, $resourceAttributes); + } + + public function toArray(): array + { + $data = array_filter([ + 'list' => $this->list, + 'next_offset' => $this->next_offset, + ]); + return $data; + } +} +?> \ No newline at end of file diff --git a/src/Responses/CreditUnitResponse/ListCreditUnitResponseListObject.php b/src/Responses/CreditUnitResponse/ListCreditUnitResponseListObject.php new file mode 100644 index 00000000..538ef469 --- /dev/null +++ b/src/Responses/CreditUnitResponse/ListCreditUnitResponseListObject.php @@ -0,0 +1,14 @@ +credit_unit = $credit_unit; + } +} diff --git a/src/Responses/CreditUnitResponse/ReactivateCreditUnitResponse.php b/src/Responses/CreditUnitResponse/ReactivateCreditUnitResponse.php new file mode 100644 index 00000000..797ab20b --- /dev/null +++ b/src/Responses/CreditUnitResponse/ReactivateCreditUnitResponse.php @@ -0,0 +1,45 @@ +credit_unit = $credit_unit; + + } + public static function from(array $resourceAttributes, array $headers = []): self + { + return new self( + isset($resourceAttributes['credit_unit']) ? CreditUnit::from($resourceAttributes['credit_unit']) : null, + $headers, $resourceAttributes); + } + + public function toArray(): array + { + $data = array_filter([ + ]); + + if($this->credit_unit instanceof CreditUnit){ + $data['credit_unit'] = $this->credit_unit->toArray(); + } + + return $data; + } +} +?> \ No newline at end of file diff --git a/src/Responses/CreditUnitResponse/UpdateCreditUnitResponse.php b/src/Responses/CreditUnitResponse/UpdateCreditUnitResponse.php new file mode 100644 index 00000000..955c9f5b --- /dev/null +++ b/src/Responses/CreditUnitResponse/UpdateCreditUnitResponse.php @@ -0,0 +1,45 @@ +credit_unit = $credit_unit; + + } + public static function from(array $resourceAttributes, array $headers = []): self + { + return new self( + isset($resourceAttributes['credit_unit']) ? CreditUnit::from($resourceAttributes['credit_unit']) : null, + $headers, $resourceAttributes); + } + + public function toArray(): array + { + $data = array_filter([ + ]); + + if($this->credit_unit instanceof CreditUnit){ + $data['credit_unit'] = $this->credit_unit->toArray(); + } + + return $data; + } +} +?> \ No newline at end of file diff --git a/src/Responses/LedgerOperationResponse/AllocateLedgerOperationResponse.php b/src/Responses/LedgerOperationResponse/AllocateLedgerOperationResponse.php new file mode 100644 index 00000000..b699c103 --- /dev/null +++ b/src/Responses/LedgerOperationResponse/AllocateLedgerOperationResponse.php @@ -0,0 +1,102 @@ + $ledger_operations + */ + public ?array $ledger_operations; + + /** + * + * @var ?array $grant_blocks + */ + public ?array $grant_blocks; + + /** + * + * @var ?array $ledger_entries + */ + public ?array $ledger_entries; + + + private function __construct( + ?LedgerAccountBalance $ledger_account_balance, + ?array $ledger_operations, + ?array $grant_blocks, + ?array $ledger_entries, + array $responseHeaders=[], + array $rawResponse=[] + ) + { + parent::__construct($responseHeaders, $rawResponse); + $this->ledger_account_balance = $ledger_account_balance; + $this->ledger_operations = $ledger_operations; + $this->grant_blocks = $grant_blocks; + $this->ledger_entries = $ledger_entries; + + } + public static function from(array $resourceAttributes, array $headers = []): self + { + $ledger_operations = array_map(fn (array $result): LedgerOperation => LedgerOperation::from( + $result + ), $resourceAttributes['ledger_operations'] ?? []); + + $grant_blocks = array_map(fn (array $result): GrantBlock => GrantBlock::from( + $result + ), $resourceAttributes['grant_blocks'] ?? []); + + $ledger_entries = array_map(fn (array $result): LedgerEntry => LedgerEntry::from( + $result + ), $resourceAttributes['ledger_entries'] ?? []); + + return new self( + isset($resourceAttributes['ledger_account_balance']) ? LedgerAccountBalance::from($resourceAttributes['ledger_account_balance']) : null, + $ledger_operations,$grant_blocks,$ledger_entries, $headers, $resourceAttributes); + } + + public function toArray(): array + { + $data = array_filter([ + ]); + + if($this->ledger_account_balance instanceof LedgerAccountBalance){ + $data['ledger_account_balance'] = $this->ledger_account_balance->toArray(); + } + + if($this->ledger_operations !== []) { + $data['ledger_operations'] = array_map( + fn (LedgerOperation $ledger_operations): array => $ledger_operations->toArray(), + $this->ledger_operations + ); + } + if($this->grant_blocks !== []) { + $data['grant_blocks'] = array_map( + fn (GrantBlock $grant_blocks): array => $grant_blocks->toArray(), + $this->grant_blocks + ); + } + if($this->ledger_entries !== []) { + $data['ledger_entries'] = array_map( + fn (LedgerEntry $ledger_entries): array => $ledger_entries->toArray(), + $this->ledger_entries + ); + } + return $data; + } +} +?> \ No newline at end of file diff --git a/src/Responses/LedgerOperationResponse/AuthorizeLedgerOperationResponse.php b/src/Responses/LedgerOperationResponse/AuthorizeLedgerOperationResponse.php index 395b7c8b..4cdfbaed 100644 --- a/src/Responses/LedgerOperationResponse/AuthorizeLedgerOperationResponse.php +++ b/src/Responses/LedgerOperationResponse/AuthorizeLedgerOperationResponse.php @@ -1,6 +1,8 @@ $grant_blocks + */ + public ?array $grant_blocks; + + /** + * + * @var ?array $ledger_entries + */ + public ?array $ledger_entries; + private function __construct( ?LedgerOperation $ledger_operation, ?LedgerAccountBalance $ledger_account_balance, + ?array $grant_blocks, + ?array $ledger_entries, array $responseHeaders=[], array $rawResponse=[] ) @@ -30,20 +46,30 @@ private function __construct( parent::__construct($responseHeaders, $rawResponse); $this->ledger_operation = $ledger_operation; $this->ledger_account_balance = $ledger_account_balance; + $this->grant_blocks = $grant_blocks; + $this->ledger_entries = $ledger_entries; } public static function from(array $resourceAttributes, array $headers = []): self { + $grant_blocks = array_map(fn (array $result): GrantBlock => GrantBlock::from( + $result + ), $resourceAttributes['grant_blocks'] ?? []); + + $ledger_entries = array_map(fn (array $result): LedgerEntry => LedgerEntry::from( + $result + ), $resourceAttributes['ledger_entries'] ?? []); + return new self( isset($resourceAttributes['ledger_operation']) ? LedgerOperation::from($resourceAttributes['ledger_operation']) : null, isset($resourceAttributes['ledger_account_balance']) ? LedgerAccountBalance::from($resourceAttributes['ledger_account_balance']) : null, - $headers, $resourceAttributes); + $grant_blocks,$ledger_entries, $headers, $resourceAttributes); } public function toArray(): array { - $data = array_filter([ + $data = array_filter([ ]); if($this->ledger_operation instanceof LedgerOperation){ @@ -51,8 +77,20 @@ public function toArray(): array } if($this->ledger_account_balance instanceof LedgerAccountBalance){ $data['ledger_account_balance'] = $this->ledger_account_balance->toArray(); - } + } + if($this->grant_blocks !== []) { + $data['grant_blocks'] = array_map( + fn (GrantBlock $grant_blocks): array => $grant_blocks->toArray(), + $this->grant_blocks + ); + } + if($this->ledger_entries !== []) { + $data['ledger_entries'] = array_map( + fn (LedgerEntry $ledger_entries): array => $ledger_entries->toArray(), + $this->ledger_entries + ); + } return $data; } } diff --git a/src/Responses/LedgerOperationResponse/CaptureAuthorizationLedgerOperationResponse.php b/src/Responses/LedgerOperationResponse/CaptureAuthorizationLedgerOperationResponse.php index a43d855f..f32a3976 100644 --- a/src/Responses/LedgerOperationResponse/CaptureAuthorizationLedgerOperationResponse.php +++ b/src/Responses/LedgerOperationResponse/CaptureAuthorizationLedgerOperationResponse.php @@ -1,6 +1,8 @@ $grant_blocks + */ + public ?array $grant_blocks; + + /** + * + * @var ?array $ledger_entries + */ + public ?array $ledger_entries; + private function __construct( ?LedgerOperation $ledger_operation, ?LedgerAccountBalance $ledger_account_balance, + ?array $grant_blocks, + ?array $ledger_entries, array $responseHeaders=[], array $rawResponse=[] ) @@ -30,20 +46,30 @@ private function __construct( parent::__construct($responseHeaders, $rawResponse); $this->ledger_operation = $ledger_operation; $this->ledger_account_balance = $ledger_account_balance; + $this->grant_blocks = $grant_blocks; + $this->ledger_entries = $ledger_entries; } public static function from(array $resourceAttributes, array $headers = []): self { + $grant_blocks = array_map(fn (array $result): GrantBlock => GrantBlock::from( + $result + ), $resourceAttributes['grant_blocks'] ?? []); + + $ledger_entries = array_map(fn (array $result): LedgerEntry => LedgerEntry::from( + $result + ), $resourceAttributes['ledger_entries'] ?? []); + return new self( isset($resourceAttributes['ledger_operation']) ? LedgerOperation::from($resourceAttributes['ledger_operation']) : null, isset($resourceAttributes['ledger_account_balance']) ? LedgerAccountBalance::from($resourceAttributes['ledger_account_balance']) : null, - $headers, $resourceAttributes); + $grant_blocks,$ledger_entries, $headers, $resourceAttributes); } public function toArray(): array { - $data = array_filter([ + $data = array_filter([ ]); if($this->ledger_operation instanceof LedgerOperation){ @@ -51,8 +77,20 @@ public function toArray(): array } if($this->ledger_account_balance instanceof LedgerAccountBalance){ $data['ledger_account_balance'] = $this->ledger_account_balance->toArray(); - } + } + if($this->grant_blocks !== []) { + $data['grant_blocks'] = array_map( + fn (GrantBlock $grant_blocks): array => $grant_blocks->toArray(), + $this->grant_blocks + ); + } + if($this->ledger_entries !== []) { + $data['ledger_entries'] = array_map( + fn (LedgerEntry $ledger_entries): array => $ledger_entries->toArray(), + $this->ledger_entries + ); + } return $data; } } diff --git a/src/Responses/LedgerOperationResponse/CaptureLedgerOperationResponse.php b/src/Responses/LedgerOperationResponse/CaptureLedgerOperationResponse.php index 1a62df12..e7fc56bc 100644 --- a/src/Responses/LedgerOperationResponse/CaptureLedgerOperationResponse.php +++ b/src/Responses/LedgerOperationResponse/CaptureLedgerOperationResponse.php @@ -1,6 +1,8 @@ $grant_blocks + */ + public ?array $grant_blocks; + + /** + * + * @var ?array $ledger_entries + */ + public ?array $ledger_entries; + private function __construct( ?LedgerOperation $ledger_operation, ?LedgerAccountBalance $ledger_account_balance, + ?array $grant_blocks, + ?array $ledger_entries, array $responseHeaders=[], array $rawResponse=[] ) @@ -30,20 +46,30 @@ private function __construct( parent::__construct($responseHeaders, $rawResponse); $this->ledger_operation = $ledger_operation; $this->ledger_account_balance = $ledger_account_balance; + $this->grant_blocks = $grant_blocks; + $this->ledger_entries = $ledger_entries; } public static function from(array $resourceAttributes, array $headers = []): self { + $grant_blocks = array_map(fn (array $result): GrantBlock => GrantBlock::from( + $result + ), $resourceAttributes['grant_blocks'] ?? []); + + $ledger_entries = array_map(fn (array $result): LedgerEntry => LedgerEntry::from( + $result + ), $resourceAttributes['ledger_entries'] ?? []); + return new self( isset($resourceAttributes['ledger_operation']) ? LedgerOperation::from($resourceAttributes['ledger_operation']) : null, isset($resourceAttributes['ledger_account_balance']) ? LedgerAccountBalance::from($resourceAttributes['ledger_account_balance']) : null, - $headers, $resourceAttributes); + $grant_blocks,$ledger_entries, $headers, $resourceAttributes); } public function toArray(): array { - $data = array_filter([ + $data = array_filter([ ]); if($this->ledger_operation instanceof LedgerOperation){ @@ -51,8 +77,20 @@ public function toArray(): array } if($this->ledger_account_balance instanceof LedgerAccountBalance){ $data['ledger_account_balance'] = $this->ledger_account_balance->toArray(); - } + } + if($this->grant_blocks !== []) { + $data['grant_blocks'] = array_map( + fn (GrantBlock $grant_blocks): array => $grant_blocks->toArray(), + $this->grant_blocks + ); + } + if($this->ledger_entries !== []) { + $data['ledger_entries'] = array_map( + fn (LedgerEntry $ledger_entries): array => $ledger_entries->toArray(), + $this->ledger_entries + ); + } return $data; } } diff --git a/src/Responses/LedgerOperationResponse/ReleaseAuthorizationLedgerOperationResponse.php b/src/Responses/LedgerOperationResponse/ReleaseAuthorizationLedgerOperationResponse.php index e237a08d..e173ea18 100644 --- a/src/Responses/LedgerOperationResponse/ReleaseAuthorizationLedgerOperationResponse.php +++ b/src/Responses/LedgerOperationResponse/ReleaseAuthorizationLedgerOperationResponse.php @@ -1,6 +1,8 @@ $grant_blocks + */ + public ?array $grant_blocks; + + /** + * + * @var ?array $ledger_entries + */ + public ?array $ledger_entries; + private function __construct( ?LedgerOperation $ledger_operation, ?LedgerAccountBalance $ledger_account_balance, + ?array $grant_blocks, + ?array $ledger_entries, array $responseHeaders=[], array $rawResponse=[] ) @@ -30,20 +46,30 @@ private function __construct( parent::__construct($responseHeaders, $rawResponse); $this->ledger_operation = $ledger_operation; $this->ledger_account_balance = $ledger_account_balance; + $this->grant_blocks = $grant_blocks; + $this->ledger_entries = $ledger_entries; } public static function from(array $resourceAttributes, array $headers = []): self { + $grant_blocks = array_map(fn (array $result): GrantBlock => GrantBlock::from( + $result + ), $resourceAttributes['grant_blocks'] ?? []); + + $ledger_entries = array_map(fn (array $result): LedgerEntry => LedgerEntry::from( + $result + ), $resourceAttributes['ledger_entries'] ?? []); + return new self( isset($resourceAttributes['ledger_operation']) ? LedgerOperation::from($resourceAttributes['ledger_operation']) : null, isset($resourceAttributes['ledger_account_balance']) ? LedgerAccountBalance::from($resourceAttributes['ledger_account_balance']) : null, - $headers, $resourceAttributes); + $grant_blocks,$ledger_entries, $headers, $resourceAttributes); } public function toArray(): array { - $data = array_filter([ + $data = array_filter([ ]); if($this->ledger_operation instanceof LedgerOperation){ @@ -51,8 +77,20 @@ public function toArray(): array } if($this->ledger_account_balance instanceof LedgerAccountBalance){ $data['ledger_account_balance'] = $this->ledger_account_balance->toArray(); - } + } + if($this->grant_blocks !== []) { + $data['grant_blocks'] = array_map( + fn (GrantBlock $grant_blocks): array => $grant_blocks->toArray(), + $this->grant_blocks + ); + } + if($this->ledger_entries !== []) { + $data['ledger_entries'] = array_map( + fn (LedgerEntry $ledger_entries): array => $ledger_entries->toArray(), + $this->ledger_entries + ); + } return $data; } } diff --git a/src/Version.php b/src/Version.php index ab47d5eb..d50c6817 100644 --- a/src/Version.php +++ b/src/Version.php @@ -4,7 +4,7 @@ final class Version { - const VERSION = '4.24.0'; + const VERSION = '4.25.0'; } ?> \ No newline at end of file