diff --git a/lib/recurly/client/operations.rb b/lib/recurly/client/operations.rb index 5de03b9b2..15aa38a22 100644 --- a/lib/recurly/client/operations.rb +++ b/lib/recurly/client/operations.rb @@ -109,7 +109,7 @@ def get_site(site_id:) # end # def list_accounts(**options) - path = interpolate_path("/accounts") + path = "/accounts" pager(path, **options) end @@ -159,7 +159,7 @@ def list_accounts(**options) # end # def create_account(body:, **options) - path = interpolate_path("/accounts") + path = "/accounts" post(path, body, Requests::AccountCreate, **options) end @@ -469,6 +469,21 @@ def verify_billing_info(account_id:, **options) post(path, options[:body], Requests::BillingInfoVerify, **options) end + # Verify an account's credit card billing cvv + # + # {https://developers.recurly.com/api/v2019-10-10#operation/verify_billing_info_cvv verify_billing_info_cvv api documentation} + # + # @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+. + # @param body [Requests::BillingInfoVerifyCVV] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoVerifyCVV} + # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. + # + # @return [Resources::Transaction] Transaction information from verify. + # + def verify_billing_info_cvv(account_id:, body:, **options) + path = interpolate_path("/accounts/{account_id}/billing_info/verify_cvv", account_id: account_id) + post(path, body, Requests::BillingInfoVerifyCVV, **options) + end + # Get the list of billing information associated with an account # # {https://developers.recurly.com/api/v2019-10-10#operation/list_billing_infos list_billing_infos api documentation} @@ -566,6 +581,38 @@ def remove_a_billing_info(account_id:, billing_info_id:, **options) delete(path, **options) end + # Verify a billing information's credit card + # + # {https://developers.recurly.com/api/v2019-10-10#operation/verify_billing_infos verify_billing_infos api documentation} + # + # @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+. + # @param billing_info_id [String] Billing Info ID. Can ONLY be used for sites utilizing the Wallet feature. + # @param body [Requests::BillingInfoVerify] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoVerify} + # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. + # + # @return [Resources::Transaction] Transaction information from verify. + # + def verify_billing_infos(account_id:, billing_info_id:, **options) + path = interpolate_path("/accounts/{account_id}/billing_infos/{billing_info_id}/verify", account_id: account_id, billing_info_id: billing_info_id) + post(path, options[:body], Requests::BillingInfoVerify, **options) + end + + # Verify a billing information's credit card cvv + # + # {https://developers.recurly.com/api/v2019-10-10#operation/verify_billing_infos_cvv verify_billing_infos_cvv api documentation} + # + # @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+. + # @param billing_info_id [String] Billing Info ID. Can ONLY be used for sites utilizing the Wallet feature. + # @param body [Requests::BillingInfoVerifyCVV] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoVerifyCVV} + # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. + # + # @return [Resources::Transaction] Transaction information from verify. + # + def verify_billing_infos_cvv(account_id:, billing_info_id:, body:, **options) + path = interpolate_path("/accounts/{account_id}/billing_infos/{billing_info_id}/verify_cvv", account_id: account_id, billing_info_id: billing_info_id) + post(path, body, Requests::BillingInfoVerifyCVV, **options) + end + # List the coupon redemptions for an account # # {https://developers.recurly.com/api/v2019-10-10#operation/list_account_coupon_redemptions list_account_coupon_redemptions api documentation} @@ -1333,7 +1380,7 @@ def list_child_accounts(account_id:, **options) # end # def list_account_acquisition(**options) - path = interpolate_path("/acquisitions") + path = "/acquisitions" pager(path, **options) end @@ -1375,7 +1422,7 @@ def list_account_acquisition(**options) # end # def list_coupons(**options) - path = interpolate_path("/coupons") + path = "/coupons" pager(path, **options) end @@ -1411,7 +1458,7 @@ def list_coupons(**options) # end # def create_coupon(body:, **options) - path = interpolate_path("/coupons") + path = "/coupons" post(path, body, Requests::CouponCreate, **options) end @@ -1578,7 +1625,7 @@ def list_unique_coupon_codes(coupon_id:, **options) # end # def list_credit_payments(**options) - path = interpolate_path("/credit_payments") + path = "/credit_payments" pager(path, **options) end @@ -1635,7 +1682,7 @@ def get_credit_payment(credit_payment_id:, **options) # end # def list_custom_field_definitions(**options) - path = interpolate_path("/custom_field_definitions") + path = "/custom_field_definitions" pager(path, **options) end @@ -1703,7 +1750,7 @@ def get_custom_field_definition(custom_field_definition_id:, **options) # end # def list_items(**options) - path = interpolate_path("/items") + path = "/items" pager(path, **options) end @@ -1738,7 +1785,7 @@ def list_items(**options) # end # def create_item(body:, **options) - path = interpolate_path("/items") + path = "/items" post(path, body, Requests::ItemCreate, **options) end @@ -1876,7 +1923,7 @@ def reactivate_item(item_id:, **options) # @return [Pager] A list of the site's measured units. # def list_measured_unit(**options) - path = interpolate_path("/measured_units") + path = "/measured_units" pager(path, **options) end @@ -1890,7 +1937,7 @@ def list_measured_unit(**options) # @return [Resources::MeasuredUnit] A new measured unit. # def create_measured_unit(body:, **options) - path = interpolate_path("/measured_units") + path = "/measured_units" post(path, body, Requests::MeasuredUnitCreate, **options) end @@ -1982,7 +2029,7 @@ def remove_measured_unit(measured_unit_id:, **options) # end # def list_invoices(**options) - path = interpolate_path("/invoices") + path = "/invoices" pager(path, **options) end @@ -1990,7 +2037,7 @@ def list_invoices(**options) # # {https://developers.recurly.com/api/v2019-10-10#operation/get_invoice get_invoice api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # # @return [Resources::Invoice] An invoice. @@ -2013,7 +2060,7 @@ def get_invoice(invoice_id:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/put_invoice put_invoice api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param body [Requests::InvoiceUpdatable] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceUpdatable} # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # @@ -2041,7 +2088,7 @@ def put_invoice(invoice_id:, body:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/get_invoice_pdf get_invoice_pdf api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # # @return [Resources::BinaryFile] An invoice as a PDF. @@ -2067,7 +2114,7 @@ def get_invoice_pdf(invoice_id:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/apply_credit_balance apply_credit_balance api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # # @return [Resources::Invoice] The updated invoice. @@ -2090,7 +2137,7 @@ def apply_credit_balance(invoice_id:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/collect_invoice collect_invoice api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param body [Requests::InvoiceCollect] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceCollect} # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # @@ -2114,7 +2161,7 @@ def collect_invoice(invoice_id:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/fail_invoice fail_invoice api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # # @return [Resources::Invoice] The updated invoice. @@ -2137,7 +2184,7 @@ def fail_invoice(invoice_id:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/mark_invoice_successful mark_invoice_successful api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # # @return [Resources::Invoice] The updated invoice. @@ -2160,7 +2207,7 @@ def mark_invoice_successful(invoice_id:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/reopen_invoice reopen_invoice api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # # @return [Resources::Invoice] The updated invoice. @@ -2183,7 +2230,7 @@ def reopen_invoice(invoice_id:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/void_invoice void_invoice api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # # @return [Resources::Invoice] The updated invoice. @@ -2206,7 +2253,7 @@ def void_invoice(invoice_id:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/record_external_transaction record_external_transaction api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param body [Requests::ExternalTransaction] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ExternalTransaction} # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # @@ -2221,7 +2268,7 @@ def record_external_transaction(invoice_id:, body:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/list_invoice_line_items list_invoice_line_items api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+. # @@ -2270,7 +2317,7 @@ def list_invoice_line_items(invoice_id:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/list_invoice_coupon_redemptions list_invoice_coupon_redemptions api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+. # @@ -2314,7 +2361,7 @@ def list_invoice_coupon_redemptions(invoice_id:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/list_related_invoices list_related_invoices api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # # @return [Pager] A list of the credit or charge invoices associated with the invoice. @@ -2336,7 +2383,7 @@ def list_related_invoices(invoice_id:, **options) # # {https://developers.recurly.com/api/v2019-10-10#operation/refund_invoice refund_invoice api documentation} # - # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. + # @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+. For number with prefix or country code, use +number-+ and +prefix+, e.g. +number-TEST-FR1001+ # @param body [Requests::InvoiceRefund] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceRefund} # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # @@ -2406,7 +2453,7 @@ def refund_invoice(invoice_id:, body:, **options) # end # def list_line_items(**options) - path = interpolate_path("/line_items") + path = "/line_items" pager(path, **options) end @@ -2497,7 +2544,7 @@ def remove_line_item(line_item_id:, **options) # end # def list_plans(**options) - path = interpolate_path("/plans") + path = "/plans" pager(path, **options) end @@ -2537,7 +2584,7 @@ def list_plans(**options) # end # def create_plan(body:, **options) - path = interpolate_path("/plans") + path = "/plans" post(path, body, Requests::PlanCreate, **options) end @@ -2822,7 +2869,7 @@ def remove_plan_add_on(plan_id:, add_on_id:, **options) # end # def list_add_ons(**options) - path = interpolate_path("/add_ons") + path = "/add_ons" pager(path, **options) end @@ -2889,7 +2936,7 @@ def get_add_on(add_on_id:, **options) # end # def list_shipping_methods(**options) - path = interpolate_path("/shipping_methods") + path = "/shipping_methods" pager(path, **options) end @@ -2903,7 +2950,7 @@ def list_shipping_methods(**options) # @return [Resources::ShippingMethod] A new shipping method. # def create_shipping_method(body:, **options) - path = interpolate_path("/shipping_methods") + path = "/shipping_methods" post(path, body, Requests::ShippingMethodCreate, **options) end @@ -2994,7 +3041,7 @@ def deactivate_shipping_method(shipping_method_id:, **options) # end # def list_subscriptions(**options) - path = interpolate_path("/subscriptions") + path = "/subscriptions" pager(path, **options) end @@ -3027,7 +3074,7 @@ def list_subscriptions(**options) # end # def create_subscription(body:, **options) - path = interpolate_path("/subscriptions") + path = "/subscriptions" post(path, body, Requests::SubscriptionCreate, **options) end @@ -3248,12 +3295,13 @@ def convert_trial(subscription_id:, **options) # {https://developers.recurly.com/api/v2019-10-10#operation/get_preview_renewal get_preview_renewal api documentation} # # @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+. + # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # # @return [Resources::InvoiceCollection] A preview of the subscription's renewal invoice(s). # - def get_preview_renewal(subscription_id:) + def get_preview_renewal(subscription_id:, **options) path = interpolate_path("/subscriptions/{subscription_id}/preview_renewal", subscription_id: subscription_id) - get(path) + get(path, **options) end # Fetch a subscription's pending change @@ -3637,7 +3685,7 @@ def remove_usage(usage_id:, **options) # end # def list_transactions(**options) - path = interpolate_path("/transactions") + path = "/transactions" pager(path, **options) end @@ -3742,7 +3790,7 @@ def reactivate_unique_coupon_code(unique_coupon_code_id:, **options) # end # def create_purchase(body:, **options) - path = interpolate_path("/purchases") + path = "/purchases" post(path, body, Requests::PurchaseCreate, **options) end @@ -3782,7 +3830,7 @@ def create_purchase(body:, **options) # end # def preview_purchase(body:, **options) - path = interpolate_path("/purchases/preview") + path = "/purchases/preview" post(path, body, Requests::PurchaseCreate, **options) end @@ -3806,7 +3854,7 @@ def preview_purchase(body:, **options) # end # def get_export_dates(**options) - path = interpolate_path("/export_dates") + path = "/export_dates" get(path, **options) end @@ -3843,6 +3891,7 @@ def get_export_files(export_date:, **options) # order. In descending order updated records will move behind the cursor and could # prevent some records from being returned. # + # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+. # # @return [Pager] A list of the the dunning_campaigns on an account. # diff --git a/lib/recurly/errors/api_errors.rb b/lib/recurly/errors/api_errors.rb index ef4009f77..23063e3ad 100644 --- a/lib/recurly/errors/api_errors.rb +++ b/lib/recurly/errors/api_errors.rb @@ -21,67 +21,36 @@ module Errors } class ResponseError < Errors::APIError; end - class ServerError < ResponseError; end - class InternalServerError < ServerError; end - class ServiceNotAvailableError < InternalServerError; end - class TaxServiceError < InternalServerError; end - class BadGatewayError < ServerError; end - class ServiceUnavailableError < ServerError; end - class RedirectionError < ResponseError; end - class NotModifiedError < ResponseError; end - class ClientError < Errors::APIError; end - class BadRequestError < ClientError; end - class InvalidContentTypeError < BadRequestError; end - class UnauthorizedError < ClientError; end - class PaymentRequiredError < ClientError; end - class ForbiddenError < ClientError; end - class InvalidApiKeyError < ForbiddenError; end - class InvalidPermissionsError < ForbiddenError; end - class NotFoundError < ClientError; end - class NotAcceptableError < ClientError; end - class UnknownApiVersionError < NotAcceptableError; end - class UnavailableInApiVersionError < NotAcceptableError; end - class InvalidApiVersionError < NotAcceptableError; end - class PreconditionFailedError < ClientError; end - class UnprocessableEntityError < ClientError; end - class ValidationError < UnprocessableEntityError; end - class MissingFeatureError < UnprocessableEntityError; end - class TransactionError < UnprocessableEntityError; end - class SimultaneousRequestError < UnprocessableEntityError; end - class ImmutableSubscriptionError < UnprocessableEntityError; end - class InvalidTokenError < UnprocessableEntityError; end - class TooManyRequestsError < ClientError; end - class RateLimitedError < TooManyRequestsError; end end end diff --git a/lib/recurly/requests/add_on_create.rb b/lib/recurly/requests/add_on_create.rb index 5d457fccd..f6656259b 100644 --- a/lib/recurly/requests/add_on_create.rb +++ b/lib/recurly/requests/add_on_create.rb @@ -71,7 +71,7 @@ class AddOnCreate < Request define_attribute :revenue_schedule_type, String # @!attribute tax_code - # @return [String] Optional field used by Avalara, Vertex, and Recurly's EU VAT tax feature to determine taxation rules. If you have your own AvaTax or Vertex account configured, use their tax codes to assign specific tax rules. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. If `item_code`/`item_id` is part of the request then `tax_code` must be absent. + # @return [String] Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. If `item_code`/`item_id` is part of the request then `tax_code` must be absent. define_attribute :tax_code, String # @!attribute tier_type diff --git a/lib/recurly/requests/add_on_update.rb b/lib/recurly/requests/add_on_update.rb index 163e13553..9fdc7f7ea 100644 --- a/lib/recurly/requests/add_on_update.rb +++ b/lib/recurly/requests/add_on_update.rb @@ -59,7 +59,7 @@ class AddOnUpdate < Request define_attribute :revenue_schedule_type, String # @!attribute tax_code - # @return [String] Optional field used by Avalara, Vertex, and Recurly's EU VAT tax feature to determine taxation rules. If you have your own AvaTax or Vertex account configured, use their tax codes to assign specific tax rules. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. If an `Item` is associated to the `AddOn` then `tax code` must be absent. + # @return [String] Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. If an `Item` is associated to the `AddOn` then `tax_code` must be absent. define_attribute :tax_code, String # @!attribute tiers diff --git a/lib/recurly/requests/address.rb b/lib/recurly/requests/address.rb index 4375c5234..f327c3356 100644 --- a/lib/recurly/requests/address.rb +++ b/lib/recurly/requests/address.rb @@ -19,7 +19,7 @@ class Address < Request define_attribute :first_name, String # @!attribute geo_code - # @return [String] Code that represents a geographic entity (location or object). Only returned for Sling Vertex Integration + # @return [String] Code that represents a geographic entity (location or object). Only returned when Vertex or Avalara for Communications is enabled. define_attribute :geo_code, String # @!attribute last_name diff --git a/lib/recurly/requests/billing_info_create.rb b/lib/recurly/requests/billing_info_create.rb index 00ff40fcd..e2d8a2149 100644 --- a/lib/recurly/requests/billing_info_create.rb +++ b/lib/recurly/requests/billing_info_create.rb @@ -55,7 +55,7 @@ class BillingInfoCreate < Request define_attribute :gateway_attributes, :GatewayAttributes # @!attribute gateway_code - # @return [String] An identifier for a specific payment gateway. Must be used in conjunction with `gateway_token`. + # @return [String] An identifier for a specific payment gateway. define_attribute :gateway_code, String # @!attribute gateway_token @@ -106,6 +106,10 @@ class BillingInfoCreate < Request # @return [String] Bank identifier code for UK based banks. Required for Bacs based billing infos. (Bacs only) define_attribute :sort_code, String + # @!attribute store_billing_info + # @return [Boolean] Whether to store this billing info onto its associated account. Defaults to `true`. + define_attribute :store_billing_info, :Boolean + # @!attribute tax_identifier # @return [String] 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. define_attribute :tax_identifier, String diff --git a/lib/recurly/requests/billing_info_verify.rb b/lib/recurly/requests/billing_info_verify.rb index 63d038a09..0a0ee2067 100644 --- a/lib/recurly/requests/billing_info_verify.rb +++ b/lib/recurly/requests/billing_info_verify.rb @@ -9,6 +9,10 @@ class BillingInfoVerify < Request # @!attribute gateway_code # @return [String] An identifier for a specific payment gateway. define_attribute :gateway_code, String + + # @!attribute three_d_secure_action_result_token_id + # @return [String] A token generated by Recurly.js after completing a 3-D Secure device fingerprinting or authentication challenge. + define_attribute :three_d_secure_action_result_token_id, String end end end diff --git a/lib/recurly/requests/billing_info_verify_cvv.rb b/lib/recurly/requests/billing_info_verify_cvv.rb new file mode 100644 index 000000000..8bee02935 --- /dev/null +++ b/lib/recurly/requests/billing_info_verify_cvv.rb @@ -0,0 +1,26 @@ +# This file is automatically created by Recurly's OpenAPI generation process +# and thus any edits you make by hand will be lost. If you wish to make a +# change to this file, please create a Github issue explaining the changes you +# need and we will usher them to the appropriate places. +module Recurly + module Requests + class BillingInfoVerifyCVV < Request + + # @!attribute gateway_code + # @return [String] An identifier for a specific payment gateway. + define_attribute :gateway_code, String + + # @!attribute three_d_secure_action_result_token_id + # @return [String] A token generated by Recurly.js after completing a 3-D Secure device fingerprinting or authentication challenge. + define_attribute :three_d_secure_action_result_token_id, String + + # @!attribute token_id + # @return [String] A token [generated by Recurly.js](https://recurly.com/developers/reference/recurly-js/#getting-a-token). + define_attribute :token_id, String + + # @!attribute verification_value + # @return [String] Unique security code for a credit card. + define_attribute :verification_value, String + end + end +end diff --git a/lib/recurly/requests/credit_application_policy.rb b/lib/recurly/requests/credit_application_policy.rb new file mode 100644 index 000000000..7457b4dd3 --- /dev/null +++ b/lib/recurly/requests/credit_application_policy.rb @@ -0,0 +1,18 @@ +# This file is automatically created by Recurly's OpenAPI generation process +# and thus any edits you make by hand will be lost. If you wish to make a +# change to this file, please create a Github issue explaining the changes you +# need and we will usher them to the appropriate places. +module Recurly + module Requests + class CreditApplicationPolicy < Request + + # @!attribute allowed_origins + # @return [Array[String]] 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`. + define_attribute :allowed_origins, Array, { :item_type => String } + + # @!attribute mode + # @return [String] + define_attribute :mode, String + end + end +end diff --git a/lib/recurly/requests/custom_field.rb b/lib/recurly/requests/custom_field.rb index fbd989aa5..36a205e9f 100644 --- a/lib/recurly/requests/custom_field.rb +++ b/lib/recurly/requests/custom_field.rb @@ -10,6 +10,14 @@ class CustomField < Request # @return [String] Fields must be created in the UI before values can be assigned to them. define_attribute :name, String + # @!attribute source_record_id + # @return [String] The UUID of the record this custom field was automatically copied from. Only present when the field was copied from another record. + define_attribute :source_record_id, String + + # @!attribute source_record_type + # @return [String] The type of record this custom field was automatically copied from. Only present when the field was copied from another record. + define_attribute :source_record_type, String + # @!attribute value # @return [String] Any values that resemble a credit card number or security code (CVV/CVC) will be rejected. define_attribute :value, String diff --git a/lib/recurly/requests/invoice_address.rb b/lib/recurly/requests/invoice_address.rb index 1285004e7..426d39b06 100644 --- a/lib/recurly/requests/invoice_address.rb +++ b/lib/recurly/requests/invoice_address.rb @@ -23,7 +23,7 @@ class InvoiceAddress < Request define_attribute :first_name, String # @!attribute geo_code - # @return [String] Code that represents a geographic entity (location or object). Only returned for Sling Vertex Integration + # @return [String] Code that represents a geographic entity (location or object). Only returned when Vertex or Avalara for Communications is enabled. define_attribute :geo_code, String # @!attribute last_name diff --git a/lib/recurly/requests/invoice_create.rb b/lib/recurly/requests/invoice_create.rb index 2b46c064a..44cf7599c 100644 --- a/lib/recurly/requests/invoice_create.rb +++ b/lib/recurly/requests/invoice_create.rb @@ -14,6 +14,10 @@ class InvoiceCreate < Request # @return [String] An automatic invoice means a corresponding transaction is run using the account's billing information at the same time the invoice is created. Manual invoices are created without a corresponding transaction. The merchant must enter a manual payment transaction or have the customer pay the invoice with an automatic method, like credit card, PayPal, Amazon, or ACH bank payment. define_attribute :collection_method, String + # @!attribute credit_application_policy + # @return [CreditApplicationPolicy] Controls whether credit invoices are automatically applied to new invoices. The `mode` field determines the application behavior. When mode is `all`, the optional `allowed_origins` array can restrict which credit invoice origins are applied. - `all`: All available credit invoices are applied (default) - `none`: No credit invoices are applied automatically + define_attribute :credit_application_policy, :CreditApplicationPolicy + # @!attribute credit_customer_notes # @return [String] This will default to the Customer Notes text specified on the Invoice Settings for credit invoices. Specify customer notes to add or override Customer Notes on credit invoices. define_attribute :credit_customer_notes, String @@ -23,7 +27,7 @@ class InvoiceCreate < Request define_attribute :currency, String # @!attribute net_terms - # @return [Integer] Integer representing the number of days after an invoice's creation that the invoice will become past due. If an invoice's net terms are set to '0', it is due 'On Receipt' and will become past due 24 hours after it’s created. If an invoice is due net 30, it will become past due at 31 days exactly. + # @return [Integer] Integer representing the number of days after an invoice's creation that the invoice will become past due. If an invoice's net terms are set to '0', it is due 'On Receipt' and will become past due 24 hours after it's created. If an invoice is due net 30, it will become past due at 31 days exactly. define_attribute :net_terms, Integer # @!attribute po_number @@ -37,6 +41,10 @@ class InvoiceCreate < Request # @!attribute vat_reverse_charge_notes # @return [String] VAT Reverse Charge Notes only appear if you have EU VAT enabled or are using your own Avalara AvaTax account and the customer is in the EU, has a VAT number, and is in a different country than your own. This will default to the VAT Reverse Charge Notes text specified on the Tax Settings page in your Recurly admin, unless custom notes were created with the original subscription. define_attribute :vat_reverse_charge_notes, String + + # @!attribute vertex_transaction_type + # @return [String] Used by Vertex for tax calculations. Possible values are sale, rental, lease. + define_attribute :vertex_transaction_type, String end end end diff --git a/lib/recurly/requests/item_create.rb b/lib/recurly/requests/item_create.rb index 4d37a2559..05acf4566 100644 --- a/lib/recurly/requests/item_create.rb +++ b/lib/recurly/requests/item_create.rb @@ -47,7 +47,7 @@ class ItemCreate < Request define_attribute :revenue_schedule_type, String # @!attribute tax_code - # @return [String] Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. The tax code values are specific to each tax system. If you are using Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. + # @return [String] Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. define_attribute :tax_code, String # @!attribute tax_exempt diff --git a/lib/recurly/requests/item_update.rb b/lib/recurly/requests/item_update.rb index 3b893dbd1..4dd49594c 100644 --- a/lib/recurly/requests/item_update.rb +++ b/lib/recurly/requests/item_update.rb @@ -47,7 +47,7 @@ class ItemUpdate < Request define_attribute :revenue_schedule_type, String # @!attribute tax_code - # @return [String] Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. The tax code values are specific to each tax system. If you are using Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. + # @return [String] Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. define_attribute :tax_code, String # @!attribute tax_exempt diff --git a/lib/recurly/requests/line_item_create.rb b/lib/recurly/requests/line_item_create.rb index 521a711c8..1297fccf6 100644 --- a/lib/recurly/requests/line_item_create.rb +++ b/lib/recurly/requests/line_item_create.rb @@ -67,7 +67,7 @@ class LineItemCreate < Request define_attribute :start_date, DateTime # @!attribute tax_code - # @return [String] Optional field used by Avalara, Vertex, and Recurly's EU VAT tax feature to determine taxation rules. If you have your own AvaTax or Vertex account configured, use their tax codes to assign specific tax rules. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. + # @return [String] Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. define_attribute :tax_code, String # @!attribute tax_exempt @@ -85,6 +85,10 @@ class LineItemCreate < Request # @!attribute unit_amount # @return [Float] A positive or negative amount with `type=charge` will result in a positive `unit_amount`. A positive or negative amount with `type=credit` will result in a negative `unit_amount`. If `item_code`/`item_id` is present, `unit_amount` can be passed in, to override the `Item`'s `unit_amount`. If `item_code`/`item_id` is not present then `unit_amount` is required. define_attribute :unit_amount, Float + + # @!attribute vertex_transaction_type + # @return [String] Used by Vertex for tax calculations. Possible values are sale, rental, lease. + define_attribute :vertex_transaction_type, String end end end diff --git a/lib/recurly/requests/plan_create.rb b/lib/recurly/requests/plan_create.rb index b0bcaf8cc..19db225b2 100644 --- a/lib/recurly/requests/plan_create.rb +++ b/lib/recurly/requests/plan_create.rb @@ -87,7 +87,7 @@ class PlanCreate < Request define_attribute :setup_fee_revenue_schedule_type, String # @!attribute tax_code - # @return [String] Optional field used by Avalara, Vertex, and Recurly's EU VAT tax feature to determine taxation rules. If you have your own AvaTax or Vertex account configured, use their tax codes to assign specific tax rules. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. + # @return [String] Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. define_attribute :tax_code, String # @!attribute tax_exempt diff --git a/lib/recurly/requests/plan_update.rb b/lib/recurly/requests/plan_update.rb index b3fa050c8..3b962b05a 100644 --- a/lib/recurly/requests/plan_update.rb +++ b/lib/recurly/requests/plan_update.rb @@ -75,7 +75,7 @@ class PlanUpdate < Request define_attribute :setup_fee_revenue_schedule_type, String # @!attribute tax_code - # @return [String] Optional field used by Avalara, Vertex, and Recurly's EU VAT tax feature to determine taxation rules. If you have your own AvaTax or Vertex account configured, use their tax codes to assign specific tax rules. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. + # @return [String] Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. define_attribute :tax_code, String # @!attribute tax_exempt diff --git a/lib/recurly/requests/purchase_create.rb b/lib/recurly/requests/purchase_create.rb index a0e9289d8..f9febea05 100644 --- a/lib/recurly/requests/purchase_create.rb +++ b/lib/recurly/requests/purchase_create.rb @@ -22,6 +22,10 @@ class PurchaseCreate < Request # @return [Array[String]] A list of coupon_codes to be redeemed on the subscription or account during the purchase. define_attribute :coupon_codes, Array, { :item_type => String } + # @!attribute credit_application_policy_override + # @return [CreditApplicationPolicy] Controls whether credit invoices are automatically applied to new invoices. The `mode` field determines the application behavior. When mode is `all`, the optional `allowed_origins` array can restrict which credit invoice origins are applied. - `all`: All available credit invoices are applied (default) - `none`: No credit invoices are applied automatically + define_attribute :credit_application_policy_override, :CreditApplicationPolicy + # @!attribute credit_customer_notes # @return [String] Notes to be put on the credit invoice resulting from credits in the purchase, if any. define_attribute :credit_customer_notes, String @@ -73,6 +77,10 @@ class PurchaseCreate < Request # @!attribute vat_reverse_charge_notes # @return [String] VAT reverse charge notes for cross border European tax settlement. define_attribute :vat_reverse_charge_notes, String + + # @!attribute vertex_transaction_type + # @return [String] Used by Vertex for tax calculations. Possible values are sale, rental, lease. + define_attribute :vertex_transaction_type, String end end end diff --git a/lib/recurly/requests/shipping_address_create.rb b/lib/recurly/requests/shipping_address_create.rb index 294bed073..d25a9f4db 100644 --- a/lib/recurly/requests/shipping_address_create.rb +++ b/lib/recurly/requests/shipping_address_create.rb @@ -27,7 +27,7 @@ class ShippingAddressCreate < Request define_attribute :first_name, String # @!attribute geo_code - # @return [String] Code that represents a geographic entity (location or object). Only returned for Sling Vertex Integration + # @return [String] Code that represents a geographic entity (location or object). Only returned when Vertex or Avalara for Communications is enabled. define_attribute :geo_code, String # @!attribute last_name diff --git a/lib/recurly/requests/shipping_address_update.rb b/lib/recurly/requests/shipping_address_update.rb index e261de005..782cccf66 100644 --- a/lib/recurly/requests/shipping_address_update.rb +++ b/lib/recurly/requests/shipping_address_update.rb @@ -27,7 +27,7 @@ class ShippingAddressUpdate < Request define_attribute :first_name, String # @!attribute geo_code - # @return [String] Code that represents a geographic entity (location or object). Only returned for Sling Vertex Integration + # @return [String] Code that represents a geographic entity (location or object). Only returned when Vertex or Avalara for Communications is enabled. define_attribute :geo_code, String # @!attribute id diff --git a/lib/recurly/requests/subscription_create.rb b/lib/recurly/requests/subscription_create.rb index c29c834d5..6fa44dd84 100644 --- a/lib/recurly/requests/subscription_create.rb +++ b/lib/recurly/requests/subscription_create.rb @@ -22,6 +22,10 @@ class SubscriptionCreate < Request # @return [String] 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. `billing_info_id` can ONLY be used for sites utilizing the Wallet feature. define_attribute :billing_info_id, String + # @!attribute bulk + # @return [Boolean] Optional field to be used only when needing to bypass the 60 second limit on creating subscriptions. Should only be used when creating subscriptions in bulk from the API. + define_attribute :bulk, :Boolean + # @!attribute collection_method # @return [String] Collection method define_attribute :collection_method, String @@ -30,6 +34,10 @@ class SubscriptionCreate < Request # @return [String] Optional coupon code to redeem on the account and discount the subscription. Please note, the subscription request will fail if the coupon is invalid. define_attribute :coupon_code, String + # @!attribute credit_application_policy + # @return [CreditApplicationPolicy] Controls whether credit invoices are automatically applied to new invoices. The `mode` field determines the application behavior. When mode is `all`, the optional `allowed_origins` array can restrict which credit invoice origins are applied. - `all`: All available credit invoices are applied (default) - `none`: No credit invoices are applied automatically + define_attribute :credit_application_policy, :CreditApplicationPolicy + # @!attribute credit_customer_notes # @return [String] If there are pending credits on the account that will be invoiced during the subscription creation, these will be used as the Customer Notes on the credit invoice. define_attribute :credit_customer_notes, String @@ -87,7 +95,7 @@ class SubscriptionCreate < Request define_attribute :shipping, :SubscriptionShippingCreate # @!attribute starts_at - # @return [DateTime] If set, the subscription will begin in the future on this date. The subscription will apply the setup fee and trial period, unless the plan has no trial. + # @return [DateTime] If set, the subscription will begin on this specified date. The subscription will apply the setup fee and trial period, unless the plan has no trial. Omit this field if the subscription should be started immediately. define_attribute :starts_at, DateTime # @!attribute tax_inclusive @@ -113,6 +121,10 @@ class SubscriptionCreate < Request # @!attribute unit_amount # @return [Float] Override the unit amount of the subscription plan by setting this value. If not provided, the subscription will inherit the price from the subscription plan for the provided currency. define_attribute :unit_amount, Float + + # @!attribute vat_reverse_charge_notes + # @return [String] This will default to the VAT reverse charge notes text specified on the Invoice Settings. Specify custom notes to add or override VAT reverse charge notes. Custom notes will stay with a subscription on all renewals. + define_attribute :vat_reverse_charge_notes, String end end end diff --git a/lib/recurly/requests/subscription_purchase.rb b/lib/recurly/requests/subscription_purchase.rb index 1ee1f38a2..6daf738ac 100644 --- a/lib/recurly/requests/subscription_purchase.rb +++ b/lib/recurly/requests/subscription_purchase.rb @@ -14,10 +14,22 @@ class SubscriptionPurchase < Request # @return [Boolean] Whether the subscription renews at the end of its term. define_attribute :auto_renew, :Boolean + # @!attribute bulk + # @return [Boolean] Optional field to be used only when needing to bypass the 60 second limit on creating subscriptions. Should only be used when creating subscriptions in bulk from the API. + define_attribute :bulk, :Boolean + + # @!attribute credit_application_policy + # @return [CreditApplicationPolicy] Controls whether credit invoices are automatically applied to new invoices. The `mode` field determines the application behavior. When mode is `all`, the optional `allowed_origins` array can restrict which credit invoice origins are applied. - `all`: All available credit invoices are applied (default) - `none`: No credit invoices are applied automatically + define_attribute :credit_application_policy, :CreditApplicationPolicy + # @!attribute custom_fields # @return [Array[CustomField]] The custom fields will only be altered when they are included in a request. Sending an empty array will not remove any existing values. To remove a field send the name with a null or empty value. define_attribute :custom_fields, Array, { :item_type => :CustomField } + # @!attribute customer_notes + # @return [String] Specify custom notes to add or override Customer Notes. Custom notes will stay with a subscription on all renewals. + define_attribute :customer_notes, String + # @!attribute next_bill_date # @return [DateTime] If present, this sets the date the subscription's next billing period will start (`current_period_ends_at`). This can be used to align the subscription’s billing to a specific day of the month. The initial invoice will be prorated for the period between the subscription's activation date and the billing period end date. Subsequent periods will be based off the plan interval. For a subscription with a trial period, this will change when the trial expires. define_attribute :next_bill_date, DateTime @@ -51,13 +63,17 @@ class SubscriptionPurchase < Request define_attribute :shipping, :SubscriptionShippingPurchase # @!attribute starts_at - # @return [DateTime] If set, the subscription will begin in the future on this date. The subscription will apply the setup fee and trial period, unless the plan has no trial. + # @return [DateTime] If set, the subscription will begin on this specified date. The subscription will apply the setup fee and trial period, unless the plan has no trial. define_attribute :starts_at, DateTime # @!attribute tax_inclusive # @return [Boolean] Determines whether or not tax is included in the unit amount. The Tax Inclusive Pricing feature (separate from the Mixed Tax Pricing feature) must be enabled to use this flag. define_attribute :tax_inclusive, :Boolean + # @!attribute terms_and_conditions + # @return [String] Specify custom notes to add or override Terms and Conditions. Custom notes will stay with a subscription on all renewals. + define_attribute :terms_and_conditions, String + # @!attribute total_billing_cycles # @return [Integer] The number of cycles/billing periods in a term. When `remaining_billing_cycles=0`, if `auto_renew=true` the subscription will renew and a new term will begin, otherwise the subscription will expire. define_attribute :total_billing_cycles, Integer @@ -69,6 +85,10 @@ class SubscriptionPurchase < Request # @!attribute unit_amount # @return [Float] Override the unit amount of the subscription plan by setting this value. If not provided, the subscription will inherit the price from the subscription plan for the provided currency. define_attribute :unit_amount, Float + + # @!attribute vat_reverse_charge_notes + # @return [String] Specify custom notes to add or override VAT reverse charge notes. Custom notes will stay with a subscription on all renewals. + define_attribute :vat_reverse_charge_notes, String end end end diff --git a/lib/recurly/requests/subscription_update.rb b/lib/recurly/requests/subscription_update.rb index 538019551..8655b42f8 100644 --- a/lib/recurly/requests/subscription_update.rb +++ b/lib/recurly/requests/subscription_update.rb @@ -18,6 +18,10 @@ class SubscriptionUpdate < Request # @return [String] Change collection method define_attribute :collection_method, String + # @!attribute credit_application_policy + # @return [CreditApplicationPolicy] Controls whether credit invoices are automatically applied to new invoices. The `mode` field determines the application behavior. When mode is `all`, the optional `allowed_origins` array can restrict which credit invoice origins are applied. - `all`: All available credit invoices are applied (default) - `none`: No credit invoices are applied automatically + define_attribute :credit_application_policy, :CreditApplicationPolicy + # @!attribute custom_fields # @return [Array[CustomField]] The custom fields will only be altered when they are included in a request. Sending an empty array will not remove any existing values. To remove a field send the name with a null or empty value. define_attribute :custom_fields, Array, { :item_type => :CustomField } @@ -61,6 +65,10 @@ class SubscriptionUpdate < Request # @!attribute terms_and_conditions # @return [String] Specify custom notes to add or override Terms and Conditions. Custom notes will stay with a subscription on all renewals. define_attribute :terms_and_conditions, String + + # @!attribute vat_reverse_charge_notes + # @return [String] Specify custom notes to add or override VAT reverse charge notes. Custom notes will stay with a subscription on all renewals. + define_attribute :vat_reverse_charge_notes, String end end end diff --git a/lib/recurly/resources/add_on.rb b/lib/recurly/resources/add_on.rb index f5db0d840..5b4571bda 100644 --- a/lib/recurly/resources/add_on.rb +++ b/lib/recurly/resources/add_on.rb @@ -87,7 +87,7 @@ class AddOn < Resource define_attribute :state, String # @!attribute tax_code - # @return [String] Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. The tax code values are specific to each tax system. If you are using Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. + # @return [String] Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. If `item_code`/`item_id` is part of the request then `tax_code` must be absent. define_attribute :tax_code, String # @!attribute tier_type diff --git a/lib/recurly/resources/address.rb b/lib/recurly/resources/address.rb index a19ab6763..de4e059a7 100644 --- a/lib/recurly/resources/address.rb +++ b/lib/recurly/resources/address.rb @@ -19,7 +19,7 @@ class Address < Resource define_attribute :first_name, String # @!attribute geo_code - # @return [String] Code that represents a geographic entity (location or object). Only returned for Sling Vertex Integration + # @return [String] Code that represents a geographic entity (location or object). Only returned when Vertex or Avalara for Communications is enabled. define_attribute :geo_code, String # @!attribute last_name diff --git a/lib/recurly/resources/credit_application_policy.rb b/lib/recurly/resources/credit_application_policy.rb new file mode 100644 index 000000000..74871a6b8 --- /dev/null +++ b/lib/recurly/resources/credit_application_policy.rb @@ -0,0 +1,18 @@ +# This file is automatically created by Recurly's OpenAPI generation process +# and thus any edits you make by hand will be lost. If you wish to make a +# change to this file, please create a Github issue explaining the changes you +# need and we will usher them to the appropriate places. +module Recurly + module Resources + class CreditApplicationPolicy < Resource + + # @!attribute allowed_origins + # @return [Array[String]] 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`. + define_attribute :allowed_origins, Array, { :item_type => String } + + # @!attribute mode + # @return [String] + define_attribute :mode, String + end + end +end diff --git a/lib/recurly/resources/custom_field.rb b/lib/recurly/resources/custom_field.rb index 5ba94ac27..a62875c8e 100644 --- a/lib/recurly/resources/custom_field.rb +++ b/lib/recurly/resources/custom_field.rb @@ -10,6 +10,14 @@ class CustomField < Resource # @return [String] Fields must be created in the UI before values can be assigned to them. define_attribute :name, String + # @!attribute source_record_id + # @return [String] The UUID of the record this custom field was automatically copied from. Only present when the field was copied from another record. + define_attribute :source_record_id, String + + # @!attribute source_record_type + # @return [String] The type of record this custom field was automatically copied from. Only present when the field was copied from another record. + define_attribute :source_record_type, String + # @!attribute value # @return [String] Any values that resemble a credit card number or security code (CVV/CVC) will be rejected. define_attribute :value, String diff --git a/lib/recurly/resources/invoice.rb b/lib/recurly/resources/invoice.rb index 0e379f1d5..7f2bff89c 100644 --- a/lib/recurly/resources/invoice.rb +++ b/lib/recurly/resources/invoice.rb @@ -42,6 +42,10 @@ class Invoice < Resource # @return [String] 3-letter ISO 4217 currency code. define_attribute :currency, String + # @!attribute custom_fields + # @return [Array[CustomField]] A list of custom fields that were on the account at the time of invoice creation and were marked to be displayed on invoices. Read-only; cannot be set directly on the invoice. + define_attribute :custom_fields, Array, { :item_type => :CustomField } + # @!attribute customer_notes # @return [String] This will default to the Customer Notes text specified on the Invoice Settings. Specify custom notes to add or override Customer Notes. define_attribute :customer_notes, String @@ -114,6 +118,10 @@ class Invoice < Resource # @return [Float] The summation of charges and credits, before discounts and taxes. define_attribute :subtotal, Float + # @!attribute subtotal_after_discount + # @return [Float] The summation of charges and credits, after discounts applied. + define_attribute :subtotal_after_discount, Float + # @!attribute tax # @return [Float] The total tax on this invoice. define_attribute :tax, Float diff --git a/lib/recurly/resources/invoice_address.rb b/lib/recurly/resources/invoice_address.rb index 619158a87..654836e48 100644 --- a/lib/recurly/resources/invoice_address.rb +++ b/lib/recurly/resources/invoice_address.rb @@ -23,7 +23,7 @@ class InvoiceAddress < Resource define_attribute :first_name, String # @!attribute geo_code - # @return [String] Code that represents a geographic entity (location or object). Only returned for Sling Vertex Integration + # @return [String] Code that represents a geographic entity (location or object). Only returned when Vertex or Avalara for Communications is enabled. define_attribute :geo_code, String # @!attribute last_name diff --git a/lib/recurly/resources/item.rb b/lib/recurly/resources/item.rb index d8d2bb5bd..8f1cee331 100644 --- a/lib/recurly/resources/item.rb +++ b/lib/recurly/resources/item.rb @@ -67,7 +67,7 @@ class Item < Resource define_attribute :state, String # @!attribute tax_code - # @return [String] Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. The tax code values are specific to each tax system. If you are using Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. + # @return [String] Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. define_attribute :tax_code, String # @!attribute tax_exempt diff --git a/lib/recurly/resources/line_item.rb b/lib/recurly/resources/line_item.rb index d3d2d82db..36940c6ee 100644 --- a/lib/recurly/resources/line_item.rb +++ b/lib/recurly/resources/line_item.rb @@ -23,7 +23,7 @@ class LineItem < Resource define_attribute :add_on_id, String # @!attribute amount - # @return [Float] `(quantity * unit_amount) - (discount + tax)` + # @return [Float] `(quantity * unit_amount) - discount + tax` define_attribute :amount, Float # @!attribute avalara_service_type @@ -179,7 +179,7 @@ class LineItem < Resource define_attribute :tax, Float # @!attribute tax_code - # @return [String] Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. The tax code values are specific to each tax system. If you are using Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. + # @return [String] Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. define_attribute :tax_code, String # @!attribute tax_exempt @@ -213,6 +213,10 @@ class LineItem < Resource # @!attribute uuid # @return [String] The UUID is useful for matching data with the CSV exports and building URLs into Recurly's UI. define_attribute :uuid, String + + # @!attribute vertex_transaction_type + # @return [String] Used by Vertex for tax calculations. Possible values are sale, rental, lease. + define_attribute :vertex_transaction_type, String end end end diff --git a/lib/recurly/resources/plan.rb b/lib/recurly/resources/plan.rb index 08a0dea39..409966a50 100644 --- a/lib/recurly/resources/plan.rb +++ b/lib/recurly/resources/plan.rb @@ -103,7 +103,7 @@ class Plan < Resource define_attribute :state, String # @!attribute tax_code - # @return [String] Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. The tax code values are specific to each tax system. If you are using Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. + # @return [String] Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. define_attribute :tax_code, String # @!attribute tax_exempt diff --git a/lib/recurly/resources/shipping_address.rb b/lib/recurly/resources/shipping_address.rb index 8a592b153..b850580ab 100644 --- a/lib/recurly/resources/shipping_address.rb +++ b/lib/recurly/resources/shipping_address.rb @@ -35,7 +35,7 @@ class ShippingAddress < Resource define_attribute :first_name, String # @!attribute geo_code - # @return [String] Code that represents a geographic entity (location or object). Only returned for Sling Vertex Integration + # @return [String] Code that represents a geographic entity (location or object). Only returned when Vertex or Avalara for Communications is enabled. define_attribute :geo_code, String # @!attribute id diff --git a/lib/recurly/resources/subscription.rb b/lib/recurly/resources/subscription.rb index 88424f3dc..59d2ebb71 100644 --- a/lib/recurly/resources/subscription.rb +++ b/lib/recurly/resources/subscription.rb @@ -54,6 +54,10 @@ class Subscription < Resource # @return [DateTime] Created at define_attribute :created_at, DateTime + # @!attribute credit_application_policy + # @return [CreditApplicationPolicy] Controls whether credit invoices are automatically applied to new invoices. The `mode` field determines the application behavior. When mode is `all`, the optional `allowed_origins` array can restrict which credit invoice origins are applied. - `all`: All available credit invoices are applied (default) - `none`: No credit invoices are applied automatically + define_attribute :credit_application_policy, :CreditApplicationPolicy + # @!attribute currency # @return [String] 3-letter ISO 4217 currency code. define_attribute :currency, String @@ -138,6 +142,10 @@ class Subscription < Resource # @return [Integer] If `auto_renew=true`, when a term completes, `total_billing_cycles` takes this value as the length of subsequent terms. Defaults to the plan's `total_billing_cycles`. define_attribute :renewal_billing_cycles, Integer + # @!attribute resume_at + # @return [DateTime] The date the subscription billing resumes following a pause. Null unless the subscription is paused or scheduled to be paused. + define_attribute :resume_at, DateTime + # @!attribute revenue_schedule_type # @return [String] Revenue schedule type define_attribute :revenue_schedule_type, String diff --git a/lib/recurly/resources/tax_detail.rb b/lib/recurly/resources/tax_detail.rb index 02bc3dba1..f5fa8eb2c 100644 --- a/lib/recurly/resources/tax_detail.rb +++ b/lib/recurly/resources/tax_detail.rb @@ -7,15 +7,15 @@ module Resources class TaxDetail < Resource # @!attribute billable - # @return [Boolean] Whether or not the line item is taxable. Only populated for a single LineItem fetch when Avalara for Communications is enabled. + # @return [Boolean] Whether or not the line item is taxable. Only populated for a single LineItem fetch when Avalara for Communications or Vertex is enabled. define_attribute :billable, :Boolean # @!attribute level - # @return [String] Provides the jurisdiction level for the Communications tax applied. Example values include city, state and federal. Present only when Avalara for Communications is enabled. + # @return [String] Provides the jurisdiction level for the Communications tax applied. Example values include city, state and federal. Present only when Avalara for Communications or Vertex is enabled. define_attribute :level, String # @!attribute name - # @return [String] Provides the name of the Communications tax applied. Present only when Avalara for Communications is enabled. + # @return [String] Provides the name of the Communications tax applied. Present only when Avalara for Communications or Vertex is enabled. define_attribute :name, String # @!attribute rate @@ -31,7 +31,7 @@ class TaxDetail < Resource define_attribute :tax, Float # @!attribute type - # @return [String] Provides the tax type for the region or type of Comminications tax when Avalara for Communications is enabled. For Canadian Sales Tax, this will be GST, HST, QST or PST. + # @return [String] Provides the tax type for the region or type of Comminications tax when Avalara for Communications or Vertex is enabled. For Canadian Sales Tax, this will be GST, HST, QST or PST. define_attribute :type, String end end diff --git a/lib/recurly/resources/tax_info.rb b/lib/recurly/resources/tax_info.rb index 98f310a50..10d83f743 100644 --- a/lib/recurly/resources/tax_info.rb +++ b/lib/recurly/resources/tax_info.rb @@ -15,7 +15,7 @@ class TaxInfo < Resource define_attribute :region, String # @!attribute tax_details - # @return [Array[TaxDetail]] Provides additional tax details for Communications taxes when Avalara for Communications is enabled or Canadian Sales Tax when there is tax applied at both the country and province levels. This will only be populated for the Invoice response when fetching a single invoice and not for the InvoiceList or LineItemList. Only populated for a single LineItem fetch when Avalara for Communications is enabled. + # @return [Array[TaxDetail]] Provides additional tax details for Communications taxes when Avalara for Communications or Vertex Tax Breakdown is enabled or Canadian Sales Tax. Tax details will only be populated for the Invoice response when fetching a single invoice and not for the InvoiceList or LineItemList. Only populated for a single LineItem fetch when Avalara for Communications is enabled. define_attribute :tax_details, Array, { :item_type => :TaxDetail } # @!attribute type diff --git a/openapi/api.yaml b/openapi/api.yaml index 79338fcad..2a5cd6475 100644 --- a/openapi/api.yaml +++ b/openapi/api.yaml @@ -187,155 +187,129 @@ security: x-tagGroups: - name: Customers tags: - - account - - note - - account_acquisition - - billing_info - - billing_infos - - subscription - - subscription_change - - shipping_address - - purchase - - usage - - automated_exports -- name: Products and Promotions - tags: - - item - - plan - - add-on - - measured_unit - - coupon - - coupon_redemption - - unique_coupon_code + - Account + - Account Note + - Account Acquisition Info + - Billing Info + - Billing Infos + - Coupon Redemption + - Subscription + - Subscription Change + - Usage + - Shipping Address - name: Invoices and Payments tags: - - invoice - - line_item - - credit_payment - - transaction + - Purchase + - Invoice + - Line Item + - Credit Payment + - Transaction +- name: Products and Promotions + tags: + - Item + - Plan + - Add-on + - Measured Unit + - Coupon + - Unique Coupon Code - name: Configuration tags: - - site - - custom_field_definition - - shipping_method - - dunning_campaigns + - Site + - Custom Field Definition + - Shipping Method + - Dunning Campaigns + - Automated Exports tags: -- name: site - x-displayName: Site -- name: custom_field_definition - x-displayName: Custom Field Definition +- name: Site +- name: Custom Field Definition description: Describes the fields that can be used as custom fields on accounts, items, line-items (one time charges), plans, or subscriptions. -- name: item - x-displayName: Item +- name: Item description: |- For merchants who sell the same things to many customers, documenting those offerings in a catalog allows for faster charge creation, easier management of offerings, and analytics about your offerings across all sales channels. Because your offerings can be physical, digital, or service-oriented, Recurly collectively calls these offerings "Items". Recurly's item catalog requires the Credit Invoices feature to be enabled. -- name: plan - x-displayName: Plan +- name: Plan description: A plan tells Recurly how often and how much to charge your customers. Plans can be created with free trials, optional products (called add-ons), setup fees, and more. -- name: add-on - x-displayName: Add-on +- name: Add-on description: An add-on is a charge billed each billing period in addition to a subscription’s base charge. Each plan may have one or more add-ons associated with it. -- name: measured_unit - x-displayName: Measured Unit +- name: Measured Unit description: A measured unit describes a usage-based add-on's usage. If different usage-based add-ons share the same measured unit, you can report on customer usage for those add-ons at the aggregated measured unit level. -- name: account - x-displayName: Account +- name: Account description: Accounts are core to managing your customers inside of Recurly. The account object stores the entire Recurly history of your customer and acts as the entry point for working with a customer's billing information, subscription data, transactions, invoices and more. -- name: note - x-displayName: Account Note +- name: Account Note description: Account notes allow your team to leave notes on an account to add context, e.g. the reason for a refund, customer requests, and/or complaints. These notes are internal and not exposed to your customers. -- name: account_acquisition - x-displayName: Account Acquisition Info +- name: Account Acquisition Info description: Recurly offers the ability to record marketing data on customer accounts to match this data with revenue and billing data events in Recurly. -- name: billing_info - x-displayName: Billing Info +- name: Billing Info description: Without the premium Wallet feature, an account can only have one stored payment method at a time. Examples include credit cards, PayPal, or bank accounts. Billing info is filled out by the customer upon purchase or when they update their information. -- name: billing_infos - x-displayName: Billing Infos +- name: Billing Infos description: If the premium Wallet feature is enabled, an account can have multiple payment methods stored. Examples include credit cards, PayPal, or bank accounts. Primary or backup billing infos can be designated from these endpoints. -- name: subscription - x-displayName: Subscription +- name: Subscription description: Subscriptions are created when your customers subscribe to one of your plans. The customer's subscription tells Recurly when and how much to bill the customer. -- name: subscription_change - x-displayName: Subscription Change +- name: Subscription Change description: Subscription changes alter subscription in a way that might affect the invoiced amount, such as changing the plan, add-ons, quantities, or shipping address. Changes can be made immediately in the current billing cycle or scheduled to take place at the next renewal. -- name: shipping_address - x-displayName: Shipping Address +- name: Shipping Address description: Shipping addresses are tied to a customer's account. Each account can have up to 20 different shipping addresses, and if you have enabled multiple subscriptions per account, you can associate different shipping addresses to each subscription. -- name: invoice - x-displayName: Invoice +- name: Invoice description: An invoice relates charges, credits, and payments together. When a subscription is created or renewed or a charge is created on the account, Recurly will sum the charges, discount or tax as appropriate, and send the invoice out for collection. -- name: line_item - x-displayName: Line Item +- name: Line Item description: Line items are the charges and credits on your customer's invoices. -- name: credit_payment - x-displayName: Credit Payment -- name: purchase - x-displayName: Purchase +- name: Credit Payment +- name: Purchase description: A purchase is a checkout containing at least one or more subscriptions or one-time charges (line items) and supports both coupon and gift card redemptions. All items purchased will be on one invoice and paid for with one transaction. The purchases endpoint can also be used to immediately create a credit invoice on an account, when Credit Invoices is enabled on your site. -- name: usage - x-displayName: Usage +- name: Usage description: Send Recurly your customer usage and we will automatically bill them in arrears at the end of the billing cycle. For more info on usage-based billing, [click here](https://docs.recurly.com/docs/usage-based-billing). -- name: transaction - x-displayName: Transaction +- name: Transaction description: Purchasing information is sent to your payment gateway in an action called a transaction. This includes the customer's billing information and the amount of money to be charged, voided, or refunded. -- name: coupon - x-displayName: Coupon +- name: Coupon description: Coupons can either be single codes that easily allow mass distribution by many customers or bulk coupons that can generate many unique coupons that can allow for individual delivery and tracking. -- name: coupon_redemption - x-displayName: Coupon Redemption +- name: Coupon Redemption 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 +- name: Unique Coupon Code description: Unique coupon codes are generated from bulk coupons. -- name: shipping_method - x-displayName: Shipping Method +- name: Shipping Method description: Shipping methods offered to send products to customers. -- name: automated_exports - x-displayName: Automated Exports +- name: Automated Exports description: Automated exports of customer data. -- name: dunning_campaigns - x-displayName: Dunning Campaigns +- name: Dunning Campaigns description: Settings used when attempting to dun customers whose payments are declined. paths: "/sites": @@ -347,7 +321,7 @@ paths: See the [Pagination Guide](/developers/guides/pagination.html) to learn how to use pagination in the API and Client Libraries. tags: - - site + - Site parameters: - "$ref": "#/components/parameters/ids" - "$ref": "#/components/parameters/limit" @@ -422,12 +396,69 @@ paths: sites.HasMore {\n\terr := sites.Fetch()\n\tif 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, site := range sites.Data {\n\t\tfmt.Printf(\"Site %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tsite.Id,\n\t\t\tsite.Subdomain,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const sites = client.listSites({ limit: 200 }) + + for await (const site of sites.each()) { + console.log(site.subdomain) + } + name: Node.js + - language: python + code: | + sites = client.list_sites(limit=200).items() + for site in sites: + print(site.subdomain) + name: Python + - language: csharp + code: | + var sites = client.ListSites(limit: 200); + foreach(Site site in sites) + { + Console.WriteLine(site.Subdomain); + } + name: ".NET" + - language: ruby + code: | + sites = @client.list_sites(limit: 200) + sites.each do |site| + puts "Site: #{site.subdomain}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager sites = client.listSites(params); + + for (Site site : sites) { + System.out.println(site.getSubdomain()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $sites = $client->listSites($params); + + foreach($sites as $site) { + echo 'Site: ' . $site->getSubdomain() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListSitesParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"asc\"),\n\tLimit: recurly.Int(200),\n}\n\nsites := client.ListSites(listParams)\n\nfor + sites.HasMore {\n\terr := sites.Fetch()\n\tif 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, site := range sites.Data {\n\t\tfmt.Printf(\"Site %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tsite.Id,\n\t\t\tsite.Subdomain,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}": get: operationId: get_site summary: Fetch a site tags: - - site + - Site parameters: - "$ref": "#/components/parameters/site_id" responses: @@ -538,10 +569,107 @@ paths: not found: %v\", e)\n\t\treturn nil, err\n\t}\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\nfmt.Printf(\"Fetched Site: %s\", site.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const site = await client.getSite(siteId) + console.log('Fetched site: ', site) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + site = client.get_site(site_id) + print("Got Site %s" % site) + 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") + name: Python + - language: csharp + code: | + try + { + Site site = client.GetSite(siteId); + Console.WriteLine($"Fetched site {site.Id}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + site = @client.get_site(site_id: site_id) + puts "Got Site #{site}" + 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 + name: Ruby + - language: java + code: | + try { + final Site site = client.getSite(siteId); + System.out.println("Fetched site: " + site.getId()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $site = $client->getSite($site_id); + + echo 'Got Site:' . PHP_EOL; + var_dump($site); + } 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; + } + name: PHP + - language: go + code: "site, err := client.GetSite(siteID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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}\nfmt.Printf(\"Fetched Site: + %s\", site.Id)" + name: Go "/sites/{site_id}/accounts": get: tags: - - account + - Account operationId: list_accounts summary: List a site's accounts description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -633,9 +761,69 @@ paths: accounts.HasMore {\n\terr := accounts.Fetch()\n\tif 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, account := range accounts.Data {\n\t\tfmt.Printf(\"Account %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\taccount.Id,\n\t\t\taccount.Code,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const accounts = client.listAccounts({ limit: 200 }) + + for await (const account of accounts.each()) { + console.log(account.code) + } + name: Node.js + - language: python + code: | + accounts = client.list_accounts(limit=200).items() + for account in accounts: + print(account.code) + name: Python + - language: csharp + code: | + var accounts = client.ListAccounts(limit: 200); + foreach(Account account in accounts) + { + Console.WriteLine(account.Code); + } + name: ".NET" + - language: ruby + code: | + accounts = @client.list_accounts(limit: 200) + accounts.each do |account| + puts "Account: #{account.code}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + Pager accounts = client.listAccounts(params); + + for (Account acct : accounts) { + System.out.println(acct.getCode()); + } + name: Java + - language: php + code: | + $params = [ + 'limit' => 200, + ]; + $accounts = $client->listAccounts($params); + + foreach($accounts as $account) { + echo 'Account code: ' . $account->getCode() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListAccountsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\naccounts := + client.ListAccounts(listParams)\n\nfor accounts.HasMore {\n\terr := accounts.Fetch()\n\tif + 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, account := range accounts.Data + {\n\t\tfmt.Printf(\"Account %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\taccount.Id,\n\t\t\taccount.Code,\n\t\t)\n\t}\n}" + name: Go post: tags: - - account + - Account operationId: create_account summary: Create an account parameters: @@ -891,13 +1079,234 @@ paths: {\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(\"Created Account: %s\", account.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const accountCreate = { + code: accountCode, + firstName: 'Benjamin', + lastName: 'Du Monde', + preferredTimeZone: 'America/Chicago', + address: { + street1: '900 Camp St', + city: 'New Orleans', + region: 'LA', + postalCode: '70115', + country: 'US' + } + } + const account = await client.createAccount(accountCreate) + console.log('Created Account: ', account.code) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + account_create = { + "code": account_code, + "first_name": "Benjamin", + "last_name": "Du Monde", + "preferred_time_zone": "America/Chicago", + "acquisition": { + "campaign": "podcast-marketing", + "channel": "social_media", + "subchannel": "twitter", + "cost": {"currency": "USD", "amount": 0.50}, + }, + "shipping_addresses": [ + { + "nickname": "Home", + "street1": "1 Tchoupitoulas St", + "city": "New Orleans", + "region": "LA", + "country": "US", + "postal_code": "70115", + "first_name": "Aaron", + "last_name": "Du Monde", + } + ], + } + account = client.create_account(account_create) + print("Created Account %s" % account) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var accountReq = new AccountCreate() + { + Code = accountCode, + FirstName = "Benjamin", + LastName = "Du Monde", + PreferredTimeZone = "America/Chicago", + Address = new Address() + { + City = "New Orleans", + Region = "LA", + Country = "US", + PostalCode = "70115", + Street1 = "900 Camp St." + } + }; + Account account = client.CreateAccount(accountReq); + Console.WriteLine($"Created account {account.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}"); + } + name: ".NET" + - language: ruby + code: | + begin + account_create = { + code: account_code, + first_name: "Benjamin", + last_name: "Du Monde", + preferred_time_zone: "America/Chicago", + acquisition: { + campaign: "podcast-marketing", + channel: "social_media", + subchannel: "twitter", + cost: { + currency: "USD", + amount: 0.50 + } + }, + shipping_addresses: [ + { + nickname: "Home", + street1: "1 Tchoupitoulas St", + city: "New Orleans", + region: "LA", + country: "US", + postal_code: "70115", + first_name: "Benjamin", + last_name: "Du Monde" + } + ] + } + account = @client.create_account(body: account_create) + puts "Created Account #{account}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + AccountCreate accountReq = new AccountCreate(); + Address address = new Address(); + + accountReq.setCode(accountCode); + accountReq.setFirstName("Aaron"); + accountReq.setLastName("Du Monde"); + accountReq.setPreferredTimeZone("America/Chicago"); + + address.setStreet1("900 Camp St."); + address.setCity("New Orleans"); + address.setRegion("LA"); + address.setCountry("US"); + address.setPostalCode("70115"); + + accountReq.setAddress(address); + + Account account = client.createAccount(accountReq); + System.out.println("Created account " + account.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()); + } + name: Java + - language: php + code: | + try { + $account_create = [ + "code" => $account_code, + "first_name" => "Douglas", + "last_name" => "DuMonde", + "preferred_time_zone" => "America/Chicago", + "shipping_addresses" => [ + [ + "first_name" => "Douglas", + "last_name" => "DuMonde", + "nickname" => "nola", + "street1" => "1 Tchoupitoulas", + "city" => "New Orleans", + "postal_code" => "70130", + "country" => "US" + ] + ] + ]; + + $account = $client->createAccount($account_create); + + echo 'Created Account:' . PHP_EOL; + var_dump($account); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "accountReq := &recurly.AccountCreate{\n\tCode: &accountCode,\n\tFirstName: + recurly.String(\"Isaac\"),\n\tLastName: recurly.String(\"Du Monde\"),\n\tEmail: + \ recurly.String(\"isaac@example.com\"),\n\tPreferredTimeZone: recurly.String(\"America/Los_Angeles\"),\n\tBillingInfo: + &recurly.BillingInfoCreate{\n\t\tFirstName: recurly.String(\"Isaac\"),\n\t\tLastName: + \ recurly.String(\"Du Monde\"),\n\t\tAddress: &recurly.AddressCreate{\n\t\t\tPhone: + \ recurly.String(\"415-555-5555\"),\n\t\t\tStreet1: recurly.String(\"400 + Alabama St.\"),\n\t\t\tCity: recurly.String(\"San Francisco\"),\n\t\t\tPostalCode: + recurly.String(\"94110\"),\n\t\t\tCountry: recurly.String(\"US\"),\n\t\t\tRegion: + \ recurly.String(\"CA\"),\n\t\t},\n\t\tNumber: recurly.String(\"4111111111111111\"),\n\t\tMonth: + \ recurly.String(\"12\"),\n\t\tYear: recurly.String(\"30\"),\n\t\tCvv: + \ recurly.String(\"123\"),\n\t},\n}\n\naccount, err := client.CreateAccount(accountReq)\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(\"Created Account: + %s\", account.Id)" + name: Go "/sites/{site_id}/accounts/{account_id}": parameters: - "$ref": "#/components/parameters/site_id" - "$ref": "#/components/parameters/account_id" get: tags: - - account + - Account operationId: get_account summary: Fetch an account responses: @@ -1002,9 +1411,106 @@ paths: not found: %v\", e)\n\t\treturn nil, err\n\t}\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\nfmt.Println(\"Fetched Account \", account.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const account = await client.getAccount(accountId) + console.log('Fetched account: ', account.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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + account = client.get_account(account_id) + print("Got Account %s" % account) + 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") + name: Python + - language: csharp + code: | + try + { + Account account = client.GetAccount(accountId); + Console.WriteLine($"Fetched account {account.Code}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + account = @client.get_account(account_id: account_id) + puts "Got Account #{account}" + 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 + name: Ruby + - language: java + code: | + try { + final Account account = client.getAccount(accountId); + System.out.println("Fetched account: " + account.getCode()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $account = $client->getAccount($account_id); + + echo 'Got Account:' . PHP_EOL; + var_dump($account); + } 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; + } + name: PHP + - language: go + code: "account, err := client.GetAccount(accountID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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}\nfmt.Println(\"Fetched Account + \", account.Id)" + name: Go put: tags: - - account + - Account operationId: update_account summary: Modify an account requestBody: @@ -1164,9 +1670,136 @@ paths: {\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(\"Updated Account: %s\", account.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const accountUpdate = { + firstName: 'Aaron', + lastName: 'Du Monde' + } + const account = await client.updateAccount(accountId, accountUpdate) + console.log('Updated account: ', account) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + account_update = {"first_name": "Aaron", "last_name": "Du Monde"} + account = client.update_account(account_id, account_update) + print("Updated Account %s" % account) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var accountReq = new AccountUpdate() { + FirstName = "Aaron", + LastName = "Du Monde" + }; + Account account = client.UpdateAccount(accountId, accountReq); + Console.WriteLine(account.FirstName); + Console.WriteLine(account.LastName); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + account_update = { + first_name: "Aaron", + last_name: "Du Monde", + } + account = @client.update_account( + account_id: account_id, + body: account_update + ) + puts "Updated Account #{account}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + final AccountUpdate accountUpdate = new AccountUpdate(); + accountUpdate.setFirstName("Aaron"); + accountUpdate.setLastName("Du Monde"); + + final Account account = client.updateAccount(accountId, accountUpdate); + System.out.println("Updated account: " + account.getCode()); + System.out.println(account.getFirstName()); + System.out.println(account.getLastName()); + } 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()); + } + name: Java + - language: php + code: | + try { + $account_update = [ + "first_name" => "Douglas", + "last_name" => "Du Monde", + ]; + + $account = $client->updateAccount($account_id, $account_update); + + echo 'Updated Account:' . PHP_EOL; + var_dump($account); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "updateReq := &recurly.AccountUpdate{\n\tFirstName: recurly.String(\"Joanna\"),\n\tLastName: + \ recurly.String(\"DuMonde\"),\n}\naccount, err := client.UpdateAccount(accountID, + 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(\"Updated Account: + %s\", account.Id)" + name: Go delete: tags: - - account + - Account operationId: deactivate_account summary: Deactivate an account description: Deactivating an account permanently deletes its billing information @@ -1277,13 +1910,106 @@ paths: not found: %v\", e)\n\t\treturn nil, err\n\t}\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\nfmt.Printf(\"Deactivated Account: %s\", account.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const account = await client.deactivateAccount(accountId) + console.log('Deleted account: ', account.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') + } + } + name: Node.js + - language: python + code: | + try: + account = client.deactivate_account(account_id) + print("Deactivated Account %s" % account) + 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") + name: Python + - language: csharp + code: | + try + { + Account account = client.DeactivateAccount(accountId); + Console.WriteLine($"Deactivated account {account.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}"); + } + name: ".NET" + - language: ruby + code: | + begin + account = @client.deactivate_account(account_id: account_id) + puts "Deactivated Account #{account}" + 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 + name: Ruby + - language: java + code: | + try { + Account account = client.deactivateAccount(accountId); + System.out.println("deactivated account " + account.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()); + } + name: Java + - language: php + code: | + try { + $account = $client->deactivateAccount($account_id); + + echo 'Deactivated Account:' . PHP_EOL; + var_dump($account); + } 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; + } + name: PHP + - language: go + code: "account, err := client.DeactivateAccount(accountID)\nif e, ok := + err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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}\nfmt.Printf(\"Deactivated + Account: %s\", account.Id)" + name: Go "/sites/{site_id}/accounts/{account_id}/acquisition": parameters: - "$ref": "#/components/parameters/site_id" - "$ref": "#/components/parameters/account_id" get: tags: - - account_acquisition + - Account Acquisition Info operationId: get_account_acquisition summary: Fetch an account's acquisition data responses: @@ -1389,9 +2115,106 @@ 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}\nfmt.Printf(\"Fetched Account Acquisition: %v\", accountAcq.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const acquisition = await client.getAccountAcquisition(accountId) + console.log('Fetched account acquisition: ', acquisition.id) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + acquisition = client.get_account_acquisition(account_id) + print("Got AccountAcquisition %s" % acquisition) + 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") + name: Python + - language: csharp + code: | + try + { + AccountAcquisition acquisition = client.GetAccountAcquisition(accountId); + Console.WriteLine($"Fetched account acquisition {acquisition.Id}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + @client.get_account_acquisition(account_id: account_id) + puts "Got AccountAcquisition" + 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 + name: Ruby + - language: java + code: | + try { + final AccountAcquisition acquisition = client.getAccountAcquisition(accountId); + System.out.println("Fetched account acquisition " + acquisition.getId()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $acquisition = $client->getAccountAcquisition($account_id); + + echo 'Got Account Acquisition:' . PHP_EOL; + var_dump($acquisition); + } 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; + } + name: PHP + - language: go + code: "accountAcq, err := client.GetAccountAcquisition(accountID)\nif e, + ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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}\nfmt.Printf(\"Fetched Account + Acquisition: %v\", accountAcq.Id)" + name: Go put: tags: - - account_acquisition + - Account Acquisition Info operationId: update_account_acquisition summary: Update an account's acquisition data requestBody: @@ -1556,9 +2379,148 @@ paths: 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(\"Updated Account Acquisition: %s\", account.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const acquisitionUpdate = { + campaign: "big-event-campaign", + channel: "social_media", + subchannel: "twitter" + } + const accountAcquisition = await client.updateAccountAcquisition(accountId, acquisitionUpdate) + console.log('Edited Account Acquisition: ', accountAcquisition) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + acquisition_update = { + "campaign": "podcast-marketing", + "channel": "social_media", + "subchannel": "twitter", + "cost": {"currency": "USD", "amount": 0.50}, + } + acquisition = client.update_account_acquisition(account_id, acquisition_update) + print("Updated AccountAcquisition %s" % acquisition) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var acquisitionReq = new AccountAcquisitionUpdatable() + { + Campaign = "big-event-campaign", + Channel = "social_media", + Subchannel = "twitter" + }; + AccountAcquisition accountAcquisition = client.UpdateAccountAcquisition(accountId, acquisitionReq); + Console.WriteLine(accountAcquisition); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + acquisition_update = { + campaign: "podcast-marketing", + channel: "social_media", + subchannel: "twitter", + cost: { + currency: "USD", + amount: 0.50 + } + } + acquisition = @client.update_account_acquisition( + account_id: account_id, + body: acquisition_update + ) + puts "Updated AccountAcqusition #{acquisition}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + final AccountAcquisitionUpdatable acqUpdate = new AccountAcquisitionUpdatable(); + acqUpdate.setCampaign("big-event-campaign"); + acqUpdate.setChannel("social_media"); + acqUpdate.setSubchannel("twitter"); + + final AccountAcquisition accountAcquisition = client.updateAccountAcquisition(accountId, acqUpdate); + System.out.println(accountAcquisition); + } 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()); + } + name: Java + - language: php + code: | + try { + $acquisition_update = [ + "campaign" => "big-event-campaign", + "channel" => "social_media", + "subchannel" => "twitter" + ]; + $acquisition = $client->updateAccountAcquisition($account_id, $acquisition_update); + + echo 'Updated AccountAcquisition:' . PHP_EOL; + var_dump($acquisition); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "updateReq := &recurly.AccountAcquisitionUpdatable{\n\tCampaign: recurly.String(\"big-event-campaign\"),\n\tChannel: + \ recurly.String(\"social_media\"),\n\tSubchannel: recurly.String(\"twitter\"),\n}\naccount, + err := client.UpdateAccountAcquisition(accountID, 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(\"Updated Account + Acquisition: %s\", account.Id)" + name: Go delete: tags: - - account_acquisition + - Account Acquisition Info operationId: remove_account_acquisition summary: Remove an account's acquisition data responses: @@ -1657,13 +2619,108 @@ paths: not found: %v\", e)\n\t\treturn nil, err\n\t}\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\nfmt.Printf(\"Removed Account Acquisition: %s\", accountAcquisition.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + await client.removeAccountAcquisition(accountId) + console.log('Removed account acquisition from account: ', accountId) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + client.remove_account_acquisition(account_id) + print("Removed AccountAcquisition for Account id=%s" % account_id) + 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") + name: Python + - language: csharp + code: | + try + { + client.RemoveAccountAcquisition(accountId); + Console.WriteLine($"Removed account acquisition from account {accountId}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + acquisition = @client.remove_account_acquisition(account_id: account_id) + puts "Removed AccountAcqusition #{acquisition}" + 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 + name: Ruby + - language: java + code: | + try { + client.removeAccountAcquisition(accountId); + System.out.println("Removed account acquisition from account " + accountId); + } 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()); + } + name: Java + - language: php + code: |- + try { + $client->removeAccountAcquisition($account_id); + echo "Removed Account Acquisition:" . PHP_EOL; + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "client.RemoveAccountAcquisition(accountID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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}\nfmt.Printf(\"Removed Account + Acquisition: %s\", accountAcquisition.Id)" + name: Go "/sites/{site_id}/accounts/{account_id}/reactivate": parameters: - "$ref": "#/components/parameters/site_id" - "$ref": "#/components/parameters/account_id" put: tags: - - account + - Account operationId: reactivate_account summary: Reactivate an inactive account description: Reactivating an account will restore its history but the customer @@ -1778,13 +2835,106 @@ paths: 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(\"Reactivated Account: %s\", account.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const account = await client.reactivateAccount(accountId) + console.log('Reactivated account: ', account.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') + } + } + name: Node.js + - language: python + code: | + try: + account = client.reactivate_account(account_id) + print("Reactivated Account %s" % account) + 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") + name: Python + - language: csharp + code: | + try + { + Account account = client.ReactivateAccount(accountId); + Console.WriteLine($"Reactivated account {account.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}"); + } + name: ".NET" + - language: ruby + code: | + begin + account = @client.reactivate_account(account_id: account_id) + puts "Reactivated account #{account}" + 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 + name: Ruby + - language: java + code: | + try { + final Account account = client.reactivateAccount(accountId); + System.out.println("Reactivated account: " + account.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()); + } + name: Java + - language: php + code: | + try { + $account = $client->reactivateAccount($account_id); + + echo 'Reactivated Account:' . PHP_EOL; + var_dump($account); + } 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; + } + name: PHP + - language: go + code: "account, err := client.ReactivateAccount(accountID)\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(\"Reactivated + Account: %s\", account.Id)" + name: Go "/sites/{site_id}/accounts/{account_id}/balance": parameters: - "$ref": "#/components/parameters/site_id" - "$ref": "#/components/parameters/account_id" get: tags: - - account + - Account operationId: get_account_balance summary: Fetch an account's balance and past due status responses: @@ -1895,10 +3045,107 @@ 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}\nfmt.Printf(\"Fetched Account Balance: %v\", accountBalance)" + x-readme: + code-samples: + - language: node + code: | + try { + const balance = await client.getAccountBalance(accountId) + console.log('Fetched account balance: ', balance.balances) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + balance = client.get_account_balance(account_id) + print("Got AccountBalance %s" % balance) + 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") + name: Python + - language: csharp + code: | + try + { + AccountBalance balance = client.GetAccountBalance(accountId); + Console.WriteLine($"Fetched account balance {balance.Balances}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + balance = @client.get_account_balance(account_id: account_id) + puts "Got AccountBalance #{balance}" + 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 + name: Ruby + - language: java + code: | + try { + final AccountBalance balance = client.getAccountBalance(accountId); + System.out.println("Fetched account balance " + balance.getBalances()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $balance = $client->getAccountBalance($account_id); + + echo 'Got Account Balance:' . PHP_EOL; + var_dump($balance); + } 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; + } + name: PHP + - language: go + code: "accountBalance, err := client.GetAccountBalance(accountID)\nif e, + ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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}\nfmt.Printf(\"Fetched Account + Balance: %v\", accountBalance)" + name: Go "/sites/{site_id}/accounts/{account_id}/billing_info": get: tags: - - billing_info + - Billing Info operationId: get_billing_info summary: Fetch an account's billing information parameters: @@ -2013,9 +3260,106 @@ paths: 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(\"Fetched Billing Info: %v\", billingInfo)" + x-readme: + code-samples: + - language: node + code: | + try { + const billingInfo = await client.getBillingInfo(accountId) + console.log('Fetched Billing Info: ', billingInfo.id) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + binfo = client.get_billing_info(account_id) + print("Got BillingInfo %s" % binfo) + 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") + name: Python + - language: csharp + code: | + try + { + BillingInfo billingInfo = client.GetBillingInfo(accountId); + Console.WriteLine($"Fetched billing info {billingInfo.Id}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + billing = @client.get_billing_info(account_id: account_id) + puts "Got BillingInfo #{billing}" + 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 + name: Ruby + - language: java + code: | + try { + final BillingInfo billingInfo = client.getBillingInfo(accountId); + System.out.println("Fetched billing info " + billingInfo.getId()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $binfo = $client->getBillingInfo($account_id); + + echo 'Got BillingInfo:' . PHP_EOL; + var_dump($binfo); + } 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; + } + name: PHP + - language: go + code: "billingInfo, err := client.GetBillingInfo(accountID)\nif e, ok := + err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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(\"Fetched + Billing Info: %v\", billingInfo)" + name: Go put: tags: - - billing_info + - Billing Info operationId: update_billing_info summary: Set an account's billing information description: | @@ -2187,9 +3531,132 @@ paths: {\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(\"Updated Billing Info: %s\", billingInfo)" + x-readme: + code-samples: + - language: node + code: | + try { + const billingInfoUpdate = { + firstName: 'Aaron', + lastName: 'Du Monde', + } + const billingInfo = await client.updateBillingInfo(accountId, billingInfoUpdate) + console.log('Updated billing info: ', billingInfo.id) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + billing_update = {"first_name": "Aaron", "last_name": "Du Monde"} + billing = client.update_billing_info(account_id, billing_update) + print("Updated BillingInfo %s" % billing) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var billingReq = new BillingInfoCreate() { + FirstName = "Benjamin", + LastName = "Du Monde" + }; + BillingInfo billingInfo = client.UpdateBillingInfo(accountId, billingReq); + Console.WriteLine($"Updated billing info {billingInfo.Id}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + billing_update = { + first_name: "Aaron", + last_name: "Du Monde", + } + billing = @client.update_billing_info( + account_id: account_id, + body: billing_update + ) + puts "Updated BillingInfo #{billing}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + final BillingInfoCreate billingUpdate = new BillingInfoCreate(); + billingUpdate.setFirstName("Aaron"); + billingUpdate.setLastName("Du Monde"); + + final BillingInfo billingInfo = client.updateBillingInfo(accountId, billingUpdate); + System.out.println("Updated billing info " + billingInfo.getId()); + } 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()); + } + name: Java + - language: php + code: | + try { + $binfo_update = [ + "first_name" => "Douglas", + "last_name" => "Du Monde", + ]; + $binfo = $client->updateBillingInfo($account_id, $binfo_update); + + echo 'Updated BillingInfo:' . PHP_EOL; + var_dump($binfo); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "updateReq := &recurly.BillingInfoCreate{\n\tFirstName: recurly.String(\"Joanna\"),\n\tLastName: + \ recurly.String(\"DuMonde\"),\n}\nbillingInfo, err := client.UpdateBillingInfo(accountID, + 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(\"Updated Billing + Info: %s\", billingInfo)" + name: Go delete: tags: - - billing_info + - Billing Info operationId: remove_billing_info summary: Remove an account's billing information parameters: @@ -2295,10 +3762,105 @@ 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 Billing Info: %v\", billingInfo)" + x-readme: + code-samples: + - language: node + code: | + try { + client.removeBillingInfo(accountId) + console.log('Removed billing info from account: ', accountId) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + client.remove_billing_info(account_id) + print("Removed BillingInfo for Account id=%s" % account_id) + 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") + name: Python + - language: csharp + code: | + try + { + client.RemoveBillingInfo(accountId); + Console.WriteLine($"Removed billing info from account {accountId}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + @client.remove_billing_info(account_id: account_id) + puts "Removed BillingInfo #{account_id}" + 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 + name: Ruby + - language: java + code: | + try { + client.removeBillingInfo(accountId); + System.out.println("Removed billing info from account " + accountId); + } 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()); + } + name: Java + - language: php + code: |- + try { + $client->removeBillingInfo($account_id); + echo "Removed Billing Info: " . $account_id . PHP_EOL; + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "billingInfo, err := client.RemoveBillingInfo(accountID)\nif e, ok + := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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 + Billing Info: %v\", billingInfo)" + name: Go "/sites/{site_id}/accounts/{account_id}/billing_info/verify": post: tags: - - billing_info + - Billing Info operationId: verify_billing_info summary: Verify an account's credit card billing information parameters: @@ -2427,20 +3989,166 @@ 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(\"Fetched Transaction: %v\", transaction)" - "/sites/{site_id}/accounts/{account_id}/billing_infos": - get: + x-readme: + code-samples: + - language: node + code: | + try { + const transaction = await client.verifyBillingInfo(accountId) + console.log('Fetched Transaction: ', transaction.id) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + transaction = client.verify_billing_info(account_id) + print("Got Transaction %s" % transaction) + 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") + name: Python + - language: csharp + code: | + try + { + Transaction transaction = client.VerifyBillingInfo(accountId); + Console.WriteLine($"Fetched transaction {transaction.Id}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + transaction = @client.verify_billing_info(account_id: account_id) + puts "Got Transaction #{transaction}" + 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 + name: Ruby + - language: java + code: | + try { + final Transaction transaction = client.verifyBillingInfo(accountId); + System.out.println("Fetched transaction " + transaction.getId()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $transaction = $client->verifyBillingInfo($account_id); + + echo 'Got Transaction:' . PHP_EOL; + var_dump($transaction); + } 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; + } + name: PHP + - language: go + code: "verifyBillingInfoParams := &recurly.VerifyBillingInfoParams{}\ntransaction, + err := client.VerifyBillingInfo(accountID, verifyBillingInfoParams)\nif + e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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(\"Fetched + Transaction: %v\", transaction)" + name: Go + "/sites/{site_id}/accounts/{account_id}/billing_info/verify_cvv": + post: tags: - - billing_infos - operationId: list_billing_infos - summary: Get the list of billing information associated with an account - description: See the [Pagination Guide](/developers/guides/pagination.html) - to learn how to use pagination in the API and Client Libraries. + - Billing Info + operationId: verify_billing_info_cvv + summary: Verify an account's credit card billing cvv parameters: - "$ref": "#/components/parameters/site_id" - "$ref": "#/components/parameters/account_id" - - "$ref": "#/components/parameters/ids" - - "$ref": "#/components/parameters/sort_dates" - - "$ref": "#/components/parameters/filter_begin_time" + requestBody: + content: + application/json: + schema: + "$ref": "#/components/schemas/BillingInfoVerifyCVV" + responses: + '200': + description: Transaction information from verify. + content: + application/json: + schema: + "$ref": "#/components/schemas/Transaction" + '404': + description: Account has no billing information, or incorrect site or account + ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '422': + description: Invalid billing information, or error running the verification + transaction. + content: + application/json: + schema: + "$ref": "#/components/schemas/ErrorMayHaveTransaction" + '429': + description: Too many CVV verification attempts. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + "/sites/{site_id}/accounts/{account_id}/billing_infos": + get: + tags: + - Billing Infos + operationId: list_billing_infos + summary: Get the list of billing information associated with an account + description: See the [Pagination Guide](/developers/guides/pagination.html) + to learn how to use pagination in the API and Client Libraries. + parameters: + - "$ref": "#/components/parameters/site_id" + - "$ref": "#/components/parameters/account_id" + - "$ref": "#/components/parameters/ids" + - "$ref": "#/components/parameters/sort_dates" + - "$ref": "#/components/parameters/filter_begin_time" - "$ref": "#/components/parameters/filter_end_time" responses: '200': @@ -2464,7 +4172,7 @@ paths: x-code-samples: [] post: tags: - - billing_infos + - Billing Infos operationId: create_billing_info summary: Add new billing information on an account description: | @@ -2525,7 +4233,7 @@ paths: "/sites/{site_id}/accounts/{account_id}/billing_infos/{billing_info_id}": get: tags: - - billing_infos + - Billing Infos operationId: get_a_billing_info summary: Fetch a billing info parameters: @@ -2548,7 +4256,7 @@ paths: x-code-samples: [] put: tags: - - billing_infos + - Billing Infos operationId: update_a_billing_info summary: Update an account's billing information description: | @@ -2609,7 +4317,7 @@ paths: x-code-samples: [] delete: tags: - - billing_infos + - Billing Infos operationId: remove_a_billing_info summary: Remove an account's billing information parameters: @@ -2637,10 +4345,103 @@ paths: schema: "$ref": "#/components/schemas/Error" x-code-samples: [] + "/sites/{site_id}/accounts/{account_id}/billing_infos/{billing_info_id}/verify": + post: + tags: + - Billing Infos + operationId: verify_billing_infos + summary: Verify a billing information's credit card + parameters: + - "$ref": "#/components/parameters/site_id" + - "$ref": "#/components/parameters/account_id" + - "$ref": "#/components/parameters/billing_info_id" + requestBody: + content: + application/json: + schema: + "$ref": "#/components/schemas/BillingInfoVerify" + required: false + responses: + '200': + description: Transaction information from verify. + content: + application/json: + schema: + "$ref": "#/components/schemas/Transaction" + '404': + description: Billing information not found, or incorrect site or account + ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '422': + description: Invalid billing information, or error running the verification + transaction. + content: + application/json: + schema: + "$ref": "#/components/schemas/ErrorMayHaveTransaction" + x-code-samples: [] + "/sites/{site_id}/accounts/{account_id}/billing_infos/{billing_info_id}/verify_cvv": + post: + tags: + - Billing Infos + operationId: verify_billing_infos_cvv + summary: Verify a billing information's credit card cvv + parameters: + - "$ref": "#/components/parameters/site_id" + - "$ref": "#/components/parameters/account_id" + - "$ref": "#/components/parameters/billing_info_id" + requestBody: + content: + application/json: + schema: + "$ref": "#/components/schemas/BillingInfoVerifyCVV" + responses: + '200': + description: Transaction information from verify. + content: + application/json: + schema: + "$ref": "#/components/schemas/Transaction" + '404': + description: Billing information not found, or incorrect site or account + ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '422': + description: Invalid billing information, or error running the verification + transaction. + content: + application/json: + schema: + "$ref": "#/components/schemas/ErrorMayHaveTransaction" + '429': + description: Too many CVV verification attempts. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] "/sites/{site_id}/accounts/{account_id}/coupon_redemptions": get: tags: - - coupon_redemption + - Coupon Redemption operationId: list_account_coupon_redemptions summary: List the coupon redemptions for an account description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -2726,10 +4527,72 @@ paths: next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, couponRedemption := range accountCouponRedemptions.Data {\n\t\tfmt.Printf(\"Account Coupon Redemption %3d: %s\\n\",\n\t\t\ti,\n\t\t\tcouponRedemption.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const redemptions = client.listAccountCouponRedemptions(accountId, { limit: 200 }) + + for await (const redemption of redemptions.each()) { + console.log(redemption.id) + } + name: Node.js + - language: python + code: | + redemptions = client.list_account_coupon_redemptions(account_id, limit=200).items() + for redemption in redemptions: + print(redemption.id) + name: Python + - language: csharp + code: | + var redemptions = client.ListAccountCouponRedemptions(accountId); + foreach(CouponRedemption redemption in redemptions) + { + Console.WriteLine(redemption.Id); + } + name: ".NET" + - language: ruby + code: | + redemptions = @client.list_account_coupon_redemptions( + account_id: account_id, + limit: 200 + ) + redemptions.each do |redemption| + puts "CouponRedemption: #{redemption.id}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager redemptions = client.listAccountCouponRedemptions(accountId, params); + + for (CouponRedemption redemption : redemptions) { + System.out.println(redemption.getId()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $account_coupon_redemptions = $client->listAccountCouponRedemptions($account->getId(), $params); + + foreach($account_coupon_redemptions as $coupon_redemption) { + echo 'Coupon redemption: ' . $coupon_redemption->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListAccountCouponRedemptionsParams{\n\tSort: + recurly.String(\"created_at\"),\n}\naccountCouponRedemptions := client.ListAccountCouponRedemptions(accountID, + listParams)\n\nfor accountCouponRedemptions.HasMore {\n\terr := accountCouponRedemptions.Fetch()\n\tif + 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, couponRedemption := range + accountCouponRedemptions.Data {\n\t\tfmt.Printf(\"Account Coupon Redemption + %3d: %s\\n\",\n\t\t\ti,\n\t\t\tcouponRedemption.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/accounts/{account_id}/coupon_redemptions/active": get: tags: - - coupon_redemption + - Coupon Redemption operationId: get_active_coupon_redemption summary: Fetch the coupon redemption that is active on an account parameters: @@ -2843,9 +4706,106 @@ 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(\"Fetched Active Coupon Redemption: %v\", couponRedemption.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const redemption = await client.getActiveCouponRedemption(accountId) + console.log('Fetched coupon redemption: ', redemption.id) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + redemption = client.get_active_coupon_redemption(account_id) + print("Got Redemption %s" % redemption) + 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") + name: Python + - language: csharp + code: | + try + { + CouponRedemption redemption = client.GetActiveCouponRedemption(accountId); + Console.WriteLine($"Fetched coupon redemption {redemption.Id}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + redemption = @client.get_active_coupon_redemption(account_id: account_id) + puts "Got CouponRedemption #{redemption}" + 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 + name: Ruby + - language: java + code: | + try { + final CouponRedemption redemption = client.getActiveCouponRedemption(accountId); + System.out.println("Fetched coupon redemption " + redemption.getId()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $redemption = $client->getActiveCouponRedemption($account_id); + + echo 'Got Redemption:' . PHP_EOL; + var_dump($redemption); + } 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; + } + name: PHP + - language: go + code: "couponRedemption, err := client.GetActiveCouponRedemption(accountID)\nif + e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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(\"Fetched + Active Coupon Redemption: %v\", couponRedemption.Id)" + name: Go post: tags: - - coupon_redemption + - Coupon Redemption operationId: create_coupon_redemption summary: Generate an active coupon redemption on an account or subscription parameters: @@ -2974,9 +4934,109 @@ paths: {\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(\"Created Coupon Redemption: %v\", couponRedemption)" + x-readme: + code-samples: + - language: python + code: | + try: + redemption_create = {"currency": "USD", "coupon_id": coupon_id} + redemption = client.create_coupon_redemption(account_id, redemption_create) + print("Created Redemption %s" % redemption) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: |- + try { + var redemptionReq = new CouponRedemptionCreate() + { + CouponId = couponId, + }; + var redemption = client.CreateCouponRedemption(accountId, redemptionReq); + Console.WriteLine($"Created coupon redemption: {redemption.Id}"); + + } 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + redemption_create = { + currency: 'USD', + coupon_id: coupon_id + } + redemption = @client.create_coupon_redemption( + account_id: account_id, + body: redemption_create + ) + puts "Created CouponRedemption #{redemption}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + CouponRedemptionCreate coupRedCreate = new CouponRedemptionCreate(); + coupRedCreate.setCouponId(couponId); + + CouponRedemption redemption = client.createCouponRedemption(accountId, coupRedCreate); + System.out.println("Created coupon redemption " + redemption.getId()); + } 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()); + } + name: Java + - language: php + code: |- + try { + $redemption_create = [ + "currency" => "USD", + "coupon_id" => "code-$coupon_code" + ]; + $redemption = $client->createCouponRedemption($account_id, $redemption_create); + echo "Created Redemption:" . PHP_EOL; + var_dump($redemption); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "redemptionReq := &recurly.CouponRedemptionCreate{\n\tCouponId: recurly.String(couponID),\n\tCurrency: + recurly.String(\"USD\"),\n}\n\ncouponRedemption, err := client.CreateCouponRedemption(accountID, + redemptionReq)\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(\"Created Coupon Redemption: + %v\", couponRedemption)" + name: Go delete: tags: - - coupon_redemption + - Coupon Redemption operationId: remove_coupon_redemption summary: Delete the active coupon redemption from an account parameters: @@ -3088,10 +5148,105 @@ 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)" + x-readme: + code-samples: + - language: node + code: | + try { + const redemption = await client.removeCouponRedemption(accountId) + console.log('Removed coupon redemption: ', redemption.id) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + client.remove_coupon_redemption(account_id) + print("Removed Redemption from Account id=%s" % account_id) + 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") + name: Python + - language: csharp + code: |- + try { + var redemption = client.RemoveCouponRedemption(accountId); + Console.WriteLine($"Removed coupon redemption from account: {redemption.Id}"); + + } 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + @client.remove_coupon_redemption(account_id: account_id) + puts "Removed CouponRedemption #{account_id}" + 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 + name: Ruby + - language: java + code: | + try { + final CouponRedemption redemption = client.removeCouponRedemption(accountId); + System.out.println("Removed coupon redemption " + redemption.getId()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: |- + try { + $redemption = $client->removeCouponRedemption($account_id); + echo "Removed Active Coupon Redemption:" . PHP_EOL; + var_dump($redemption); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "couponRedemption, err := client.RemoveCouponRedemption(accountID)\nif + e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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)" + name: Go "/sites/{site_id}/accounts/{account_id}/credit_payments": get: tags: - - credit_payment + - Credit Payment operationId: list_account_credit_payments summary: List an account's credit payments description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -3183,10 +5338,72 @@ 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, creditPayment := range creditPayments.Data {\n\t\tfmt.Printf(\"Account Credit Payment %3d: %s\\n\",\n\t\t\ti,\n\t\t\tcreditPayment.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const payments = client.listAccountCreditPayments(accountId, { limit: 200 }) + + for await (const payment of payments.each()) { + console.log(payment.uuid) + } + name: Node.js + - language: python + code: | + payments = client.list_account_credit_payments(account_id, limit=200).items() + for payment in payments: + print(payment.id) + name: Python + - language: csharp + code: | + var payments = client.ListAccountCreditPayments(accountId, limit: 200); + foreach(CreditPayment payment in payments) + { + Console.WriteLine(payment.Uuid); + } + name: ".NET" + - language: ruby + code: | + payments = @client.list_account_credit_payments( + account_id: account_id, + limit: 200 + ) + payments.each do |payment| + puts "CreditPayment: #{payment.id}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + Pager payments = client.listAccountCreditPayments(accountId, params); + + for (CreditPayment payment : payments) { + System.out.println(payment.getUuid()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $credit_payments = $client->listAccountCreditPayments($account->getId(), $params); + + foreach($credit_payments as $payment) { + echo 'Credit Payment: ' . $payment->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListAccountCreditPaymentsParams{\n\tSort: + \ recurly.String(\"created_at\"),\n\tOrder: recurly.String(\"desc\"),\n\tLimit: + recurly.Int(200),\n}\ncreditPayments := client.ListAccountCreditPayments(accountID, + listParams)\n\nfor creditPayments.HasMore {\n\terr := creditPayments.Fetch()\n\tif + 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, creditPayment := range creditPayments.Data + {\n\t\tfmt.Printf(\"Account Credit Payment %3d: %s\\n\",\n\t\t\ti,\n\t\t\tcreditPayment.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/accounts/{account_id}/invoices": get: tags: - - invoice + - Invoice operationId: list_account_invoices summary: List an account's invoices description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -3280,9 +5497,70 @@ paths: ok {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, invoice := range accountInvoices.Data {\n\t\tfmt.Printf(\"Account Invoice %3d: %s\\n\",\n\t\t\ti,\n\t\t\tinvoice.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const invoices = client.listAccountInvoices(accountId, { limit: 200 }) + + for await (const invoice of invoices.each()) { + console.log(invoice.number) + } + name: Node.js + - language: python + code: | + invoices = client.list_account_invoices(account_id, limit=200).items() + for invoice in invoices: + print(invoice.number) + name: Python + - language: csharp + code: | + var invoices = client.ListAccountInvoices(accountId); + foreach(Invoice invoice in invoices) + { + Console.WriteLine(invoice.Id); + } + name: ".NET" + - language: ruby + code: | + invoices = @client.list_account_invoices( + account_id: account_id, + limit: 200 + ) + invoices.each do |invoice| + puts "Invoice: #{invoice.number}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager invoices = client.listAccountInvoices(accountId, params); + + for (Invoice invoice : invoices) { + System.out.println(invoice.getNumber()); + } + name: Java + - language: php + code: | + $params = ['limit' => 10]; + $invoices = $client->listAccountInvoices($account->getId(), $params); + foreach($invoices as $invoice) { + echo 'Account invoice: ' . $invoice->getNumber() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListAccountInvoicesParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\naccountInvoices + := client.ListAccountInvoices(accountID, listParams)\n\nfor accountInvoices.HasMore + {\n\terr := accountInvoices.Fetch()\n\tif 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, invoice := range accountInvoices.Data {\n\t\tfmt.Printf(\"Account Invoice + %3d: %s\\n\",\n\t\t\ti,\n\t\t\tinvoice.Id,\n\t\t)\n\t}\n}" + name: Go post: tags: - - invoice + - Invoice operationId: create_invoice summary: Create an invoice for pending line items parameters: @@ -3450,10 +5728,142 @@ paths: {\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(\"Created Invoice Collection: %v\", collection)" + x-readme: + code-samples: + - language: node + code: | + try { + let invoiceCreate = { + currency: 'USD', + collectionMethod: 'automatic' + } + let invoiceCollection = await client.createInvoice(accountId, invoiceCreate) + console.log('Created Invoice') + console.log('Charge Invoice: ', invoiceCollection.chargeInvoice) + console.log('Credit Invoices: ', invoiceCollection.creditInvoices) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice_create = {"currency": "USD", "collection_method": "automatic"} + invoice_collection = client.create_invoice(account_id, invoice_create) + print("Created InvoiceCollection %s" % invoice_collection) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + // creates an invoice based on pending charges or credits on account + var collection = client.CreateInvoice(accountId, new InvoiceCreate() + { + Currency = "USD", + CollectionMethod = "automatic" + }); + Console.WriteLine("Created Invoice"); + Console.WriteLine(collection.ChargeInvoice); + Console.WriteLine(collection.CreditInvoices); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + invoice_create = { + currency: 'USD', + collection_method: 'automatic' + } + collection = @client.create_invoice( + account_id: account_id, + body: invoice_create + ) + puts "Created InvoiceCollection #{collection}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + InvoiceCreate invoiceCreate = new InvoiceCreate(); + invoiceCreate.setCurrency("USD"); + invoiceCreate.setCollectionMethod("automatic"); + + InvoiceCollection collection = client.createInvoice(accountId, invoiceCreate); + System.out.println("Created Invoice"); + System.out.println(collection.getChargeInvoice()); + System.out.println(collection.getCreditInvoices()); + } 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()); + } + name: Java + - language: php + code: |- + try { + $invoice_create = [ + "currency" => "USD", + "collection_method" => "automatic" + ]; + $invoice_collection = $client->createInvoice( + $account_id, + $invoice_create + ); + echo "Created Invoice:" . PHP_EOL; + var_dump($invoice_collection); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "invoiceReq := &recurly.InvoiceCreate{\n\tCurrency: recurly.String(\"USD\"),\n\tCollectionMethod: + recurly.String(\"automatic\"),\n}\n\ncollection, err := client.CreateInvoice(accountID, + invoiceReq)\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(\"Created Invoice + Collection: %v\", collection)" + name: Go "/sites/{site_id}/accounts/{account_id}/invoices/preview": post: tags: - - invoice + - Invoice operationId: preview_invoice summary: Preview new invoice for pending line items parameters: @@ -3620,10 +6030,142 @@ paths: 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(\"Preview Invoice %v\", collection.ChargeInvoice)" + x-readme: + code-samples: + - language: node + code: | + try { + const collection = await client.previewInvoice(accountId, { + currency: "USD", + collectionMethod: "automatic" + }) + console.log(`Previewed invoice due at ${collection.chargeInvoice.dueAt}`) + console.log(collection.chargeInvoice) + console.log(collection.creditInvoices) + } catch(err) { + + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice_preview = {"currency": "USD", "collection_method": "automatic"} + invoice_collection = client.preview_invoice(account_id, invoice_preview) + print("Preview InvoiceCollection %s" % invoice_collection) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + // creates a preview invoice based on pending charges or credits on account + var collection = client.PreviewInvoice(accountId, new InvoiceCreate() + { + Currency = "USD", + CollectionMethod = "automatic" + }); + Console.WriteLine($"Previewed invoice DueAt {collection.ChargeInvoice.DueAt}"); + Console.WriteLine(collection.ChargeInvoice); + Console.WriteLine(collection.CreditInvoices); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + invoice_preview = { + currency: "USD", + collection_method: "automatic" + } + collection = @client.create_invoice( + account_id: account_id, + body: invoice_preview + ) + puts "Created InvoiceCollection #{collection}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + InvoiceCreate invoiceCreate = new InvoiceCreate(); + invoiceCreate.setCurrency("USD"); + invoiceCreate.setCollectionMethod("automatic"); + + InvoiceCollection collection = client.previewInvoice(accountId, invoiceCreate); + System.out.println("Previewed Invoice due at " + collection.getChargeInvoice().getDueAt()); + System.out.println(collection.getChargeInvoice()); + System.out.println(collection.getCreditInvoices()); + } 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()); + } + name: Java + - language: php + code: |- + try { + $invoice_preview = [ + "currency" => "USD", + "collection_method" => "automatic" + ]; + $invoice_collection = $client->previewInvoice( + $account_id, + $invoice_preview + ); + echo "Previewed Invoice:" . PHP_EOL; + var_dump($invoice_collection); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "invoiceReq := &recurly.InvoiceCreate{\n\tCurrency: recurly.String(\"USD\"),\n}\n\ncollection, + err := client.PreviewInvoice(accountID, invoiceReq)\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(\"Preview Invoice + %v\", collection.ChargeInvoice)" + name: Go "/sites/{site_id}/accounts/{account_id}/line_items": get: tags: - - line_item + - Line Item operationId: list_account_line_items summary: List an account's line items description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -3719,9 +6261,71 @@ paths: ok {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, lineItem := range accountLineItems.Data {\n\t\tfmt.Printf(\"Account Line Item %3d: %s\\n\",\n\t\t\ti,\n\t\t\tlineItem.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const lineItems = client.listAccountLineItems(accountId, { limit: 200 }) + + for await (const lineItem of lineItems.each()) { + console.log(lineItem.id) + } + name: Node.js + - language: python + code: | + line_items = client.list_account_line_items(account_id, limit=200).items() + for line_item in line_items: + print(line_item.id) + name: Python + - language: csharp + code: | + var lineItems = client.ListAccountLineItems(accountId); + foreach(LineItem lineItem in lineItems) + { + Console.WriteLine(lineItem.Id); + } + name: ".NET" + - language: ruby + code: | + line_items = @client.list_account_line_items( + account_id: account_id, + limit: 200 + ) + line_items.each do |line_item| + puts "LineItem: #{line_item.id}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager lineItems = client.listAccountLineItems(accountId, params); + + for (LineItem lineItem : lineItems) { + System.out.println(lineItem.getId()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $account_line_items = $client->listAccountLineItems($account_id, $params); + + foreach($account_line_items as $line_item) { + echo 'Account line item: ' . $line_item->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListAccountLineItemsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\naccountLineItems + := client.ListAccountLineItems(accountID, listParams)\n\nfor accountLineItems.HasMore + {\n\terr := accountLineItems.Fetch()\n\tif 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, lineItem := range accountLineItems.Data {\n\t\tfmt.Printf(\"Account + Line Item %3d: %s\\n\",\n\t\t\ti,\n\t\t\tlineItem.Id,\n\t\t)\n\t}\n}" + name: Go post: tags: - - line_item + - Line Item operationId: create_line_item summary: Create a new line item for the account description: When using the Credit Invoices feature, utilize the purchases endpoint @@ -3889,10 +6493,147 @@ paths: 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(\"Created Line Item: %v\", lineItem)" + x-readme: + code-samples: + - language: node + code: | + try { + let lineItemReq = { + currency: 'USD', + unitAmount: 1000, + type: 'charge' // choose "credit" for a credit + } + let lineItem = await client.createLineItem(accountId, lineItemReq) + console.log('Created Line Item: ', lineItem.uuid) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + line_item_create = { + "currency": "USD", + "unit_amount": 1000, + "type": "charge", # choose "credit" for a credit + } + line_item = client.create_line_item(account_id, line_item_create) + print("Created LineItem %s" % line_item) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + // creates a pending charge or credit on the account + var lineItemReq = new LineItemCreate() + { + Currency = "USD", + UnitAmount = 1000, + Type = "charge" // choose "credit" for a credit + }; + LineItem lineItem = client.CreateLineItem(accountId, lineItemReq); + Console.WriteLine($"Created line item {lineItem.Uuid}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + line_item_create = { + currency: 'USD', + unit_amount: 1_000, + type: :charge + } + line_item = @client.create_line_item( + account_id: account_id, + body: line_item_create + ) + puts "Created LineItem #{line_item}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + LineItemCreate lineItemCreate = new LineItemCreate(); + lineItemCreate.setCurrency("USD"); + lineItemCreate.setUnitAmount(1000.0f); + lineItemCreate.setType("charge"); // choose "credit" for a credit + + LineItem lineItem = client.createLineItem(accountId, lineItemCreate); + System.out.println("Created line item " + lineItem.getUuid()); + } 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()); + } + name: Java + - language: php + code: |- + try { + $line_item_create = [ + 'currency' => 'USD', + 'unit_amount' => 1000, + 'type' => 'charge' + ]; + $line_item = $client->createLineItem( + $account->getId(), + $line_item_create + ); + echo 'Created Line Item:' . PHP_EOL; + var_dump($line_item); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "lineItemReq := &recurly.LineItemCreate{\n\tCurrency: recurly.String(\"USD\"),\n\tUnitAmount: + recurly.Float(1000),\n\tType: recurly.String(\"charge\"),\n}\n\nlineItem, + err := client.CreateLineItem(accountID, lineItemReq)\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(\"Created Line + Item: %v\", lineItem)" + name: Go "/sites/{site_id}/accounts/{account_id}/notes": get: tags: - - note + - Account Note operationId: list_account_notes summary: List an account's notes description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -3970,10 +6711,68 @@ paths: {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, note := range accountNotes.Data {\n\t\tfmt.Printf(\"Account Note %3d: %s\\n\",\n\t\t\ti,\n\t\t\tnote.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const notes = client.listAccountNotes(accountId, { limit: 200 }) + + for await (const note of notes.each()) { + console.log(note.message) + } + name: Node.js + - language: python + code: | + line_items = client.list_account_line_items(account_id, limit=200).items() + for line_item in line_items: + print(line_item.id) + name: Python + - language: csharp + code: | + var notes = client.ListAccountNotes(accountId); + foreach(AccountNote note in notes) + { + Console.WriteLine(note.Message); + } + name: ".NET" + - language: ruby + code: | + account_notes = @client.list_account_notes(account_id: account_id, limit: 200) + account_notes.each do |note| + puts "AccountNote: #{note.message}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager notes = client.listAccountNotes(accountId, params); + + for (AccountNote note : notes) { + System.out.println(note.getMessage()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $account_notes = $client->listAccountNotes($account_id, $params); + + foreach($account_notes as $note) { + echo 'Account note: ' . $note->getMessage() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListAccountNotesParams{}\naccountNotes := + client.ListAccountNotes(accountID, listParams)\n\nfor accountNotes.HasMore + {\n\terr := accountNotes.Fetch()\n\tif 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, note := range accountNotes.Data {\n\t\tfmt.Printf(\"Account Note %3d: + %s\\n\",\n\t\t\ti,\n\t\t\tnote.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/accounts/{account_id}/notes/{account_note_id}": get: tags: - - note + - Account Note operationId: get_account_note summary: Fetch an account note parameters: @@ -4097,10 +6896,111 @@ 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}\nfmt.Printf(\"Fetched Account Note: %v\", accountNote)" + x-readme: + code-samples: + - language: node + code: | + try { + console.log(accountId) + const note = await client.getAccountNote(accountId, accountNoteId) + console.log('Fetched account note: ', note.message) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + note = client.get_account_note(account_id, note_id) + print("Got AccountNote %s" % note) + 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") + name: Python + - language: csharp + code: | + try + { + AccountNote note = client.GetAccountNote(accountId, accountNoteId); + Console.WriteLine($"Fetched account note: {note.Message}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + note = @client.get_account_note( + account_id: account_id, + account_note_id: note_id + ) + puts "Got AccountNote #{note}" + 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 + name: Ruby + - language: java + code: | + try { + final AccountNote note = client.getAccountNote(accountId, accountNoteId); + System.out.println("Fetched account note: " + note.getMessage()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $note = $client->getAccountNote($account_id, $account_node_id); + + echo 'Got Account Note:' . PHP_EOL; + var_dump($note); + } 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; + } + name: PHP + - language: go + code: "accountNote, err := client.GetAccountNote(accountID, accountNoteID)\nif + e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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}\nfmt.Printf(\"Fetched Account + Note: %v\", accountNote)" + name: Go "/sites/{site_id}/accounts/{account_id}/shipping_addresses": get: tags: - - shipping_address + - Shipping Address operationId: list_shipping_addresses summary: Fetch a list of an account's shipping addresses description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -4187,9 +7087,71 @@ paths: ok {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, shippingAddress := range shippingAddresses.Data {\n\t\tfmt.Printf(\"Shipping Address %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tshippingAddress.Id,\n\t\t\tshippingAddress.Street1,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const addresses = client.listShippingAddresses(accountId, { limit: 200 }) + + for await (const address of addresses.each()) { + console.log(address.street1) + } + name: Node.js + - language: python + code: | + shipping_addresses = client.list_shipping_addresses(account_id).items() + for shipping_address in shipping_addresses: + print(shipping_address.id) + name: Python + - language: csharp + code: | + var addresses = client.ListShippingAddresses(accountId); + foreach(ShippingAddress address in addresses) + { + Console.WriteLine(address.Street1); + } + name: ".NET" + - language: ruby + code: | + shipping_addresses = @client.list_shipping_addresses( + account_id: account_id, + limit: 200 + ) + shipping_addresses.each do |addr| + puts "ShippingAddress: #{addr.nickname} - #{addr.street1}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager addresses = client.listShippingAddresses(accountId, params); + + for (ShippingAddress address : addresses) { + System.out.println(address.getStreet1()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $shippingAddresses = $client->listShippingAddresses($account_id, $params); + + foreach($shippingAddresses as $address) { + echo 'Shipping Address: ' . $address->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListShippingAddressesParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\nshippingAddresses + := client.ListShippingAddresses(accountID, listParams)\n\nfor shippingAddresses.HasMore + {\n\terr := shippingAddresses.Fetch()\n\tif 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, shippingAddress := range shippingAddresses.Data {\n\t\tfmt.Printf(\"Shipping + Address %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tshippingAddress.Id,\n\t\t\tshippingAddress.Street1,\n\t\t)\n\t}\n}" + name: Go post: tags: - - shipping_address + - Shipping Address operationId: create_shipping_address summary: Create a new shipping address for the account parameters: @@ -4376,10 +7338,168 @@ paths: {\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(\"Created Shipping Address: %v\", shippingAddress.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const shippingAddressCreate = { + firstName: 'Aaron', + lastName: 'Du Monde', + street1: '900 Camp St.', + city: 'New Orleans', + region: 'LA', + postalCode: '70115', + country: 'US' + } + const address = await client.createShippingAddress(accountId, shippingAddressCreate) + console.log('Created shipping address: ', address.street1) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + shipping_addr_create = { + "first_name": "Aaron", + "last_name": "Du Monde", + "street1": "900 Camp St.", + "city": "New Orleans", + "postal_code": "70115", + "country": "US", + } + shad = client.create_shipping_address(account_id, shipping_addr_create) + print("Created ShippingAddress %s" % shad) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var addrReq = new ShippingAddressCreate() + { + FirstName = "Benjamin", + LastName = "Du Monde", + Street1 = "900 Camp St.", + City = "New Orleans", + Region = "LA", + PostalCode = "70115", + Country = "US", + }; + ShippingAddress address = client.CreateShippingAddress(accountId, addrReq); + Console.WriteLine($"Created shipping address {address.Street1}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + shipping_address_create = { + nickname: 'Work', + street1: '900 Camp St', + city: 'New Orleans', + region: 'LA', + country: 'US', + postal_code: '70115', + first_name: 'Joanna', + last_name: 'Du Monde' + } + shipping_address = @client.create_shipping_address(account_id: account_id, body: shipping_address_create) + puts "Created Shipping Address #{shipping_address}" + 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 + name: Ruby + - language: java + code: | + try { + ShippingAddressCreate shippingAddressCreate = new ShippingAddressCreate(); + shippingAddressCreate.setFirstName("Aaron"); + shippingAddressCreate.setLastName("Du Monde"); + shippingAddressCreate.setStreet1("900 Camp St"); + shippingAddressCreate.setCity("New Orleans"); + shippingAddressCreate.setRegion("LA"); + shippingAddressCreate.setPostalCode("70115"); + shippingAddressCreate.setCountry("US"); + + ShippingAddress shippingAddress = client.createShippingAddress(accountId, shippingAddressCreate); + System.out.println("Created shipping address " + shippingAddress.getStreet1()); + } 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()); + } + name: Java + - language: php + code: | + try { + $address_create = [ + "nickname" => "Work", + "street1" => "900 Camp St", + "city" => "New Orleans", + "region" => "LA", + "country" => "US", + "postal_code" => "70115", + "first_name" => "Douglas", + "last_name" => "Du Monde" + ]; + $shipping_address = $client->createShippingAddress($account_id, $address_create); + + echo "Created Shpping Address:" . PHP_EOL; + var_dump($shipping_address); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "shippingReq := &recurly.ShippingAddressCreate{\n\tNickname: recurly.String(\"Home\"),\n\tStreet1: + \ recurly.String(\"1 Tchoupitoulas St\"),\n\tCity: recurly.String(\"New + Orleans\"),\n\tRegion: recurly.String(\"LA\"),\n\tCountry: recurly.String(\"US\"),\n\tPostalCode: + recurly.String(\"70115\"),\n\tFirstName: recurly.String(\"Aaron\"),\n\tLastName: + \ recurly.String(\"Du Monde\"),\n}\n\nshippingAddress, err := client.CreateShippingAddress(accountID, + shippingReq)\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(\"Created Shipping + Address: %v\", shippingAddress.Id)" + name: Go "/sites/{site_id}/accounts/{account_id}/shipping_addresses/{shipping_address_id}": get: tags: - - shipping_address + - Shipping Address operationId: get_shipping_address summary: Fetch an account's shipping address parameters: @@ -4497,9 +7617,109 @@ 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}\nfmt.Printf(\"Fetched Shipping Address: %v\", shippingAddress)" + x-readme: + code-samples: + - language: node + code: | + try { + const address = await client.getShippingAddress(accountId, shippingAddressId) + console.log('Fetched shipping address: ', address.street1) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + client.get_shipping_address(account_id, shipping_address_id) + print("Got ShippingAddress %s" % shipping_address_id) + 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") + name: Python + - language: csharp + code: | + try + { + ShippingAddress address = client.GetShippingAddress(accountId, shippingAddressId); + Console.WriteLine($"Fetched shipping address {address.Id}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + address = @client.get_shipping_address( + account_id: account_id, + shipping_address_id: shipping_address_id + ) + puts "Got ShippingAddress #{address}" + 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 + name: Ruby + - language: java + code: | + try { + final ShippingAddress address = client.getShippingAddress(accountId, shippingAddressId); + System.out.println("Fetched shipping address " + address.getId()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $shipping_address = $client->getShippingAddress($account_id, $shipping_address_id); + + echo 'Got Shipping Address:' . PHP_EOL; + var_dump($shipping_address); + } 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; + } + name: PHP + - language: go + code: "shippingAddress, err := client.GetShippingAddress(accountID, shippingAddressID)\nif + e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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}\nfmt.Printf(\"Fetched Shipping + Address: %v\", shippingAddress)" + name: Go put: tags: - - shipping_address + - Shipping Address operationId: update_shipping_address summary: Update an account's shipping address parameters: @@ -4668,9 +7888,142 @@ paths: %v\", e)\n\t\treturn nil, err\n\t}\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\nfmt.Printf(\"Updated Shipping Address: %v\", shippingAddress)" + x-readme: + code-samples: + - language: node + code: | + try { + const shadUpdate = { + firstName: "Benjamin", + lastName: "Du Monde" + } + const address = await client.updateShippingAddress(accountId, shippingAddressId, shadUpdate) + console.log('Updated shipping address: ', address.street1) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + address_update = { + "first_name": "Aaron", + "last_name": "Du Monde", + "postal_code": "70130", + } + address = client.update_shipping_address( + account_id, shipping_address_id, address_update + ) + print("Updated ShippingAddress %s" % address) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var shadReq = new ShippingAddressUpdate() + { + FirstName = "Aaron", + LastName = "Du Monde" + }; + ShippingAddress address = client.UpdateShippingAddress(accountId, shippingAddressId, shadReq); + Console.WriteLine($"Updated shipping address {address.Street1}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + address_update = { + first_name: "Aaron", + last_name: "Du Monde", + postal_code: "70130" + } + address = @client.update_shipping_address( + account_id: account_id, + shipping_address_id: shipping_address_id, + body: address_update + ) + puts "Updated ShippingAddress #{address}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + final ShippingAddressUpdate shadUpdate = new ShippingAddressUpdate(); + shadUpdate.setFirstName("Aaron"); + shadUpdate.setLastName("Du Monde"); + + final ShippingAddress address = client.updateShippingAddress(accountId, shippingAddressId, shadUpdate); + System.out.println("Updated shipping address " + address.getStreet1()); + } 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()); + } + name: Java + - language: php + code: | + try { + $shad_update = [ + "first_name" => "Douglas", + "last_name" => "Du Monde", + ]; + $shad = $client->updateShippingAddress($account_id, $shipping_address_id, $shad_update); + + echo 'Updated Shipping Address:' . PHP_EOL; + var_dump($shad); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "updateReq := &recurly.ShippingAddressUpdate{\n\tFirstName: recurly.String(\"Joanna\"),\n\tLastName: + \ recurly.String(\"DuMonde\"),\n}\nshippingAddress, err := client.UpdateShippingAddress(accountID, + shippingAddressID, updateReq)\nif e, ok := err.(*recurly.Error); ok {\n\tif + e.Type == recurly.ErrorTypeNotFound {\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}\nfmt.Printf(\"Updated Shipping Address: + %v\", shippingAddress)" + name: Go delete: tags: - - shipping_address + - Shipping Address operationId: remove_shipping_address summary: Remove an account's shipping address parameters: @@ -4776,10 +8129,108 @@ 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 Shipping Address: %v\", shippingAddress)" + x-readme: + code-samples: + - language: node + code: | + try { + await client.removeShippingAddress(accountId, shippingAddress.id) + console.log('Removed shipping address: ', shippingAddress.street1) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + client.remove_shipping_address(account_id, shipping_address_id) + print("Removed ShippingAddress %s" % shipping_address_id) + 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") + name: Python + - language: csharp + code: | + try + { + client.RemoveShippingAddress(accountId, shippingAddressId); + Console.WriteLine($"Removed shipping address {shippingAddressId}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + @client.remove_shipping_address( + account_id: account_id, + shipping_address_id: shipping_address_id + ) + puts "Removed ShippingAddress #{shipping_address_id}" + 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 + name: Ruby + - language: java + code: | + try { + client.removeShippingAddress(accountId, shippingAddressId); + System.out.println("Removed shipping address " + shippingAddressId); + } 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()); + } + name: Java + - language: php + code: |- + try { + $client->removeShippingAddress($account_id, $shipping_address_id); + echo "Removed Shipping Address:" . PHP_EOL; + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "shippingAddress, err := client.RemoveShippingAddress(accountID, shippingAddressID)\nif + e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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 + Shipping Address: %v\", shippingAddress)" + name: Go "/sites/{site_id}/accounts/{account_id}/subscriptions": get: tags: - - subscription + - Subscription operationId: list_account_subscriptions summary: List an account's subscriptions description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -4872,10 +8323,71 @@ paths: ok {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, sub := range accountSubscriptions.Data {\n\t\tfmt.Printf(\"Account Subscription %3d: %s\\n\",\n\t\t\ti,\n\t\t\tsub.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const subscriptions = client.listAccountSubscriptions(accountId, { limit: 200 }) + + for await (const subscription of subscriptions.each()) { + console.log(subscription.uuid) + } + name: Node.js + - language: python + code: | + subscriptions = client.list_account_subscriptions(account.id, limit=200).items() + for subscription in subscriptions: + print(subscription.uuid) + name: Python + - language: csharp + code: | + var subscriptions = client.ListAccountSubscriptions(accountId); + foreach(Subscription subscription in subscriptions) { + Console.WriteLine(subscription.Id); + } + name: ".NET" + - language: ruby + code: | + subscriptions = @client.list_account_subscriptions( + account_id: account_id, + limit: 200 + ) + subscriptions.each do |subscription| + puts "Subscription: #{subscription.uuid}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager subscriptions = client.listAccountSubscriptions(accountId, params); + + for (Subscription subscription : subscriptions) { + System.out.println(subscription.getUuid()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $account_subscriptions = $client->listAccountSubscriptions($account_id, $params); + + foreach($account_subscriptions as $sub) { + echo 'Account subscription: ' . $sub->getUuid() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListAccountSubscriptionsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\naccountSubscriptions + := client.ListAccountSubscriptions(accountID, listParams)\n\nfor accountSubscriptions.HasMore + {\n\terr := accountSubscriptions.Fetch()\n\tif 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, sub := range accountSubscriptions.Data {\n\t\tfmt.Printf(\"Account + Subscription %3d: %s\\n\",\n\t\t\ti,\n\t\t\tsub.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/accounts/{account_id}/transactions": get: tags: - - transaction + - Transaction operationId: list_account_transactions summary: List an account's transactions description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -4970,10 +8482,72 @@ paths: ok {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, transaction := range accountTransactions.Data {\n\t\tfmt.Printf(\"Account Transaction %3d: %s\\n\",\n\t\t\ti,\n\t\t\ttransaction.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const transactions = client.listAccountTransactions(accountId, { limit: 200 }) + + for await (const transaction of transactions.each()) { + console.log(transaction.uuid) + } + name: Node.js + - language: python + code: | + transactions = client.list_account_transactions(account_id, limit=200).items() + for transaction in transactions: + print("Transaction %s" % transaction.id) + name: Python + - language: csharp + code: | + var transactions = client.ListAccountTransactions(accountId); + foreach(Transaction transaction in transactions) + { + Console.WriteLine(transaction.Id); + } + name: ".NET" + - language: ruby + code: | + transactions = @client.list_account_transactions( + account_id: account_id, + limit: 200 + ) + transactions.each do |transaction| + puts "Transaction: #{transaction.uuid}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager transactions = client.listAccountTransactions(accountId, params); + + for (Transaction transaction : transactions) { + System.out.println(transaction.getUuid()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $account_transactions = $client->listAccountTransactions($account_id, $params); + + foreach($account_transactions as $transaction) { + echo 'Account transactions: ' . $transaction->getUuid() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListAccountTransactionsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\naccountTransactions + := client.ListAccountTransactions(accountID, listParams)\n\nfor accountTransactions.HasMore + {\n\terr := accountTransactions.Fetch()\n\tif 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, transaction := range accountTransactions.Data {\n\t\tfmt.Printf(\"Account + Transaction %3d: %s\\n\",\n\t\t\ti,\n\t\t\ttransaction.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/accounts/{account_id}/accounts": get: tags: - - account + - Account operationId: list_child_accounts summary: List an account's child accounts description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -5045,10 +8619,45 @@ paths: ok := err.(*recurly.Error); ok {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, account := range accounts.Data {\n\t\tfmt.Printf(\"Child Account %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\taccount.Id,\n\t\t\taccount.Code,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: python + code: | + child_accounts = client.list_child_accounts(account_id, limit=200).items() + for account in child_accounts: + print("Child Account %s" % account.code) + name: Python + - language: ruby + code: | + child_accounts = @client.list_child_accounts( + account_id: account_id, + limit: 200 + ) + child_accounts.each do |child| + puts "Account: #{child.code}" + end + name: Ruby + - language: php + code: | + $params = ['limit' => 200]; + $child_accounts = $client->listChildAccounts($account_id, $params); + + foreach($child_accounts as $child_account) { + echo 'Child Account: ' . $child_account->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListChildAccountsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\naccounts := + client.ListChildAccounts(accountID, listParams)\n\nfor accounts.HasMore + {\n\terr := accounts.Fetch()\n\tif 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, account := range + accounts.Data {\n\t\tfmt.Printf(\"Child Account %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\taccount.Id,\n\t\t\taccount.Code,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/acquisitions": get: tags: - - account_acquisition + - Account Acquisition Info operationId: list_account_acquisition summary: List a site's account acquisition data description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -5137,10 +8746,69 @@ paths: ok {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, a := range accountAcquisition.Data {\n\t\tfmt.Printf(\"Account Acquisition %3d: %s\\n\",\n\t\t\ti,\n\t\t\ta.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const acquisitions = client.listAccountAcquisition({ limit: 200 }) + + for await (const acquisition of acquisitions.each()) { + console.log(acquisition.id) + } + name: Node.js + - language: python + code: | + acquisitions = client.list_account_acquisition(limit=200).items() + for acquisition in acquisitions: + print(acquisition.id) + name: Python + - language: csharp + code: | + var acquisitions = client.ListAccountAcquisition(); + foreach(AccountAcquisition acquisition in acquisitions) + { + Console.WriteLine(acquisition.Id); + } + name: ".NET" + - language: ruby + code: | + acquisitions = @client.list_account_acquisition(limit: 200) + acquisitions.each do |acquisition| + puts "AccountAcquisition: #{acquisition.cost}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager acquisitions = client.listAccountAcquisition(params); + + for (AccountAcquisition acquisition : acquisitions) { + System.out.println(acquisition.getId()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $account_acquisition = $client->listAccountAcquisition($params); + + foreach($account_acquisition as $aa) { + echo 'Account acquisition: ' . $aa->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListAccountAcquisitionParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"asc\"),\n\tLimit: recurly.Int(200),\n}\naccountAcquisition + := client.ListAccountAcquisition(listParams)\n\nfor accountAcquisition.HasMore + {\n\terr := accountAcquisition.Fetch()\n\tif 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, a := range accountAcquisition.Data {\n\t\tfmt.Printf(\"Account Acquisition + %3d: %s\\n\",\n\t\t\ti,\n\t\t\ta.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/coupons": get: tags: - - coupon + - Coupon operationId: list_coupons summary: List a site's coupons description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -5227,9 +8895,66 @@ paths: coupons.HasMore {\n\terr := coupons.Fetch()\n\tif 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, coupon := range coupons.Data {\n\t\tfmt.Printf(\"Coupon %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tcoupon.Id,\n\t\t\tcoupon.Code,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const coupons = client.listCoupons({ limit: 200 }) + + for await (const coupon of coupons.each()) { + console.log(coupon.code) + } + name: Node.js + - language: python + code: | + coupons = client.list_coupons(limit=200).items() + for coupon in coupons: + print(coupon.code) + name: Python + - language: csharp + code: | + var coupons = client.ListCoupons(limit: 200); + foreach(Coupon coupon in coupons) + { + Console.WriteLine(coupon.Code); + } + name: ".NET" + - language: ruby + code: | + coupons = @client.list_coupons(limit: 200) + coupons.each do |coupon| + puts "coupon: #{coupon.code}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager coupons = client.listCoupons(params); + + for (Coupon coupon : coupons) { + System.out.println(coupon.getCode()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $coupons = $client->listCoupons($params); + + foreach($coupons as $coupon) { + echo 'Coupon: ' . $coupon->getCode() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListCouponsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\ncoupons := client.ListCoupons(listParams)\n\nfor + coupons.HasMore {\n\terr := coupons.Fetch()\n\tif 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, coupon := range coupons.Data {\n\t\tfmt.Printf(\"Coupon %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tcoupon.Id,\n\t\t\tcoupon.Code,\n\t\t)\n\t}\n}" + name: Go post: tags: - - coupon + - Coupon operationId: create_coupon summary: Create a new coupon parameters: @@ -5425,10 +9150,172 @@ paths: 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(\"Created Coupon: %v\", coupon.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const couponCreate = { + name: "Promotional Coupon", + code: couponCode, + discount_type: "fixed", + currencies: [{"currency": "USD", "discount": 10}], + } + const coupon = await client.createCoupon(couponCreate) + console.log('Created coupon: ', coupon.id) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + coupon_create = { + "name": "Promotional Coupon", + "code": coupon_code, + "discount_type": "fixed", + "currencies": [{"currency": "USD", "discount": 10000}], + } + coupon = client.create_coupon(coupon_create) + print("Created Coupon %s" % coupon) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var couponReq = new CouponCreate() + { + Name = "Promotional Coupon", + Code = couponCode, + DiscountType = "fixed", + Currencies = new List() { + new CouponPricing() { + Currency = "USD", + Discount = 1000 + } + } + }; + Coupon coupon = client.CreateCoupon(couponReq); + Console.WriteLine($"Created coupon {coupon.Id}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + coupon_create = { + name: "Promotional Coupon", + code: coupon_code, + discount_type: 'fixed', + currencies: [ + { + currency: 'USD', + discount: 10_000 + } + ] + } + coupon = @client.create_coupon( + body: coupon_create + ) + puts "Created Coupon #{coupon}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + CouponCreate couponCreate = new CouponCreate(); + + couponCreate.setName("Promotional Coupon"); + couponCreate.setCode(couponCode); + + List currencies = new ArrayList(); + CouponPricing couponPrice = new CouponPricing(); + couponPrice.setCurrency("USD"); + couponPrice.setDiscount(10.0f); + currencies.add(couponPrice); + + couponCreate.setCurrencies(currencies); + + Coupon coupon = client.createCoupon(couponCreate); + System.out.println("Created 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()); + } + name: Java + - language: php + code: | + try { + $coupon_create = [ + "name" => "Promotional Coupon", + "code" => $coupon_code, + "discount_type" => "fixed", + "currencies" => [ + "currency" => "USD", + "discount" => 10 + ] + ]; + + $coupon = $client->createCoupon($coupon_create); + + echo 'Created Coupon:' . PHP_EOL; + var_dump($coupon); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "couponReq := &recurly.CouponCreate{\n\tName: recurly.String(\"Promotional + Coupon\"),\n\tMaxRedemptions: recurly.Int(50),\n\tMaxRedemptionsPerAccount: + recurly.Int(1),\n\tCode: recurly.String(genUuid()),\n\tDiscountType: + \ recurly.String(\"percent\"),\n\tDiscountPercent: recurly.Int(25),\n}\n\ncoupon, + err := client.CreateCoupon(couponReq)\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(\"Created Coupon: + %v\", coupon.Id)" + name: Go "/sites/{site_id}/coupons/{coupon_id}": get: tags: - - coupon + - Coupon operationId: get_coupon summary: Fetch a coupon parameters: @@ -5542,9 +9429,106 @@ paths: 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(\"Fetched Coupon: %v\", coupon.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const coupon = await client.getCoupon(couponId) + console.log('Fetched 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + coupon = client.get_coupon(coupon_id) + print("Got 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") + name: Python + - language: csharp + code: | + try + { + Coupon coupon = client.GetCoupon(couponId); + Console.WriteLine($"Fetched coupon {coupon.Code}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + coupon = @client.get_coupon(coupon_id: coupon_id) + puts "Got 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 + name: Ruby + - language: java + code: | + try { + final Coupon coupon = client.getCoupon(couponId); + System.out.println("Fetched coupon " + coupon.getCode()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $coupon = $client->getCoupon($coupon_id); + + echo 'Got 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; + } + name: PHP + - language: go + code: "coupon, err := client.GetCoupon(couponID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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(\"Fetched + Coupon: %v\", coupon.Id)" + name: Go put: tags: - - coupon + - Coupon operationId: update_coupon summary: Update an active coupon parameters: @@ -5696,9 +9680,126 @@ paths: {\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}\n\nfmt.Printf(\"Updated Coupon: %v\", coupon.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const couponUpdate = { + name: "New Coupon Name" + } + const coupon = await client.updateCoupon(couponId, couponUpdate) + console.log('Updated coupon: ', coupon) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + coupon_update = { + "name": "New Coupon Name", + } + coupon = client.update_coupon(coupon_id, coupon_update) + print("Updated 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") + name: Python + - language: csharp + code: | + try + { + var couponReq = new CouponUpdate() { + Name = "New Coupon Name" + }; + Coupon coupon = client.UpdateCoupon(couponId, couponReq); + Console.WriteLine($"Updated Coupon: {coupon.Id}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + coupon_update = { + name: "New Coupon Name" + } + coupon = @client.update_coupon(coupon_id: coupon_id, body: coupon_update) + puts "Updated 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 + name: Ruby + - language: java + code: | + try { + final CouponUpdate couponUpdate = new CouponUpdate(); + couponUpdate.setName("New Coupon Name"); + + final Coupon coupon = client.updateCoupon(couponId, couponUpdate); + System.out.println("Updated coupon: " + coupon.getCode()); + System.out.println(coupon.getName()); + } 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()); + } + name: Java + - language: php + code: | + try { + $coupon_update = [ + "name" => "New Coupon Name" + ]; + $coupon = $client->updateCoupon($coupon_id, $coupon_update); + + echo 'Updated Coupon:' . PHP_EOL; + var_dump($coupon); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "updateReq := &recurly.CouponUpdate{\n\tName: recurly.String(\"New + Coupon Name\"),\n}\ncoupon, err := client.UpdateCoupon(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}\n\nfmt.Printf(\"Updated + Coupon: %v\", coupon.Id)" + name: Go delete: tags: - - coupon + - Coupon operationId: deactivate_coupon summary: Expire a coupon parameters: @@ -5807,10 +9908,100 @@ paths: // Something bad happened... tell the user so that they can fix it? echo 'Some unexpected Recurly error happened. Try again later.' . PHP_EOL; } + x-readme: + code-samples: + - language: node + code: | + try { + const coupon = await client.deactivateCoupon(couponId) + console.log('Deactivated 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + coupon = client.deactivate_coupon(coupon_id) + print("Deactivated 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") + name: Python + - language: csharp + code: | + try + { + Coupon coupon = client.DeactivateCoupon(couponId); + Console.WriteLine($"Deactivated coupon {coupon.Code}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + coupon = @client.deactivate_coupon(coupon_id: coupon_id) + puts "Deactivated 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 + name: Ruby + - language: java + code: | + try { + final Coupon coupon = client.deactivateCoupon(couponId); + System.out.println("Deactivated coupon " + coupon.getCode()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $coupon = $client->deactivateCoupon($coupon_id); + + echo 'Deactivated 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; + } + name: PHP "/sites/{site_id}/coupons/{coupon_id}/generate": post: tags: - - unique_coupon_code + - Unique Coupon Code operationId: generate_unique_coupon_codes summary: Generate unique coupon codes parameters: @@ -5853,7 +10044,7 @@ paths: "/sites/{site_id}/coupons/{coupon_id}/restore": put: tags: - - coupon + - Coupon operationId: restore_coupon summary: Restore an inactive coupon description: Make an expired coupon redeemable again. You can change editable @@ -6000,10 +10191,120 @@ paths: {\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)" + x-readme: + code-samples: + - language: node + code: | + 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') + } + + } + name: Node.js + - language: python + code: | + 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") + name: Python + - language: csharp + code: | + 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}"); + } + name: ".NET" + - language: ruby + code: | + 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 + name: Ruby + - language: java + code: | + 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()); + } + name: Java + - language: php + code: | + 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; + } + name: PHP + - language: go + code: "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)" + name: Go "/sites/{site_id}/coupons/{coupon_id}/unique_coupon_codes": get: tags: - - unique_coupon_code + - Unique Coupon Code operationId: list_unique_coupon_codes summary: List unique coupon codes associated with a bulk coupon description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -6040,7 +10341,7 @@ paths: "/sites/{site_id}/credit_payments": get: tags: - - credit_payment + - Credit Payment operationId: list_credit_payments summary: List a site's credit payments description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -6127,10 +10428,69 @@ paths: := creditPayments.Fetch()\n\tif 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, creditPayment := range creditPayments.Data {\n\t\tfmt.Printf(\"Credit Payment %3d: %s\\n\",\n\t\t\ti,\n\t\t\tcreditPayment.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const payments = client.listCreditPayments({ limit: 200 }) + + for await (const payment of payments.each()) { + console.log(payment.uuid) + } + name: Node.js + - language: python + code: | + payments = client.list_credit_payments(limit=200).items() + for payment in payments: + print("Credit Payment %s" % payment.id) + name: Python + - language: csharp + code: | + var payments = client.ListCreditPayments(limit: 200); + foreach(CreditPayment payment in payments) + { + Console.WriteLine(payment.Uuid); + } + name: ".NET" + - language: ruby + code: | + payments = @client.list_credit_payments(limit: 200) + payments.each do |payment| + puts "CreditPayment: #{payment.id}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager payments = client.listCreditPayments(params); + + for (CreditPayment payment : payments) { + System.out.println(payment.getUuid()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $credit_payments = $client->listCreditPayments($params); + + foreach($credit_payments as $payment) { + echo 'Credit Payment: ' . $payment->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListCreditPaymentsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\ncreditPayments + := client.ListCreditPayments(listParams)\n\nfor creditPayments.HasMore + {\n\terr := creditPayments.Fetch()\n\tif 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, creditPayment := range creditPayments.Data {\n\t\tfmt.Printf(\"Credit + Payment %3d: %s\\n\",\n\t\t\ti,\n\t\t\tcreditPayment.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/credit_payments/{credit_payment_id}": get: tags: - - credit_payment + - Credit Payment operationId: get_credit_payment summary: Fetch a credit payment parameters: @@ -6159,7 +10519,7 @@ paths: "/sites/{site_id}/custom_field_definitions": get: tags: - - custom_field_definition + - Custom Field Definition operationId: list_custom_field_definitions summary: List a site's custom field definitions description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -6259,10 +10619,69 @@ 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, definition := range customFieldDefinitions.Data {\n\t\tfmt.Printf(\"Custom Field Definition %3d: %s\\n\",\n\t\t\ti,\n\t\t\tdefinition.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const definitions = client.listCustomFieldDefinitions({ limit: 200 }) + + for await (const definition of definitions.each()) { + console.log(definition.displayName) + } + name: Node.js + - language: python + code: | + custom_fields = client.list_custom_field_definitions(limit=200).items() + for custom_field in custom_fields: + print(custom_field.name) + name: Python + - language: csharp + code: | + var fields = client.ListCustomFieldDefinitions(limit: 200); + foreach(CustomFieldDefinition def in fields) + { + Console.WriteLine(def.DisplayName); + } + name: ".NET" + - language: ruby + code: | + custom_fields = @client.list_custom_field_definitions(limit: 200) + custom_fields.each do |field| + puts "CustomFieldDefinition: #{field.name}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager fields = client.listCustomFieldDefinitions(params); + + for (CustomFieldDefinition field : fields) { + System.out.println(field.getDisplayName()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $custom_field_definitions = $client->listCustomFieldDefinitions($params); + + foreach($custom_field_definitions as $definition) { + echo 'Custom Field Definition: ' . $definition->getName() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListCustomFieldDefinitionsParams{\n\tSort: + \ recurly.String(\"created_at\"),\n\tOrder: recurly.String(\"desc\"),\n\tLimit: + recurly.Int(200),\n}\ncustomFieldDefinitions := client.ListCustomFieldDefinitions(listParams)\n\nfor + customFieldDefinitions.HasMore {\n\terr := customFieldDefinitions.Fetch()\n\tif + 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, definition := range customFieldDefinitions.Data + {\n\t\tfmt.Printf(\"Custom Field Definition %3d: %s\\n\",\n\t\t\ti,\n\t\t\tdefinition.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/custom_field_definitions/{custom_field_definition_id}": get: tags: - - custom_field_definition + - Custom Field Definition operationId: get_custom_field_definition summary: Fetch an custom field definition parameters: @@ -6376,10 +10795,107 @@ 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}\nfmt.Printf(\"Fetched Custom Field Definition: %s\", definition.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const definition = await client.getCustomFieldDefinition(definitionId) + console.log('Fetched custom field definition: ', definition.displayName) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + custom_field_definition = client.get_custom_field_definition(custom_field_definition_id) + print("Custom Field Definition %s" % custom_field_definition) + except recurly.errors.NotFoundError as e: + print("Invoice not found") + name: Python + - language: csharp + code: | + try + { + CustomFieldDefinition definition = client.GetCustomFieldDefinition(definitionId); + Console.WriteLine($"Fetched custom field definition {definition.DisplayName}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + custom_field_definition = @client.get_custom_field_definition( + custom_field_definition_id: custom_field_definition_id + ) + puts "Got Custom Field Definition #{custom_field_definition}" + 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 + name: Ruby + - language: java + code: | + try { + final CustomFieldDefinition definition = client.getCustomFieldDefinition(definitionId); + System.out.println("Fetched custom field definition " + definition.getDisplayName()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $custom_field_def = $client->getCustomFieldDefinition($definition_id); + + echo 'Got CustomFieldDefinition:' . PHP_EOL; + var_dump($custom_field_def); + } 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; + } + name: PHP + - language: go + code: "definition, err := client.GetCustomFieldDefinition(customFieldDefinitionID)\nif + e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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}\nfmt.Printf(\"Fetched Custom + Field Definition: %s\", definition.Id)" + name: Go "/sites/{site_id}/items": get: tags: - - item + - Item operationId: list_items summary: List a site's items description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -6467,9 +10983,66 @@ paths: items.HasMore {\n\terr := items.Fetch()\n\tif 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, item := range items.Data {\n\t\tfmt.Printf(\"Item %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\titem.Id,\n\t\t\titem.Code,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const items = client.listItems({ limit: 200 }) + + for await (const item of items.each()) { + console.log(item.code) + } + name: Node.js + - language: python + code: | + items = client.list_items(limit=200).items() + for item in items: + print(item.code) + name: Python + - language: csharp + code: | + var items = client.ListItems(limit: 200); + foreach(Item item in items) + { + Console.WriteLine(item.Code); + } + name: ".NET" + - language: ruby + code: | + items = @client.list_items(limit: 200) + items.each do |item| + puts "Item: #{item.code}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + Pager items = client.listItems(params); + + for (Item item : items) { + System.out.println(item.getCode()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $items = $client->listItems($params); + + foreach($items as $item) { + echo 'Item: ' . $item->getCode() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListItemsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\nitems := client.ListItems(listParams)\n\nfor + items.HasMore {\n\terr := items.Fetch()\n\tif 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, item := range items.Data {\n\t\tfmt.Printf(\"Item %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\titem.Id,\n\t\t\titem.Code,\n\t\t)\n\t}\n}" + name: Go post: tags: - - item + - Item operationId: create_item summary: Create a new item parameters: @@ -6679,10 +11252,186 @@ paths: 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(\"Created Item: %v\", item.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const itemCreate = { + code: itemCode, + name: "Item Name", + description: "Item Description", + external_sku: "a35JE-44", + accounting_code: "item-code-127", + revenue_schedule_type: "at_range_end", + custom_fields: [{ + name: "custom-field-1", + value: "Custom Field 1 value" + }] + } + const item = await client.createItem(itemCreate) + console.log('Created Item: ', item.code) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + item_create = { + "code": item_code, + "name": "Item Name", + "description": "Item Description", + "external_sku": "a35JE-44", + "accounting_code": "item-code-127", + "revenue_schedule_type": "at_range_end", + "custom_fields": [{ + "name": "custom-field-1", + "value": "Custom Field 1 value" + }] + } + item = client.create_item(item_create) + print("Created Item %s" % item) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var itemReq = new ItemCreate() + { + Code = itemCode, + Name = "Item Name", + Description = "Item Description", + ExternalSku = "a35JE-44", + AccountingCode = "item-code-127", + RevenueScheduleType = "at_range_end", + CustomFields = new List() { + new CustomField() { + Name = "custom-field-1", + Value = "Custom Field 1 value" + } + } + }; + Item item = client.CreateItem(itemReq); + Console.WriteLine($"Created item {item.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}"); + } + name: ".NET" + - language: ruby + code: | + begin + item_create = { + code: item_code, + name: "Item Name", + description: "Item Description", + external_sku: "a35JE-44", + accounting_code: "item-code-127", + revenue_schedule_type: "at_range_end", + custom_fields: [{ + name: "custom-field-1", + value: "Custom Field 1 value" + }] + } + item = @client.create_item(body: item_create) + puts "Created Item #{item}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + ItemCreate itemReq = new ItemCreate(); + + itemReq.setCode(itemCode); + itemReq.setName("Item Name"); + itemReq.setDescription("Item Description"); + itemReq.setExternalSku("a35JE-44"); + itemReq.setAccountingCode("item-code-127"); + itemReq.setRevenueScheduleType("at_range_end"); + + List customFields = new ArrayList<>(); + CustomField customField = new CustomField(); + customField.setName("custom-field-1"); + customField.setValue("Custom Field 1 value"); + customFields.add(customField); + + itemReq.setCustomFields(customFields); + + + Item item = client.createItem(itemReq); + System.out.println("Created item " + item.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()); + } + name: Java + - language: php + code: | + try { + $item_create = [ + "code" => $item_code, + "name" => "Coffee Grinder", + "description" => "A professional-grade bean grinder." + ]; + $item = $client->createItem($item_create); + + echo 'Created Item:' . PHP_EOL; + var_dump($item); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "itemReq := &recurly.ItemCreate{\n\tCode: &itemCode,\n\tName: + \ recurly.String(\"Item Name\"),\n\tDescription: recurly.String(\"Item + Description\"),\n\tExternalSku: recurly.String(\"a35JE-44\"),\n\tAccountingCode: + \ recurly.String(\"item-code-127\"),\n\tRevenueScheduleType: recurly.String(\"at_range_end\"),\n}\n\nitem, + err := client.CreateItem(itemReq)\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(\"Created Item: + %v\", item.Id)" + name: Go "/sites/{site_id}/items/{item_id}": get: tags: - - item + - Item operationId: get_item summary: Fetch an item parameters: @@ -6796,9 +11545,106 @@ paths: 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(\"Fetched Item: %v\", item.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const item = await client.getItem(itemId) + console.log('Fetched item: ', item.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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + item = client.get_item(item_id) + print("Got Item %s" % item) + 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") + name: Python + - language: csharp + code: | + try + { + Item item = client.GetItem(itemId); + Console.WriteLine($"Fetched item {item.Code}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + item = @client.get_item(item_id: item_id) + puts "Got Item #{item}" + 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 + name: Ruby + - language: java + code: | + try { + final Item item = client.getItem(itemId); + System.out.println("Fetched item: " + item.getCode()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $item = $client->getItem($item_id); + + echo 'Got Item:' . PHP_EOL; + var_dump($item); + } 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; + } + name: PHP + - language: go + code: "item, err := client.GetItem(itemID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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(\"Fetched + Item: %v\", item.Id)" + name: Go put: tags: - - item + - Item operationId: update_item summary: Update an active item parameters: @@ -6963,9 +11809,139 @@ paths: validation: %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(\"Updated Item: %v\", item.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const itemUpdate = { + name: 'New Item Name', + description: 'New Item Description' + } + const item = await client.updateItem(itemId, itemUpdate) + console.log('Updated item: ', item) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + item_update = { + "name": "New Item Name", + "description": "New Item Description", + } + item = client.update_item(item_id, item_update) + print("Updated Item %s" % item) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var itemReq = new ItemUpdate() { + Name = "New Item Name", + Description = "New Item Description", + }; + Item item = client.UpdateItem(itemId, itemReq); + Console.WriteLine(item.Name); + Console.WriteLine(item.Description); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + item_update = { + name: "New Item Name", + description: "New Item Description" + } + item = @client.update_item( + item_id: item_id, + body: item_update + ) + puts "Updated Item #{item}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + final ItemUpdate itemUpdate = new ItemUpdate(); + itemUpdate.setName("New Item Name"); + itemUpdate.setDescription("New Item Description"); + + final Item item = client.updateItem(itemId, itemUpdate); + System.out.println("Updated item: " + item.getCode()); + System.out.println(item.getName()); + System.out.println(item.getDescription()); + } 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()); + } + name: Java + - language: php + code: | + try { + $item_update = [ + "name" => "Dark Roast Coffee Beans", + "description" => "A special dark roast version.", + ]; + $item = $client->updateItem($item_id, $item_update); + + echo 'Updated Item:' . PHP_EOL; + var_dump($item); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "updateReq := &recurly.ItemUpdate{\n\tName: recurly.String(\"Pothos + Plant\"),\n\tDescription: recurly.String(\"A sturdy houseplant\"),\n}\nitem, + err := client.UpdateItem(itemID, 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}\n\nfmt.Printf(\"Updated + Item: %v\", item.Id)" + name: Go delete: tags: - - item + - Item operationId: deactivate_item summary: Deactivate an item parameters: @@ -7077,13 +12053,106 @@ paths: not found: %v\", e)\n\t\treturn nil, err\n\t}\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\nfmt.Printf(\"Item deactivated: %s\", deactivatedItem.Code)" + x-readme: + code-samples: + - language: node + code: | + try { + const item = await client.deactivateItem(itemId) + console.log('Deleted item: ', item.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') + } + } + name: Node.js + - language: python + code: | + try: + item = client.deactivate_item(item_id) + print("Deactivated Item %s" % item) + 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") + name: Python + - language: csharp + code: | + try + { + Item item = client.DeactivateItem(itemId); + Console.WriteLine($"Deactivated item {item.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}"); + } + name: ".NET" + - language: ruby + code: | + begin + item = @client.deactivate_item(item_id: item_id) + puts "Deactivated Item #{item}" + 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 + name: Ruby + - language: java + code: | + try { + Item item = client.deactivateItem(itemId); + System.out.println("deactivated item " + item.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()); + } + name: Java + - language: php + code: | + try { + $item = $client->deactivateItem($item_id); + + echo 'Deactivated Item:' . PHP_EOL; + var_dump($item); + } 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; + } + name: PHP + - language: go + code: "deactivatedItem, err := client.DeactivateItem(itemID)\nif e, ok := + err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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}\nfmt.Printf(\"Item deactivated: + %s\", deactivatedItem.Code)" + name: Go "/sites/{site_id}/items/{item_id}/reactivate": parameters: - "$ref": "#/components/parameters/site_id" - "$ref": "#/components/parameters/item_id" put: tags: - - item + - Item operationId: reactivate_item summary: Reactivate an inactive item description: Reactivating an item makes it available for new purchases. It will @@ -7198,10 +12267,103 @@ paths: 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(\"Reactivated Item: %s\", item.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const item = await client.reactivateItem(itemId) + console.log('Reactivated item: ', item.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') + } + } + name: Node.js + - language: python + code: | + try: + item = client.reactivate_item(item_id) + print("Reactivated Item %s" % item) + 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") + name: Python + - language: csharp + code: | + try + { + Item item = client.ReactivateItem(itemId); + Console.WriteLine($"Reactivated item {item.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}"); + } + name: ".NET" + - language: ruby + code: | + begin + item = @client.reactivate_item(item_id: item_id) + puts "Reactivated Item #{item}" + 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 + name: Ruby + - language: java + code: | + try { + final Item item = client.reactivateItem(itemId); + System.out.println("Reactivated item: " + item.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()); + } + name: Java + - language: php + code: | + try { + $item = $client->reactivateItem($item_id); + + echo 'Reactivate Item:' . PHP_EOL; + var_dump($item); + } 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; + } + name: PHP + - language: go + code: "item, err := client.ReactivateItem(itemID)\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(\"Reactivated + Item: %s\", item.Id)" + name: Go "/sites/{site_id}/measured_units": get: tags: - - measured_unit + - Measured Unit operationId: list_measured_unit summary: List a site's measured units description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -7237,7 +12399,7 @@ paths: x-code-samples: [] post: tags: - - measured_unit + - Measured Unit operationId: create_measured_unit summary: Create a new measured unit parameters: @@ -7283,7 +12445,7 @@ paths: "/sites/{site_id}/measured_units/{measured_unit_id}": get: tags: - - measured_unit + - Measured Unit operationId: get_measured_unit summary: Fetch a measured unit parameters: @@ -7311,7 +12473,7 @@ paths: x-code-samples: [] put: tags: - - measured_unit + - Measured Unit operationId: update_measured_unit summary: Update a measured unit parameters: @@ -7357,7 +12519,7 @@ paths: x-code-samples: [] delete: tags: - - measured_unit + - Measured Unit operationId: remove_measured_unit summary: Remove a measured unit description: A mesured unit cannot be deleted if it is used by an active plan. @@ -7387,7 +12549,7 @@ paths: "/sites/{site_id}/invoices": get: tags: - - invoice + - Invoice operationId: list_invoices summary: List a site's invoices description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -7476,10 +12638,68 @@ paths: invoices.HasMore {\n\terr := invoices.Fetch()\n\tif 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, invoice := range invoices.Data {\n\t\tfmt.Printf(\"Invoice %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tinvoice.Id,\n\t\t\tinvoice.Number,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const invoices = client.listInvoices({ limit: 200 }) + + for await (const invoice of invoices.each()) { + console.log(invoice.number) + } + name: Node.js + - language: python + code: | + invoices = client.list_invoices(limit=200).items() + for invoice in invoices: + print(invoice.number) + name: Python + - language: csharp + code: | + var invoices = client.ListInvoices(limit: 200); + foreach(Invoice invoice in invoices) + { + Console.WriteLine(invoice.Number); + } + name: ".NET" + - language: ruby + code: | + invoices = @client.list_invoices(limit: 200) + invoices.each do |invoice| + puts "Invoice: #{invoice.number}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager invoices = client.listInvoices(params); + + for (Invoice invoice : invoices) { + System.out.println(invoice.getNumber()); + } + name: Java + - language: php + code: | + $params = ['limit' => '200']; + $invoices = $client->listInvoices($params); + + foreach($invoices as $invoice) { + echo 'Invoice: ' . $invoice->getNumber() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListInvoicesParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\ninvoices := + client.ListInvoices(listParams)\n\nfor invoices.HasMore {\n\terr := invoices.Fetch()\n\tif + 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, invoice := range invoices.Data + {\n\t\tfmt.Printf(\"Invoice %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tinvoice.Id,\n\t\t\tinvoice.Number,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/invoices/{invoice_id}": get: tags: - - invoice + - Invoice operationId: get_invoice summary: Fetch an invoice parameters: @@ -7593,9 +12813,106 @@ paths: 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(\"Fetched Invoice: %v\", invoice)" + x-readme: + code-samples: + - language: node + code: | + try { + const invoice = await client.getInvoice(invoiceId) + console.log('Fetched Invoice: ', invoice.number) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice = client.get_invoice(invoice_id) + print("Got Invoice %s" % invoice) + 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") + name: Python + - language: csharp + code: | + try + { + Invoice invoice = client.GetInvoice(invoiceId); + Console.WriteLine($"Fetched invoice #{invoice.Number}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + invoice = @client.get_invoice(invoice_id: invoice_id) + puts "Got invoice #{invoice}" + 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 + name: Ruby + - language: java + code: | + try { + final Invoice invoice = client.getInvoice(invoiceId); + System.out.println("Fetched invoice " + invoice.getNumber()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $invoice = $client->getInvoice($invoice_id); + + echo 'Got Invoice:' . PHP_EOL; + var_dump($invoice); + } 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; + } + name: PHP + - language: go + code: "invoice, err := client.GetInvoice(invoiceID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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(\"Fetched + Invoice: %v\", invoice)" + name: Go put: tags: - - invoice + - Invoice operationId: put_invoice summary: Update an invoice parameters: @@ -7744,10 +13061,136 @@ paths: 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(\"Updated Invoice: %s\", invoice.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const invoiceUpdate = { + customerNotes: "New notes", + termsAndConditions: "New terms and conditions" + } + + const invoice = await client.putInvoice(invoiceId, invoiceUpdate) + console.log('Edited invoice: ', invoice.number) + } catch(err) { + + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice_update = { + "customer_notes": "New Notes", + "terms_and_conditions": "New Terms and Conditions", + } + invoice = client.put_invoice(invoice_id, invoice_update) + print("Updated Invoice %s" % invoice.id) + 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") + name: Python + - language: csharp + code: | + try + { + var invoiceReq = new InvoiceUpdatable() + { + CustomerNotes = "New Notes", + TermsAndConditions = "New Terms and Conditions" + }; + Invoice invoice = client.PutInvoice(invoiceId, invoiceReq); + Console.WriteLine($"Edited invoice #{invoice.Number}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + invoice_update = { + customer_notes: "New Notes", + terms_and_conditions: "New Terms and Conditions" + } + invoice = @client.put_invoice(invoice_id: invoice_id, body: invoice_update) + puts "Updated invoice #{invoice}" + 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 + name: Ruby + - language: java + code: | + try { + final InvoiceUpdatable invoiceUpdate = new InvoiceUpdatable(); + invoiceUpdate.setCustomerNotes("New notes"); + invoiceUpdate.setTermsAndConditions("New terms and conditions"); + + final Invoice invoice = client.putInvoice(invoiceId, invoiceUpdate); + System.out.println("Edited invoice " + invoice.getNumber()); + } 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()); + } + name: Java + - language: php + code: | + try { + $invoice_update = [ + "customer_notes" => "New Notes", + "terms_and_conditions" => "New terms and conditions", + ]; + $invoice = $client->putInvoice($invoice_id, $invoice_update); + + echo 'Updated Invoice:' . PHP_EOL; + var_dump($invoice); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "updateReq := &recurly.InvoiceUpdatable{\n\tCustomerNotes: recurly.String(\"New + Notes\"),\n\tTermsAndConditions: recurly.String(\"New Terms and Conditions\"),\n}\ninvoice, + err := client.PutInvoice(invoiceID, 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(\"Updated Invoice: + %s\", invoice.Id)" + name: Go "/sites/{site_id}/invoices/{invoice_id}.pdf": get: tags: - - invoice + - Invoice operationId: get_invoice_pdf summary: Fetch an invoice as a PDF parameters: @@ -7882,10 +13325,127 @@ paths: // Something bad happened... tell the user so that they can fix it? echo 'Some unexpected Recurly error happened. Try again later.' . PHP_EOL; } + x-readme: + code-samples: + - language: node + code: | + try { + const invoice = await client.getInvoicePdf(invoiceId) + console.log('Fetched Invoice: ', invoice) + const filename = `${downloadDirectory}/nodeinvoice-${invoiceId}.pdf` + await fs.writeFile(filename, invoice.data, 'binary', (err) => { + // throws an error, you could also catch it here + if (err) throw err; + + // success case, the file was saved + console.log('Saved Invoice PDF to', filename) + }) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice = client.get_invoice_pdf(invoice_id) + print("Got Invoice %s" % invoice) + filename = "%s/pythoninvoice-%s.pdf" % (download_directory, invoice_id) + with open(filename, 'wb') as file: + file.write(invoice.data) + print("Saved Invoice PDF to %s" % filename) + 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") + name: Python + - language: csharp + code: | + try + { + BinaryFile invoice = client.GetInvoicePdf(invoiceId); + string filename = $"{downloadDirectory}/dotnetinvoice-{invoiceId}.pdf"; + System.IO.File.WriteAllBytes(filename, invoice.Data); + Console.WriteLine($"Saved Invoice PDF to {filename}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + invoice = @client.get_invoice_pdf(invoice_id: invoice_id) + puts "Got invoice #{invoice}" + filename = "#{download_directory}/rubyinvoice-#{invoice_id}.pdf" + IO.write(filename, invoice.data) + puts "Saved Invoice PDF to #{filename}" + 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 + name: Ruby + - language: java + code: | + try { + final BinaryFile invoice = client.getInvoicePdf(invoiceId); + //System.out.println("Fetched invoice " + invoice.getData()); + String filename = downloadDirectory + "/javainvoice-" + invoiceId + ".pdf"; + + FileOutputStream fos = new FileOutputStream(filename); + fos.write(invoice.getData()); + fos.close(); + System.out.println("Saved Invoice PDF to " + filename); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } catch (java.io.IOException e) { + System.out.println("Unexpected File Writing Error: " + e.toString()); + } + name: Java + - language: php + code: | + try { + $invoice = $client->getInvoicePdf($invoice_id); + echo 'Got Invoice PDF:' . PHP_EOL; + var_dump($invoice); + $invoice_fp = fopen("php-invoice-" . $invoice_id . ".pdf", "w"); + fwrite($invoice_fp, $invoice->getData()); + fclose($invoice_fp); + } 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; + } + name: PHP "/sites/{site_id}/invoices/{invoice_id}/apply_credit_balance": put: tags: - - invoice + - Invoice operationId: apply_credit_balance summary: Apply available credit to a pending or past due charge invoice description: Apply credit payment to the outstanding balance on an existing @@ -8009,10 +13569,107 @@ paths: validation: %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(\"Applied credit balance to invoice: %v\", invoice)" + x-readme: + code-samples: + - language: node + code: | + try { + const invoice = await client.applyCreditBalance(invoiceId) + console.log('Applied credit balance to invoice: ', invoice) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice = client.apply_credit_balance(invoice_id) + print("Applied credit balance to invoice %s" % invoice.id) + 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") + name: Python + - language: csharp + code: | + try + { + Invoice invoice = client.ApplyCreditBalance(invoiceId); + Console.WriteLine($"Applied credit balance to invoice #{invoice.Number}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + invoice = @client.apply_credit_balance(invoice_id: invoice_id) + puts "Applied credit balance to invoice #{invoice}" + 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 + name: Ruby + - language: java + code: | + try { + final Invoice invoice = client.applyCreditBalance(invoiceId); + System.out.println("Applied credit balance to invoice " + invoice.getId()); + } catch (final 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 (final ApiException e) { + // Use ApiException to catch a generic error from the API + System.out.println("Unexpected Recurly Error: " + e.getError().getMessage()); + } + name: Java + - language: php + code: | + try { + $invoice = $client->applyCreditBalance($invoice_id); + + echo 'Applied credit balance to invoice:' . PHP_EOL; + var_dump($invoice); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "invoice, err := client.ApplyCreditBalance(invoiceID)\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}\n\nfmt.Printf(\"Applied + credit balance to invoice: %v\", invoice)" + name: Go "/sites/{site_id}/invoices/{invoice_id}/collect": put: tags: - - invoice + - Invoice operationId: collect_invoice summary: Collect a pending or past due, automatic invoice description: Force a collection attempt using the stored billing information. @@ -8140,10 +13797,107 @@ paths: == 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(\"Collected Invoice: %v\", collectedInvoice)" + x-readme: + code-samples: + - language: node + code: | + try { + const invoice = await client.collectInvoice(invoiceId) + console.log('Collected invoice: ', invoice.number) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice = client.collect_invoice(invoice_id) + print("Collected Invoice %s" % invoice) + except recurly.errors.NotFoundError as e: + print("Invoice not found") + name: Python + - language: csharp + code: | + try + { + Invoice invoice = client.CollectInvoice(invoiceId); + Console.WriteLine($"Collected invoice #{invoice.Number}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + invoice = @client.collect_invoice(invoice_id: invoice_id) + puts "Collected invoice #{invoice}" + 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 + name: Ruby + - language: java + code: | + try { + final Invoice invoice = client.collectInvoice(invoiceId); + System.out.println("Collected invoice: " + invoice.getNumber()); + } 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()); + } + name: Java + - language: php + code: | + try { + $invoice = $client->collectInvoice($invoice_id); + + echo 'Collected Invoice:' . PHP_EOL; + var_dump($invoice); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "collectInvoiceParams := &recurly.CollectInvoiceParams{\n\tBody: &recurly.InvoiceCollect{\n\t\tTransactionType: + recurly.String(\"moto\"),\n\t},\n}\n\ncollectedInvoice, err := client.CollectInvoice(invoiceID, + collectInvoiceParams)\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(\"Collected Invoice: + %v\", collectedInvoice)" + name: Go "/sites/{site_id}/invoices/{invoice_id}/mark_failed": put: tags: - - invoice + - Invoice operationId: fail_invoice summary: Mark an open invoice as failed description: | @@ -8267,10 +14021,107 @@ paths: 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(\"Invoice failed: %v\", invoice)" + x-readme: + code-samples: + - language: node + code: | + try { + const invoice = await client.failInvoice(invoiceId) + console.log('Failed invoice: ', invoice.number) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice = client.fail_invoice(invoice_id) + print("Failed Invoice %s" % invoice.id) + 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") + name: Python + - language: csharp + code: | + try + { + Invoice invoice = client.FailInvoice(invoiceId); + Console.WriteLine($"Failed invoice #{invoice.Number}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + invoice = @client.fail_invoice(invoice_id: invoice_id) + puts "Failed invoice #{invoice}" + 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 + name: Ruby + - language: java + code: | + try { + final Invoice invoice = client.failInvoice(invoiceId); + System.out.println("Failed invoice: " + invoice.getNumber()); + } 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()); + } + name: Java + - language: php + code: | + try { + $invoice = $client->failInvoice($invoice_id); + + echo 'Failed Invoice:' . PHP_EOL; + var_dump($invoice); + } 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; + } + name: PHP + - language: go + code: "invoice, err := client.FailInvoice(invoiceID)\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(\"Invoice failed: + %v\", invoice)" + name: Go "/sites/{site_id}/invoices/{invoice_id}/mark_successful": put: tags: - - invoice + - Invoice operationId: mark_invoice_successful summary: Mark an open invoice as successful description: | @@ -8396,10 +14247,109 @@ paths: {\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}\n\nfmt.Printf(\"Marked Invoice Successful: %v\", invoice)" + x-readme: + code-samples: + - language: node + code: | + try { + const invoice = await client.markInvoiceSuccessful(invoiceId) + console.log(`Marked invoice #${invoice.number} successful`) + } catch(err) { + + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice = client.mark_invoice_successful(invoice_id) + print("Marked Invoice successful %s" % invoice) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + Invoice invoice = client.MarkInvoiceSuccessful(invoiceId); + Console.WriteLine($"Marked invoice #{invoice.Number} successful"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + invoice = @client.mark_invoice_successful(invoice_id: invoice_id) + puts "Marked invoice sucessful #{invoice}" + 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 + name: Ruby + - language: java + code: | + try { + final Invoice invoice = client.markInvoiceSuccessful(invoiceId); + System.out.println("Marked invoice " + invoice.getNumber() + " successful"); + } 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()); + } + name: Java + - language: php + code: | + try { + $invoice = $client->markInvoiceSuccessful($invoice_id); + + echo 'Marked Invoice Successful:' . PHP_EOL; + var_dump($invoice); + } 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; + } + name: PHP + - language: go + code: "invoice, err := client.MarkInvoiceSuccessful(invoiceID)\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}\n\nfmt.Printf(\"Marked Invoice + Successful: %v\", invoice)" + name: Go "/sites/{site_id}/invoices/{invoice_id}/reopen": put: tags: - - invoice + - Invoice operationId: reopen_invoice summary: Reopen a closed, manual invoice parameters: @@ -8520,10 +14470,107 @@ paths: 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(\"Reopened Invoice: %v\", invoice)" + x-readme: + code-samples: + - language: node + code: | + try { + const invoice = await client.reopenInvoice(invoiceId) + console.log('Reopened invoice: ', invoice.number) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice = client.reopen_invoice(invoice_id) + print("Reopened Invoice %s" % invoice.id) + 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") + name: Python + - language: csharp + code: | + try + { + Invoice invoice = client.ReopenInvoice(invoiceId); + Console.WriteLine($"Reopened invoice #{invoice.Number}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + invoice = @client.reopen_invoice(invoice_id: invoice_id) + puts "Reopened invoice #{invoice}" + 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 + name: Ruby + - language: java + code: | + try { + final Invoice invoice = client.reopenInvoice(invoiceId); + System.out.println("Reopened invoice: " + invoice.getNumber()); + } 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()); + } + name: Java + - language: php + code: | + try { + $invoice = $client->reopenInvoice($invoice_id); + + echo 'Reopened Invoice:' . PHP_EOL; + var_dump($invoice); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "invoice, err := client.ReopenInvoice(invoiceID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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(\"Reopened + Invoice: %v\", invoice)" + name: Go "/sites/{site_id}/invoices/{invoice_id}/void": put: tags: - - invoice + - Invoice operationId: void_invoice summary: Void a credit invoice. description: Invoice must be a credit invoice (`type=credit`) and cannot be @@ -8627,10 +14674,88 @@ paths: validation: %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(\"Voided Invoice: %v\", invoice)" + x-readme: + code-samples: + - language: node + code: | + try { + const invoice = await client.voidInvoice(invoiceId) + console.log('Voided invoice: ', invoice) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice = client.void_invoice(invoice_id) + print("Voided Invoice %s" % invoice.id) + 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") + name: Python + - language: ruby + code: | + begin + invoice = @client.void_invoice(invoice_id: invoice_id) + puts "Voided invoice #{invoice}" + 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 + name: Ruby + - language: java + code: | + try { + final Invoice invoice = client.voidInvoice(invoiceId); + System.out.println("Voided invoice " + invoice.getId()); + } catch (final 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 (final ApiException e) { + // Use ApiException to catch a generic error from the API + System.out.println("Unexpected Recurly Error: " + e.getError().getMessage()); + } + name: Java + - language: php + code: | + try { + $invoice = $client->voidInvoice($invoice_id); + + echo 'Voided Invoice:' . PHP_EOL; + var_dump($invoice); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "invoice, err := client.VoidInvoice(invoiceID)\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}\n\nfmt.Printf(\"Voided Invoice: + %v\", invoice)" + name: Go "/sites/{site_id}/invoices/{invoice_id}/transactions": post: tags: - - invoice + - Invoice operationId: record_external_transaction summary: Record an external payment for a manual invoices. description: This endpoint allows you to record an offline payment that was @@ -8692,10 +14817,34 @@ paths: console.log('Unknown Error: ', err) } } + x-readme: + code-samples: + - language: node + code: | + try { + const externalTrx = { + description: "A check collected outside of Recurly", + amount: 10.0, + payment_method: 'check' + } + const transaction = await client.recordExternalTransaction(invoiceId, externalTrx) + console.log('External Transaction: ', transaction) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js "/sites/{site_id}/invoices/{invoice_id}/line_items": get: tags: - - line_item + - Line Item operationId: list_invoice_line_items summary: List an invoice's line items description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -8794,10 +14943,76 @@ paths: {\n\terr := lineItems.Fetch()\n\tif 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, lineItem := range lineItems.Data {\n\t\tfmt.Printf(\"Invoice Line Item %3d: %s\\n\",\n\t\t\ti,\n\t\t\tlineItem.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const lineItems = client.listInvoiceLineItems(invoiceId, { limit: 200 }) + + for await (const lineItem of lineItems.each()) { + console.log(lineItem.id) + } + name: Node.js + - language: python + code: | + try: + line_items = client.list_invoice_line_items(invoice_id, limit=200).items() + for item in line_items: + print("Invoice Line Items %s" % item.id) + 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") + name: Python + - language: csharp + code: | + var lineItems = client.ListInvoiceLineItems(invoiceId); + foreach(LineItem lineItem in lineItems) + { + Console.WriteLine(lineItem.Id); + } + name: ".NET" + - language: ruby + code: | + line_items = @client.list_invoice_line_items( + invoice_id: invoice_id, + limit: 200 + ) + line_items.each do |line_item| + puts "Line Item: #{line_item.id}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); + Pager lineItems = client.listInvoiceLineItems(invoiceId, params); + + for (LineItem lineItem : lineItems) { + System.out.println(lineItem.getId()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $invoice_line_items = $client->listInvoiceLineItems($invoice_id, $params); + + foreach($invoice_line_items as $line_item) { + echo 'Invoice Line Item: ' . $line_item->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListInvoiceLineItemsParams{\n\tSort: recurly.String(\"created_at\"),\n}\nlineItems + := client.ListInvoiceLineItems(invoiceID, listParams)\n\nfor lineItems.HasMore + {\n\terr := lineItems.Fetch()\n\tif 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, lineItem := range lineItems.Data {\n\t\tfmt.Printf(\"Invoice Line Item + %3d: %s\\n\",\n\t\t\ti,\n\t\t\tlineItem.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/invoices/{invoice_id}/coupon_redemptions": get: tags: - - coupon_redemption + - Coupon Redemption operationId: list_invoice_coupon_redemptions summary: List the coupon redemptions applied to an invoice description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -8886,10 +15101,76 @@ 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 redemptions.Data {\n\t\tfmt.Printf(\"Invoice Coupon Redemption %3d: %s\\n\",\n\t\t\ti,\n\t\t\tredemption.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const redemptions = client.listInvoiceCouponRedemptions(invoiceId, { limit: 200 }) + + for await (const redemption of redemptions.each()) { + console.log(redemption.id) + } + name: Node.js + - language: python + code: | + try: + redemptions = client.list_invoice_coupon_redemptions(invoice_id, limit=200).items() + for redemption in redemptions: + print("Invoice Coupon Redemption %s" % redemption) + 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") + name: Python + - language: csharp + code: | + var couponRedemptions = client.ListInvoiceCouponRedemptions(invoiceId); + foreach(CouponRedemption redemption in couponRedemptions) + { + Console.WriteLine(redemption.Id); + } + name: ".NET" + - language: ruby + code: | + coupon_redemptions = @client.list_invoice_coupon_redemptions( + invoice_id: invoice_id, + limit: 200 + ) + coupon_redemptions.each do |redemption| + puts "CouponRedemption: #{redemption.id}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager redemptions = client.listInvoiceCouponRedemptions(invoiceId, params); + + for (CouponRedemption redemption : redemptions) { + System.out.println(redemption.getId()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $invoice_coupon_redemptions = $client->listInvoiceCouponRedemptions($invoice_id, $params); + + foreach($invoice_coupon_redemptions as $redemption) { + echo 'Invoice Coupon Redemption: ' . $redemption->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListInvoiceCouponRedemptionsParams{\n\tSort: + recurly.String(\"created_at\"),\n}\nredemptions := client.ListInvoiceCouponRedemptions(invoiceID, + listParams)\n\nfor redemptions.HasMore {\n\terr := redemptions.Fetch()\n\tif + 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 redemptions.Data + {\n\t\tfmt.Printf(\"Invoice Coupon Redemption %3d: %s\\n\",\n\t\t\ti,\n\t\t\tredemption.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/invoices/{invoice_id}/related_invoices": get: tags: - - invoice + - Invoice operationId: list_related_invoices summary: List an invoice's related credit or charge invoices description: | @@ -8974,18 +15255,80 @@ paths: {\n\terr := invoices.Fetch()\n\tif 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, invoice := range invoices.Data {\n\t\tfmt.Printf(\"Related Invoice %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tinvoice.Id,\n\t\t\tinvoice.Number,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const invoices = client.listRelatedInvoices(invoiceId, { limit: 200 }) + + for await (const invoice of invoices.each()) { + console.log(invoice.number) + } + name: Node.js + - language: python + code: | + try: + related_invoices = client.list_related_invoices(invoice_id, limit=200).items() + for invoice in related_invoices: + print("Related invoice %s" % invoice.id) + 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") + name: Python + - language: csharp + code: | + var invoices = client.ListRelatedInvoices(invoiceId); + foreach(Invoice invoice in invoices) + { + Console.WriteLine(invoice.Number); + } + name: ".NET" + - language: ruby + code: | + invoices = @client.list_related_invoices( + invoice_id: invoice_id, + limit: 200 + ) + invoices.each do |invoice| + puts "Invoice: #{invoice.number}" + end + name: Ruby + - language: java + code: | + final Pager invoices = client.listRelatedInvoices(invoiceId); + + for (Invoice invoice : invoices) { + System.out.println(invoice.getNumber()); + } + name: Java + - language: php + code: | + $related_invoices = $client->listRelatedInvoices($invoice_id); + + foreach($related_invoices as $invoice) { + echo 'Related Invoice: ' . $invoice->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "invoices := client.ListRelatedInvoices(invoiceID)\n\nfor invoices.HasMore + {\n\terr := invoices.Fetch()\n\tif 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, invoice := range + invoices.Data {\n\t\tfmt.Printf(\"Related Invoice %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tinvoice.Id,\n\t\t\tinvoice.Number,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/invoices/{invoice_id}/refund": post: tags: - - invoice + - Invoice operationId: refund_invoice summary: Refund an invoice description: | There are two ways to do a refund: - * refund a specific amount which is divided across all the line items. - * refund quantities of line items. - If you want to refund the entire refundable amount on the invoice, the - simplest way is to do `type=amount` without specifiying an `amount`. + * Apply a specific dollar/cent amount or percentage amount to an entire invoice, which will refund the resulting amount across all line items on the invoice. + * If you want to refund the entire refundable amount on the invoice, the simplest way is to do `type=amount` without specifiying an `amount`. + * Note: You must have the Credit Memos feature flag enabled on your site to utilize percentage amount refunds on invoices. + * Apply a refund to one or more individual line items on an invoice. A line item can be refunded by a quantity amount, a specific dollar/cent amount, or a percentage amount and will only apply to the specific line item you are aiming to refund. + * Note: You must have the Credit Memos feature flag enabled on your site to utilize specific dollar/cent amount and percentage amount refunds on line items. parameters: - "$ref": "#/components/parameters/site_id" - "$ref": "#/components/parameters/invoice_id" @@ -9141,10 +15484,139 @@ paths: {\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}\n\nfmt.Printf(\"Refunded Invoice: %v\", invoice)" + x-readme: + code-samples: + - language: node + code: | + try { + const invoiceRefund = { + creditCustomerNotes: "Notes on credits", + type: "amount", // could also be "line_items" + amount: 100 + } + + const invoice = await client.refundInvoice(invoiceId, invoiceRefund) + console.log('Refunded invoice: ', invoice.number) + } catch(err) { + + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + invoice_refund = {"type": "amount", "amount": 100} + invoice = client.refund_invoice(invoice_id, invoice_refund) + print("Refunded Invoice %s" % invoice) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var refundReq = new InvoiceRefund() { + CreditCustomerNotes = "Notes on credits", + Type = "amount", // could also be "line_items" + Amount = 100 + }; + Invoice invoice = client.RefundInvoice(invoiceId, refundReq); + Console.WriteLine($"Refunded Invoice #{invoice.Number}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + invoice_refund = { + type: "amount", + amount: 100, + } + invoice = @client.refund_invoice( + invoice_id: invoice_id, + body: invoice_refund + ) + puts "Refunded invoice #{invoice}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + final InvoiceRefund invoiceRefund = new InvoiceRefund(); + invoiceRefund.setCreditCustomerNotes("Notes on credits"); + invoiceRefund.setType("amount"); // could also be "line_items" + invoiceRefund.setAmount(100f); + + final Invoice invoice = client.refundInvoice(invoiceId, invoiceRefund); + System.out.println("Refunded invoice " + invoice.getNumber()); + } 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()); + } + name: Java + - language: php + code: | + try { + $refund = [ + "type" => "amount", + "amount" => 1 + ]; + $invoice_collection = $client->refundInvoice($invoice_id, $refund); + + echo 'Refunded Invoice:' . PHP_EOL; + var_dump($invoice_collection); + } 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; + } + name: PHP + - language: go + code: "refundReq := &recurly.InvoiceRefund{\n\tType: recurly.String(\"amount\"),\n\tAmount: + recurly.Float(1),\n\tExternalRefund: &recurly.ExternalRefund{\n\t\tPaymentMethod: + recurly.String(\"credit_card\"),\n\t},\n}\ninvoice, err := client.RefundInvoice(invoiceID, + refundReq)\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}\n\nfmt.Printf(\"Refunded + Invoice: %v\", invoice)" + name: Go "/sites/{site_id}/line_items": get: tags: - - line_item + - Line Item operationId: list_line_items summary: List a site's line items description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -9236,10 +15708,70 @@ paths: lineItems.HasMore {\n\terr := lineItems.Fetch()\n\tif 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, lineItem := range lineItems.Data {\n\t\tfmt.Printf(\"Line Item %3d: %s\\n\",\n\t\t\ti,\n\t\t\tlineItem.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const lineItems = client.listLineItems({ limit: 200 }) + + for await (const item of lineItems.each()) { + console.log(`Item ${item.id} for ${item.amount}`) + } + name: Node.js + - language: python + code: | + line_items = client.list_line_items(limit=200).items() + for line_item in line_items: + print(line_item.id) + name: Python + - language: csharp + code: | + var lineItems = client.ListLineItems(limit: 200); + foreach(LineItem item in lineItems) + { + Console.WriteLine($"Item {item.Uuid} for {item.Amount}"); + } + name: ".NET" + - language: ruby + code: | + line_items = @client.list_line_items( + limit: 200 + ) + line_items.each do |line_item| + puts "LineItem: #{line_item.id}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager lineItems = client.listLineItems(params); + + for (LineItem lineItem : lineItems) { + System.out.println("Item " + lineItem.getUuid() + " for " + lineItem.getAmount()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $line_items = $client->listLineItems($params); + + foreach($line_items as $line_item) { + echo 'Line item: ' . $line_item->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListLineItemsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\nlineItems := + client.ListLineItems(listParams)\n\nfor lineItems.HasMore {\n\terr := + lineItems.Fetch()\n\tif 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, lineItem := + range lineItems.Data {\n\t\tfmt.Printf(\"Line Item %3d: %s\\n\",\n\t\t\ti,\n\t\t\tlineItem.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/line_items/{line_item_id}": get: tags: - - line_item + - Line Item operationId: get_line_item summary: Fetch a line item parameters: @@ -9353,9 +15885,106 @@ paths: not found: %v\", e)\n\t\treturn nil, err\n\t}\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\nfmt.Printf(\"Fetched Line Item: %v\", lineItem)" + x-readme: + code-samples: + - language: node + code: | + try { + const lineItem = await client.getLineItem(lineItemId) + console.log('Fetched line item: ', lineItem.uuid) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + line_item = client.get_line_item(line_item_id) + print("Got LineItem %s" % line_item) + 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") + name: Python + - language: csharp + code: | + try + { + LineItem lineItem = client.GetLineItem(lineItemId); + Console.WriteLine($"Fetched line item {lineItem.Uuid}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + line_item = @client.get_line_item(line_item_id: line_item_id) + puts "Got LineItem #{line_item}" + 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 + name: Ruby + - language: java + code: | + try { + final LineItem lineItem = client.getLineItem(lineItemId); + System.out.println("Fetched line item " + lineItem.getUuid()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $line_item = $client->getLineItem($line_item_id); + + echo 'Got LineItem:' . PHP_EOL; + var_dump($line_item); + } 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; + } + name: PHP + - language: go + code: "lineItem, err := client.GetLineItem(lineItemID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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}\nfmt.Printf(\"Fetched Line + Item: %v\", lineItem)" + name: Go delete: tags: - - line_item + - Line Item operationId: remove_line_item summary: Delete an uninvoiced line item parameters: @@ -9471,10 +16100,107 @@ paths: not found: %v\", e)\n\t\treturn nil, err\n\t}\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\nfmt.Printf(\"Removed Line Item: %v\", lineItem)" + x-readme: + code-samples: + - language: node + code: | + try { + await client.removeLineItem(lineItemId) + console.log('Removed line item: ', lineItemId) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + client.remove_line_item(line_item_id) + print("Removed LineItem %s" % line_item_id) + 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") + name: Python + - language: csharp + code: | + try + { + client.RemoveLineItem(lineItemId); + Console.WriteLine($"Removed line item {lineItemId}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + @client.remove_line_item( + line_item_id: line_item_id + ) + puts "Removed LineItem #{line_item_id}" + 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 + name: Ruby + - language: java + code: | + try { + client.removeLineItem(lineItemId); + System.out.println("Removed line item " + lineItemId); + } 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()); + } + name: Java + - language: php + code: | + try { + $client->removeLineItem($line_item_id); + echo 'Removed LineItem: ' . $line_item_id . PHP_EOL; + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "lineItem, err := client.RemoveLineItem(lineItemID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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}\nfmt.Printf(\"Removed Line + Item: %v\", lineItem)" + name: Go "/sites/{site_id}/plans": get: tags: - - plan + - Plan operationId: list_plans summary: List a site's plans description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -9562,9 +16288,66 @@ paths: plans.HasMore {\n\terr := plans.Fetch()\n\tif 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, plan := range plans.Data {\n\t\tfmt.Printf(\"Plan %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tplan.Id,\n\t\t\tplan.Code,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const plans = client.listPlans({ limit: 200 }) + + for await (const plan of plans.each()) { + console.log(plan.code) + } + name: Node.js + - language: python + code: | + plans = client.list_plans(limit=200).items() + for plan in plans: + print(plan.code) + name: Python + - language: csharp + code: | + var plans = client.ListPlans(limit: 200); + foreach(Plan plan in plans) + { + Console.WriteLine(plan.Code); + } + name: ".NET" + - language: ruby + code: | + plans = @client.list_plans(limit: 200) + plans.each do |plan| + puts "Plan: #{plan.code}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager plans = client.listPlans(params); + + for (Plan plan : plans) { + System.out.println(plan.getCode()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $plans = $client->listPlans($params); + + foreach($plans as $plan) { + echo 'Plan: ' . $plan->getCode() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListPlansParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\nplans := client.ListPlans(listParams)\n\nfor + plans.HasMore {\n\terr := plans.Fetch()\n\tif 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, plan := range plans.Data {\n\t\tfmt.Printf(\"Plan %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tplan.Id,\n\t\t\tplan.Code,\n\t\t)\n\t}\n}" + name: Go post: tags: - - plan + - Plan operationId: create_plan summary: Create a plan parameters: @@ -9760,10 +16543,178 @@ paths: 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(\"Created Plan: %v\", plan.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const planCreate = { + name: 'Monthly Coffee Subscription', + code: planCode, + currencies: [ + { + currency: 'USD', + unitAmount: 10000 + } + ] + } + const plan = await client.createPlan(planCreate) + console.log('Created Plan: ', plan.code) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + plan_create = { + "name": "Monthly Coffee Subscription", + "code": plan_code, + "currencies": [{"currency": "USD", "unit_amount": 10000}], + } + plan = client.create_plan(plan_create) + print("Created Plan %s" % plan) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var planReq = new PlanCreate() + { + Name = "Monthly Coffee Subscription", + Code = planCode, + Currencies = new List() { + new PlanPricing() { + Currency = "USD", + UnitAmount = 10000 + } + } + }; + Plan plan = client.CreatePlan(planReq); + Console.WriteLine($"Created plan {plan.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}"); + } + name: ".NET" + - language: ruby + code: | + begin + plan_create = { + code: plan_code, + name: plan_name, + currencies: [ + currency: "USD", + setup_fee: 1_000 + ], + add_ons: [ + { + name: 'Extra User', + code: 'extra_user', + currencies: [ + { currency: 'USD', unit_amount: 10_000 } + ] + } + ] + } + plan = @client.create_plan(body: plan_create) + puts "Created Plan #{plan}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + PlanCreate planCreate = new PlanCreate(); + + planCreate.setName("Monthly Coffee Subscription"); + planCreate.setCode(planCode); + + List currencies = new ArrayList(); + PlanPricing planPrice = new PlanPricing(); + planPrice.setCurrency("USD"); + planPrice.setUnitAmount(10000.0f); + currencies.add(planPrice); + + planCreate.setCurrencies(currencies); + + Plan plan = client.createPlan(planCreate); + System.out.println("Created Plan " + planCode); + } 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()); + } + name: Java + - language: php + code: | + try { + $plan_create = [ + "name" => "Monthly Coffee Subscription", + "code" => $plan_code, + "currencies" => [ + [ + "currency" => "USD", + "unit_amount" => 10000 + ] + ] + ]; + + $plan = $client->createPlan($plan_create); + + echo 'Created Plan:' . PHP_EOL; + var_dump($plan); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "planReq := &recurly.PlanCreate{\n\tCode: &planCode,\n\tName: recurly.String(\"Monthly + Coffee Subscription\"),\n\tCurrencies: []recurly.PlanPricingCreate{\n\t\t{\n\t\t\tCurrency: + \ recurly.String(\"USD\"),\n\t\t\tUnitAmount: recurly.Float(10000),\n\t\t},\n\t},\n}\n\nplan, + err := client.CreatePlan(planReq)\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(\"Created Plan: + %v\", plan.Id)" + name: Go "/sites/{site_id}/plans/{plan_id}": get: tags: - - plan + - Plan operationId: get_plan summary: Fetch a plan parameters: @@ -9877,9 +16828,106 @@ paths: 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(\"Fetched Plan: %s\", plan.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const plan = await client.getPlan(planId) + console.log('Fetched plan: ', plan.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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + plan = client.get_plan(plan_id) + print("Got Plan %s" % plan) + 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") + name: Python + - language: csharp + code: | + try + { + Plan plan = client.GetPlan(planId); + Console.WriteLine($"Fetched plan {plan.Code}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + plan = @client.get_plan(plan_id: plan_id) + puts "Got plan #{plan}" + 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 + name: Ruby + - language: java + code: | + try { + final Plan plan = client.getPlan(planId); + System.out.println("Fetched plan " + plan.getCode()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $plan = $client->getPlan($plan_id); + + echo 'Got Plan:' . PHP_EOL; + var_dump($plan); + } 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; + } + name: PHP + - language: go + code: "plan, err := client.GetPlan(planID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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(\"Fetched + Plan: %s\", plan.Id)" + name: Go put: tags: - - plan + - Plan operationId: update_plan summary: Update a plan parameters: @@ -10024,9 +17072,125 @@ paths: {\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}\n\nfmt.Printf(\"Updated Plan: %s\", plan.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const planUpdate = { + name: 'New monthly coffee subscription' + } + const plan = await client.updatePlan(planId, planUpdate) + console.log('Updated plan: ', plan.code) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + plan_update = { + "name": "Monthly Kombucha Subscription", + } + plan = client.update_plan(plan_id, plan_update) + print("Updated Plan %s" % plan) + 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") + name: Python + - language: csharp + code: | + try + { + var planReq = new PlanUpdate() { + Name = "New Monthly Coffee Subscription" + }; + Plan plan = client.UpdatePlan(planId, planReq); + Console.WriteLine($"Updated plan {plan.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}"); + } + name: ".NET" + - language: ruby + code: | + begin + plan_update = { + name: "Monthly Kombucha Subscription" + } + plan = @client.update_plan(plan_id: plan_id, body: plan_update) + puts "Updated plan #{plan}" + 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 + name: Ruby + - language: java + code: | + try { + final PlanUpdate planUpdate = new PlanUpdate(); + planUpdate.setName("New Monthly Coffee Subscription"); + + final Plan plan = client.updatePlan(planId, planUpdate); + System.out.println("Updated plan " + plan.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()); + } + name: Java + - language: php + code: | + try { + $plan_update = [ + "name" => "Monthly Tea Subscription" + ]; + $plan = $client->updatePlan($plan_id, $plan_update); + + echo 'Updated Plan:' . PHP_EOL; + var_dump($plan); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "updateReq := &recurly.PlanUpdate{\n\tName: recurly.String(\"Monthly + Houseplant Subscription\"),\n}\nplan, err := client.UpdatePlan(planID, + 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}\n\nfmt.Printf(\"Updated + Plan: %s\", plan.Id)" + name: Go delete: tags: - - plan + - Plan operationId: remove_plan summary: Remove a plan parameters: @@ -10132,10 +17296,105 @@ paths: 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 Plan: %s\", plan.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const plan = await client.removePlan(planId) + console.log('Removed plan: ', plan.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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + plan = client.remove_plan(plan_id) + print("Removed Plan %s" % plan) + 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") + name: Python + - language: csharp + code: | + try + { + Plan plan = client.RemovePlan(planId); + Console.WriteLine($"Removed plan {plan.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}"); + } + name: ".NET" + - language: ruby + code: | + begin + plan = @client.remove_plan(plan_id: plan_id) + puts "Removed plan #{plan}" + 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 + name: Ruby + - language: java + code: | + try { + final Plan plan = client.removePlan(planId); + System.out.println("Removed plan " + plan.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()); + } + name: Java + - language: php + code: | + try { + $plan = $client->removePlan($plan_id); + echo 'Removed Plan: ' . $plan_id . PHP_EOL; + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "plan, err := client.RemovePlan(planID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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 + Plan: %s\", plan.Id)" + name: Go "/sites/{site_id}/plans/{plan_id}/add_ons": get: tags: - - add-on + - Add-on operationId: list_plan_add_ons summary: List a plan's add-ons description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -10228,9 +17487,70 @@ paths: := err.(*recurly.Error); ok {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, addOn := range addOns.Data {\n\t\tfmt.Printf(\"Add-On %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\taddOn.Id,\n\t\t\taddOn.Code,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const addOns = client.listPlanAddOns(planId, { limit: 200 }) + + for await (const addOn of addOns.each()) { + console.log(addOn.code) + } + name: Node.js + - language: python + code: | + add_ons = client.list_plan_add_ons(plan_id).items() + for add_on in add_ons: + print(add_on.code) + name: Python + - language: csharp + code: | + var addOns = client.ListPlanAddOns(planId); + foreach(AddOn addOn in addOns) + { + Console.WriteLine(addOn.Code); + } + name: ".NET" + - language: ruby + code: | + add_ons = @client.list_plan_add_ons( + plan_id: plan_id, + limit: 200 + ) + add_ons.each do |add_on| + puts "AddOn: #{add_on.code}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager addOns = client.listPlanAddOns(planId, params); + + for (AddOn addOn : addOns) { + System.out.println(addOn.getCode()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $plan_add_ons = $client->listPlanAddOns($plan_id, $params); + + foreach($plan_add_ons as $add_on) { + echo 'Plan add-on: ' . $add_on->getCode() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListPlanAddOnsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\naddOns := client.ListPlanAddOns(planID, + listParams)\n\nfor addOns.HasMore {\n\terr := addOns.Fetch()\n\tif 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, addOn := range addOns.Data + {\n\t\tfmt.Printf(\"Add-On %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\taddOn.Id,\n\t\t\taddOn.Code,\n\t\t)\n\t}\n}" + name: Go post: tags: - - add-on + - Add-on operationId: create_plan_add_on summary: Create an add-on parameters: @@ -10425,10 +17745,176 @@ paths: 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(\"Created Plan Add-On: %v\", planAddOn.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const addOnCreate = { + code: 'coffee_grinder', + name: 'A quality grinder for your beans', + defaultQuantity: 1, + currencies: [ + { + currency: 'USD', + unitAmount: 10000 + } + ] + } + + const addOn = await client.createPlanAddOn(planId, addOnCreate) + console.log('Created add-on: ', addOn.code) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + add_on_create = { + "code": "coffee_grinder", + "name": "A quality grinder for your beans", + "default_quantity": 1, + "currencies": [{"currency": "USD", "unit_amount": 10000}], + } + add_on = client.create_plan_add_on(plan_id, add_on_create) + print("Created PlanAddOn %s" % add_on) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var addOnReq = new AddOnCreate() { + Code = "coffee_grinder", + Name = "A quality grinder for your beans", + DefaultQuantity = 1, + Currencies = new List() { + new AddOnPricing() { + Currency = "USD", + UnitAmount = 10000 + } + } + }; + AddOn addOn = client.CreatePlanAddOn(planId, addOnReq); + Console.WriteLine($"Created add-on {addOn.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}"); + } + name: ".NET" + - language: ruby + code: | + begin + new_add_on = { + code: 'coffee_grinder', + name: 'A quality grinder for your beans', + default_quantity: 1, + currencies: [ + { + currency: 'USD', + unit_amount: 10_000 + } + ] + } + add_on = @client.create_plan_add_on(plan_id: plan_id, body: new_add_on) + puts "Created plan add-on #{add_on}" + 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 + name: Ruby + - language: java + code: | + try { + AddOnCreate addOnCreate = new AddOnCreate(); + + addOnCreate.setCode("coffee-grinder"); + addOnCreate.setName("A quality grinder for your beans"); + addOnCreate.setDefaultQuantity(1); + + List currencies = new ArrayList(); + AddOnPricing addOnPrice = new AddOnPricing(); + addOnPrice.setCurrency("USD"); + addOnPrice.setUnitAmount(10000.0f); + currencies.add(addOnPrice); + + addOnCreate.setCurrencies(currencies); + + AddOn addOn = client.createPlanAddOn(planId, addOnCreate); + System.out.println("Created add-on " + addOn.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()); + } + name: Java + - language: php + code: | + try { + $add_on_create = [ + "code" => $add_on_code, + "name" => "Fresh beans shipped monthly", + "currencies" => [ + [ + "currency" => "USD", + "unit_amount" => 10 + ] + ] + ]; + + $add_on = $client->createPlanAddOn($plan_id, $add_on_create); + + echo 'Created Plan:' . PHP_EOL; + var_dump($plan); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "addOnReq := &recurly.AddOnCreate{\n\tCode: &addOnCode,\n\tName: recurly.String(\"Fresh + beans shipped monthly\"),\n\tCurrencies: []recurly.AddOnPricingCreate{\n\t\t{\n\t\t\tCurrency: + \ recurly.String(\"USD\"),\n\t\t\tUnitAmount: recurly.Float(10),\n\t\t},\n\t},\n}\n\nplanAddOn, + err := client.CreatePlanAddOn(planID, addOnReq)\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(\"Created Plan + Add-On: %v\", planAddOn.Id)" + name: Go "/sites/{site_id}/plans/{plan_id}/add_ons/{add_on_id}": get: tags: - - add-on + - Add-on operationId: get_plan_add_on summary: Fetch a plan's add-on parameters: @@ -10545,9 +18031,108 @@ 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}\nfmt.Printf(\"Fetched Plan Add-On: %v\", planAddOn)" + x-readme: + code-samples: + - language: node + code: | + try { + const addOn = await client.getPlanAddOn(planId, addOnId) + console.log('Fetched add-on: ', addOn.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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + add_on = client.get_plan_add_on(plan_id, add_on_id) + print("Got Plan Add-On %s" % add_on) + 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") + name: Python + - language: csharp + code: | + try + { + AddOn addOn = client.GetPlanAddOn(planId, addOnId); + Console.WriteLine($"Fetched add-on {addOn.Code}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + add_on = @client.get_plan_add_on( + plan_id: plan_id, add_on_id: add_on_id + ) + puts "Got plan add-on #{add_on}" + 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 + name: Ruby + - language: java + code: | + try { + final AddOn addOn = client.getPlanAddOn(planId, addOnId); + System.out.println("Fetched add-on " + addOn.getCode()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $add_on = $client->getPlanAddOn($plan_id, $add_on_id); + + echo 'Got Plan Add-On:' . PHP_EOL; + var_dump($add_on); + } 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; + } + name: PHP + - language: go + code: "planAddOn, err := client.GetPlanAddOn(planID, planAddOnID)\nif e, + ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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}\nfmt.Printf(\"Fetched Plan + Add-On: %v\", planAddOn)" + name: Go put: tags: - - add-on + - Add-on operationId: update_plan_add_on summary: Update an add-on parameters: @@ -10688,9 +18273,120 @@ 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}\nfmt.Printf(\"Updated Plan Add-On: %v\", planAddOn)" + x-readme: + code-samples: + - language: node + code: | + try { + const addOnUpdate = { + name: 'New AddOn Name', + } + const addOn = await client.updatePlanAddOn(planId, addOnId, addOnUpdate) + console.log('Updated add-on: ', addOn) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + add_on_update = { + "name": "New Add-On Name", + } + add_on = client.update_plan_add_on(plan_id, add_on_id, add_on_update) + print("Updated Plan Add-On %s" % add_on) + 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") + name: Python + - language: csharp + code: | + try + { + var addOnReq = new AddOnUpdate { + Name = "New Add-On Name" + }; + AddOn addOn = client.UpdatePlanAddOn(planId, planAddOnId, addOnReq); + Console.WriteLine($"Updated add-on: {addOn.Code}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: "begin\n add_on_update = {\n name: \"A quality grinder for your + finest beans\"\n }\n add_on = @client.update_plan_add_on(\n plan_id: + plan_id, \n add_on_id: add_on_id, \n body: add_on_update\n )\n + \ puts \"Updated add-on #{add_on}\"\nrescue Recurly::Errors::NotFoundError\n + \ # If the resource was not found, you may want to alert the user or\n + \ # just return nil\n puts \"Resource Not Found\"\nend\n" + name: Ruby + - language: java + code: | + try { + final AddOnUpdate addOnUpdate = new AddOnUpdate(); + addOnUpdate.setName("New Add-On Name"); + + final AddOn addOn = client.updatePlanAddOn(planId, addOnId, addOnUpdate); + System.out.println("Updated add-on " + addOn.getCode()); + System.out.println(addOn.getName()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $add_on_update = [ + "name" => "New AddOn Name", + ]; + $add_on = $client->updatePlanAddOn($plan_id, $add_on_id, $add_on_update); + + echo ' Updated Plan AddOn:' . PHP_EOL; + var_dump($add_on); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "updateReq := &recurly.AddOnUpdate{\n\tName: recurly.String(\"New + Add-On Name\"),\n}\nplanAddOn, err := client.UpdatePlanAddOn(planID, planAddOnID, + updateReq)\nif e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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}\nfmt.Printf(\"Updated Plan + Add-On: %v\", planAddOn)" + name: Go delete: tags: - - add-on + - Add-on operationId: remove_plan_add_on summary: Remove an add-on parameters: @@ -10794,10 +18490,103 @@ 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}\nfmt.Printf(\"Removed Plan Add-On: %v\", planAddOn)" + x-readme: + code-samples: + - language: node + code: | + try { + const addOn = await client.removePlanAddOn(planId, addOnId) + console.log('Removed plan add-on: ', addOn) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + add_on = client.remove_plan_add_on(plan_id, add_on_id) + print("Removed Plan Add-On %s" % add_on_id) + 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") + name: Python + - language: csharp + code: | + try + { + AddOn addOn = client.RemovePlanAddOn(planId, planAddOnId); + Console.WriteLine($"Removed Plan Add-On: {addOn.Code}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: "begin\n add_on = @client.remove_plan_add_on(\n plan_id: plan_id, + \n add_on_id: add_on_id\n )\n puts \"Removed add-on #{add_on}\"\nrescue + Recurly::Errors::NotFoundError\n # If the resource was not found, you + may want to alert the user or\n # just return nil\n puts \"Resource + Not Found\"\nend\n" + name: Ruby + - language: java + code: |- + try { + final AddOn addOn = client.removePlanAddOn(planId, addOnId); + System.out.println("Removed add-on " + addOn.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()); + } + name: Java + - language: php + code: | + try { + $add_on = $client->removePlanAddOn($plan_id, $add_on_id); + + echo 'Removed Plan AddOn:' . PHP_EOL; + var_dump($add_on); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "planAddOn, err := client.RemovePlanAddOn(planID, planAddOnID)\nif + e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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}\nfmt.Printf(\"Removed Plan + Add-On: %v\", planAddOn)" + name: Go "/sites/{site_id}/add_ons": get: tags: - - add-on + - Add-on operationId: list_add_ons summary: List a site's add-ons description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -10887,10 +18676,69 @@ paths: addOns.HasMore {\n\terr := addOns.Fetch()\n\tif 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, addOn := range addOns.Data {\n\t\tfmt.Printf(\"Add On %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\taddOn.Id,\n\t\t\taddOn.Code,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const addOns = client.listAddOns({ limit: 200 }) + + for await (const addOn of addOns.each()) { + console.log(addOn.code) + } + name: Node.js + - language: python + code: | + add_ons = client.list_add_ons().items() + for add_on in add_ons: + print("Add-On %s" % add_on.code) + name: Python + - language: csharp + code: | + var addOns = client.ListAddOns(); + foreach(AddOn addOn in addOns) + { + Console.WriteLine(addOn.Code); + } + name: ".NET" + - language: ruby + code: | + add_ons = @client.list_add_ons( + limit: 200 + ) + add_ons.each do |add_on| + puts "AddOn: #{add_on.code}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager addOns = client.listAddOns(params); + + for (AddOn addOn : addOns) { + System.out.println(addOn.getCode()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $add_ons = $client->listAddOns($params); + + foreach($add_ons as $addon) { + echo 'Add-on: ' . $addon->getCode() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListAddOnsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\naddOns := client.ListAddOns(listParams)\n\nfor + addOns.HasMore {\n\terr := addOns.Fetch()\n\tif 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, addOn := range addOns.Data {\n\t\tfmt.Printf(\"Add On %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\taddOn.Id,\n\t\t\taddOn.Code,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/add_ons/{add_on_id}": get: tags: - - add-on + - Add-on operationId: get_add_on summary: Fetch an add-on parameters: @@ -11004,10 +18852,107 @@ paths: 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(\"Fetched Add-On: %s\", addOn.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const addOn = await client.getAddOn(addOnId) + console.log('Fetched add-on: ', addOn) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + add_on = client.get_add_on(add_on_id) + print("Got Add-On %s" % add_on) + 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") + name: Python + - language: csharp + code: | + try + { + AddOn addOn = client.GetAddOn(addOnId); + Console.WriteLine($"Fetched add-on: {addOn.Code}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + add_on = @client.get_add_on(add_on_id: add_on_id) + puts "Got add-on #{add_on}" + 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 + name: Ruby + - language: java + code: | + try { + final AddOn addOn = client.getAddOn(addOnId); + System.out.println("Fetched add-on " + addOn.getCode()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $add_on = $client->getAddOn($add_on_id); + + echo 'Got Plan Add-On:' . PHP_EOL; + var_dump($add_on); + } 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; + } + name: PHP + - language: go + code: "addOn, err := client.GetAddOn(planAddOnID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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(\"Fetched + Add-On: %s\", addOn.Id)" + name: Go "/sites/{site_id}/shipping_methods": get: tags: - - shipping_method + - Shipping Method operationId: list_shipping_methods summary: List a site's shipping methods description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -11098,9 +19043,70 @@ paths: ok {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, method := range shippingMethods.Data {\n\t\tfmt.Printf(\"Shipping Method %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tmethod.Id,\n\t\t\tmethod.Code,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const methods = client.listShippingMethods({ limit: 200 }) + + for await (const method of methods.each()) { + console.log(method.code) + } + name: Node.js + - language: python + code: | + shipping_methods = client.list_shipping_methods(limit=200).items() + for shipping_method in shipping_methods: + print("Shipping Method %s" % shipping_method.code) + name: Python + - language: csharp + code: | + var shippingMethods = client.ListShippingMethods(); + foreach(ShippingMethod shippingMethod in shippingMethods) + { + Console.WriteLine(shippingMethod.Code); + } + name: ".NET" + - language: ruby + code: | + shipping_methods = @client.list_shipping_methods( + limit: 200 + ) + shipping_methods.each do |shipping_method| + puts "Shipping Method: #{shipping_method.code}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager shippingMethods = client.listShippingMethods(params); + + for (ShippingMethod shippingMethod : shippingMethods) { + System.out.println(shippingMethod.getCode()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $shipping_methods = $client->listShippingMethods($params); + + foreach($shipping_methods as $shipping_method) { + echo 'Shipping Method: ' . $shipping_method->getCode() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListShippingMethodsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\nshippingMethods + := client.ListShippingMethods(listParams)\n\nfor shippingMethods.HasMore + {\n\terr := shippingMethods.Fetch()\n\tif 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, method := range shippingMethods.Data {\n\t\tfmt.Printf(\"Shipping Method + %3d: %s, %s\\n\",\n\t\t\ti,\n\t\t\tmethod.Id,\n\t\t\tmethod.Code,\n\t\t)\n\t}\n}" + name: Go post: tags: - - shipping_method + - Shipping Method operationId: create_shipping_method summary: Create a new shipping method parameters: @@ -11146,7 +19152,7 @@ paths: "/sites/{site_id}/shipping_methods/{id}": get: tags: - - shipping_method + - Shipping Method operationId: get_shipping_method summary: Fetch a shipping method parameters: @@ -11181,7 +19187,7 @@ paths: "/sites/{site_id}/shipping_methods/{shipping_method_id}": put: tags: - - shipping_method + - Shipping Method operationId: update_shipping_method summary: Update an active Shipping Method parameters: @@ -11227,7 +19233,7 @@ paths: x-code-samples: [] delete: tags: - - shipping_method + - Shipping Method operationId: deactivate_shipping_method summary: Deactivate a shipping method parameters: @@ -11258,7 +19264,7 @@ paths: "/sites/{site_id}/subscriptions": get: tags: - - subscription + - Subscription operationId: list_subscriptions summary: List a site's subscriptions description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -11347,9 +19353,67 @@ paths: := subscriptions.Fetch()\n\tif 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, subscription := range subscriptions.Data {\n\t\tfmt.Printf(\"Subscription %3d: %s\\n\",\n\t\t\ti,\n\t\t\tsubscription.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const subscriptions = client.listSubscriptions({ limit: 200 }) + + for await (const subscription of subscriptions.each()) { + console.log(subscription.uuid) + } + name: Node.js + - language: python + code: | + subscriptions = client.list_subscriptions(limit=200).items() + for subscription in subscriptions: + print(subscription.uuid) + name: Python + - language: csharp + code: | + var subscriptions = client.ListSubscriptions(limit: 200); + foreach(Subscription subscription in subscriptions) + { + Console.WriteLine(subscription.Uuid); + } + name: ".NET" + - language: ruby + code: | + subscriptions = @client.list_subscriptions(limit: 200) + subscriptions.each do |subscription| + puts "Subscription: #{subscription.uuid}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager subscriptions = client.listSubscriptions(params); + + for (Subscription subscription : subscriptions) { + System.out.println(subscription.getUuid()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $subscriptions = $client->listSubscriptions($params); + + foreach($subscriptions as $sub) { + echo 'Subscription: ' . $sub->getUuid() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListSubscriptionsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\nsubscriptions + := client.ListSubscriptions(listParams)\n\nfor subscriptions.HasMore {\n\terr + := subscriptions.Fetch()\n\tif 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, subscription + := range subscriptions.Data {\n\t\tfmt.Printf(\"Subscription %3d: %s\\n\",\n\t\t\ti,\n\t\t\tsubscription.Id,\n\t\t)\n\t}\n}" + name: Go post: tags: - - subscription + - Subscription operationId: create_subscription summary: Create a new subscription parameters: @@ -11525,10 +19589,157 @@ paths: {\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(\"Created Subscription: %s\", subscription.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + let subscriptionReq = { + planCode: planCode, + currency: `USD`, + account: { + code: accountCode + } + } + let sub = await client.createSubscription(subscriptionReq) + console.log('Created subscription: ', sub.uuid) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + sub_create = { + "plan_code": plan_code, + "currency": "USD", + "account": {"code": account_code}, + } + sub = client.create_subscription(sub_create) + print("Created Subscription %s" % sub) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var subReq = new SubscriptionCreate() + { + Currency = "USD", + Account = new AccountCreate() + { + Code = accountCode + }, + PlanCode = planCode, + }; + Subscription subscription = client.CreateSubscription(subReq); + Console.WriteLine($"Created Subscription with Id: {subscription.Uuid}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + subscription_create = { + plan_code: plan_code, + currency: "USD", + # This can be an existing account or a new account + account: { + code: account_code, + } + } + subscription = @client.create_subscription( + body: subscription_create + ) + puts "Created Subscription #{subscription}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + SubscriptionCreate subscriptionCreate = new SubscriptionCreate(); + AccountCreate accountCreate = new AccountCreate(); + + accountCreate.setCode(accountCode); + subscriptionCreate.setCurrency("USD"); + subscriptionCreate.setAccount(accountCreate); + subscriptionCreate.setPlanCode(planCode); + + Subscription subscription = client.createSubscription(subscriptionCreate); + System.out.println("Created Subscription with Id: " + subscription.getUuid()); + } 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()); + } + name: Java + - language: php + code: | + try { + $sub_create = [ + "plan_code" => $plan_code, + "currency" => "USD", + "account" => [ + "code" => $account_code + ], + ]; + + $subscription = $client->createSubscription($sub_create); + + echo 'Created Subscription:' . PHP_EOL; + var_dump($subscription); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "subReq := &recurly.SubscriptionCreate{\n\tPlanCode: recurly.String(planCode),\n\tAccount: + &recurly.AccountCreate{\n\t\tCode: recurly.String(accountCode),\n\t},\n\tCurrency: + recurly.String(\"USD\"),\n}\n\nsubscription, err := client.CreateSubscription(subReq)\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(\"Created Subscription: + %s\", subscription.Id)" + name: Go "/sites/{site_id}/subscriptions/{subscription_id}": get: tags: - - subscription + - Subscription operationId: get_subscription summary: Fetch a subscription parameters: @@ -11644,9 +19855,108 @@ paths: not found: %v\", e)\n\t\treturn nil, err\n\t}\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\nfmt.Printf(\"Fetched Subscription: %s\", sub.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const subscription = await client.getSubscription(subscriptionId) + console.log('Fetched subscription: ', subscription.uuid) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + subscription = client.get_subscription(subscription_id) + print("Got Subscription %s" % subscription) + 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") + name: Python + - language: csharp + code: | + try + { + Subscription subscription = client.GetSubscription(sub.Id); + Console.WriteLine($"Fetched Subscription {subscription.Id}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + subscription = @client.get_subscription( + subscription_id: subscription_id + ) + puts "Got Subscription #{subscription}" + 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 + name: Ruby + - language: java + code: | + try { + final Subscription subscription = client.getSubscription(subscriptionId); + System.out.println("Fetched Subscription: " + subscription.getUuid()); + } 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()); + } + name: Java + - language: php + code: | + try { + $subscription = $client->getSubscription($subscription_id); + + echo 'Got Subscription:' . PHP_EOL; + var_dump($subscription); + } 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; + } + name: PHP + - language: go + code: "sub, err := client.GetSubscription(subID)\nif e, ok := err.(*recurly.Error); + ok {\n\tif e.Type == recurly.ErrorTypeNotFound {\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}\nfmt.Printf(\"Fetched Subscription: + %s\", sub.Id)" + name: Go put: tags: - - subscription + - Subscription operationId: modify_subscription summary: Modify a subscription description: This only lets you change the subscription settings that have no @@ -11792,9 +20102,135 @@ paths: {\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(\"Modified Subscription: %s\", sub.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const update = { + termsAndConditions: "Some new terms and conditions", + customerNotes: "Some new customer notes" + } + const subscription = await client.modifySubscription(subscriptionId, update) + console.log('Modified subscription: ', subscription.uuid) + } catch(err) { + + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + sub_update = {"customer_notes": "New Notes", "terms_and_conditions": "New TaC"} + subscription = client.modify_subscription(subscription_id, sub_update) + print("Modified Subscription %s" % subscription) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var updateReq = new SubscriptionUpdate() + { + TermsAndConditions = "Some New Terms and Conditions", + CustomerNotes = "Some New Customer Notes" + }; + Subscription subscription = client.ModifySubscription(subscriptionId, updateReq); + Console.WriteLine($"Modified Subscription {subscription.Uuid}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + subscription_update = { + customer_notes: "New Notes", + terms_and_conditions: "New ToC" + } + subscription = @client.modify_subscription( + subscription_id: subscription_id, + body: subscription_update + ) + puts "Modified Subscription #{subscription}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + final SubscriptionUpdate subUpdate = new SubscriptionUpdate(); + subUpdate.setTermsAndConditions("Some new terms and conditions"); + subUpdate.setCustomerNotes("Some new customer notes"); + final Subscription subscription = client.modifySubscription(subscriptionId, subUpdate); + System.out.println("Modified Subscription: " + subscription.getUuid()); + } 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()); + } + name: Java + - language: php + code: | + try { + $changes = [ + "terms_and_conditions" => "Some new terms and conditions", + "customer_notes" => "Some new customer notes" + ]; + + $subscription = $client->modifySubscription($subscription_id, $changes); + + echo 'Modified Subscription:' . PHP_EOL; + var_dump($subscription); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "updateReq := &recurly.SubscriptionUpdate{\n\tTermsAndConditions: + recurly.String(\"Some new terms and conditions\"),\n\tCustomerNotes: recurly.String(\"Some + new customer notes\"),\n}\nsub, err := client.ModifySubscription(subID, + 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(\"Modified Subscription: + %s\", sub.Id)" + name: Go delete: tags: - - subscription + - Subscription operationId: terminate_subscription summary: Terminate a subscription description: | @@ -11953,10 +20389,112 @@ paths: 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(\"Terminated Subscription: %v\", subscription)" + x-readme: + code-samples: + - language: node + code: | + try { + const subscription = await client.terminateSubscription(subscriptionId) + console.log('Terminated subscription: ', subscription.uuid) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + subscription = client.terminate_subscription(subscription_id) + print("Terminated Subscription %s" % subscription) + 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") + name: Python + - language: csharp + code: | + try + { + Subscription subscription = client.TerminateSubscription(subscriptionId); + Console.WriteLine($"Terminated Subscription {subscription.Uuid}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + subscription = @client.terminate_subscription( + subscription_id: subscription_id, + ) + puts "Terminated Subscription #{subscription}" + 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 + name: Ruby + - language: java + code: | + try { + QueryParams queryParams = new QueryParams(); + queryParams.setRefund("none"); // "full" for a full refund, "partial" for prorated refund + client.terminateSubscription(subscriptionId, queryParams); + System.out.println("Terminated Subscription: " + subscriptionId); + } 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()); + } + name: Java + - language: php + code: | + try { + $subscription = $client->terminateSubscription($subscription_id); + + echo 'Terminated Subscription:' . PHP_EOL; + var_dump($subscription); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "terminateParams := &recurly.TerminateSubscriptionParams{}\nsubscription, + err := client.TerminateSubscription(subID, terminateParams)\nif e, ok + := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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(\"Terminated + Subscription: %v\", subscription)" + name: Go "/sites/{site_id}/subscriptions/{subscription_id}/cancel": put: tags: - - subscription + - Subscription operationId: cancel_subscription summary: Cancel a subscription description: A canceled subscription will continue through its current billing @@ -12091,10 +20629,111 @@ paths: {\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(\"Canceled Subscription: %s\", subscription.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + let expiredSub = await client.cancelSubscription(subscriptionId) + console.log('Canceled Subscription: ', expiredSub.uuid) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + subscription = client.cancel_subscription(subscription_id) + print("Canceled Subscription %s" % subscription) + 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") + name: Python + - language: csharp + code: | + try + { + Subscription subscription = client.CancelSubscription(subscriptionId); + Console.WriteLine($"Canceled Subscription {subscription.Uuid}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + subscription = @client.cancel_subscription( + subscription_id: subscription_id + ) + puts "Canceled Subscription #{subscription}" + 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 + name: Ruby + - language: java + code: | + try { + final Subscription subscription = client.cancelSubscription(subscriptionId); + System.out.println("Canceled Subscription: " + subscription.getUuid()); + } 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()); + } + name: Java + - language: php + code: | + try { + $subscription = $client->cancelSubscription($subscription_id); + + echo 'Canceled Subscription:' . PHP_EOL; + var_dump($subscription); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "cancelParams := &recurly.CancelSubscriptionParams{\n\tBody: &recurly.SubscriptionCancel{\n\t\tTimeframe: + recurly.String(\"bill_date\"),\n\t},\n}\n\nsubscription, err := client.CancelSubscription(subID, + cancelParams)\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(\"Canceled Subscription: %s\", + subscription.Id)" + name: Go "/sites/{site_id}/subscriptions/{subscription_id}/reactivate": put: tags: - - subscription + - Subscription operationId: reactivate_subscription summary: Reactivate a canceled subscription description: | @@ -12222,10 +20861,110 @@ paths: 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(\"Reactivated Subscription: %s\", sub.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const subscription = await client.reactivateSubscription(subscriptionId) + console.log('Reactivated subscription: ', subscription.uuid) + } catch(err) { + + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + subscription = client.reactivate_subscription(subscription_id) + print("Reactivated Subscription %s" % subscription) + 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") + name: Python + - language: csharp + code: | + try + { + Subscription subscription = client.ReactivateSubscription(subscriptionId); + Console.WriteLine($"Reactivated Subscription {subscription.Uuid}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + subscription = @client.reactivate_subscription( + subscription_id: subscription_id + ) + puts "Reactivated Canceled Subscription #{subscription}" + 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 + name: Ruby + - language: java + code: | + try { + final Subscription subscription = client.reactivateSubscription(subscriptionId); + System.out.println("Reactivated Subscription: " + subscription.getUuid()); + } 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()); + } + name: Java + - language: php + code: | + try { + $subscription = $client->reactivateSubscription($subscription_id); + + echo 'Reactivated Subscription:' . PHP_EOL; + var_dump($subscription); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "sub, err := client.ReactivateSubscription(subID)\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(\"Reactivated + Subscription: %s\", sub.Id)" + name: Go "/sites/{site_id}/subscriptions/{subscription_id}/pause": put: tags: - - subscription + - Subscription operationId: pause_subscription summary: Pause subscription description: | @@ -12377,10 +21116,126 @@ paths: {\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(\"Paused Subscription: %s\", sub.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + let pauseReq = { + remaining_pause_cycles: 2, + } + const subscription = await client.pauseSubscription(subscriptionId, pauseReq) + console.log('Paused subscription: ', subscription.id) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + sub_pause = {"remaining_pause_cycles": 10} + subscription = client.pause_subscription(subscription_id, sub_pause) + print("Paused Subscription %s" % subscription) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var pauseReq = new SubscriptionPause() { + RemainingPauseCycles = 2 + }; + Subscription subscription = client.PauseSubscription(subscriptionId, pauseReq); + Console.WriteLine($"Paused Subscription {subscription.Id}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + subscription_pause = { + remaining_pause_cycles: 10 + } + subscription = @client.pause_subscription( + subscription_id: subscription_id, + body: subscription_pause + ) + puts "Paused Subscription #{subscription}" + 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 + name: Ruby + - language: java + code: | + try { + final SubscriptionPause subPause = new SubscriptionPause(); + subPause.setRemainingPauseCycles(10); + + final Subscription subscription = client.pauseSubscription(subscriptionId, subPause); + System.out.println("Paused Subscription: " + subscription.getUuid()); + } 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()); + } + name: Java + - language: php + code: | + try { + $sub_pause = [ "remaining_pause_cycles" => 10 ]; + $subscription = $client->pauseSubscription($subscription_id, $sub_pause); + + echo 'Paused Subscription:' . PHP_EOL; + var_dump($subscription); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "pauseReq := &recurly.SubscriptionPause{\n\tRemainingPauseCycles: + recurly.Int(1),\n}\nsub, err := client.PauseSubscription(subID, pauseReq)\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(\"Paused Subscription: + %s\", sub.Id)" + name: Go "/sites/{site_id}/subscriptions/{subscription_id}/resume": put: tags: - - subscription + - Subscription operationId: resume_subscription summary: Resume subscription description: | @@ -12509,10 +21364,110 @@ paths: 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(\"Resumed Subscription: %s\", sub.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const subscription = await client.resumeSubscription(subscriptionId) + console.log('Resumed subscription: ', subscription.id) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + subscription = client.resume_subscription(subscription_id) + print("Resumed Subscription %s" % subscription) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + Subscription subscription = client.ResumeSubscription(subscriptionId); + Console.WriteLine($"Resumed Subscription {subscription.Id}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + subscription = @client.resume_subscription( + subscription_id: subscription_id + ) + puts "Resumed Subscription #{subscription}" + 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 + name: Ruby + - language: java + code: | + try { + final Subscription subscription = client.resumeSubscription(subscriptionId); + System.out.println("Resumed Subscription: " + subscription.getUuid()); + } 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()); + } + name: Java + - language: php + code: | + try { + $subscription = $client->resumeSubscription($subscription_id); + + echo 'Resumed Subscription:' . PHP_EOL; + var_dump($subscription); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "sub, err := client.ResumeSubscription(subID)\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(\"Resumed Subscription: + %s\", sub.Id)" + name: Go "/sites/{site_id}/subscriptions/{subscription_id}/convert_trial": put: tags: - - subscription + - Subscription operationId: convert_trial summary: Convert trial subscription description: This will immediately convert a trial subscription to a fully active @@ -12553,13 +21508,14 @@ paths: "/sites/{site_id}/subscriptions/{subscription_id}/preview_renewal": get: tags: - - subscription + - Subscription operationId: get_preview_renewal summary: Fetch a preview of a subscription's renewal invoice(s) description: The subscriptions's renewal invoice(s) will be returned if they exist; if they don't (for example, if the subscription is not set to renew), it will return an result with no invoices. parameters: + - "$ref": "#/components/parameters/site_id" - "$ref": "#/components/parameters/subscription_id" responses: '200': @@ -12590,7 +21546,7 @@ paths: "/sites/{site_id}/subscriptions/{subscription_id}/change": get: tags: - - subscription_change + - Subscription Change operationId: get_subscription_change summary: Fetch a subscription's pending change parameters: @@ -12719,9 +21675,108 @@ 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}\nfmt.Printf(\"Fetched subscription change: %s\", subscriptionChange.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const change = await client.getSubscriptionChange(subscriptionId) + console.log('Fetched subscription change: ', change.id) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + change = client.get_subscription_change(subscription_id) + print("Got SubscriptionChange %s" % change) + 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") + name: Python + - language: csharp + code: | + try + { + SubscriptionChange change = client.GetSubscriptionChange(subscriptionId); + Console.WriteLine($"Fetched subscription change {change.Id}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + change = @client.get_subscription_change( + subscription_id: subscription_id + ) + puts "Got SubscriptionChange #{change}" + 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 + name: Ruby + - language: java + code: | + try { + final SubscriptionChange change = client.getSubscriptionChange(subscriptionId); + System.out.println("Fetched Subscription change " + change.getId()); + } 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()); + } + name: Java + - language: php + code: | + try { + $change = $client->getSubscriptionChange($subscription_id); + + echo 'Got Pending Subscription Change:' . PHP_EOL; + var_dump($change); + } 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; + } + name: PHP + - language: go + code: "subscriptionChange, err := client.GetSubscriptionChange(subID)\nif + e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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}\nfmt.Printf(\"Fetched subscription + change: %s\", subscriptionChange.Id)" + name: Go post: tags: - - subscription_change + - Subscription Change operationId: create_subscription_change summary: Create a new subscription change description: | @@ -12889,9 +21944,135 @@ paths: {\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(\"Subscription changed: %s\", subscriptionChange.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const subscriptionChangeCreate = { + planCode: newPlanCode, + timeframe: 'now' + } + + const change = await client.createSubscriptionChange(subscriptionId, subscriptionChangeCreate) + console.log('Created subscription change: ', change.id) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + sub_change_create = {"plan_code": new_plan_code, "timeframe": "now"} + change = client.create_subscription_change(subscription_id, sub_change_create) + print("Created SubscriptionChange %s" % change) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var changeReq = new SubscriptionChangeCreate() + { + PlanCode = newPlanCode, + Timeframe = "now" // choose "now" or "renewal" + }; + SubscriptionChange change = client.CreateSubscriptionChange(subscriptionId, changeReq); + Console.WriteLine($"Created subscription change {change.Id}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + change_create = { + timeframe: "now", + plan_code: new_plan_code + } + change = @client.create_subscription_change( + subscription_id: subscription_id, + body: change_create + ) + puts "Created SubscriptionChange #{change}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + SubscriptionChangeCreate changeCreate = new SubscriptionChangeCreate(); + + changeCreate.setPlanCode(newPlanCode); + changeCreate.setTimeframe("now"); // choose "now" or "renewal" + + SubscriptionChange change = client.createSubscriptionChange(subscriptionId, changeCreate); + System.out.println("Created subscription " + change.getId()); + } 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()); + } + name: Java + - language: php + code: | + try { + $change_create = [ + "plan_code" => $new_plan_code, + "timeframe" => "now" + ]; + $change = $client->createSubscriptionChange($subscription_id, $change_create); + + echo 'Created Subscription Change:' . PHP_EOL; + var_dump($change); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "changeReq := &recurly.SubscriptionChangeCreate{\n\tPlanCode: recurly.String(newPlanCode),\n\tTimeframe: + recurly.String(\"now\"),\n}\nsubscriptionChange, err := client.CreateSubscriptionChange(subID, + changeReq)\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(\"Subscription + changed: %s\", subscriptionChange.Id)" + name: Go delete: tags: - - subscription_change + - Subscription Change operationId: remove_subscription_change summary: Delete the pending subscription change parameters: @@ -13003,10 +22184,107 @@ 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 Subscription Change: %v\", subscriptionChange)" + x-readme: + code-samples: + - language: node + code: | + try { + await client.removeSubscriptionChange(subscriptionId) + console.log('Removed subscription change: ', subscriptionId) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + client.remove_subscription_change(subscription_id) + print("Removed SubscriptionChange from Subscription id=%s" % subscription_id) + 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") + name: Python + - language: csharp + code: | + try + { + client.RemoveSubscriptionChange(subscriptionId); + Console.WriteLine($"Removed subscription change from {subscriptionId}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + @client.remove_subscription_change( + subscription_id: subscription_id + ) + puts "Removed SubscriptionChange #{subscription_id}" + 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 + name: Ruby + - language: java + code: | + try { + client.removeSubscriptionChange(subscriptionId); + System.out.println("Removed Subscription change from " + subscriptionId); + } 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()); + } + name: Java + - language: php + code: | + try { + $client->removeSubscriptionChange($subscription_id); + echo 'Removed Subscription Change: ' . $subscription_id . PHP_EOL; + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "subscriptionChange, err := client.RemoveSubscriptionChange(subID)\nif + e, ok := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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 + Subscription Change: %v\", subscriptionChange)" + name: Go "/sites/{site_id}/subscriptions/{subscription_id}/change/preview": post: tags: - - subscription_change + - Subscription Change operationId: preview_subscription_change summary: Preview a new subscription change description: Calling this will not save the subscription change or overwrite @@ -13050,7 +22328,7 @@ paths: "/sites/{site_id}/subscriptions/{subscription_id}/invoices": get: tags: - - invoice + - Invoice operationId: list_subscription_invoices summary: List a subscription's invoices description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -13145,10 +22423,72 @@ paths: {\n\t\tfmt.Printf(\"Failed to retrieve next page: %v\", e)\n\t\tbreak\n\t}\n\tfor i, invoice := range subInvoices.Data {\n\t\tfmt.Printf(\"Subscription Invoice %3d: %s\\n\",\n\t\t\ti,\n\t\t\tinvoice.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const invoices = client.listSubscriptionInvoices(subscriptionId, { limit: 200 }) + + for await (const invoice of invoices.each()) { + console.log(invoice.number) + } + name: Node.js + - language: python + code: | + invoices = client.list_subscription_invoices(subscription_id).items() + for invoice in invoices: + print(invoice.number) + name: Python + - language: csharp + code: | + var subscriptionInvoices = client.ListSubscriptionInvoices(subscriptionId); + foreach(Invoice invoice in subscriptionInvoices) + { + Console.WriteLine(invoice.Number); + } + name: ".NET" + - language: ruby + code: | + invoices = @client.list_subscription_invoices( + subscription_id: subscription_id, + limit: 200 + ) + invoices.each do |invoice| + puts "Invoice: #{invoice.number}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager invoices = client.listSubscriptionInvoices(subscriptionId, params); + + for (Invoice invoice : invoices) { + System.out.println(invoice.getNumber()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $subscription_invoices = $client->listSubscriptionInvoices($subscription_id, $params); + + foreach($subscription_invoices as $sub_invoice) { + echo 'Subscription Invoice: ' . $sub_invoice->getNumber() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListSubscriptionInvoicesParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\nsubInvoices + := client.ListSubscriptionInvoices(subID, listParams)\n\nfor subInvoices.HasMore + {\n\terr := subInvoices.Fetch()\n\tif 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, invoice := range subInvoices.Data {\n\t\tfmt.Printf(\"Subscription + Invoice %3d: %s\\n\",\n\t\t\ti,\n\t\t\tinvoice.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/subscriptions/{subscription_id}/line_items": get: tags: - - line_item + - Line Item operationId: list_subscription_line_items summary: List a subscription's line items description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -13244,10 +22584,72 @@ 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, lineItem := range subLineItems.Data {\n\t\tfmt.Printf(\"Subscription Line Item %3d: %s\\n\",\n\t\t\ti,\n\t\t\tlineItem.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const lineItems = client.listSubscriptionLineItems(subscriptionId, { limit: 200 }) + + for await (const lineItem of lineItems.each()) { + console.log(lineItem.id) + } + name: Node.js + - language: python + code: | + line_items = client.list_subscription_line_items(subscription_id).items() + for line_item in line_items: + print(line_item.id) + name: Python + - language: csharp + code: | + var subscriptionLineItems = client.ListSubscriptionLineItems(subscriptionId); + foreach(LineItem lineItem in subscriptionLineItems) + { + Console.WriteLine(lineItem.Id); + } + name: ".NET" + - language: ruby + code: | + line_items = @client.list_subscription_line_items( + subscription_id: subscription_id, + limit: 200 + ) + line_items.each do |line_item| + puts "LineItem: #{line_item.id}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager lineItems = client.listSubscriptionLineItems(subscriptionId, params); + + for (LineItem lineItem : lineItems) { + System.out.println(lineItem.getId()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $subscription_line_items = $client->listSubscriptionLineItems($subscription_id, $params); + + foreach($subscription_line_items as $line_item) { + echo 'Subscription Invoice: ' . $line_item->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListSubscriptionLineItemsParams{\n\tSort: + \ recurly.String(\"created_at\"),\n\tOrder: recurly.String(\"desc\"),\n\tLimit: + recurly.Int(200),\n}\nsubLineItems := client.ListSubscriptionLineItems(subID, + listParams)\n\nfor subLineItems.HasMore {\n\terr := subLineItems.Fetch()\n\tif + 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, lineItem := range subLineItems.Data + {\n\t\tfmt.Printf(\"Subscription Line Item %3d: %s\\n\",\n\t\t\ti,\n\t\t\tlineItem.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/subscriptions/{subscription_id}/coupon_redemptions": get: tags: - - coupon_redemption + - Coupon Redemption operationId: list_subscription_coupon_redemptions summary: List the coupon redemptions for a subscription description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -13331,10 +22733,71 @@ 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}" + x-readme: + code-samples: + - language: node + code: | + const redemptions = client.listSubscriptionCouponRedemptions(subscriptionId, { limit: 200 }) + + for await (const redemption of redemptions.each()) { + console.log(redemption.id) + } + name: Node.js + - language: python + code: | + redemptions = client.list_subscription_coupon_redemptions(subscription_id).items() + for redemption in redemptions: + print(redemption.uuid) + name: Python + - language: csharp + code: | + var subscriptionCouponRedemptions = client.ListSubscriptionCouponRedemptions(subscriptionId); + foreach(CouponRedemption redemption in subscriptionCouponRedemptions) + { + Console.WriteLine(redemption.Id); + } + name: ".NET" + - language: ruby + code: | + coupon_redemptions = @client.list_subscription_coupon_redemptions( + subscription_id: subscription_id, + limit: 200 + ) + coupon_redemptions.each do |redemption| + puts "CouponRedemption: #{redemption.id}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager redemptions = client.listSubscriptionCouponRedemptions(subscriptionId, params); + + for (CouponRedemption redemption : redemptions) { + System.out.println(redemption.getId()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $subscription_coupon_redemptions = $client->listSubscriptionCouponRedemptions($subscription_id, $params); + + foreach($subscription_coupon_redemptions as $redemption) { + echo 'Subscription Coupon Redemption: ' . $redemption->getId() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListSubscriptionCouponRedemptionsParams{\n\tSort: + recurly.String(\"created_at\"),\n}\nsubCouponRedemptions := client.ListSubscriptionCouponRedemptions(subID, + listParams)\n\nfor subCouponRedemptions.HasMore {\n\terr := subCouponRedemptions.Fetch()\n\tif + 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}" + name: Go "/sites/{site_id}/subscriptions/{subscription_id}/add_ons/{add_on_id}/usage": get: tags: - - usage + - Usage operationId: list_usage summary: List a subscription add-on's usage records parameters: @@ -13376,7 +22839,7 @@ paths: x-code-samples: [] post: tags: - - usage + - Usage operationId: create_usage summary: Log a usage record on this subscription add-on parameters: @@ -13424,7 +22887,7 @@ paths: "/sites/{site_id}/usage/{usage_id}": get: tags: - - usage + - Usage operationId: get_usage summary: Get a usage record parameters: @@ -13458,7 +22921,7 @@ paths: x-code-samples: [] put: tags: - - usage + - Usage operationId: update_usage summary: Update a usage record parameters: @@ -13504,7 +22967,7 @@ paths: x-code-samples: [] delete: tags: - - usage + - Usage operationId: remove_usage summary: Delete a usage record. parameters: @@ -13541,7 +23004,7 @@ paths: "/sites/{site_id}/transactions": get: tags: - - transaction + - Transaction operationId: list_transactions summary: List a site's transactions description: See the [Pagination Guide](/developers/guides/pagination.html) @@ -13631,10 +23094,68 @@ paths: := transactions.Fetch()\n\tif 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, transaction := range transactions.Data {\n\t\tfmt.Printf(\"Transaction %3d: %s\\n\",\n\t\t\ti,\n\t\t\ttransaction.Id,\n\t\t)\n\t}\n}" + x-readme: + code-samples: + - language: node + code: | + const transactions = client.listTransactions({ limit: 200 }) + + for await (const transaction of transactions.each()) { + console.log(transaction.uuid) + } + name: Node.js + - language: python + code: | + transactions = client.list_transactions(limit=200).items() + for transaction in transactions: + print(transaction.uuid) + name: Python + - language: csharp + code: | + var transactions = client.ListTransactions(limit: 200); + foreach(Transaction transaction in transactions) + { + Console.WriteLine(transaction.Uuid); + } + name: ".NET" + - language: ruby + code: | + transactions = @client.list_transactions(limit: 200) + transactions.each do |transaction| + puts "Transaction: #{transaction.uuid}" + end + name: Ruby + - language: java + code: | + QueryParams params = new QueryParams(); + params.setLimit(200); // Pull 200 records at a time + final Pager transactions = client.listTransactions(params); + + for (Transaction transaction : transactions) { + System.out.println(transaction.getUuid()); + } + name: Java + - language: php + code: | + $params = ['limit' => 200]; + $transactions = $client->listTransactions($params); + + foreach($transactions as $transaction) { + echo 'Transaction: ' . $transaction->getUuid() . PHP_EOL; + } + name: PHP + - language: go + code: "listParams := &recurly.ListTransactionsParams{\n\tSort: recurly.String(\"created_at\"),\n\tOrder: + recurly.String(\"desc\"),\n\tLimit: recurly.Int(200),\n}\ntransactions + := client.ListTransactions(listParams)\n\nfor transactions.HasMore {\n\terr + := transactions.Fetch()\n\tif 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, transaction + := range transactions.Data {\n\t\tfmt.Printf(\"Transaction %3d: %s\\n\",\n\t\t\ti,\n\t\t\ttransaction.Id,\n\t\t)\n\t}\n}" + name: Go "/sites/{site_id}/transactions/{transaction_id}": get: tags: - - transaction + - Transaction operationId: get_transaction summary: Fetch a transaction parameters: @@ -13748,13 +23269,110 @@ 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}\nfmt.Printf(\"Fetched Transaction: %v\", transaction.Id)" + x-readme: + code-samples: + - language: node + code: | + try { + const transaction = await client.getTransaction(transactionId) + console.log('Fetched transaction: ', transaction.uuid) + } 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') + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + transaction = client.get_transaction(transaction_id) + print("Got Transaction %s" % transaction) + 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") + name: Python + - language: csharp + code: | + try + { + Transaction transaction = client.GetTransaction(transactionId); + Console.WriteLine($"Fetched transaction {transaction.Uuid}"); + } + catch (Recurly.Errors.NotFound ex) + { + // If the resource was not found + // we may want to alert the user or just return null + Console.WriteLine($"Resource Not Found: {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}"); + } + name: ".NET" + - language: ruby + code: | + begin + transaction = @client.get_transaction(transaction_id: transaction_id) + puts "Got Transaction #{transaction}" + 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 + name: Ruby + - language: java + code: | + try { + Transaction transaction = client.getTransaction(transactionId); + System.out.println("Fetched transaction " + transaction.getUuid()); + } catch (NotFoundException e) { + // If the resource was not found + // we may want to alert the user or just return null + System.out.println("Resource Not Found: " + 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()); + } + name: Java + - language: php + code: | + try { + $transaction = $client->getTransaction($transaction_id); + + echo 'Got Transaction:' . PHP_EOL; + var_dump($transaction); + } 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; + } + name: PHP + - language: go + code: "transaction, err := client.GetTransaction(transactionID)\nif e, ok + := err.(*recurly.Error); ok {\n\tif e.Type == recurly.ErrorTypeNotFound + {\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}\nfmt.Printf(\"Fetched Transaction: + %v\", transaction.Id)" + name: Go "/sites/{site_id}/unique_coupon_codes/{unique_coupon_code_id}": parameters: - "$ref": "#/components/parameters/site_id" - "$ref": "#/components/parameters/unique_coupon_code_id" get: tags: - - unique_coupon_code + - Unique Coupon Code operationId: get_unique_coupon_code summary: Fetch a unique coupon code responses: @@ -13779,7 +23397,7 @@ paths: x-code-samples: [] delete: tags: - - unique_coupon_code + - Unique Coupon Code operationId: deactivate_unique_coupon_code summary: Deactivate a unique coupon code description: Expire a unique code, making that specific code no longer redeemable. @@ -13816,7 +23434,7 @@ paths: - "$ref": "#/components/parameters/unique_coupon_code_id" put: tags: - - unique_coupon_code + - Unique Coupon Code operationId: reactivate_unique_coupon_code summary: Restore a unique coupon code responses: @@ -13848,7 +23466,7 @@ paths: "/sites/{site_id}/purchases": post: tags: - - purchase + - Purchase operationId: create_purchase summary: Create a new purchase description: A purchase is a checkout containing at least one or more subscriptions @@ -14079,10 +23697,210 @@ paths: 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(\"Created Purchase: %s\", collection.ChargeInvoice.Number)" + x-readme: + code-samples: + - language: node + code: | + try { + let purchaseReq = { + currency: 'USD', + account: { + code: accountCode, + firstName: 'Benjamin', + lastName: 'Du Monde', + billingInfo: { + tokenId: rjsTokenId + } + }, + subscriptions: [ + { planCode: planCode }, + ] + } + let invoiceCollection = await client.createPurchase(purchaseReq) + console.log('Created Charge Invoice: ', invoiceCollection.chargeInvoice) + console.log('Created Credit Invoices: ', invoiceCollection.creditInvoices) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + purchase = { + "currency": "USD", + "account": { + "code": account_code, + "first_name": "Benjamin", + "last_name": "Du Monde", + "billing_info": {"token_id": rjs_token_id}, + }, + "subscriptions": [{"plan_code": plan_code}], + } + invoice_collection = client.create_purchase(purchase) + print("Created Charge Invoice %s" % invoice_collection.charge_invoice) + print("Created Credit Invoices %s" % invoice_collection.credit_invoices) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var purchaseReq = new PurchaseCreate() + { + Currency = "USD", + Account = new AccountPurchase() + { + Code = accountCode, + FirstName = "Benjamin", + LastName = "Du Monde", + BillingInfo = new BillingInfoCreate() + { + TokenId = rjsTokenId + } + }, + Subscriptions = new List() + { + new SubscriptionPurchase() { PlanCode = planCode } + } + }; + InvoiceCollection collection = client.CreatePurchase(purchaseReq); + Console.WriteLine($"Created ChargeInvoice with Number: {collection.ChargeInvoice.Number}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + purchase = { + currency: "USD", + account: { + code: account_code, + first_name: "Benjamin", + last_name: "Du Monde", + billing_info: { + token_id: rjs_token_id + }, + }, + subscriptions: [ + { plan_code: plan_code } + ] + } + invoice_collection = @client.create_purchase( + body: purchase + ) + puts "Created Charge Invoice #{invoice_collection.charge_invoice}" + puts "Created Credit Invoices #{invoice_collection.credit_invoices}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + + AccountPurchase account = new AccountPurchase(); + account.setCode(accountCode); + account.setFirstName("Benjamin"); + account.setLastName("DuMonde"); + + BillingInfoCreate billing = new BillingInfoCreate(); + billing.setTokenId(rjsTokenId); + account.setBillingInfo(billing); + + List subscriptions = new ArrayList(); + SubscriptionPurchase sub = new SubscriptionPurchase(); + sub.setPlanCode(planCode); + subscriptions.add(sub); + + PurchaseCreate purchase = new PurchaseCreate(); + purchase.setCurrency("USD"); + purchase.setAccount(account); + purchase.setSubscriptions(subscriptions); + + InvoiceCollection collection = client.createPurchase(purchase); + System.out.println("Created ChargeInvoice with Id: " + collection.getChargeInvoice().getId()); + } 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()); + System.out.println("Params: " + e.getError().getParams()); + } catch (ApiException e) { + // Use ApiException to catch a generic error from the API + System.out.println("Unexpected Recurly Error: " + e.getError().getMessage()); + } + name: Java + - language: php + code: | + try { + $purchase_create = [ + "currency" => "USD", + "account" => [ + "code" => $account_code, + "first_name" => "Douglas", + "last_name" => "Du Monde", + "billing_info" => [ + "token_id" => $rjs_token_id + ], + ], + "subscriptions" => [ + [ + "plan_code" => $plan_code + ] + ] + ]; + $invoice_collection = $client->createPurchase($purchase_create); + echo 'Created Invoices:' . PHP_EOL; + var_dump($invoice_collection); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "purchaseReq := &recurly.PurchaseCreate{\n\tCurrency: recurly.String(\"USD\"),\n\tAccount: + &recurly.AccountPurchase{\n\t\tCode: recurly.String(accountCode),\n\t},\n\tSubscriptions: + []recurly.SubscriptionPurchase{\n\t\t{\n\t\t\tPlanCode: recurly.String(planCode),\n\t\t\tNextBillDate: + recurly.Time(time.Date(2078, time.November, 10, 23, 0, 0, 0, time.UTC)),\n\t\t},\n\t},\n\tShipping: + &recurly.ShippingPurchase{\n\t\tAddressId: recurly.String(shippingAddressID),\n\t},\n}\n\ncollection, + err := client.CreatePurchase(purchaseReq)\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(\"Created Purchase: + %s\", collection.ChargeInvoice.Number)" + name: Go "/sites/{site_id}/purchases/preview": post: tags: - - purchase + - Purchase operationId: preview_purchase summary: Preview a new purchase description: A purchase is a checkout containing at least one or more subscriptions @@ -14315,12 +24133,214 @@ paths: 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(\"Preview Charge Invoice %v\", collection.ChargeInvoice)" + x-readme: + code-samples: + - language: node + code: | + try { + let purchaseReq = { + currency: 'USD', + account: { + firstName: 'Benjamin', + lastName: 'Du Monde', + code: accountCode, + billingInfo: { + tokenId: rjsTokenId + } + }, + subscriptions: [ + { planCode: planCode }, + ] + } + let invoiceCollection = await client.previewPurchase(purchaseReq) + console.log('Preview Charge Invoice: ', invoiceCollection.chargeInvoice) + console.log('Preview Credit Invoices: ', invoiceCollection.creditInvoices) + } catch (err) { + if (err instanceof recurly.errors.ValidationError) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + console.log('Failed validation', err.params) + } else { + // 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 + console.log('Unknown Error: ', err) + } + } + name: Node.js + - language: python + code: | + try: + purchase = { + "currency": "USD", + "account": { + "code": account_code, + "first_name": "Benjamin", + "last_name": "Du Monde", + "billing_info": {"token_id": rjs_token_id}, + }, + "subscriptions": [{"plan_code": plan_code}], + } + invoice_collection = client.preview_purchase(purchase) + print("Preview Charge Invoice %s" % invoice_collection.charge_invoice) + print("Preview Credit Invoices %s" % invoice_collection.credit_invoices) + except recurly.errors.ValidationError as e: + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.error.params + print("ValidationError: %s" % e.error.message) + print(e.error.params) + name: Python + - language: csharp + code: | + try + { + var purchaseReq = new PurchaseCreate() + { + Currency = "USD", + Account = new AccountPurchase() + { + Code = accountCode, + FirstName = "Benjamin", + LastName = "Du Monde", + BillingInfo = new BillingInfoCreate() + { + TokenId = rjsTokenId + } + }, + Subscriptions = new List() + { + new SubscriptionPurchase() { PlanCode = planCode } + } + }; + InvoiceCollection collection = client.PreviewPurchase(purchaseReq); + Console.WriteLine($"Preview ChargeInvoice with Total: {collection.ChargeInvoice.Total}"); + } + 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}"); + } + name: ".NET" + - language: ruby + code: | + begin + purchase = { + currency: "USD", + account: { + code: account_code, + first_name: "Benjamin", + last_name: "Du Monde", + billing_info: { + token_id: rjs_token_id + }, + }, + subscriptions: [ + { plan_code: plan_code } + ] + } + invoice_collection = @client.preview_purchase( + body: purchase + ) + puts "Preview Charge Invoice #{invoice_collection.charge_invoice}" + puts "Preview Credit Invoices #{invoice_collection.credit_invoices}" + rescue Recurly::Errors::ValidationError => e + # If the request was invalid, you may want to tell your user + # why. You can find the invalid params and reasons in e.recurly_error.params + puts "ValidationError: #{e.recurly_error.params}" + end + name: Ruby + - language: java + code: | + try { + + AccountPurchase account = new AccountPurchase(); + account.setCode(accountCode); + account.setFirstName("Joanna"); + account.setLastName("DuMonde"); + + BillingInfoCreate billing = new BillingInfoCreate(); + billing.setTokenId(rjsTokenId); + account.setBillingInfo(billing); + + List subscriptions = new ArrayList(); + SubscriptionPurchase sub = new SubscriptionPurchase(); + sub.setPlanCode(planCode); + subscriptions.add(sub); + + PurchaseCreate purchase = new PurchaseCreate(); + purchase.setCurrency("USD"); + purchase.setAccount(account); + purchase.setSubscriptions(subscriptions); + + InvoiceCollection collection = client.previewPurchase(purchase); + System.out.println("Preview Charge Invoice:" + collection.getChargeInvoice()); + System.out.println("Preview Credit Invoices: " + collection.getCreditInvoices()); + + } 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()); + System.out.println("Params: " + e.getError().getParams()); + } catch (ApiException e) { + // Use ApiException to catch a generic error from the API + System.out.println("Unexpected Recurly Error: " + e.getError().getMessage()); + } + name: Java + - language: php + code: | + try { + $purchase_preview = [ + "currency" => "USD", + "account" => [ + "code" => $account_code, + "first_name" => "Douglas", + "last_name" => "Du Monde", + "billing_info" => [ + "token_id" => $rjs_token_id + ], + ], + "subscriptions" => [ + [ + "plan_code" => $plan_code + ] + ] + ]; + $invoice_collection = $client->previewPurchase($purchase_preview); + echo 'Preview Invoices:' . PHP_EOL; + var_dump($invoice_collection); + } catch (\Recurly\Errors\Validation $e) { + // If the request was not valid, you may want to tell your user + // why. You can find the invalid params and reasons in err.params + var_dump($e); + } catch (\Recurly\RecurlyError $e) { + // 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 + var_dump($e); + } + name: PHP + - language: go + code: "purchaseReq := &recurly.PurchaseCreate{\n\tCurrency: recurly.String(\"USD\"),\n\tAccount: + &recurly.AccountPurchase{\n\t\tCode: recurly.String(account.Code),\n\t},\n\tSubscriptions: + []recurly.SubscriptionPurchase{\n\t\t{\n\t\t\tPlanCode: recurly.String(plan.Code),\n\t\t\tNextBillDate: + recurly.Time(time.Date(2078, time.November, 10, 23, 0, 0, 0, time.UTC)),\n\t\t},\n\t},\n\tShipping: + &recurly.ShippingPurchase{\n\t\tAddressId: recurly.String(shippingAddressID),\n\t},\n}\ncollection, + err := client.PreviewPurchase(purchaseReq)\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(\"Preview Charge + Invoice %v\", collection.ChargeInvoice)" + name: Go "/sites/{site_id}/export_dates": parameters: - "$ref": "#/components/parameters/site_id" get: tags: - - automated_exports + - Automated Exports operationId: get_export_dates summary: List the dates that have an available export to download. description: Returns a list of dates for which export files are available for @@ -14427,13 +24447,98 @@ paths: ok {\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\n\nfor _, date := range exportDates.Dates {\n\tfmt.Println(\"Exports are available for: \", date)\n}" + x-readme: + code-samples: + - language: node + code: | + try { + const export_dates = await client.getExportDates() + export_dates.dates.forEach(date => { + console.log(`Exports are available for: ${date}`) + }) + } catch (err) { + if (err instanceof recurly.ApiError) { + console.log('Unexpected error', err) + } + } + name: Node.js + - language: python + code: | + try: + export_dates = client.get_export_dates() + for date in export_dates.dates: + print( "Exports are available for: %s" % date) + 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") + name: Python + - language: csharp + code: | + try + { + ExportDates exportDates = client.GetExportDates(); + foreach (var date in exportDates.Dates) + { + System.Console.WriteLine($"Exports are available for: {date}"); + } + } + catch (Recurly.Errors.ApiError ex) + { + // Use ApiError to catch a generic error from the API + Console.WriteLine($"Unexpected Recurly Error: {ex.Error.Message}"); + } + name: ".NET" + - language: ruby + code: | + begin + export_dates = @client.get_export_dates() + export_dates.dates.each do |date| + puts "Exports are available for: #{date}" + end + 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 + name: Ruby + - language: java + code: | + try { + ExportDates exportDates = client.getExportDates(); + for (String date : exportDates.getDates()) { + System.out.println("Exports are available for: " + date); + } + } catch (ApiException e) { + // Use ApiException to catch a generic error from the API + System.out.println("Unexpected Recurly Error: " + e.getError().getMessage()); + } + name: Java + - language: php + code: | + try { + $export_dates = $client->getExportDates(); + foreach($export_dates->getDates() as $date) + { + echo "Exports are available for: {$date}" . PHP_EOL; + } + } catch (\Recurly\RecurlyError $e) { + echo 'Some unexpected Recurly error happened. Try again later.' . PHP_EOL; + } + name: PHP + - language: go + code: "exportDates, err := client.GetExportDates()\nif e, ok := err.(*recurly.Error); + ok {\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, + err\n}\n\nfor _, date := range exportDates.Dates {\n\tfmt.Println(\"Exports + are available for: \", date)\n}" + name: Go "/sites/{site_id}/export_dates/{export_date}/export_files": parameters: - "$ref": "#/components/parameters/site_id" - "$ref": "#/components/parameters/export_date" get: tags: - - automated_exports + - Automated Exports operationId: get_export_files summary: List of the export files that are available to download. description: Returns a list of presigned URLs to download export files for the @@ -14540,15 +24645,101 @@ paths: err.(*recurly.Error); ok {\n\tfmt.Printf(\"Unexpected Recurly error: %v\", e)\n\treturn nil, err\n}\n\nfor _, file := range exportFiles.Files {\n\tfmt.Println(\"Export file download URL: \", file.Href)\n}" + x-readme: + code-samples: + - language: node + code: | + try { + const export_files = await client.getExportFiles(export_date) + export_files.files.forEach(file => { + console.log(`Export file download URL: ${file.href}`) + }) + } catch (err) { + if (err instanceof recurly.ApiError) { + console.log('Unexpected error', err) + } + } + name: Node.js + - language: python + code: | + try: + export_files = client.get_export_files(export_date) + for file in export_files.files: + print( "Export file download URL: %s" % file.href) + 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") + name: Python + - language: csharp + code: | + try + { + ExportFiles exportFiles = client.GetExportFiles(exportDate: exportDate); + foreach (var file in exportFiles.Files) + { + System.Console.WriteLine($"Export file download URL: {file.Href}"); + } + } + catch (Recurly.Errors.ApiError ex) + { + // Use ApiError to catch a generic error from the API + Console.WriteLine($"Unexpected Recurly Error: {ex.Error.Message}"); + } + name: ".NET" + - language: ruby + code: | + begin + export_files = @client.get_export_files(export_date: export_date) + export_files.files.each do |file| + puts "Export file download URL: #{file.href}" + end + 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 + name: Ruby + - language: java + code: | + try { + ExportFiles exportFiles = client.getExportFiles(exportDate); + for (ExportFile file : exportFiles.getFiles()) { + System.out.println("Export file download URL: " + file.getHref()); + } + } catch (ApiException e) { + // Use ApiException to catch a generic error from the API + System.out.println("Unexpected Recurly Error: " + e.getError()); + } + name: Java + - language: php + code: | + try { + $export_files = $client->getExportFiles($export_date); + foreach($export_files->getFiles() as $file) + { + echo "Export file download URL: {$file->getHref()}" . PHP_EOL; + } + } catch (\Recurly\RecurlyError $e) { + echo 'Some unexpected Recurly error happened. Try again later.' . PHP_EOL; + } + name: PHP + - language: go + code: "exportFiles, err := client.GetExportFiles(exportDate)\nif e, ok := + err.(*recurly.Error); ok {\n\tfmt.Printf(\"Unexpected Recurly error: %v\", + e)\n\treturn nil, err\n}\n\nfor _, file := range exportFiles.Files {\n\tfmt.Println(\"Export + file download URL: \", file.Href)\n}" + name: Go "/sites/{site_id}/dunning_campaigns": get: tags: - - dunning_campaigns + - Dunning Campaigns operationId: list_dunning_campaigns summary: List the dunning campaigns for a site description: See the [Pagination Guide](/developers/guides/pagination.html) to learn how to use pagination in the API and Client Libraries. parameters: + - "$ref": "#/components/parameters/site_id" - "$ref": "#/components/parameters/sort_dates" responses: '200': @@ -14575,7 +24766,7 @@ paths: - "$ref": "#/components/parameters/dunning_campaign_id" get: tags: - - dunning_campaigns + - Dunning Campaigns operationId: get_dunning_campaign summary: Fetch a dunning campaign responses: @@ -14609,7 +24800,7 @@ paths: - "$ref": "#/components/parameters/dunning_campaign_id" put: tags: - - dunning_campaigns + - Dunning Campaigns operationId: put_dunning_campaign_bulk_update summary: Assign a dunning campaign to multiple plans requestBody: @@ -14721,7 +24912,8 @@ components: name: invoice_id in: path description: Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. - For number use prefix `number-`, e.g. `number-1000`. + For number use prefix `number-`, e.g. `number-1000`. For number with prefix + or country code, use `number-` and `prefix`, e.g. `number-TEST-FR1001` required: true schema: type: string @@ -15959,7 +26151,7 @@ components: type: string maxLength: 20 description: Code that represents a geographic entity (location or object). - Only returned for Sling Vertex Integration + Only returned when Vertex or Avalara for Communications is enabled. AddOnMini: type: object title: Add-on mini details @@ -16128,11 +26320,14 @@ components: minimum: 0 tax_code: type: string - title: Tax code - description: Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. - The tax code values are specific to each tax system. If you are using - Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. maxLength: 50 + title: Tax code + description: Optional field used by Avalara, Vertex, and Recurly's In-the-Box + tax solution to determine taxation rules. You can pass in specific tax + codes using any of these tax integrations. For Recurly's In-the-Box tax + offering you can also choose to instead use simple values of `unknown`, + `physical`, or `digital` tax codes. If `item_code`/`item_id` is part of + the request then `tax_code` must be absent. display_quantity: type: boolean title: Display quantity? @@ -16339,14 +26534,14 @@ components: minimum: 0 tax_code: type: string - title: Tax code - description: Optional field used by Avalara, Vertex, and Recurly's EU VAT - tax feature to determine taxation rules. If you have your own AvaTax or - Vertex account configured, use their tax codes to assign specific tax - rules. If you are using Recurly's EU VAT feature, you can use values of - `unknown`, `physical`, or `digital`. If `item_code`/`item_id` is part - of the request then `tax_code` must be absent. maxLength: 50 + title: Tax code + description: Optional field used by Avalara, Vertex, and Recurly's In-the-Box + tax solution to determine taxation rules. You can pass in specific tax + codes using any of these tax integrations. For Recurly's In-the-Box tax + offering you can also choose to instead use simple values of `unknown`, + `physical`, or `digital` tax codes. If `item_code`/`item_id` is part of + the request then `tax_code` must be absent. currencies: type: array title: Add-on pricing @@ -16472,14 +26667,14 @@ components: minimum: 0 tax_code: type: string - title: Tax code - description: Optional field used by Avalara, Vertex, and Recurly's EU VAT - tax feature to determine taxation rules. If you have your own AvaTax or - Vertex account configured, use their tax codes to assign specific tax - rules. If you are using Recurly's EU VAT feature, you can use values of - `unknown`, `physical`, or `digital`. If an `Item` is associated to the - `AddOn` then `tax code` must be absent. maxLength: 50 + title: Tax code + description: Optional field used by Avalara, Vertex, and Recurly's In-the-Box + tax solution to determine taxation rules. You can pass in specific tax + codes using any of these tax integrations. For Recurly's In-the-Box tax + offering you can also choose to instead use simple values of `unknown`, + `physical`, or `digital` tax codes. If an `Item` is associated to the + `AddOn` then `tax_code` must be absent. display_quantity: type: boolean title: Display quantity? @@ -16670,8 +26865,7 @@ components: maxLength: 50 gateway_code: type: string - title: An identifier for a specific payment gateway. Must be used in conjunction - with `gateway_token`. + title: An identifier for a specific payment gateway. maxLength: 12 gateway_attributes: type: object @@ -16788,6 +26982,10 @@ components: billing info marked `primary_payment_method` can be set as a backup. An account can have a maximum of 1 backup, if a user sets a different payment method as a backup, the existing backup will no longer be marked as such. + store_billing_info: + type: boolean + description: Whether to store this billing info onto its associated account. + Defaults to `true`. BillingInfoVerify: type: object properties: @@ -16795,6 +26993,30 @@ components: type: string description: An identifier for a specific payment gateway. maxLength: 13 + three_d_secure_action_result_token_id: + type: string + description: A token generated by Recurly.js after completing a 3-D Secure + device fingerprinting or authentication challenge. + maxLength: 50 + BillingInfoVerifyCVV: + type: object + properties: + verification_value: + type: string + description: Unique security code for a credit card. + gateway_code: + type: string + description: An identifier for a specific payment gateway. + maxLength: 13 + token_id: + type: string + description: A token [generated by Recurly.js](https://recurly.com/developers/reference/recurly-js/#getting-a-token). + maxLength: 50 + three_d_secure_action_result_token_id: + type: string + description: A token generated by Recurly.js after completing a 3-D Secure + device fingerprinting or authentication challenge. + maxLength: 50 Coupon: type: object properties: @@ -17480,6 +27702,23 @@ components: description: Any values that resemble a credit card number or security code (CVV/CVC) will be rejected. maxLength: 255 + source_record_type: + type: string + title: Source record type + description: The type of record this custom field was automatically copied + from. Only present when the field was copied from another record. + readOnly: true + enum: + - account + - plan + - product + - subscription + source_record_id: + type: string + title: Source record ID + description: The UUID of the record this custom field was automatically + copied from. Only present when the field was copied from another record. + readOnly: true required: - name - value @@ -17491,6 +27730,15 @@ components: remove a field send the name with a null or empty value. items: "$ref": "#/components/schemas/CustomField" + InvoiceCustomFields: + type: array + title: Custom fields + description: A list of custom fields that were on the account at the time of + invoice creation and were marked to be displayed on invoices. Read-only; cannot + be set directly on the invoice. + readOnly: true + items: + "$ref": "#/components/schemas/CustomField" CustomFieldDefinition: type: object title: Custom field definition @@ -17678,11 +27926,13 @@ components: minimum: 0 tax_code: type: string - title: Tax code - description: Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. - The tax code values are specific to each tax system. If you are using - Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. maxLength: 50 + title: Tax code + description: Optional field used by Avalara, Vertex, and Recurly's In-the-Box + tax solution to determine taxation rules. You can pass in specific tax + codes using any of these tax integrations. For Recurly's In-the-Box tax + offering you can also choose to instead use simple values of `unknown`, + `physical`, or `digital` tax codes. tax_exempt: type: boolean title: Tax exempt? @@ -17767,11 +28017,13 @@ components: minimum: 0 tax_code: type: string - title: Tax code - description: Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. - The tax code values are specific to each tax system. If you are using - Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. maxLength: 50 + title: Tax code + description: Optional field used by Avalara, Vertex, and Recurly's In-the-Box + tax solution to determine taxation rules. You can pass in specific tax + codes using any of these tax integrations. For Recurly's In-the-Box tax + offering you can also choose to instead use simple values of `unknown`, + `physical`, or `digital` tax codes. tax_exempt: type: boolean title: Tax exempt? @@ -17844,11 +28096,13 @@ components: minimum: 0 tax_code: type: string - title: Tax code - description: Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. - The tax code values are specific to each tax system. If you are using - Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. maxLength: 50 + title: Tax code + description: Optional field used by Avalara, Vertex, and Recurly's In-the-Box + tax solution to determine taxation rules. You can pass in specific tax + codes using any of these tax integrations. For Recurly's In-the-Box tax + offering you can also choose to instead use simple values of `unknown`, + `physical`, or `digital` tax codes. tax_exempt: type: boolean title: Tax exempt? @@ -17998,6 +28252,11 @@ components: title: Subtotal description: The summation of charges and credits, before discounts and taxes. + subtotal_after_discount: + type: number + format: float + title: Subtotal After Discount + description: The summation of charges and credits, after discounts applied. tax: type: number format: float @@ -18100,6 +28359,8 @@ components: description: Unique ID to identify the dunning campaign used when dunning the invoice. For sites without multiple dunning campaigns enabled, this will always be the default dunning campaign. + custom_fields: + "$ref": "#/components/schemas/InvoiceCustomFields" InvoiceCreate: type: object properties: @@ -18139,10 +28400,12 @@ components: description: Integer representing the number of days after an invoice's creation that the invoice will become past due. If an invoice's net terms are set to '0', it is due 'On Receipt' and will become past due 24 hours - after it’s created. If an invoice is due net 30, it will become past due + after it's created. If an invoice is due net 30, it will become past due at 31 days exactly. default: 0 minimum: 0 + credit_application_policy: + "$ref": "#/components/schemas/CreditApplicationPolicy" po_number: type: string title: Purchase order number @@ -18164,6 +28427,15 @@ components: will default to the VAT Reverse Charge Notes text specified on the Tax Settings page in your Recurly admin, unless custom notes were created with the original subscription. + vertex_transaction_type: + type: string + title: Vertex Transaction Type + description: Used by Vertex for tax calculations. Possible values are sale, + rental, lease. + enum: + - sale + - rental + - lease required: - currency InvoiceCollect: @@ -18645,7 +28917,7 @@ components: type: number format: float title: Total after discounts and taxes - description: "`(quantity * unit_amount) - (discount + tax)`" + description: "`(quantity * unit_amount) - discount + tax`" description: type: string title: Description @@ -18719,13 +28991,24 @@ components: Refer to [the documentation](https://help.avalara.com/AvaTax_for_Communications/Tax_Calculation/AvaTax_for_Communications_Tax_Engine/Mapping_Resources/TM_00115_AFC_Modules_Corresponding_Transaction_Types) for more available t/s types. minimum: 0 + vertex_transaction_type: + type: string + title: Vertex Transaction Type + description: Used by Vertex for tax calculations. Possible values are sale, + rental, lease. + enum: + - sale + - rental + - lease tax_code: type: string - title: Tax code - description: Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. - The tax code values are specific to each tax system. If you are using - Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. maxLength: 50 + title: Tax code + description: Optional field used by Avalara, Vertex, and Recurly's In-the-Box + tax solution to determine taxation rules. You can pass in specific tax + codes using any of these tax integrations. For Recurly's In-the-Box tax + offering you can also choose to instead use simple values of `unknown`, + `physical`, or `digital` tax codes. tax_info: "$ref": "#/components/schemas/TaxInfo" proration_rate: @@ -18926,15 +29209,24 @@ components: for more available t/s types. If an `Item` is associated to the `LineItem`, then the `avalara_service_type` must be absent. minimum: 0 + vertex_transaction_type: + type: string + title: Vertex Transaction Type + description: Used by Vertex for tax calculations. Possible values are sale, + rental, lease. + enum: + - sale + - rental + - lease tax_code: type: string - title: Tax code - description: Optional field used by Avalara, Vertex, and Recurly's EU VAT - tax feature to determine taxation rules. If you have your own AvaTax or - Vertex account configured, use their tax codes to assign specific tax - rules. If you are using Recurly's EU VAT feature, you can use values of - `unknown`, `physical`, or `digital`. maxLength: 50 + title: Tax code + description: Optional field used by Avalara, Vertex, and Recurly's In-the-Box + tax solution to determine taxation rules. You can pass in specific tax + codes using any of these tax integrations. For Recurly's In-the-Box tax + offering you can also choose to instead use simple values of `unknown`, + `physical`, or `digital` tax codes. product_code: type: string title: Product code @@ -19156,11 +29448,13 @@ components: minimum: 0 tax_code: type: string - title: Tax code - description: Used by Avalara, Vertex, and Recurly’s EU VAT tax feature. - The tax code values are specific to each tax system. If you are using - Recurly’s EU VAT feature you can use `unknown`, `physical`, or `digital`. maxLength: 50 + title: Tax code + description: Optional field used by Avalara, Vertex, and Recurly's In-the-Box + tax solution to determine taxation rules. You can pass in specific tax + codes using any of these tax integrations. For Recurly's In-the-Box tax + offering you can also choose to instead use simple values of `unknown`, + `physical`, or `digital` tax codes. tax_exempt: type: boolean title: Tax exempt? @@ -19345,13 +29639,13 @@ components: minimum: 0 tax_code: type: string - title: Tax code - description: Optional field used by Avalara, Vertex, and Recurly's EU VAT - tax feature to determine taxation rules. If you have your own AvaTax or - Vertex account configured, use their tax codes to assign specific tax - rules. If you are using Recurly's EU VAT feature, you can use values of - `unknown`, `physical`, or `digital`. maxLength: 50 + title: Tax code + description: Optional field used by Avalara, Vertex, and Recurly's In-the-Box + tax solution to determine taxation rules. You can pass in specific tax + codes using any of these tax integrations. For Recurly's In-the-Box tax + offering you can also choose to instead use simple values of `unknown`, + `physical`, or `digital` tax codes. tax_exempt: type: boolean title: Tax exempt? @@ -19561,13 +29855,13 @@ components: minimum: 0 tax_code: type: string - title: Tax code - description: Optional field used by Avalara, Vertex, and Recurly's EU VAT - tax feature to determine taxation rules. If you have your own AvaTax or - Vertex account configured, use their tax codes to assign specific tax - rules. If you are using Recurly's EU VAT feature, you can use values of - `unknown`, `physical`, or `digital`. maxLength: 50 + title: Tax code + description: Optional field used by Avalara, Vertex, and Recurly's In-the-Box + tax solution to determine taxation rules. You can pass in specific tax + codes using any of these tax integrations. For Recurly's In-the-Box tax + offering you can also choose to instead use simple values of `unknown`, + `physical`, or `digital` tax codes. tax_exempt: type: boolean title: Tax exempt? @@ -19780,7 +30074,7 @@ components: type: string maxLength: 20 description: Code that represents a geographic entity (location or object). - Only returned for Sling Vertex Integration + Only returned when Vertex or Avalara for Communications is enabled. created_at: type: string title: Created at @@ -19840,7 +30134,7 @@ components: type: string maxLength: 20 description: Code that represents a geographic entity (location or object). - Only returned for Sling Vertex Integration + Only returned when Vertex or Avalara for Communications is enabled. required: - first_name - last_name @@ -20095,7 +30389,7 @@ components: type: string maxLength: 20 description: Code that represents a geographic entity (location or object). - Only returned for Sling Vertex Integration + Only returned when Vertex or Avalara for Communications is enabled. Site: type: object properties: @@ -20269,6 +30563,12 @@ components: title: Remaining pause cycles description: Null unless subscription is paused or will pause at the end of the current billing period. + resume_at: + type: string + format: date-time + title: Resume at + description: The date the subscription billing resumes following a pause. + Null unless the subscription is paused or scheduled to be paused. currency: type: string title: Currency @@ -20334,6 +30634,8 @@ components: at 31 days exactly. minimum: 0 default: 0 + credit_application_policy: + "$ref": "#/components/schemas/CreditApplicationPolicy" terms_and_conditions: type: string title: Terms and conditions @@ -20992,9 +31294,10 @@ components: type: string format: date-time title: Start date - description: If set, the subscription will begin in the future on this date. + description: If set, the subscription will begin on this specified date. The subscription will apply the setup fee and trial period, unless the - plan has no trial. + plan has no trial. Omit this field if the subscription should be started + immediately. next_bill_date: type: string format: date-time @@ -21038,6 +31341,8 @@ components: - evenly - at_range_end - at_range_start + credit_application_policy: + "$ref": "#/components/schemas/CreditApplicationPolicy" terms_and_conditions: type: string title: Terms and conditions @@ -21057,6 +31362,12 @@ components: description: If there are pending credits on the account that will be invoiced during the subscription creation, these will be used as the Customer Notes on the credit invoice. + vat_reverse_charge_notes: + type: string + title: VAT reverse charge notes + description: This will default to the VAT reverse charge notes text specified + on the Invoice Settings. Specify custom notes to add or override VAT reverse + charge notes. Custom notes will stay with a subscription on all renewals. po_number: type: string title: Purchase order number @@ -21080,6 +31391,12 @@ components: mail order and telephone transactions. enum: - moto + bulk: + type: boolean + description: Optional field to be used only when needing to bypass the 60 + second limit on creating subscriptions. Should only be used when creating + subscriptions in bulk from the API. + default: false required: - plan_code - currency @@ -21141,7 +31458,7 @@ components: type: string format: date-time title: Start date - description: If set, the subscription will begin in the future on this date. + description: If set, the subscription will begin on this specified date. The subscription will apply the setup fee and trial period, unless the plan has no trial. next_bill_date: @@ -21187,6 +31504,29 @@ components: description: The new set of ramp intervals for the subscription. items: "$ref": "#/components/schemas/SubscriptionRampInterval" + credit_application_policy: + "$ref": "#/components/schemas/CreditApplicationPolicy" + terms_and_conditions: + type: string + title: Terms and conditions + description: Specify custom notes to add or override Terms and Conditions. + Custom notes will stay with a subscription on all renewals. + customer_notes: + type: string + title: Customer notes + description: Specify custom notes to add or override Customer Notes. Custom + notes will stay with a subscription on all renewals. + vat_reverse_charge_notes: + type: string + title: VAT reverse charge notes + description: Specify custom notes to add or override VAT reverse charge + notes. Custom notes will stay with a subscription on all renewals. + bulk: + type: boolean + description: Optional field to be used only when needing to bypass the 60 + second limit on creating subscriptions. Should only be used when creating + subscriptions in bulk from the API. + default: false required: - plan_code SubscriptionUpdate: @@ -21233,6 +31573,8 @@ components: - evenly - at_range_end - at_range_start + credit_application_policy: + "$ref": "#/components/schemas/CreditApplicationPolicy" terms_and_conditions: type: string title: Terms and conditions @@ -21243,6 +31585,11 @@ components: title: Customer notes description: Specify custom notes to add or override Customer Notes. Custom notes will stay with a subscription on all renewals. + vat_reverse_charge_notes: + type: string + title: VAT reverse charge notes + description: Specify custom notes to add or override VAT reverse charge + notes. Custom notes will stay with a subscription on all renewals. po_number: type: string title: Purchase order number @@ -21430,11 +31777,11 @@ components: tax_details: type: array description: Provides additional tax details for Communications taxes when - Avalara for Communications is enabled or Canadian Sales Tax when there - is tax applied at both the country and province levels. This will only - be populated for the Invoice response when fetching a single invoice and - not for the InvoiceList or LineItemList. Only populated for a single LineItem - fetch when Avalara for Communications is enabled. + Avalara for Communications or Vertex Tax Breakdown is enabled or Canadian + Sales Tax. Tax details will only be populated for the Invoice response + when fetching a single invoice and not for the InvoiceList or LineItemList. + Only populated for a single LineItem fetch when Avalara for Communications + is enabled. items: "$ref": "#/components/schemas/TaxDetail" TaxDetail: @@ -21445,8 +31792,8 @@ components: type: string title: Type description: Provides the tax type for the region or type of Comminications - tax when Avalara for Communications is enabled. For Canadian Sales Tax, - this will be GST, HST, QST or PST. + tax when Avalara for Communications or Vertex is enabled. For Canadian + Sales Tax, this will be GST, HST, QST or PST. region: type: string title: Region @@ -21467,18 +31814,18 @@ components: type: string title: Name description: Provides the name of the Communications tax applied. Present - only when Avalara for Communications is enabled. + only when Avalara for Communications or Vertex is enabled. level: type: string title: Level description: Provides the jurisdiction level for the Communications tax applied. Example values include city, state and federal. Present only - when Avalara for Communications is enabled. + when Avalara for Communications or Vertex is enabled. billable: type: boolean title: Billable description: Whether or not the line item is taxable. Only populated for - a single LineItem fetch when Avalara for Communications is enabled. + a single LineItem fetch when Avalara for Communications or Vertex is enabled. Transaction: type: object properties: @@ -22030,6 +32377,8 @@ components: at 31 days exactly. minimum: 0 default: 0 + credit_application_policy_override: + "$ref": "#/components/schemas/CreditApplicationPolicy" terms_and_conditions: type: string title: Terms and conditions @@ -22041,6 +32390,15 @@ components: type: string title: VAT reverse charge notes description: VAT reverse charge notes for cross border European tax settlement. + vertex_transaction_type: + type: string + title: Vertex Transaction Type + description: Used by Vertex for tax calculations. Possible values are sale, + rental, lease. + enum: + - sale + - rental + - lease credit_customer_notes: type: string title: Credit customer notes @@ -22220,6 +32578,7 @@ components: format: date-time description: When the current settings were updated in Recurly. DunningInterval: + type: object properties: days: type: integer @@ -22244,6 +32603,7 @@ components: items: type: string DunningCampaignsBulkUpdateResponse: + type: object properties: object: type: string @@ -22258,6 +32618,7 @@ components: items: "$ref": "#/components/schemas/Plan" PaymentMethod: + type: object properties: object: type: string @@ -22590,6 +32951,52 @@ components: a transaction. Pass this value to Recurly.js so it can continue the challenge flow. maxLength: 22 + CreditApplicationPolicy: + type: object + title: Credit Application Policy + description: | + Controls whether credit invoices are automatically applied to new invoices. + The `mode` field determines the application behavior. When mode is `all`, + the optional `allowed_origins` array can restrict which credit invoice origins + are applied. + - `all`: All available credit invoices are applied (default) + - `none`: No credit invoices are applied automatically + properties: + mode: + type: string + enum: + - all + - none + default: all + 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/CreditApplicationAllowedOriginType" + required: + - mode + CreditApplicationAllowedOriginType: + 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 ExportDates: type: object properties: