From 611c58aa691171b53ef17dfcc8461a36b98ad745 Mon Sep 17 00:00:00 2001 From: DX Codefresh Date: Mon, 6 Feb 2023 22:49:37 +0000 Subject: [PATCH] Generated Latest Changes for v2021-02-25 --- openapi/api.yaml | 508 +++++++++++++++++++++++++++++++++++++++++++ recurly/client.py | 116 ++++++++++ recurly/resources.py | 104 +++++++++ 3 files changed, 728 insertions(+) diff --git a/openapi/api.yaml b/openapi/api.yaml index ea341f0a..e288d72f 100644 --- a/openapi/api.yaml +++ b/openapi/api.yaml @@ -201,6 +201,7 @@ x-tagGroups: - automated_exports - external_subscriptions - external_products + - gift_cards - name: Products and Promotions tags: - item @@ -350,6 +351,10 @@ tags: description: A product from an external resource that is not managed by the Recurly platform and instead is managed by third-party platforms like Apple App Store and Google Play Store. +- name: gift_cards + x-displayName: Gift Cards + description: Add gift card purchases to your checkout and allow gift card recipients + to redeem the gift card for credit towards any of your products. paths: "/sites": get: @@ -15402,6 +15407,175 @@ paths: schema: "$ref": "#/components/schemas/Error" x-code-samples: [] + "/gift_cards": + get: + tags: + - gift_cards + operationId: list_gift_cards + summary: List gift cards + responses: + '200': + description: List of all created gift cards on your site. + content: + application/json: + schema: + "$ref": "#/components/schemas/GiftCardList" + '404': + description: Incorrect site. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + post: + tags: + - gift_cards + operationId: create_gift_card + summary: Create gift card + requestBody: + content: + application/json: + schema: + "$ref": "#/components/schemas/GiftCardCreate" + required: true + responses: + '201': + description: Returns the gift card + content: + application/json: + schema: + "$ref": "#/components/schemas/GiftCard" + '400': + description: Bad request; perhaps missing or invalid parameters. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '422': + description: Gift card cannot be completed for the specified reason. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + "/gift_cards/{gift_card_id}": + parameters: + - "$ref": "#/components/parameters/gift_card_id" + get: + tags: + - gift_cards + operationId: get_gift_card + summary: Fetch a gift card + responses: + '200': + description: Gift card details + content: + application/json: + schema: + "$ref": "#/components/schemas/GiftCard" + '404': + description: Incorrect site or gift card ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + "/gift_cards/preview": + post: + tags: + - gift_cards + operationId: preview_gift_card + summary: Preview gift card + requestBody: + content: + application/json: + schema: + "$ref": "#/components/schemas/GiftCardCreate" + required: true + responses: + '201': + description: Returns the gift card + content: + application/json: + schema: + "$ref": "#/components/schemas/GiftCard" + '400': + description: Bad request; perhaps missing or invalid parameters. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '422': + description: Gift card cannot be completed for the specified reason. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + "/gift_cards/{redemption_code}/redeem": + parameters: + - "$ref": "#/components/parameters/redemption_code" + post: + tags: + - gift_cards + operationId: redeem_gift_card + summary: Redeem gift card + requestBody: + content: + application/json: + schema: + "$ref": "#/components/schemas/GiftCardRedeem" + required: true + responses: + '201': + description: Redeems and returns the gift card + content: + application/json: + schema: + "$ref": "#/components/schemas/GiftCard" + '400': + description: Bad request; perhaps missing or invalid parameters. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '422': + description: Gift card cannot be redeemed for the specified reason. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] servers: - url: https://v3.recurly.com - url: https://v3.eu.recurly.com @@ -15576,6 +15750,20 @@ components: required: true schema: type: string + gift_card_id: + name: gift_card_id + in: path + description: Gift Card ID, e.g. `e28zov4fw0v2`. + required: true + schema: + type: string + redemption_code: + name: redemption_code + in: path + description: Gift Card redemption code, e.g., `N1A2T8IRXSCMO40V`. + required: true + schema: + type: string ids: name: ids in: query @@ -16257,6 +16445,15 @@ components: required: - code - "$ref": "#/components/schemas/AccountUpdate" + AccountReference: + type: object + properties: + id: + type: string + maxLength: 13 + code: + type: string + maxLength: 50 AccountUpdate: type: object properties: @@ -20721,6 +20918,16 @@ components: subscription. maxLength: 13 readOnly: true + started_with_gift: + type: boolean + default: false + description: Whether the subscription was started with a gift certificate. + title: Started with Gift + converted_at: + type: string + format: date-time + description: When the subscription was converted from a gift card. + title: Converted at SubscriptionAddOn: type: object title: Subscription Add-on @@ -21433,6 +21640,11 @@ components: created by this request. Supports 'moto' value, which is the acronym for mail order and telephone transactions. "$ref": "#/components/schemas/GatewayTransactionTypeEnum" + gift_card_redemption_code: + type: string + title: Gift card Redemption Code + description: A gift card redemption code to be redeemed on the purchase + invoice. required: - plan_code - currency @@ -22850,6 +23062,262 @@ components: type: string description: Username of the associated payment method. Currently only associated with Venmo. + GiftCardList: + type: object + properties: + object: + type: string + title: Object type + description: Will always be List. + has_more: + type: boolean + description: Indicates there are more results on subsequent pages. + next: + type: string + description: Path to subsequent page of results. + data: + type: array + items: + "$ref": "#/components/schemas/GiftCard" + GiftCard: + type: object + description: Gift card details + properties: + id: + title: Gift card ID + type: string + maxLength: 13 + readOnly: true + object: + title: Object type + type: string + readOnly: true + gifter_account_id: + title: Gifter account ID + type: string + maxLength: 13 + description: The ID of the account that purchased the gift card. + recipient_account_id: + title: Recipient account ID + type: string + maxLength: 13 + description: The ID of the account that redeemed the gift card redemption + code. Does not have a value until gift card is redeemed. + purchase_invoice_id: + title: Purchase invoice ID + type: string + maxLength: 13 + description: The ID of the invoice for the gift card purchase made by the + gifter. + redemption_invoice_id: + title: Redemption invoice ID + type: string + maxLength: 13 + description: The ID of the invoice for the gift card redemption made by + the recipient. Does not have a value until gift card is redeemed. + redemption_code: + title: Redemption code + type: string + description: The unique redemption code for the gift card, generated by + Recurly. Will be 16 characters, alphanumeric, displayed uppercase, but + accepted in any case at redemption. Used by the recipient account to create + a credit in the amount of the `unit_amount` on their account. + balance: + title: Remaining balance + type: number + format: float + description: The remaining credit on the recipient account associated with + this gift card. Only has a value once the gift card has been redeemed. + Can be used to create gift card balance displays for your customers. + product_code: + title: Product code + type: string + description: The product code or SKU of the gift card product. + unit_amount: + title: Purchase unit amount + type: number + format: float + description: The amount of the gift card, which is the amount of the charge + to the gifter account and the amount of credit that is applied to the + recipient account upon successful redemption. + currency: + title: Currency + type: string + description: 3-letter ISO 4217 currency code. + maxLength: 3 + delivery: + title: Delivery details + description: The delivery details for the gift card. + readOnly: true + "$ref": "#/components/schemas/GiftCardDelivery" + created_at: + type: string + format: date-time + title: Created at + readOnly: true + updated_at: + type: string + format: date-time + title: Last updated at + readOnly: true + delivered_at: + type: string + format: date-time + title: Delivered at + readOnly: true + description: When the gift card was sent to the recipient by Recurly via + email, if method was email and the "Gift Card Delivery" email template + was enabled. This will be empty for post delivery or email delivery where + the email template was disabled. + redeemed_at: + type: string + format: date-time + title: Redeemed at + readOnly: true + description: When the gift card was redeemed by the recipient. + canceled_at: + type: string + format: date-time + title: Canceled at + readOnly: true + description: When the gift card was canceled. + GiftCardCreate: + type: object + description: Gift card details + properties: + product_code: + title: Product code + type: string + description: The product code or SKU of the gift card product. + unit_amount: + title: Purchase unit amount + type: number + format: float + description: The amount of the gift card, which is the amount of the charge + to the gifter account and the amount of credit that is applied to the + recipient account upon successful redemption. + currency: + title: Currency + type: string + description: 3-letter ISO 4217 currency code. + maxLength: 3 + delivery: + title: Delivery details + description: The delivery details for the gift card. + readOnly: true + "$ref": "#/components/schemas/GiftCardDeliveryCreate" + gifter_account: + title: Gifter account details + description: Block of account details for the gifter. This references an + existing account_code. + readOnly: true + "$ref": "#/components/schemas/AccountPurchase" + required: + - product_code + - unit_amount + - currency + - delivery + - gifter_account + GiftCardDeliveryCreate: + type: object + description: Gift card delivery details + properties: + method: + title: Delivery method + description: Whether the delivery method is email or postal service. + "$ref": "#/components/schemas/DeliveryMethodEnum" + email_address: + title: Recipient email address + type: string + description: The email address of the recipient. Required if `method` is + `email`. + deliver_at: + type: string + format: date-time + title: Deliver at + readOnly: true + description: When the gift card should be delivered to the recipient. If + null, the gift card will be delivered immediately. If a datetime is provided, + the delivery will be in an hourly window, rounding down. For example, + 6:23 pm will be in the 6:00 pm hourly batch. + first_name: + title: Recipient first name + type: string + description: The first name of the recipient. + last_name: + title: Recipient last name + type: string + description: The last name of the recipient. + recipient_address: + title: Recipient address + description: Address information for the recipient. Required if `method` + is `post`. + "$ref": "#/components/schemas/Address" + gifter_name: + title: Gifter name + type: string + description: The name of the gifter for the purpose of a message displayed + to the recipient. + personal_message: + title: Personal message + type: string + maxLength: 255 + description: The personal message from the gifter to the recipient. + required: + - method + GiftCardDelivery: + type: object + description: Gift card delivery details + properties: + method: + title: Delivery method + description: Whether the delivery method is email or postal service. + "$ref": "#/components/schemas/DeliveryMethodEnum" + email_address: + title: Recipient email address + type: string + description: The email address of the recipient. + deliver_at: + type: string + format: date-time + title: Deliver at + readOnly: true + description: When the gift card should be delivered to the recipient. If + null, the gift card will be delivered immediately. If a datetime is provided, + the delivery will be in an hourly window, rounding down. For example, + 6:23 pm will be in the 6:00 pm hourly batch. + first_name: + title: Recipient first name + type: string + description: The first name of the recipient. + last_name: + title: Recipient last name + type: string + description: The last name of the recipient. + recipient_address: + title: Recipient address + description: Address information for the recipient. + "$ref": "#/components/schemas/Address" + gifter_name: + title: Gifter name + type: string + description: The name of the gifter for the purpose of a message displayed + to the recipient. + personal_message: + title: Personal message + type: string + maxLength: 255 + description: The personal message from the gifter to the recipient. + GiftCardRedeem: + type: object + description: The information necessary to redeem a gift card. + properties: + recipient_account: + title: Recipient account + description: The account for the recipient of the gift card. + "$ref": "#/components/schemas/AccountReference" + required: + - recipient_account Error: type: object properties: @@ -22891,6 +23359,9 @@ components: code: title: Code "$ref": "#/components/schemas/ErrorCodeEnum" + decline_code: + title: Decline code + "$ref": "#/components/schemas/DeclineCodeEnum" message: type: string title: Customer message @@ -23062,6 +23533,11 @@ components: enum: - parent - self + DeliveryMethodEnum: + type: string + enum: + - email + - post GatewayTransactionTypeEnum: type: string enum: @@ -23699,6 +24175,38 @@ components: - unmapped_partner_error - vaultly_service_unavailable - zero_dollar_auth_not_supported + DeclineCodeEnum: + type: string + enum: + - account_closed + - call_issuer + - card_not_activated + - card_not_supported + - cardholder_requested_stop + - do_not_honor + - do_not_try_again + - exceeds_daily_limit + - generic_decline + - expired_card + - fraudulent + - insufficient_funds + - incorrect_address + - incorrect_security_code + - invalid_amount + - invalid_number + - invalid_transaction + - issuer_unavailable + - lifecycle_decline + - lost_card + - pickup_card + - policy_decline + - restricted_card + - restricted_card_chargeback + - security_decline + - stolen_card + - try_again + - update_cardholder_data + - requires_3d_secure ExportDates: type: object properties: diff --git a/recurly/client.py b/recurly/client.py index 677b5ad8..d5fd71b2 100644 --- a/recurly/client.py +++ b/recurly/client.py @@ -4638,3 +4638,119 @@ def list_account_external_subscriptions(self, account_id, **options): """ path = self._interpolate_path("/accounts/%s/external_subscriptions", account_id) return Pager(self, path, **options) + + def list_gift_cards(self, **options): + """List gift cards + + Returns + ------- + + Pager + List of all created gift cards on your site. + """ + path = self._interpolate_path( + "/gift_cards", + ) + return Pager(self, path, **options) + + def create_gift_card(self, body, **options): + """Create gift card + + Parameters + ---------- + + body : dict + The request body. It should follow the schema of GiftCardCreate. + + Keyword Arguments + ----------------- + + headers : dict + Extra HTTP headers to send with the request. + + Returns + ------- + + GiftCard + Returns the gift card + """ + path = self._interpolate_path( + "/gift_cards", + ) + return self._make_request("POST", path, body, **options) + + def get_gift_card(self, gift_card_id, **options): + """Fetch a gift card + + Parameters + ---------- + + gift_card_id : str + Gift Card ID, e.g. `e28zov4fw0v2`. + + Keyword Arguments + ----------------- + + headers : dict + Extra HTTP headers to send with the request. + + Returns + ------- + + GiftCard + Gift card details + """ + path = self._interpolate_path("/gift_cards/%s", gift_card_id) + return self._make_request("GET", path, None, **options) + + def preview_gift_card(self, body, **options): + """Preview gift card + + Parameters + ---------- + + body : dict + The request body. It should follow the schema of GiftCardCreate. + + Keyword Arguments + ----------------- + + headers : dict + Extra HTTP headers to send with the request. + + Returns + ------- + + GiftCard + Returns the gift card + """ + path = self._interpolate_path( + "/gift_cards/preview", + ) + return self._make_request("POST", path, body, **options) + + def redeem_gift_card(self, redemption_code, body, **options): + """Redeem gift card + + Parameters + ---------- + + redemption_code : str + Gift Card redemption code, e.g., `N1A2T8IRXSCMO40V`. + body : dict + The request body. It should follow the schema of GiftCardRedeem. + + Keyword Arguments + ----------------- + + headers : dict + Extra HTTP headers to send with the request. + + Returns + ------- + + GiftCard + Redeems and returns the gift card + """ + path = self._interpolate_path("/gift_cards/%s/redeem", redemption_code) + return self._make_request("POST", path, body, **options) diff --git a/recurly/resources.py b/recurly/resources.py index d14f9b3b..19e48ddd 100644 --- a/recurly/resources.py +++ b/recurly/resources.py @@ -462,6 +462,8 @@ class TransactionError(Resource): Category code : str Code + decline_code : str + Decline code merchant_advice : str Merchant message message : str @@ -477,6 +479,7 @@ class TransactionError(Resource): schema = { "category": str, "code": str, + "decline_code": str, "merchant_advice": str, "message": str, "object": str, @@ -1599,6 +1602,8 @@ class Subscription(Resource): Canceled at collection_method : str Collection method + converted_at : datetime + When the subscription was converted from a gift card. coupon_redemptions : :obj:`list` of :obj:`CouponRedemptionMini` Returns subscription level coupon redemptions that are tied to this subscription. created_at : datetime @@ -1651,6 +1656,8 @@ class Subscription(Resource): Revenue schedule type shipping : SubscriptionShipping Subscription shipping details + started_with_gift : bool + Whether the subscription was started with a gift certificate. state : str State subtotal : float @@ -1690,6 +1697,7 @@ class Subscription(Resource): "billing_info_id": str, "canceled_at": datetime, "collection_method": str, + "converted_at": datetime, "coupon_redemptions": ["CouponRedemptionMini"], "created_at": datetime, "currency": str, @@ -1716,6 +1724,7 @@ class Subscription(Resource): "renewal_billing_cycles": int, "revenue_schedule_type": str, "shipping": "SubscriptionShipping", + "started_with_gift": bool, "state": str, "subtotal": float, "tax": float, @@ -3226,3 +3235,98 @@ class GrantedBy(Resource): "id": str, "object": str, } + + +class GiftCard(Resource): + """ + Attributes + ---------- + balance : float + The remaining credit on the recipient account associated with this gift card. Only has a value once the gift card has been redeemed. Can be used to create gift card balance displays for your customers. + canceled_at : datetime + When the gift card was canceled. + created_at : datetime + Created at + currency : str + 3-letter ISO 4217 currency code. + delivered_at : datetime + When the gift card was sent to the recipient by Recurly via email, if method was email and the "Gift Card Delivery" email template was enabled. This will be empty for post delivery or email delivery where the email template was disabled. + delivery : GiftCardDelivery + The delivery details for the gift card. + gifter_account_id : str + The ID of the account that purchased the gift card. + id : str + Gift card ID + object : str + Object type + product_code : str + The product code or SKU of the gift card product. + purchase_invoice_id : str + The ID of the invoice for the gift card purchase made by the gifter. + recipient_account_id : str + The ID of the account that redeemed the gift card redemption code. Does not have a value until gift card is redeemed. + redeemed_at : datetime + When the gift card was redeemed by the recipient. + redemption_code : str + The unique redemption code for the gift card, generated by Recurly. Will be 16 characters, alphanumeric, displayed uppercase, but accepted in any case at redemption. Used by the recipient account to create a credit in the amount of the `unit_amount` on their account. + redemption_invoice_id : str + The ID of the invoice for the gift card redemption made by the recipient. Does not have a value until gift card is redeemed. + unit_amount : float + The amount of the gift card, which is the amount of the charge to the gifter account and the amount of credit that is applied to the recipient account upon successful redemption. + updated_at : datetime + Last updated at + """ + + schema = { + "balance": float, + "canceled_at": datetime, + "created_at": datetime, + "currency": str, + "delivered_at": datetime, + "delivery": "GiftCardDelivery", + "gifter_account_id": str, + "id": str, + "object": str, + "product_code": str, + "purchase_invoice_id": str, + "recipient_account_id": str, + "redeemed_at": datetime, + "redemption_code": str, + "redemption_invoice_id": str, + "unit_amount": float, + "updated_at": datetime, + } + + +class GiftCardDelivery(Resource): + """ + Attributes + ---------- + deliver_at : datetime + When the gift card should be delivered to the recipient. If null, the gift card will be delivered immediately. If a datetime is provided, the delivery will be in an hourly window, rounding down. For example, 6:23 pm will be in the 6:00 pm hourly batch. + email_address : str + The email address of the recipient. + first_name : str + The first name of the recipient. + gifter_name : str + The name of the gifter for the purpose of a message displayed to the recipient. + last_name : str + The last name of the recipient. + method : str + Whether the delivery method is email or postal service. + personal_message : str + The personal message from the gifter to the recipient. + recipient_address : Address + Address information for the recipient. + """ + + schema = { + "deliver_at": datetime, + "email_address": str, + "first_name": str, + "gifter_name": str, + "last_name": str, + "method": str, + "personal_message": str, + "recipient_address": "Address", + }