Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 151 additions & 33 deletions openapi/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ tags:
allow for individual delivery and tracking.
- name: coupon_redemption
x-displayName: Coupon Redemption
description: Coupon redemptions are created when a coupon is applied to an account.
This allows you to track your promotions.
description: Coupon redemptions are created when a coupon is applied to an account
or subscription. This allows you to track your promotions.
- name: unique_coupon_code
x-displayName: Unique Coupon Code
description: Unique coupon codes are generated from bulk coupons.
Expand Down Expand Up @@ -1142,14 +1142,11 @@ paths:
const account = await client.deactivateAccount(accountId)
console.log('Deleted account: ', account.code)
} catch (err) {
if (err && err.type === 'not-found') {
if (err instanceof recurly.errors.NotFoundError) {
// If the request was not found, you may want to alert the user or
// just return null
console.log('Resource Not Found')
}
// If we don't know what to do with the err, we should
// probably re-raise and let our web framework and logger handle it
throw err
}
- lang: Python
source: |
Expand Down Expand Up @@ -1649,14 +1646,11 @@ paths:
const account = await client.reactivateAccount(accountId)
console.log('Reactivated account: ', account.code)
} catch (err) {
if (err && err.type === 'not_found') {
if (err instanceof recurly.errors.NotFoundError) {
// If the request was not found, you may want to alert the user or
// just return null
console.log('Resource Not Found')
}
// If we don't know what to do with the err, we should
// probably re-raise and let our web framework and logger handle it
throw err
}
- lang: Python
source: |
Expand Down Expand Up @@ -2678,7 +2672,7 @@ paths:
- account
- coupon_redemption
operationId: create_coupon_redemption
summary: Generate an active coupon redemption on an account
summary: Generate an active coupon redemption on an account or subscription
parameters:
- "$ref": "#/components/parameters/site_id"
- "$ref": "#/components/parameters/account_id"
Expand Down Expand Up @@ -5743,7 +5737,108 @@ paths:
application/json:
schema:
"$ref": "#/components/schemas/Error"
x-code-samples: []
x-code-samples:
- lang: Node.js
source: |
try {
const coupon = await client.restoreCoupon(couponId, {
name: "New Coupon Name"
})
console.log('Restored coupon: ', coupon.code)
} catch (err) {
if (err instanceof recurly.errors.NotFoundError) {
// If the request was not found, you may want to alert the user or
// just return null
console.log('Resource Not Found')
}

}
- lang: Python
source: |
try:
coupon = client.restore_coupon(coupon_id, {
"name": "New Coupon Name"
})
print("Restored Coupon %s" % coupon)
except recurly.errors.NotFoundError:
# If the resource was not found, you may want to alert the user or
# just return nil
print("Resource Not Found")
- lang: ".NET"
source: |
try
{
var couponReq = new CouponUpdate() {
Name = "New Coupon Name"
};
Coupon coupon = client.RestoreCoupon(couponId, couponReq);
Console.WriteLine($"Restored coupon {coupon.Code}");
}
catch (Recurly.Errors.Validation ex)
{
// If the request was not valid, you may want to tell your user
// why. You can find the invalid params and reasons in ex.Error.Params
Console.WriteLine($"Failed validation: {ex.Error.Message}");
}
catch (Recurly.Errors.ApiError ex)
{
// Use ApiError to catch a generic error from the API
Console.WriteLine($"Unexpected Recurly Error: {ex.Error.Message}");
}
- lang: Ruby
source: |
begin
coupon = @client.restore_coupon(coupon_id: coupon_id, body: {
name: "New Coupon Name"
})
puts "Restored coupon #{coupon}"
rescue Recurly::Errors::NotFoundError
# If the resource was not found, you may want to alert the user or
# just return nil
puts "Resource Not Found"
end
- lang: Java
source: |
try {
final CouponUpdate couponUpdate = new CouponUpdate();
couponUpdate.setName("New Coupon Name");

final Coupon coupon = client.restoreCoupon(couponId, couponUpdate);
System.out.println("Restored coupon: " + coupon.getCode());
} catch (ValidationException e) {
// If the request was not valid, you may want to tell your user
// why. You can find the invalid params and reasons in e.getError().getParams()
System.out.println("Failed validation: " + e.getError().getMessage());
} catch (ApiException e) {
// Use ApiException to catch a generic error from the API
System.out.println("Unexpected Recurly Error: " + e.getError().getMessage());
}
- lang: PHP
source: |
try {
$coupon_update = [
"name" => "New Coupon Name"
];
$coupon = $client->restoreCoupon($coupon_id, $coupon_update);

echo 'Restored Coupon:' . PHP_EOL;
var_dump($coupon);
} catch (\Recurly\Errors\NotFound $e) {
// Could not find the resource, you may want to inform the user
// or just return a NULL
echo 'Could not find resource.' . PHP_EOL;
var_dump($e);
} catch (\Recurly\RecurlyError $e) {
// Something bad happened... tell the user so that they can fix it?
echo 'Some unexpected Recurly error happened. Try again later.' . PHP_EOL;
}
- lang: Go
source: "updateReq := &recurly.CouponUpdate{\n\tName: recurly.String(\"New
Coupon Name\"),\n}\ncoupon, err := client.RestoreCoupon(couponId, updateReq)\nif
e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeValidation
{\n\t\tfmt.Printf(\"Failed validation: %v\", e)\n\t\treturn nil, err\n\t}\n\tfmt.Printf(\"Unexpected
Recurly error: %v\", e)\n\treturn nil, err\n}\nfmt.Printf(\"Restored Coupon:
%s\", coupon.Id)"
"/sites/{site_id}/coupons/{coupon_id}/unique_coupon_codes":
get:
tags:
Expand Down Expand Up @@ -6742,14 +6837,11 @@ paths:
const item = await client.deactivateItem(itemId)
console.log('Deleted item: ', item.code)
} catch (err) {
if (err && err.type === 'not-found') {
if (err instanceof recurly.errors.NotFoundError) {
// If the request was not found, you may want to alert the user or
// just return null
console.log('Resource Not Found')
}
// If we don't know what to do with the err, we should
// probably re-raise and let our web framework and logger handle it
throw err
}
- lang: Python
source: |
Expand Down Expand Up @@ -6866,14 +6958,11 @@ paths:
const item = await client.reactivateItem(itemId)
console.log('Reactivated item: ', item.code)
} catch (err) {
if (err && err.type === 'not_found') {
if (err instanceof recurly.errors.NotFoundError) {
// If the request was not found, you may want to alert the user or
// just return null
console.log('Resource Not Found')
}
// If we don't know what to do with the err, we should
// probably re-raise and let our web framework and logger handle it
throw err
}
- lang: Python
source: |
Expand Down Expand Up @@ -15065,7 +15154,7 @@ components:
maxLength: 255
company:
type: string
maxLength: 50
maxLength: 100
vat_number:
type: string
description: The VAT number of the account (to avoid having the VAT applied).
Expand Down Expand Up @@ -16117,6 +16206,17 @@ components:
- checking
- savings
description: The bank account type. (ACH only)
tax_identifier:
type: string
description: Tax identifier is required if adding a billing info that is
a consumer card in Brazil. This would be the customer's CPF, CPF is a
Brazilian tax identifier for all tax paying residents.
tax_identifier_type:
type: string
enum:
- cpf
description: this field and a value of 'cpf' are required if adding a billing
info that is an elo or hipercard type in Brazil.
primary_payment_method:
type: boolean
title: Primary Payment Method
Expand Down Expand Up @@ -16611,6 +16711,9 @@ components:
description: The Account on which the coupon was applied.
readOnly: true
"$ref": "#/components/schemas/AccountMini"
subscription_id:
type: string
title: Subscription ID
coupon:
"$ref": "#/components/schemas/Coupon"
state:
Expand Down Expand Up @@ -16658,6 +16761,9 @@ components:
title: Currency
description: 3-letter ISO 4217 currency code.
maxLength: 3
subscription_id:
type: string
title: Subscription ID
required:
- coupon_id
CouponRedemptionMini:
Expand Down Expand Up @@ -18631,13 +18737,13 @@ components:
the setup fee will be charged at the time of signup. Setup fees do not
increase with the quantity of a subscription plan.
minimum: 0
maximum: 100000
maximum: 1000000
unit_amount:
type: number
format: float
title: Unit price
minimum: 0
maximum: 100000
maximum: 1000000
PlanUpdate:
type: object
properties:
Expand Down Expand Up @@ -18770,11 +18876,6 @@ components:
type: object
title: Hosted pages settings
"$ref": "#/components/schemas/PlanHostedPages"
add_ons:
type: array
title: Add Ons
items:
"$ref": "#/components/schemas/AddOnCreate"
allow_any_item_on_subscriptions:
type: boolean
title: Allow any item on subscriptions
Expand All @@ -18795,7 +18896,7 @@ components:
format: float
title: Unit price
minimum: 0
maximum: 100000
maximum: 1000000
required:
- currency
- unit_amount
Expand All @@ -18812,7 +18913,7 @@ components:
format: float
title: Unit price
minimum: 0
maximum: 100000
maximum: 1000000
required:
- currency
- unit_amount
Expand Down Expand Up @@ -19611,6 +19712,7 @@ components:
* Optionally, override the add-on's default unit amount.
* If the plan add-on's `tier_type` is `tiered`, `volume`, or `stairstep`, then `unit_amount` must be absent.
minimum: 0
maximum: 1000000
tiers:
type: array
title: Tiers
Expand Down Expand Up @@ -19684,6 +19786,7 @@ components:
title: Unit amount
description: Optionally, override the add-on's default unit amount.
minimum: 0
maximum: 1000000
tiers:
type: array
title: Tiers
Expand Down Expand Up @@ -19724,6 +19827,7 @@ components:
format: float
title: Unit amount
minimum: 0
maximum: 1000000
SubscriptionCancel:
type: object
properties:
Expand Down Expand Up @@ -19856,7 +19960,7 @@ components:
the plan's default unit amount. The subscription's current currency will
be used.
minimum: 0
maximum: 100000
maximum: 1000000
quantity:
type: integer
title: Quantity
Expand Down Expand Up @@ -19981,6 +20085,13 @@ components:
are provided the `plan_id` will be used.
account:
"$ref": "#/components/schemas/AccountCreate"
billing_info_id:
type: string
title: Billing Info ID
description: The `billing_info_id` is the value that represents a specific
billing info for an end customer. When `billing_info_id` is used to assign
billing info to the subscription, all future billing events for the subscription
will bill to the specified billing info.
shipping:
title: Shipping address
description: Create a shipping address on the account and assign it to the
Expand All @@ -20006,7 +20117,7 @@ components:
this value. If not provided, the subscription will inherit the price from
the subscription plan for the provided currency.
minimum: 0
maximum: 100000
maximum: 1000000
quantity:
type: integer
title: Quantity
Expand Down Expand Up @@ -20140,7 +20251,7 @@ components:
this value in cents. If not provided, the subscription will inherit the
price from the subscription plan for the provided currency.
minimum: 0
maximum: 100000
maximum: 1000000
quantity:
type: integer
title: Quantity
Expand Down Expand Up @@ -20914,6 +21025,13 @@ components:
maxLength: 3
account:
"$ref": "#/components/schemas/AccountPurchase"
billing_info_id:
type: string
title: Billing info ID
description: The `billing_info_id` is the value that represents a specific
billing info for an end customer. When `billing_info_id` is used to assign
billing info to the subscription, all future billing events for the subscription
will bill to the specified billing info.
collection_method:
type: string
title: Collection method
Expand Down
2 changes: 1 addition & 1 deletion recurly/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def get_active_coupon_redemption(self, account_id):
return self._make_request("GET", path, None, None)

def create_coupon_redemption(self, account_id, body):
"""Generate an active coupon redemption on an account
"""Generate an active coupon redemption on an account or subscription

Parameters
----------
Expand Down
3 changes: 3 additions & 0 deletions recurly/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ class CouponRedemption(Resource):
The date and time the redemption was removed from the account (un-redeemed).
state : str
Coupon Redemption state
subscription_id : str
Subscription ID
updated_at : datetime
Last updated at
"""
Expand All @@ -607,6 +609,7 @@ class CouponRedemption(Resource):
"object": str,
"removed_at": datetime,
"state": str,
"subscription_id": str,
"updated_at": datetime,
}

Expand Down