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: diff --git a/recurly/client.py b/recurly/client.py index c45af3fa..8664fad3 100644 --- a/recurly/client.py +++ b/recurly/client.py @@ -840,6 +840,64 @@ def remove_coupon_redemption(self, account_id, **options): ) return self._make_request("DELETE", path, None, **options) + def get_coupon_redemption(self, account_id, coupon_redemption_id, **options): + """Show the coupon redemption + + Parameters + ---------- + + account_id : str + Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`. + coupon_redemption_id : str + Coupon Redemption ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + + Keyword Arguments + ----------------- + + headers : dict + Extra HTTP headers to send with the request. + + Returns + ------- + + CouponRedemption + A coupon redemption. + """ + path = self._interpolate_path( + "/accounts/%s/coupon_redemptions/%s", account_id, coupon_redemption_id + ) + return self._make_request("GET", path, None, **options) + + def remove_coupon_redemption_by_id( + self, account_id, coupon_redemption_id, **options + ): + """Delete the coupon redemption + + Parameters + ---------- + + account_id : str + Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`. + coupon_redemption_id : str + Coupon Redemption ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + + Keyword Arguments + ----------------- + + headers : dict + Extra HTTP headers to send with the request. + + Returns + ------- + + CouponRedemption + Coupon redemption deleted. + """ + path = self._interpolate_path( + "/accounts/%s/coupon_redemptions/%s", account_id, coupon_redemption_id + ) + return self._make_request("DELETE", path, None, **options) + def list_account_credit_payments(self, account_id, **options): """List an account's credit payments @@ -4874,6 +4932,70 @@ def list_subscription_coupon_redemptions(self, subscription_id, **options): ) return Pager(self, path, **options) + def get_subscription_coupon_redemption( + self, subscription_id, coupon_redemption_id, **options + ): + """Show the coupon redemption for a subscription + + Parameters + ---------- + + subscription_id : str + Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + coupon_redemption_id : str + Coupon Redemption ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + + Keyword Arguments + ----------------- + + headers : dict + Extra HTTP headers to send with the request. + + Returns + ------- + + CouponRedemption + The coupon redemption on a subscription. + """ + path = self._interpolate_path( + "/subscriptions/%s/coupon_redemptions/%s", + subscription_id, + coupon_redemption_id, + ) + return self._make_request("GET", path, None, **options) + + def remove_subscription_coupon_redemption( + self, subscription_id, coupon_redemption_id, **options + ): + """Delete the coupon redemption from a subscription + + Parameters + ---------- + + subscription_id : str + Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + coupon_redemption_id : str + Coupon Redemption ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`. + + Keyword Arguments + ----------------- + + headers : dict + Extra HTTP headers to send with the request. + + Returns + ------- + + CouponRedemption + Coupon redemption deleted. + """ + path = self._interpolate_path( + "/subscriptions/%s/coupon_redemptions/%s", + subscription_id, + coupon_redemption_id, + ) + return self._make_request("DELETE", path, None, **options) + def list_usage(self, subscription_id, add_on_id, **options): """List a subscription add-on's usage records diff --git a/recurly/resources.py b/recurly/resources.py index 991bb423..3c28bbb7 100644 --- a/recurly/resources.py +++ b/recurly/resources.py @@ -1032,6 +1032,8 @@ class CouponRedemption(Resource): Subscription ID updated_at : datetime Last updated at + uuid : str + The UUID is useful for matching data with the CSV exports and building URLs into Recurly's UI. """ schema = { @@ -1046,6 +1048,7 @@ class CouponRedemption(Resource): "state": str, "subscription_id": str, "updated_at": datetime, + "uuid": str, } @@ -2037,12 +2040,15 @@ class InvoiceCollection(Resource): Credit invoices object : str Object type + verification_transactions : :obj:`list` of :obj:`Transaction` + Verification transactions (used for free trial payment method validation) """ schema = { "charge_invoice": "Invoice", "credit_invoices": ["Invoice"], "object": str, + "verification_transactions": ["Transaction"], } @@ -2132,7 +2138,9 @@ class Subscription(Resource): Created at credit_application_policy : CreditApplicationPolicy 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. currency : str 3-letter ISO 4217 currency code. current_period_ends_at : datetime @@ -2693,6 +2701,10 @@ class CreditApplicationPolicy(Resource): """ Attributes ---------- + allowed_origins : :obj:`list` of :obj:`str` + 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`. mode : str Determines which credit invoices are applied to invoices: - `all`: All available credit invoices are applied (default) @@ -2700,6 +2712,7 @@ class CreditApplicationPolicy(Resource): """ schema = { + "allowed_origins": list, "mode": str, }