diff --git a/lib/recurly/client.php b/lib/recurly/client.php index 0db45bbd..45d89469 100644 --- a/lib/recurly/client.php +++ b/lib/recurly/client.php @@ -543,6 +543,38 @@ public function removeCouponRedemption(string $account_id, array $options = []): return $this->makeRequest('DELETE', $path, [], $options); } + /** + * Show the coupon redemption + * + * @param string $account_id Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`. + * @param string $coupon_redemption_id Coupon Redemption ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + * @param array $options Associative array of optional parameters + * + * @return \Recurly\Resources\CouponRedemption A coupon redemption. + * @link https://developers.recurly.com/api/v2021-02-25#operation/get_coupon_redemption + */ + public function getCouponRedemption(string $account_id, string $coupon_redemption_id, array $options = []): \Recurly\Resources\CouponRedemption + { + $path = $this->interpolatePath("/accounts/{account_id}/coupon_redemptions/{coupon_redemption_id}", ['account_id' => $account_id, 'coupon_redemption_id' => $coupon_redemption_id]); + return $this->makeRequest('GET', $path, [], $options); + } + + /** + * Delete the coupon redemption + * + * @param string $account_id Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`. + * @param string $coupon_redemption_id Coupon Redemption ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + * @param array $options Associative array of optional parameters + * + * @return \Recurly\Resources\CouponRedemption Coupon redemption deleted. + * @link https://developers.recurly.com/api/v2021-02-25#operation/remove_coupon_redemption_by_id + */ + public function removeCouponRedemptionById(string $account_id, string $coupon_redemption_id, array $options = []): \Recurly\Resources\CouponRedemption + { + $path = $this->interpolatePath("/accounts/{account_id}/coupon_redemptions/{coupon_redemption_id}", ['account_id' => $account_id, 'coupon_redemption_id' => $coupon_redemption_id]); + return $this->makeRequest('DELETE', $path, [], $options); + } + /** * List an account's credit payments * @@ -3196,6 +3228,38 @@ public function listSubscriptionCouponRedemptions(string $subscription_id, array return new \Recurly\Pager($this, $path, $options); } + /** + * Show the coupon redemption for a subscription + * + * @param string $subscription_id Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + * @param string $coupon_redemption_id Coupon Redemption ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + * @param array $options Associative array of optional parameters + * + * @return \Recurly\Resources\CouponRedemption The coupon redemption on a subscription. + * @link https://developers.recurly.com/api/v2021-02-25#operation/get_subscription_coupon_redemption + */ + public function getSubscriptionCouponRedemption(string $subscription_id, string $coupon_redemption_id, array $options = []): \Recurly\Resources\CouponRedemption + { + $path = $this->interpolatePath("/subscriptions/{subscription_id}/coupon_redemptions/{coupon_redemption_id}", ['subscription_id' => $subscription_id, 'coupon_redemption_id' => $coupon_redemption_id]); + return $this->makeRequest('GET', $path, [], $options); + } + + /** + * Delete the coupon redemption from a subscription + * + * @param string $subscription_id Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + * @param string $coupon_redemption_id Coupon Redemption ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + * @param array $options Associative array of optional parameters + * + * @return \Recurly\Resources\CouponRedemption Coupon redemption deleted. + * @link https://developers.recurly.com/api/v2021-02-25#operation/remove_subscription_coupon_redemption + */ + public function removeSubscriptionCouponRedemption(string $subscription_id, string $coupon_redemption_id, array $options = []): \Recurly\Resources\CouponRedemption + { + $path = $this->interpolatePath("/subscriptions/{subscription_id}/coupon_redemptions/{coupon_redemption_id}", ['subscription_id' => $subscription_id, 'coupon_redemption_id' => $coupon_redemption_id]); + return $this->makeRequest('DELETE', $path, [], $options); + } + /** * List a subscription add-on's usage records * diff --git a/lib/recurly/resources/coupon_redemption.php b/lib/recurly/resources/coupon_redemption.php index 171ce335..e38696f4 100644 --- a/lib/recurly/resources/coupon_redemption.php +++ b/lib/recurly/resources/coupon_redemption.php @@ -23,6 +23,7 @@ class CouponRedemption extends RecurlyResource private $_state; private $_subscription_id; private $_updated_at; + private $_uuid; protected static $array_hints = [ ]; @@ -280,4 +281,27 @@ public function setUpdatedAt(string $updated_at): void { $this->_updated_at = $updated_at; } + + /** + * Getter method for the uuid attribute. + * The UUID is useful for matching data with the CSV exports and building URLs into Recurly's UI. + * + * @return ?string + */ + public function getUuid(): ?string + { + return $this->_uuid; + } + + /** + * Setter method for the uuid attribute. + * + * @param string $uuid + * + * @return void + */ + public function setUuid(string $uuid): void + { + $this->_uuid = $uuid; + } } \ No newline at end of file diff --git a/lib/recurly/resources/credit_application_policy.php b/lib/recurly/resources/credit_application_policy.php index fcdaf0d1..d836e0ce 100644 --- a/lib/recurly/resources/credit_application_policy.php +++ b/lib/recurly/resources/credit_application_policy.php @@ -12,12 +12,40 @@ // phpcs:disable class CreditApplicationPolicy extends RecurlyResource { + private $_allowed_origins; private $_mode; protected static $array_hints = [ + 'setAllowedOrigins' => 'string', ]; + /** + * Getter method for the allowed_origins attribute. + * Optional array of credit invoice origin types to allow when mode is `all`. +If not specified when mode is `all`, credits from all origins are applied. +Only valid when mode is `all`. + + * + * @return array + */ + public function getAllowedOrigins(): array + { + return $this->_allowed_origins ?? [] ; + } + + /** + * Setter method for the allowed_origins attribute. + * + * @param array $allowed_origins + * + * @return void + */ + public function setAllowedOrigins(array $allowed_origins): void + { + $this->_allowed_origins = $allowed_origins; + } + /** * Getter method for the mode attribute. * Determines which credit invoices are applied to invoices: diff --git a/lib/recurly/resources/invoice_collection.php b/lib/recurly/resources/invoice_collection.php index 283bc43a..2c59ddb0 100644 --- a/lib/recurly/resources/invoice_collection.php +++ b/lib/recurly/resources/invoice_collection.php @@ -15,9 +15,11 @@ class InvoiceCollection extends RecurlyResource private $_charge_invoice; private $_credit_invoices; private $_object; + private $_verification_transactions; protected static $array_hints = [ 'setCreditInvoices' => '\Recurly\Resources\Invoice', + 'setVerificationTransactions' => '\Recurly\Resources\Transaction', ]; @@ -89,4 +91,27 @@ public function setObject(string $object): void { $this->_object = $object; } + + /** + * Getter method for the verification_transactions attribute. + * Verification transactions (used for free trial payment method validation) + * + * @return array + */ + public function getVerificationTransactions(): array + { + return $this->_verification_transactions ?? [] ; + } + + /** + * Setter method for the verification_transactions attribute. + * + * @param array $verification_transactions + * + * @return void + */ + public function setVerificationTransactions(array $verification_transactions): void + { + $this->_verification_transactions = $verification_transactions; + } } \ No newline at end of file diff --git a/lib/recurly/resources/subscription.php b/lib/recurly/resources/subscription.php index b7d9cdfb..2025763a 100644 --- a/lib/recurly/resources/subscription.php +++ b/lib/recurly/resources/subscription.php @@ -425,7 +425,9 @@ public function setCreatedAt(string $created_at): void /** * Getter method for the credit_application_policy attribute. * Controls whether credit invoices are automatically applied to new invoices. -The `mode` field determines the application behavior. +The `mode` field determines the application behavior. When mode is `all`, +the optional `allowed_origins` array can restrict which credit invoice origins +are applied. * * @return ?\Recurly\Resources\CreditApplicationPolicy diff --git a/openapi/api.yaml b/openapi/api.yaml index bcc620f0..5e94bcf3 100644 --- a/openapi/api.yaml +++ b/openapi/api.yaml @@ -3312,6 +3312,70 @@ paths: {\n\t\tfmt.Printf(\"Resource not found: %v\", e)\n\t\treturn nil, err\n\t}\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\n\nfmt.Printf(\"Removed Coupon Redemption: %v\", couponRedemption.Id)" + "/accounts/{account_id}/coupon_redemptions/{coupon_redemption_id}": + get: + tags: + - coupon_redemption + operationId: get_coupon_redemption + summary: Show the coupon redemption + parameters: + - "$ref": "#/components/parameters/account_id" + - "$ref": "#/components/parameters/coupon_redemption_id" + responses: + '200': + description: A coupon redemption. + content: + application/json: + schema: + "$ref": "#/components/schemas/CouponRedemption" + '404': + description: Incorrect site, account ID, or coupon redemption ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + delete: + tags: + - coupon_redemption + operationId: remove_coupon_redemption_by_id + summary: Delete the coupon redemption + description: Deactivate the coupon redemption on an account. + parameters: + - "$ref": "#/components/parameters/account_id" + - "$ref": "#/components/parameters/coupon_redemption_id" + responses: + '200': + description: Coupon redemption deleted. + content: + application/json: + schema: + "$ref": "#/components/schemas/CouponRedemption" + '404': + description: Incorrect site, account ID, or coupon redemption ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '422': + description: The coupon redemption is already expired or inactive. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] "/accounts/{account_id}/credit_payments": get: tags: @@ -14749,6 +14813,70 @@ paths: e, ok := err.(*recurly.Error); ok {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, redemption := range subCouponRedemptions.Data() {\n\t\tfmt.Printf(\"Subscription Coupon Redemption %3d: %s\\n\",\n\t\t\ti,\n\t\t\tredemption.Id,\n\t\t)\n\t}\n}" + "/subscriptions/{subscription_id}/coupon_redemptions/{coupon_redemption_id}": + get: + tags: + - coupon_redemption + operationId: get_subscription_coupon_redemption + summary: Show the coupon redemption for a subscription + parameters: + - "$ref": "#/components/parameters/subscription_id" + - "$ref": "#/components/parameters/coupon_redemption_id" + responses: + '200': + description: The coupon redemption on a subscription. + content: + application/json: + schema: + "$ref": "#/components/schemas/CouponRedemption" + '404': + description: Incorrect site, subscription ID, or coupon redemption ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + delete: + tags: + - coupon_redemption + operationId: remove_subscription_coupon_redemption + summary: Delete the coupon redemption from a subscription + description: Deactivate the coupon redemption on a subscription. + parameters: + - "$ref": "#/components/parameters/subscription_id" + - "$ref": "#/components/parameters/coupon_redemption_id" + responses: + '200': + description: Coupon redemption deleted. + content: + application/json: + schema: + "$ref": "#/components/schemas/CouponRedemption" + '404': + description: Incorrect site, subscription ID, or coupon redemption ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '422': + description: The coupon redemption is already expired or inactive. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] "/subscriptions/{subscription_id}/add_ons/{add_on_id}/usage": get: tags: @@ -17051,6 +17179,14 @@ components: required: true schema: type: string + coupon_redemption_id: + name: coupon_redemption_id + in: path + description: Coupon Redemption ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. + For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + required: true + schema: + type: string credit_payment_id: name: credit_payment_id in: path @@ -19754,6 +19890,13 @@ components: title: Object type description: Will always be `coupon`. readOnly: true + uuid: + type: string + title: Recurly UUID + description: The UUID is useful for matching data with the CSV exports and + building URLs into Recurly's UI. + maxLength: 32 + readOnly: true account: type: object title: Account @@ -20974,6 +21117,13 @@ components: title: Credit invoices items: "$ref": "#/components/schemas/Invoice" + verification_transactions: + type: array + title: Verification transactions + description: Verification transactions (used for free trial payment method + validation) + items: + "$ref": "#/components/schemas/Transaction" InvoiceUpdate: type: object properties: @@ -27104,10 +27254,20 @@ components: title: Credit Application Policy description: | Controls whether credit invoices are automatically applied to new invoices. - The `mode` field determines the application behavior. + The `mode` field determines the application behavior. When mode is `all`, + the optional `allowed_origins` array can restrict which credit invoice origins + are applied. properties: mode: "$ref": "#/components/schemas/CreditApplicationModeEnum" + allowed_origins: + type: array + description: | + Optional array of credit invoice origin types to allow when mode is `all`. + If not specified when mode is `all`, credits from all origins are applied. + Only valid when mode is `all`. + items: + "$ref": "#/components/schemas/CreditApplicationAllowedOriginTypeEnum" required: - mode CreditApplicationModeEnum: @@ -27121,6 +27281,25 @@ components: - all - none default: all + CreditApplicationAllowedOriginTypeEnum: + type: string + title: Credit Application Allowed Origin Type + description: The origin type of a credit invoice that can be allowed in a credit + application policy + enum: + - line_item_refund + - open_amount_refund + - immediate_change + - termination + - credit + - write_off + - refund + - external_refund + - carryforward_credit + - usage_correction + - prepayment + - gift_card + - carryforward_gift_credit InvoiceRefundTypeEnum: type: string enum: