class Recurly::Client

Constants

ALLOWED_OPTIONS
BASE36_ALPHABET
BASE_HOST
BASE_PORT
BINARY_TYPES
CA_FILE
JSON_CONTENT_TYPE
LOG_LEVELS
MAX_RETRIES

Attributes

connection_pool[RW]

@return [Recurly::ConnectionPool]

site_id[R]

Used by the operations.rb file to interpolate paths

Public Class Methods

new(api_key:, logger: nil) { |self| ... } click to toggle source

Initialize a client. It requires an API key.

@example

API_KEY = '83749879bbde395b5fe0cc1a5abf8e5'
client = Recurly::Client.new(api_key: API_KEY)
sub = client.get_subscription(subscription_id: 'abcd123456')

@example

# You can also pass the initializer a block. This will give you
# a client scoped for just that block
Recurly::Client.new(api_key: API_KEY) do |client|
  sub = client.get_subscription(subscription_id: 'abcd123456')
end

@example

# If you only plan on using the client for more than one site,
# you should initialize a new client for each site.

client = Recurly::Client.new(api_key: API_KEY1)
sub = client.get_subscription(subscription_id: 'uuid-abcd123456')

# you should create a new client to connect to another site
client = Recurly::Client.new(api_key: API_KEY2)
sub = client.get_subscription(subscription_id: 'uuid-abcd7890')

@param api_key [String] The private API key @param logger [Logger] A logger to use. Defaults to creating a new STDOUT logger with level WARN.

# File lib/recurly/client.rb, line 57
    def initialize(api_key:, logger: nil)
      raise ArgumentError, "'api_key' must be set to a non-nil value" if api_key.nil?

      set_api_key(api_key)

      if logger.nil?
        @logger = Logger.new(STDOUT).tap do |l|
          l.level = Logger::WARN
        end
      else
        unless LOG_LEVELS.all? { |lev| logger.respond_to?(lev) }
          raise ArgumentError, "You must pass in a logger implementation that responds to the following messages: #{LOG_LEVELS}"
        end
        @logger = logger
      end

      if @logger.level < Logger::INFO
        msg = <<-MSG
        The Recurly logger should not be initialized
        beyond the level INFO. It is currently configured to emit
        headers and request / response bodies. This has the potential to leak
        PII and other sensitive information and should never be used in production.
        MSG
        log_warn("SECURITY_WARNING", message: msg)
      end

      # execute block with this client if given
      yield(self) if block_given?
    end

Public Instance Methods

api_version() click to toggle source
# File lib/recurly/client/operations.rb, line 7
def api_version
  "v2021-02-25"
end
cancel_subscription(subscription_id:, **options) click to toggle source

Cancel a subscription

{developers.recurly.com/api/v2021-02-25#operation/cancel_subscription cancel_subscription api documenation}

@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 params [Hash] Optional query string parameters:

:body [Requests::SubscriptionCancel] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionCancel}

@return [Resources::Subscription] A canceled or failed subscription. @example

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
# File lib/recurly/client/operations.rb, line 3204
def cancel_subscription(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/cancel", subscription_id: subscription_id)
  put(path, options[:body], Requests::SubscriptionCancel, **options)
end
collect_invoice(invoice_id:, **options) click to toggle source

Collect a pending or past due, automatic invoice

{developers.recurly.com/api/v2021-02-25#operation/collect_invoice collect_invoice api documenation}

@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 params [Hash] Optional query string parameters:

:body [Requests::InvoiceCollect] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceCollect}

@return [Resources::Invoice] The updated invoice. @example

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
# File lib/recurly/client/operations.rb, line 2138
def collect_invoice(invoice_id:, **options)
  path = interpolate_path("/invoices/{invoice_id}/collect", invoice_id: invoice_id)
  put(path, options[:body], Requests::InvoiceCollect, **options)
end
convert_trial(subscription_id:, **options) click to toggle source

Convert trial subscription

{developers.recurly.com/api/v2021-02-25#operation/convert_trial convert_trial api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Subscription] A subscription.

# File lib/recurly/client/operations.rb, line 3298
def convert_trial(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/convert_trial", subscription_id: subscription_id)
  put(path, **options)
end
create_account(body:, **options) click to toggle source

Create an account

{developers.recurly.com/api/v2021-02-25#operation/create_account create_account api documenation}

@param body [Requests::AccountCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AccountCreate} @param params [Hash] Optional query string parameters:

@return [Resources::Account] An account. @example

begin
  account_create = {
    code: account_code,
    first_name: "Benjamin",
    last_name: "Du Monde",
    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
# File lib/recurly/client/operations.rb, line 168
def create_account(body:, **options)
  path = "/accounts"
  post(path, body, Requests::AccountCreate, **options)
end
create_billing_info(account_id:, body:, **options) click to toggle source

Add new billing information on an account

{developers.recurly.com/api/v2021-02-25#operation/create_billing_info create_billing_info api documenation}

@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::BillingInfoCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoCreate} @param params [Hash] Optional query string parameters:

@return [Resources::BillingInfo] Updated billing information.

# File lib/recurly/client/operations.rb, line 525
def create_billing_info(account_id:, body:, **options)
  path = interpolate_path("/accounts/{account_id}/billing_infos", account_id: account_id)
  post(path, body, Requests::BillingInfoCreate, **options)
end
create_coupon(body:, **options) click to toggle source

Create a new coupon

{developers.recurly.com/api/v2021-02-25#operation/create_coupon create_coupon api documenation}

@param body [Requests::CouponCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponCreate} @param params [Hash] Optional query string parameters:

@return [Resources::Coupon] A new coupon. @example

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
# File lib/recurly/client/operations.rb, line 1451
def create_coupon(body:, **options)
  path = "/coupons"
  post(path, body, Requests::CouponCreate, **options)
end
create_coupon_redemption(account_id:, body:, **options) click to toggle source

Generate an active coupon redemption on an account or subscription

{developers.recurly.com/api/v2021-02-25#operation/create_coupon_redemption create_coupon_redemption api documenation}

@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::CouponRedemptionCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponRedemptionCreate} @param params [Hash] Optional query string parameters:

@return [Resources::CouponRedemption] Returns the new coupon redemption. @example

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
# File lib/recurly/client/operations.rb, line 672
def create_coupon_redemption(account_id:, body:, **options)
  path = interpolate_path("/accounts/{account_id}/coupon_redemptions/active", account_id: account_id)
  post(path, body, Requests::CouponRedemptionCreate, **options)
end
create_invoice(account_id:, body:, **options) click to toggle source

Create an invoice for pending line items

{developers.recurly.com/api/v2021-02-25#operation/create_invoice create_invoice api documenation}

@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::InvoiceCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceCreate} @param params [Hash] Optional query string parameters:

@return [Resources::InvoiceCollection] Returns the new invoices. @example

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
# File lib/recurly/client/operations.rb, line 818
def create_invoice(account_id:, body:, **options)
  path = interpolate_path("/accounts/{account_id}/invoices", account_id: account_id)
  post(path, body, Requests::InvoiceCreate, **options)
end
create_item(body:, **options) click to toggle source

Create a new item

{developers.recurly.com/api/v2021-02-25#operation/create_item create_item api documenation}

@param body [Requests::ItemCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ItemCreate} @param params [Hash] Optional query string parameters:

@return [Resources::Item] A new item. @example

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
# File lib/recurly/client/operations.rb, line 1791
def create_item(body:, **options)
  path = "/items"
  post(path, body, Requests::ItemCreate, **options)
end
create_line_item(account_id:, body:, **options) click to toggle source

Create a new line item for the account

{developers.recurly.com/api/v2021-02-25#operation/create_line_item create_line_item api documenation}

@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::LineItemCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::LineItemCreate} @param params [Hash] Optional query string parameters:

@return [Resources::LineItem] Returns the new line item. @example

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
# File lib/recurly/client/operations.rb, line 933
def create_line_item(account_id:, body:, **options)
  path = interpolate_path("/accounts/{account_id}/line_items", account_id: account_id)
  post(path, body, Requests::LineItemCreate, **options)
end
create_measured_unit(body:, **options) click to toggle source

Create a new measured unit

{developers.recurly.com/api/v2021-02-25#operation/create_measured_unit create_measured_unit api documenation}

@param body [Requests::MeasuredUnitCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::MeasuredUnitCreate} @param params [Hash] Optional query string parameters:

@return [Resources::MeasuredUnit] A new measured unit.

# File lib/recurly/client/operations.rb, line 1943
def create_measured_unit(body:, **options)
  path = "/measured_units"
  post(path, body, Requests::MeasuredUnitCreate, **options)
end
create_plan(body:, **options) click to toggle source

Create a plan

{developers.recurly.com/api/v2021-02-25#operation/create_plan create_plan api documenation}

@param body [Requests::PlanCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PlanCreate} @param params [Hash] Optional query string parameters:

@return [Resources::Plan] A plan. @example

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
# File lib/recurly/client/operations.rb, line 2584
def create_plan(body:, **options)
  path = "/plans"
  post(path, body, Requests::PlanCreate, **options)
end
create_plan_add_on(plan_id:, body:, **options) click to toggle source

Create an add-on

{developers.recurly.com/api/v2021-02-25#operation/create_plan_add_on create_plan_add_on api documenation}

@param plan_id [String] Plan ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param body [Requests::AddOnCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AddOnCreate} @param params [Hash] Optional query string parameters:

@return [Resources::AddOn] An add-on. @example

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
# File lib/recurly/client/operations.rb, line 2742
def create_plan_add_on(plan_id:, body:, **options)
  path = interpolate_path("/plans/{plan_id}/add_ons", plan_id: plan_id)
  post(path, body, Requests::AddOnCreate, **options)
end
create_purchase(body:, **options) click to toggle source

Create a new purchase

{developers.recurly.com/api/v2021-02-25#operation/create_purchase create_purchase api documenation}

@param body [Requests::PurchaseCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PurchaseCreate} @param params [Hash] Optional query string parameters:

@return [Resources::InvoiceCollection] Returns the new invoices @example

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
# File lib/recurly/client/operations.rb, line 3813
def create_purchase(body:, **options)
  path = "/purchases"
  post(path, body, Requests::PurchaseCreate, **options)
end
create_shipping_address(account_id:, body:, **options) click to toggle source

Create a new shipping address for the account

{developers.recurly.com/api/v2021-02-25#operation/create_shipping_address create_shipping_address api documenation}

@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::ShippingAddressCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingAddressCreate} @param params [Hash] Optional query string parameters:

@return [Resources::ShippingAddress] Returns the new shipping address. @example

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
# File lib/recurly/client/operations.rb, line 1077
def create_shipping_address(account_id:, body:, **options)
  path = interpolate_path("/accounts/{account_id}/shipping_addresses", account_id: account_id)
  post(path, body, Requests::ShippingAddressCreate, **options)
end
create_shipping_method(body:, **options) click to toggle source

Create a new shipping method

{developers.recurly.com/api/v2021-02-25#operation/create_shipping_method create_shipping_method api documenation}

@param body [Requests::ShippingMethodCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingMethodCreate} @param params [Hash] Optional query string parameters:

@return [Resources::ShippingMethod] A new shipping method.

# File lib/recurly/client/operations.rb, line 2959
def create_shipping_method(body:, **options)
  path = "/shipping_methods"
  post(path, body, Requests::ShippingMethodCreate, **options)
end
create_subscription(body:, **options) click to toggle source

Create a new subscription

{developers.recurly.com/api/v2021-02-25#operation/create_subscription create_subscription api documenation}

@param body [Requests::SubscriptionCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionCreate} @param params [Hash] Optional query string parameters:

@return [Resources::Subscription] A subscription. @example

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
# File lib/recurly/client/operations.rb, line 3086
def create_subscription(body:, **options)
  path = "/subscriptions"
  post(path, body, Requests::SubscriptionCreate, **options)
end
create_subscription_change(subscription_id:, body:, **options) click to toggle source

Create a new subscription change

{developers.recurly.com/api/v2021-02-25#operation/create_subscription_change create_subscription_change api documenation}

@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 body [Requests::SubscriptionChangeCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionChangeCreate} @param params [Hash] Optional query string parameters:

@return [Resources::SubscriptionChange] A subscription change. @example

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
# File lib/recurly/client/operations.rb, line 3368
def create_subscription_change(subscription_id:, body:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/change", subscription_id: subscription_id)
  post(path, body, Requests::SubscriptionChangeCreate, **options)
end
create_usage(subscription_id:, add_on_id:, body:, **options) click to toggle source

Log a usage record on this subscription add-on

{developers.recurly.com/api/v2021-02-25#operation/create_usage create_usage api documenation}

@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 add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param body [Requests::UsageCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::UsageCreate} @param params [Hash] Optional query string parameters:

@return [Resources::Usage] The created usage record.

# File lib/recurly/client/operations.rb, line 3618
def create_usage(subscription_id:, add_on_id:, body:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/add_ons/{add_on_id}/usage", subscription_id: subscription_id, add_on_id: add_on_id)
  post(path, body, Requests::UsageCreate, **options)
end
deactivate_account(account_id:, **options) click to toggle source

Deactivate an account

{developers.recurly.com/api/v2021-02-25#operation/deactivate_account deactivate_account api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Account] An account. @example

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
# File lib/recurly/client/operations.rb, line 245
def deactivate_account(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}", account_id: account_id)
  delete(path, **options)
end
deactivate_coupon(coupon_id:, **options) click to toggle source

Expire a coupon

{developers.recurly.com/api/v2021-02-25#operation/deactivate_coupon deactivate_coupon api documenation}

@param coupon_id [String] Coupon ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-10off. @param params [Hash] Optional query string parameters:

@return [Resources::Coupon] The expired Coupon @example

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
# File lib/recurly/client/operations.rb, line 1524
def deactivate_coupon(coupon_id:, **options)
  path = interpolate_path("/coupons/{coupon_id}", coupon_id: coupon_id)
  delete(path, **options)
end
deactivate_item(item_id:, **options) click to toggle source

Deactivate an item

{developers.recurly.com/api/v2021-02-25#operation/deactivate_item deactivate_item api documenation}

@param item_id [String] Item ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-red. @param params [Hash] Optional query string parameters:

@return [Resources::Item] An item. @example

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
# File lib/recurly/client/operations.rb, line 1868
def deactivate_item(item_id:, **options)
  path = interpolate_path("/items/{item_id}", item_id: item_id)
  delete(path, **options)
end
deactivate_shipping_method(shipping_method_id:, **options) click to toggle source

Deactivate a shipping method

{developers.recurly.com/api/v2021-02-25#operation/deactivate_shipping_method deactivate_shipping_method api documenation}

@param shipping_method_id [String] Shipping Method ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-usps_2-day. @param params [Hash] Optional query string parameters:

@return [Resources::ShippingMethod] A shipping method.

# File lib/recurly/client/operations.rb, line 3002
def deactivate_shipping_method(shipping_method_id:, **options)
  path = interpolate_path("/shipping_methods/{shipping_method_id}", shipping_method_id: shipping_method_id)
  delete(path, **options)
end
deactivate_unique_coupon_code(unique_coupon_code_id:, **options) click to toggle source

Deactivate a unique coupon code

{developers.recurly.com/api/v2021-02-25#operation/deactivate_unique_coupon_code deactivate_unique_coupon_code api documenation}

@param unique_coupon_code_id [String] Unique Coupon Code ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-abc-8dh2-def. @param params [Hash] Optional query string parameters:

@return [Resources::UniqueCouponCode] A unique coupon code.

# File lib/recurly/client/operations.rb, line 3759
def deactivate_unique_coupon_code(unique_coupon_code_id:, **options)
  path = interpolate_path("/unique_coupon_codes/{unique_coupon_code_id}", unique_coupon_code_id: unique_coupon_code_id)
  delete(path, **options)
end
generate_unique_coupon_codes(coupon_id:, body:, **options) click to toggle source

Generate unique coupon codes

{developers.recurly.com/api/v2021-02-25#operation/generate_unique_coupon_codes generate_unique_coupon_codes api documenation}

@param coupon_id [String] Coupon ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-10off. @param body [Requests::CouponBulkCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponBulkCreate} @param params [Hash] Optional query string parameters:

@return [Resources::UniqueCouponCodeParams] A set of parameters that can be passed to the `list_unique_coupon_codes` endpoint to obtain only the newly generated `UniqueCouponCodes`.

# File lib/recurly/client/operations.rb, line 1539
def generate_unique_coupon_codes(coupon_id:, body:, **options)
  path = interpolate_path("/coupons/{coupon_id}/generate", coupon_id: coupon_id)
  post(path, body, Requests::CouponBulkCreate, **options)
end
get_a_billing_info(account_id:, billing_info_id:, **options) click to toggle source

Fetch a billing info

{developers.recurly.com/api/v2021-02-25#operation/get_a_billing_info get_a_billing_info api documenation}

@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. @param params [Hash] Optional query string parameters:

@return [Resources::BillingInfo] A billing info.

# File lib/recurly/client/operations.rb, line 540
def get_a_billing_info(account_id:, billing_info_id:, **options)
  path = interpolate_path("/accounts/{account_id}/billing_infos/{billing_info_id}", account_id: account_id, billing_info_id: billing_info_id)
  get(path, **options)
end
get_account(account_id:, **options) click to toggle source

Fetch an account

{developers.recurly.com/api/v2021-02-25#operation/get_account get_account api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Account] An account. @example

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
# File lib/recurly/client/operations.rb, line 191
def get_account(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}", account_id: account_id)
  get(path, **options)
end
get_account_acquisition(account_id:, **options) click to toggle source

Fetch an account's acquisition data

{developers.recurly.com/api/v2021-02-25#operation/get_account_acquisition get_account_acquisition api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::AccountAcquisition] An account's acquisition data. @example

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
# File lib/recurly/client/operations.rb, line 268
def get_account_acquisition(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/acquisition", account_id: account_id)
  get(path, **options)
end
get_account_balance(account_id:, **options) click to toggle source

Fetch an account's balance and past due status

{developers.recurly.com/api/v2021-02-25#operation/get_account_balance get_account_balance api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::AccountBalance] An account's balance. @example

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
# File lib/recurly/client/operations.rb, line 373
def get_account_balance(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/balance", account_id: account_id)
  get(path, **options)
end
get_account_note(account_id:, account_note_id:, **options) click to toggle source

Fetch an account note

{developers.recurly.com/api/v2021-02-25#operation/get_account_note get_account_note api documenation}

@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 account_note_id [String] Account Note ID. @param params [Hash] Optional query string parameters:

@return [Resources::AccountNote] An account note. @example

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
# File lib/recurly/client/operations.rb, line 994
def get_account_note(account_id:, account_note_id:, **options)
  path = interpolate_path("/accounts/{account_id}/notes/{account_note_id}", account_id: account_id, account_note_id: account_note_id)
  get(path, **options)
end
get_add_on(add_on_id:, **options) click to toggle source

Fetch an add-on

{developers.recurly.com/api/v2021-02-25#operation/get_add_on get_add_on api documenation}

@param add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param params [Hash] Optional query string parameters:

@return [Resources::AddOn] An add-on. @example

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
# File lib/recurly/client/operations.rb, line 2898
def get_add_on(add_on_id:, **options)
  path = interpolate_path("/add_ons/{add_on_id}", add_on_id: add_on_id)
  get(path, **options)
end
get_billing_info(account_id:, **options) click to toggle source

Fetch an account's billing information

{developers.recurly.com/api/v2021-02-25#operation/get_billing_info get_billing_info api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::BillingInfo] An account's billing information. @example

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
# File lib/recurly/client/operations.rb, line 396
def get_billing_info(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/billing_info", account_id: account_id)
  get(path, **options)
end
get_coupon(coupon_id:, **options) click to toggle source

Fetch a coupon

{developers.recurly.com/api/v2021-02-25#operation/get_coupon get_coupon api documenation}

@param coupon_id [String] Coupon ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-10off. @param params [Hash] Optional query string parameters:

@return [Resources::Coupon] A coupon. @example

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
# File lib/recurly/client/operations.rb, line 1474
def get_coupon(coupon_id:, **options)
  path = interpolate_path("/coupons/{coupon_id}", coupon_id: coupon_id)
  get(path, **options)
end
get_credit_payment(credit_payment_id:, **options) click to toggle source

Fetch a credit payment

{developers.recurly.com/api/v2021-02-25#operation/get_credit_payment get_credit_payment api documenation}

@param credit_payment_id [String] Credit Payment ID or UUID. For ID no prefix is used e.g. e28zov4fw0v2. For UUID use prefix uuid-, e.g. uuid-123457890. @param params [Hash] Optional query string parameters:

@return [Resources::CreditPayment] A credit payment.

# File lib/recurly/client/operations.rb, line 1639
def get_credit_payment(credit_payment_id:, **options)
  path = interpolate_path("/credit_payments/{credit_payment_id}", credit_payment_id: credit_payment_id)
  get(path, **options)
end
get_custom_field_definition(custom_field_definition_id:, **options) click to toggle source

Fetch an custom field definition

{developers.recurly.com/api/v2021-02-25#operation/get_custom_field_definition get_custom_field_definition api documenation}

@param custom_field_definition_id [String] Custom Field Definition ID @param params [Hash] Optional query string parameters:

@return [Resources::CustomFieldDefinition] An custom field definition. @example

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
# File lib/recurly/client/operations.rb, line 1710
def get_custom_field_definition(custom_field_definition_id:, **options)
  path = interpolate_path("/custom_field_definitions/{custom_field_definition_id}", custom_field_definition_id: custom_field_definition_id)
  get(path, **options)
end
get_dunning_campaign(dunning_campaign_id:, **options) click to toggle source

Show the settings for a dunning campaign

{developers.recurly.com/api/v2021-02-25#operation/get_dunning_campaign get_dunning_campaign api documenation}

@param dunning_campaign_id [String] Dunning Campaign ID, e.g. e28zov4fw0v2. @param params [Hash] Optional query string parameters:

@return [Resources::DunningCampaign] Settings for a dunning campaign.

# File lib/recurly/client/operations.rb, line 3933
def get_dunning_campaign(dunning_campaign_id:, **options)
  path = interpolate_path("/dunning_campaigns/{dunning_campaign_id}", dunning_campaign_id: dunning_campaign_id)
  get(path, **options)
end
get_export_dates(**options) click to toggle source

List the dates that have an available export to download.

{developers.recurly.com/api/v2021-02-25#operation/get_export_dates get_export_dates api documenation}

@param params [Hash] Optional query string parameters:

@return [Resources::ExportDates] Returns a list of dates. @example

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
# File lib/recurly/client/operations.rb, line 3877
def get_export_dates(**options)
  path = "/export_dates"
  get(path, **options)
end
get_export_files(export_date:, **options) click to toggle source

List of the export files that are available to download.

{developers.recurly.com/api/v2021-02-25#operation/get_export_files get_export_files api documenation}

@param export_date [String] Date for which to get a list of available automated export files. Date must be in YYYY-MM-DD format. @param params [Hash] Optional query string parameters:

@return [Resources::ExportFiles] Returns a list of export files to download. @example

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
# File lib/recurly/client/operations.rb, line 3902
def get_export_files(export_date:, **options)
  path = interpolate_path("/export_dates/{export_date}/export_files", export_date: export_date)
  get(path, **options)
end
get_invoice(invoice_id:, **options) click to toggle source

Fetch an invoice

{developers.recurly.com/api/v2021-02-25#operation/get_invoice get_invoice api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Invoice] An invoice. @example

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
# File lib/recurly/client/operations.rb, line 2060
def get_invoice(invoice_id:, **options)
  path = interpolate_path("/invoices/{invoice_id}", invoice_id: invoice_id)
  get(path, **options)
end
get_invoice_pdf(invoice_id:, **options) click to toggle source

Fetch an invoice as a PDF

{developers.recurly.com/api/v2021-02-25#operation/get_invoice_pdf get_invoice_pdf api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::BinaryFile] An invoice as a PDF. @example

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
# File lib/recurly/client/operations.rb, line 2114
def get_invoice_pdf(invoice_id:, **options)
  path = interpolate_path("/invoices/{invoice_id}.pdf", invoice_id: invoice_id)
  get(path, **options)
end
get_item(item_id:, **options) click to toggle source

Fetch an item

{developers.recurly.com/api/v2021-02-25#operation/get_item get_item api documenation}

@param item_id [String] Item ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-red. @param params [Hash] Optional query string parameters:

@return [Resources::Item] An item. @example

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
# File lib/recurly/client/operations.rb, line 1814
def get_item(item_id:, **options)
  path = interpolate_path("/items/{item_id}", item_id: item_id)
  get(path, **options)
end
get_line_item(line_item_id:, **options) click to toggle source

Fetch a line item

{developers.recurly.com/api/v2021-02-25#operation/get_line_item get_line_item api documenation}

@param line_item_id [String] Line Item ID. @param params [Hash] Optional query string parameters:

@return [Resources::LineItem] A line item. @example

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
# File lib/recurly/client/operations.rb, line 2473
def get_line_item(line_item_id:, **options)
  path = interpolate_path("/line_items/{line_item_id}", line_item_id: line_item_id)
  get(path, **options)
end
get_measured_unit(measured_unit_id:, **options) click to toggle source

Fetch a measured unit

{developers.recurly.com/api/v2021-02-25#operation/get_measured_unit get_measured_unit api documenation}

@param measured_unit_id [String] Measured unit ID or name. For ID no prefix is used e.g. e28zov4fw0v2. For name use prefix name-, e.g. name-Storage. @param params [Hash] Optional query string parameters:

@return [Resources::MeasuredUnit] An item.

# File lib/recurly/client/operations.rb, line 1957
def get_measured_unit(measured_unit_id:, **options)
  path = interpolate_path("/measured_units/{measured_unit_id}", measured_unit_id: measured_unit_id)
  get(path, **options)
end
get_plan(plan_id:, **options) click to toggle source

Fetch a plan

{developers.recurly.com/api/v2021-02-25#operation/get_plan get_plan api documenation}

@param plan_id [String] Plan ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param params [Hash] Optional query string parameters:

@return [Resources::Plan] A plan. @example

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
# File lib/recurly/client/operations.rb, line 2607
def get_plan(plan_id:, **options)
  path = interpolate_path("/plans/{plan_id}", plan_id: plan_id)
  get(path, **options)
end
get_plan_add_on(plan_id:, add_on_id:, **options) click to toggle source

Fetch a plan's add-on

{developers.recurly.com/api/v2021-02-25#operation/get_plan_add_on get_plan_add_on api documenation}

@param plan_id [String] Plan ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param params [Hash] Optional query string parameters:

@return [Resources::AddOn] An add-on. @example

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
# File lib/recurly/client/operations.rb, line 2768
def get_plan_add_on(plan_id:, add_on_id:, **options)
  path = interpolate_path("/plans/{plan_id}/add_ons/{add_on_id}", plan_id: plan_id, add_on_id: add_on_id)
  get(path, **options)
end
get_preview_renewal(subscription_id:, **options) click to toggle source

Fetch a preview of a subscription's renewal invoice(s)

{developers.recurly.com/api/v2021-02-25#operation/get_preview_renewal get_preview_renewal api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::InvoiceCollection] A preview of the subscription's renewal invoice(s).

# File lib/recurly/client/operations.rb, line 3312
def get_preview_renewal(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/preview_renewal", subscription_id: subscription_id)
  get(path, **options)
end
get_shipping_address(account_id:, shipping_address_id:, **options) click to toggle source

Fetch an account's shipping address

{developers.recurly.com/api/v2021-02-25#operation/get_shipping_address get_shipping_address api documenation}

@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 shipping_address_id [String] Shipping Address ID. @param params [Hash] Optional query string parameters:

@return [Resources::ShippingAddress] A shipping address. @example

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
# File lib/recurly/client/operations.rb, line 1104
def get_shipping_address(account_id:, shipping_address_id:, **options)
  path = interpolate_path("/accounts/{account_id}/shipping_addresses/{shipping_address_id}", account_id: account_id, shipping_address_id: shipping_address_id)
  get(path, **options)
end
get_shipping_method(shipping_method_id:, **options) click to toggle source

Fetch a shipping method

{developers.recurly.com/api/v2021-02-25#operation/get_shipping_method get_shipping_method api documenation}

@param shipping_method_id [String] Shipping Method ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-usps_2-day. @param params [Hash] Optional query string parameters:

@return [Resources::ShippingMethod] A shipping method.

# File lib/recurly/client/operations.rb, line 2973
def get_shipping_method(shipping_method_id:, **options)
  path = interpolate_path("/shipping_methods/{shipping_method_id}", shipping_method_id: shipping_method_id)
  get(path, **options)
end
get_site(site_id:, **options) click to toggle source

Fetch a site

{developers.recurly.com/api/v2021-02-25#operation/get_site get_site api documenation}

@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. @param params [Hash] Optional query string parameters:

@return [Resources::Site] A site. @example

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
# File lib/recurly/client/operations.rb, line 69
def get_site(site_id:, **options)
  path = interpolate_path("/sites/{site_id}", site_id: site_id)
  get(path, **options)
end
get_subscription(subscription_id:, **options) click to toggle source

Fetch a subscription

{developers.recurly.com/api/v2021-02-25#operation/get_subscription get_subscription api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Subscription] A subscription. @example

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
# File lib/recurly/client/operations.rb, line 3111
def get_subscription(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}", subscription_id: subscription_id)
  get(path, **options)
end
get_subscription_change(subscription_id:, **options) click to toggle source

Fetch a subscription's pending change

{developers.recurly.com/api/v2021-02-25#operation/get_subscription_change get_subscription_change api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::SubscriptionChange] A subscription's pending change. @example

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
# File lib/recurly/client/operations.rb, line 3337
def get_subscription_change(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/change", subscription_id: subscription_id)
  get(path, **options)
end
get_transaction(transaction_id:, **options) click to toggle source

Fetch a transaction

{developers.recurly.com/api/v2021-02-25#operation/get_transaction get_transaction api documenation}

@param transaction_id [String] Transaction ID or UUID. For ID no prefix is used e.g. e28zov4fw0v2. For UUID use prefix uuid-, e.g. uuid-123457890. @param params [Hash] Optional query string parameters:

@return [Resources::Transaction] A transaction. @example

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
# File lib/recurly/client/operations.rb, line 3731
def get_transaction(transaction_id:, **options)
  path = interpolate_path("/transactions/{transaction_id}", transaction_id: transaction_id)
  get(path, **options)
end
get_unique_coupon_code(unique_coupon_code_id:, **options) click to toggle source

Fetch a unique coupon code

{developers.recurly.com/api/v2021-02-25#operation/get_unique_coupon_code get_unique_coupon_code api documenation}

@param unique_coupon_code_id [String] Unique Coupon Code ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-abc-8dh2-def. @param params [Hash] Optional query string parameters:

@return [Resources::UniqueCouponCode] A unique coupon code.

# File lib/recurly/client/operations.rb, line 3745
def get_unique_coupon_code(unique_coupon_code_id:, **options)
  path = interpolate_path("/unique_coupon_codes/{unique_coupon_code_id}", unique_coupon_code_id: unique_coupon_code_id)
  get(path, **options)
end
get_usage(usage_id:, **options) click to toggle source

Get a usage record

{developers.recurly.com/api/v2021-02-25#operation/get_usage get_usage api documenation}

@param usage_id [String] Usage Record ID. @param params [Hash] Optional query string parameters:

@return [Resources::Usage] The usage record.

# File lib/recurly/client/operations.rb, line 3632
def get_usage(usage_id:, **options)
  path = interpolate_path("/usage/{usage_id}", usage_id: usage_id)
  get(path, **options)
end
list_account_acquisition(**options) click to toggle source

List a site's account acquisition data

{developers.recurly.com/api/v2021-02-25#operation/list_account_acquisition list_account_acquisition api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

@return [Pager<Resources::AccountAcquisition>] A list of the site's account acquisition data. @example

params = {
  limit: 200
}
acquisitions = @client.list_account_acquisition(params: params)
acquisitions.each do |acquisition|
  puts "AccountAcquisition: #{acquisition.cost}"
end
# File lib/recurly/client/operations.rb, line 1370
def list_account_acquisition(**options)
  path = "/acquisitions"
  pager(path, **options)
end
list_account_coupon_redemptions(account_id:, **options) click to toggle source

Show the coupon redemptions for an account

{developers.recurly.com/api/v2021-02-25#operation/list_account_coupon_redemptions list_account_coupon_redemptions api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :state [String] Filter by state.

@return [Pager<Resources::CouponRedemption>] A list of the the coupon redemptions on an account. @example

params = {
  limit: 200
}
redemptions = @client.list_account_coupon_redemptions(
  account_id: account_id,
  params: params
)
redemptions.each do |redemption|
  puts "CouponRedemption: #{redemption.id}"
end
# File lib/recurly/client/operations.rb, line 619
def list_account_coupon_redemptions(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/coupon_redemptions", account_id: account_id)
  pager(path, **options)
end
list_account_credit_payments(account_id:, **options) click to toggle source

List an account's credit payments

{developers.recurly.com/api/v2021-02-25#operation/list_account_credit_payments list_account_credit_payments api documenation}

@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 params [Hash] Optional query string parameters:

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

@return [Pager<Resources::CreditPayment>] A list of the account's credit payments. @example

params = {
  limit: 200
}
payments = @client.list_account_credit_payments(
  account_id: account_id,
  params: params
)
payments.each do |payment|
  puts "CreditPayment: #{payment.id}"
end
# File lib/recurly/client/operations.rb, line 732
def list_account_credit_payments(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/credit_payments", account_id: account_id)
  pager(path, **options)
end
list_account_invoices(account_id:, **options) click to toggle source

List an account's invoices

{developers.recurly.com/api/v2021-02-25#operation/list_account_invoices list_account_invoices api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :type [String] Filter by type when:
- +type=charge+, only charge invoices will be returned.
- +type=credit+, only credit invoices will be returned.
- +type=non-legacy+, only charge and credit invoices will be returned.
- +type=legacy+, only legacy invoices will be returned.

@return [Pager<Resources::Invoice>] A list of the account's invoices. @example

params = {
  limit: 200
}
invoices = @client.list_account_invoices(
  account_id: account_id,
  params: params
)
invoices.each do |invoice|
  puts "Invoice: #{invoice.number}"
end
# File lib/recurly/client/operations.rb, line 787
def list_account_invoices(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/invoices", account_id: account_id)
  pager(path, **options)
end
list_account_line_items(account_id:, **options) click to toggle source

List an account's line items

{developers.recurly.com/api/v2021-02-25#operation/list_account_line_items list_account_line_items api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :original [String] Filter by original field.
     :state [String] Filter by state field.
     :type [String] Filter by type field.

@return [Pager<Resources::LineItem>] A list of the account's line items. @example

params = {
  limit: 200
}
line_items = @client.list_account_line_items(
  account_id: account_id,
  params: params
)
line_items.each do |line_item|
  puts "LineItem: #{line_item.id}"
end
# File lib/recurly/client/operations.rb, line 901
def list_account_line_items(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/line_items", account_id: account_id)
  pager(path, **options)
end
list_account_notes(account_id:, **options) click to toggle source

Fetch a list of an account's notes

{developers.recurly.com/api/v2021-02-25#operation/list_account_notes list_account_notes api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

@return [Pager<Resources::AccountNote>] A list of an account's notes. @example

params = {
  limit: 200
}
account_notes = @client.list_account_notes(account_id: account_id, params: params)
account_notes.each do |note|
  puts "AccountNote: #{note.message}"
end
# File lib/recurly/client/operations.rb, line 967
def list_account_notes(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/notes", account_id: account_id)
  pager(path, **options)
end
list_account_subscriptions(account_id:, **options) click to toggle source

List an account's subscriptions

{developers.recurly.com/api/v2021-02-25#operation/list_account_subscriptions list_account_subscriptions api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :state [String] Filter by state.

- When +state=active+, +state=canceled+, +state=expired+, or +state=future+, subscriptions with states that match the query and only those subscriptions will be returned.
- When +state=in_trial+, only subscriptions that have a trial_started_at date earlier than now and a trial_ends_at date later than now will be returned.
- When +state=live+, only subscriptions that are in an active, canceled, or future state or are in trial will be returned.

@return [Pager<Resources::Subscription>] A list of the account's subscriptions. @example

params = {
  limit: 200
}
subscriptions = @client.list_account_subscriptions(
  account_id: account_id,
  params: params
)
subscriptions.each do |subscription|
  puts "Subscription: #{subscription.uuid}"
end
# File lib/recurly/client/operations.rb, line 1220
def list_account_subscriptions(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/subscriptions", account_id: account_id)
  pager(path, **options)
end
list_account_transactions(account_id:, **options) click to toggle source

List an account's transactions

{developers.recurly.com/api/v2021-02-25#operation/list_account_transactions list_account_transactions api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :type [String] Filter by type field. The value +payment+ will return both +purchase+ and +capture+ transactions.
     :success [String] Filter by success field.

@return [Pager<Resources::Transaction>] A list of the account's transactions. @example

params = {
  limit: 200
}
transactions = @client.list_account_transactions(
  account_id: account_id,
  params: params
)
transactions.each do |transaction|
  puts "Transaction: #{transaction.uuid}"
end
# File lib/recurly/client/operations.rb, line 1271
def list_account_transactions(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/transactions", account_id: account_id)
  pager(path, **options)
end
list_accounts(**options) click to toggle source

List a site's accounts

{developers.recurly.com/api/v2021-02-25#operation/list_accounts list_accounts api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :email [String] Filter for accounts with this exact email address. A blank value will return accounts with both +null+ and +""+ email addresses. Note that multiple accounts can share one email address.
     :subscriber [Boolean] Filter for accounts with or without a subscription in the +active+,
+canceled+, or +future+ state.

     :past_due [String] Filter for accounts with an invoice in the +past_due+ state.

@return [Pager<Resources::Account>] A list of the site's accounts. @example

params = {
  limit: 200
}
accounts = @client.list_accounts(params: params)
accounts.each do |account|
  puts "Account: #{account.code}"
end
# File lib/recurly/client/operations.rb, line 119
def list_accounts(**options)
  path = "/accounts"
  pager(path, **options)
end
list_active_coupon_redemptions(account_id:, **options) click to toggle source

Show the coupon redemptions that are active on an account

{developers.recurly.com/api/v2021-02-25#operation/list_active_coupon_redemptions list_active_coupon_redemptions api documenation}

@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 params [Hash] Optional query string parameters:

@return [Pager<Resources::CouponRedemption>] Active coupon redemptions on an account. @example

params = {
  limit: 200
}
redemptions = @client.list_active_coupon_redemptions(account_id: account_id, params: params)
redemptions.each do |redemption|
  puts "Redemption: #{redemption.id}"
end
# File lib/recurly/client/operations.rb, line 641
def list_active_coupon_redemptions(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/coupon_redemptions/active", account_id: account_id)
  pager(path, **options)
end
list_add_ons(**options) click to toggle source

List a site's add-ons

{developers.recurly.com/api/v2021-02-25#operation/list_add_ons list_add_ons api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :state [String] Filter by state.

@return [Pager<Resources::AddOn>] A list of add-ons. @example

params = {
  limit: 200
}
add_ons = @client.list_add_ons(
  params: params
)
add_ons.each do |add_on|
  puts "AddOn: #{add_on.code}"
end
# File lib/recurly/client/operations.rb, line 2875
def list_add_ons(**options)
  path = "/add_ons"
  pager(path, **options)
end
list_billing_infos(account_id:, **options) click to toggle source

Get the list of billing information associated with an account

{developers.recurly.com/api/v2021-02-25#operation/list_billing_infos list_billing_infos api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

@return [Pager<Resources::BillingInfo>] A list of the the billing information for an account's

# File lib/recurly/client/operations.rb, line 510
def list_billing_infos(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/billing_infos", account_id: account_id)
  pager(path, **options)
end
list_child_accounts(account_id:, **options) click to toggle source

List an account's child accounts

{developers.recurly.com/api/v2021-02-25#operation/list_child_accounts list_child_accounts api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :email [String] Filter for accounts with this exact email address. A blank value will return accounts with both +null+ and +""+ email addresses. Note that multiple accounts can share one email address.
     :subscriber [Boolean] Filter for accounts with or without a subscription in the +active+,
+canceled+, or +future+ state.

     :past_due [String] Filter for accounts with an invoice in the +past_due+ state.

@return [Pager<Resources::Account>] A list of an account's child accounts. @example

params = {
  limit: 200
}
child_accounts = @client.list_child_accounts(
  account_id: account_id,
  params: params
)
child_accounts.each do |child|
  puts "Account: #{child.code}"
end
# File lib/recurly/client/operations.rb, line 1325
def list_child_accounts(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/accounts", account_id: account_id)
  pager(path, **options)
end
list_coupons(**options) click to toggle source

List a site's coupons

{developers.recurly.com/api/v2021-02-25#operation/list_coupons list_coupons api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

@return [Pager<Resources::Coupon>] A list of the site's coupons. @example

params = {
  limit: 200
}
coupons = @client.list_coupons(params: params)
coupons.each do |coupon|
  puts "coupon: #{coupon.code}"
end
# File lib/recurly/client/operations.rb, line 1415
def list_coupons(**options)
  path = "/coupons"
  pager(path, **options)
end
list_credit_payments(**options) click to toggle source

List a site's credit payments

{developers.recurly.com/api/v2021-02-25#operation/list_credit_payments list_credit_payments api documenation}

@param params [Hash] Optional query string parameters:

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

@return [Pager<Resources::CreditPayment>] A list of the site's credit payments. @example

params = {
  limit: 200
}
payments = @client.list_credit_payments(params: params)
payments.each do |payment|
  puts "CreditPayment: #{payment.id}"
end
# File lib/recurly/client/operations.rb, line 1625
def list_credit_payments(**options)
  path = "/credit_payments"
  pager(path, **options)
end
list_custom_field_definitions(**options) click to toggle source

List a site's custom field definitions

{developers.recurly.com/api/v2021-02-25#operation/list_custom_field_definitions list_custom_field_definitions api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :related_type [String] Filter by related type.

@return [Pager<Resources::CustomFieldDefinition>] A list of the site's custom field definitions. @example

params = {
  limit: 200
}
custom_fields = @client.list_custom_field_definitions(params: params)
custom_fields.each do |field|
  puts "CustomFieldDefinition: #{field.name}"
end
# File lib/recurly/client/operations.rb, line 1685
def list_custom_field_definitions(**options)
  path = "/custom_field_definitions"
  pager(path, **options)
end
list_dunning_campaigns(**options) click to toggle source

Show the dunning campaigns for a site

{developers.recurly.com/api/v2021-02-25#operation/list_dunning_campaigns list_dunning_campaigns api documenation}

@param params [Hash] Optional query string parameters:

     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

@return [Pager<Resources::DunningCampaign>] A list of the the dunning_campaigns on an account.

# File lib/recurly/client/operations.rb, line 3919
def list_dunning_campaigns(**options)
  path = "/dunning_campaigns"
  pager(path, **options)
end
list_invoice_coupon_redemptions(invoice_id:, **options) click to toggle source

Show the coupon redemptions applied to an invoice

{developers.recurly.com/api/v2021-02-25#operation/list_invoice_coupon_redemptions list_invoice_coupon_redemptions api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

@return [Pager<Resources::CouponRedemption>] A list of the the coupon redemptions associated with the invoice. @example

params = {
  limit: 200
}
coupon_redemptions = @client.list_invoice_coupon_redemptions(
  invoice_id: invoice_id,
  params: params
)
coupon_redemptions.each do |redemption|
  puts "CouponRedemption: #{redemption.id}"
end
# File lib/recurly/client/operations.rb, line 2344
def list_invoice_coupon_redemptions(invoice_id:, **options)
  path = interpolate_path("/invoices/{invoice_id}/coupon_redemptions", invoice_id: invoice_id)
  pager(path, **options)
end
list_invoice_line_items(invoice_id:, **options) click to toggle source

List an invoice's line items

{developers.recurly.com/api/v2021-02-25#operation/list_invoice_line_items list_invoice_line_items api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :original [String] Filter by original field.
     :state [String] Filter by state field.
     :type [String] Filter by type field.

@return [Pager<Resources::LineItem>] A list of the invoice's line items. @example

params = {
  limit: 200
}
line_items = @client.list_invoice_line_items(
  invoice_id: invoice_id,
  params: params
)
line_items.each do |line_item|
  puts "Line Item: #{line_item.id}"
end
# File lib/recurly/client/operations.rb, line 2297
def list_invoice_line_items(invoice_id:, **options)
  path = interpolate_path("/invoices/{invoice_id}/line_items", invoice_id: invoice_id)
  pager(path, **options)
end
list_invoices(**options) click to toggle source

List a site's invoices

{developers.recurly.com/api/v2021-02-25#operation/list_invoices list_invoices api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :type [String] Filter by type when:
- +type=charge+, only charge invoices will be returned.
- +type=credit+, only credit invoices will be returned.
- +type=non-legacy+, only charge and credit invoices will be returned.
- +type=legacy+, only legacy invoices will be returned.

@return [Pager<Resources::Invoice>] A list of the site's invoices. @example

params = {
  limit: 200
}
invoices = @client.list_invoices(params: params)
invoices.each do |invoice|
  puts "Invoice: #{invoice.number}"
end
# File lib/recurly/client/operations.rb, line 2037
def list_invoices(**options)
  path = "/invoices"
  pager(path, **options)
end
list_items(**options) click to toggle source

List a site's items

{developers.recurly.com/api/v2021-02-25#operation/list_items list_items api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :state [String] Filter by state.

@return [Pager<Resources::Item>] A list of the site's items. @example

params = {
  limit: 200
}
items = @client.list_items(params: params)
items.each do |item|
  puts "Item: #{item.code}"
end
# File lib/recurly/client/operations.rb, line 1756
def list_items(**options)
  path = "/items"
  pager(path, **options)
end
list_line_items(**options) click to toggle source

List a site's line items

{developers.recurly.com/api/v2021-02-25#operation/list_line_items list_line_items api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :original [String] Filter by original field.
     :state [String] Filter by state field.
     :type [String] Filter by type field.

@return [Pager<Resources::LineItem>] A list of the site's line items. @example

params = {
  limit: 200
}
line_items = @client.list_line_items(
  params: params
)
line_items.each do |line_item|
  puts "LineItem: #{line_item.id}"
end
# File lib/recurly/client/operations.rb, line 2450
def list_line_items(**options)
  path = "/line_items"
  pager(path, **options)
end
list_measured_unit(**options) click to toggle source

List a site's measured units

{developers.recurly.com/api/v2021-02-25#operation/list_measured_unit list_measured_unit api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :state [String] Filter by state.

@return [Pager<Resources::MeasuredUnit>] A list of the site's measured units.

# File lib/recurly/client/operations.rb, line 1929
def list_measured_unit(**options)
  path = "/measured_units"
  pager(path, **options)
end
list_plan_add_ons(plan_id:, **options) click to toggle source

List a plan's add-ons

{developers.recurly.com/api/v2021-02-25#operation/list_plan_add_ons list_plan_add_ons api documenation}

@param plan_id [String] Plan ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :state [String] Filter by state.

@return [Pager<Resources::AddOn>] A list of add-ons. @example

params = {
  limit: 200
}
add_ons = @client.list_plan_add_ons(
  plan_id: plan_id,
  params: params
)
add_ons.each do |add_on|
  puts "AddOn: #{add_on.code}"
end
# File lib/recurly/client/operations.rb, line 2707
def list_plan_add_ons(plan_id:, **options)
  path = interpolate_path("/plans/{plan_id}/add_ons", plan_id: plan_id)
  pager(path, **options)
end
list_plans(**options) click to toggle source

List a site's plans

{developers.recurly.com/api/v2021-02-25#operation/list_plans list_plans api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :state [String] Filter by state.

@return [Pager<Resources::Plan>] A list of plans. @example

params = {
  limit: 200
}
plans = @client.list_plans(params: params)
plans.each do |plan|
  puts "Plan: #{plan.code}"
end
# File lib/recurly/client/operations.rb, line 2544
def list_plans(**options)
  path = "/plans"
  pager(path, **options)
end
list_shipping_addresses(account_id:, **options) click to toggle source

Fetch a list of an account's shipping addresses

{developers.recurly.com/api/v2021-02-25#operation/list_shipping_addresses list_shipping_addresses api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

@return [Pager<Resources::ShippingAddress>] A list of an account's shipping addresses. @example

params = {
  limit: 200
}
shipping_addresses = @client.list_shipping_addresses(
  account_id: account_id,
  params: params
)
shipping_addresses.each do |addr|
  puts "ShippingAddress: #{addr.nickname} - #{addr.street1}"
end
# File lib/recurly/client/operations.rb, line 1043
def list_shipping_addresses(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/shipping_addresses", account_id: account_id)
  pager(path, **options)
end
list_shipping_methods(**options) click to toggle source

List a site's shipping methods

{developers.recurly.com/api/v2021-02-25#operation/list_shipping_methods list_shipping_methods api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

@return [Pager<Resources::ShippingMethod>] A list of the site's shipping methods. @example

params = {
  limit: 200
}
shipping_methods = @client.list_shipping_methods(
  params: params
)
shipping_methods.each do |shipping_method|
  puts "Shipping Method: #{shipping_method.code}"
end
# File lib/recurly/client/operations.rb, line 2945
def list_shipping_methods(**options)
  path = "/shipping_methods"
  pager(path, **options)
end
list_sites(**options) click to toggle source

List sites

{developers.recurly.com/api/v2021-02-25#operation/list_sites list_sites api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :state [String] Filter by state.

@return [Pager<Resources::Site>] A list of sites. @example

params = {
  limit: 200
}
sites = @client.list_sites(params: params)
sites.each do |site|
  puts "Site: #{site.subdomain}"
end
# File lib/recurly/client/operations.rb, line 46
def list_sites(**options)
  path = "/sites"
  pager(path, **options)
end
list_subscription_coupon_redemptions(subscription_id:, **options) click to toggle source

Show the coupon redemptions for a subscription

{developers.recurly.com/api/v2021-02-25#operation/list_subscription_coupon_redemptions list_subscription_coupon_redemptions api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

@return [Pager<Resources::CouponRedemption>] A list of the the coupon redemptions on a subscription. @example

params = {
  limit: 200
}
coupon_redemptions = @client.list_subscription_coupon_redemptions(
  subscription_id: subscription_id,
  params: params
)
coupon_redemptions.each do |redemption|
  puts "CouponRedemption: #{redemption.id}"
end
# File lib/recurly/client/operations.rb, line 3562
def list_subscription_coupon_redemptions(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/coupon_redemptions", subscription_id: subscription_id)
  pager(path, **options)
end
list_subscription_invoices(subscription_id:, **options) click to toggle source

List a subscription's invoices

{developers.recurly.com/api/v2021-02-25#operation/list_subscription_invoices list_subscription_invoices api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :type [String] Filter by type when:
- +type=charge+, only charge invoices will be returned.
- +type=credit+, only credit invoices will be returned.
- +type=non-legacy+, only charge and credit invoices will be returned.
- +type=legacy+, only legacy invoices will be returned.

@return [Pager<Resources::Invoice>] A list of the subscription's invoices. @example

params = {
  limit: 200
}
invoices = @client.list_subscription_invoices(
  subscription_id: subscription_id,
  params: params
)
invoices.each do |invoice|
  puts "Invoice: #{invoice.number}"
end
# File lib/recurly/client/operations.rb, line 3463
def list_subscription_invoices(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/invoices", subscription_id: subscription_id)
  pager(path, **options)
end
list_subscription_line_items(subscription_id:, **options) click to toggle source

List a subscription's line items

{developers.recurly.com/api/v2021-02-25#operation/list_subscription_line_items list_subscription_line_items api documenation}

@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 params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :original [String] Filter by original field.
     :state [String] Filter by state field.
     :type [String] Filter by type field.

@return [Pager<Resources::LineItem>] A list of the subscription's line items. @example

params = {
  limit: 200
}
line_items = @client.list_subscription_line_items(
  subscription_id: subscription_id,
  params: params
)
line_items.each do |line_item|
  puts "LineItem: #{line_item.id}"
end
# File lib/recurly/client/operations.rb, line 3515
def list_subscription_line_items(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/line_items", subscription_id: subscription_id)
  pager(path, **options)
end
list_subscriptions(**options) click to toggle source

List a site's subscriptions

{developers.recurly.com/api/v2021-02-25#operation/list_subscriptions list_subscriptions api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :state [String] Filter by state.

- When +state=active+, +state=canceled+, +state=expired+, or +state=future+, subscriptions with states that match the query and only those subscriptions will be returned.
- When +state=in_trial+, only subscriptions that have a trial_started_at date earlier than now and a trial_ends_at date later than now will be returned.
- When +state=live+, only subscriptions that are in an active, canceled, or future state or are in trial will be returned.

@return [Pager<Resources::Subscription>] A list of the site's subscriptions. @example

params = {
  limit: 200
}
subscriptions = @client.list_subscriptions(params: params)
subscriptions.each do |subscription|
  puts "Subscription: #{subscription.uuid}"
end
# File lib/recurly/client/operations.rb, line 3053
def list_subscriptions(**options)
  path = "/subscriptions"
  pager(path, **options)
end
list_transactions(**options) click to toggle source

List a site's transactions

{developers.recurly.com/api/v2021-02-25#operation/list_transactions list_transactions api documenation}

@param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :type [String] Filter by type field. The value +payment+ will return both +purchase+ and +capture+ transactions.
     :success [String] Filter by success field.

@return [Pager<Resources::Transaction>] A list of the site's transactions. @example

params = {
  limit: 200
}
transactions = @client.list_transactions(params: params)
transactions.each do |transaction|
  puts "Transaction: #{transaction.uuid}"
end
# File lib/recurly/client/operations.rb, line 3708
def list_transactions(**options)
  path = "/transactions"
  pager(path, **options)
end
list_unique_coupon_codes(coupon_id:, **options) click to toggle source

List unique coupon codes associated with a bulk coupon

{developers.recurly.com/api/v2021-02-25#operation/list_unique_coupon_codes list_unique_coupon_codes api documenation}

@param coupon_id [String] Coupon ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-10off. @param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

@return [Pager<Resources::UniqueCouponCode>] A list of unique coupon codes that were generated

# File lib/recurly/client/operations.rb, line 1592
def list_unique_coupon_codes(coupon_id:, **options)
  path = interpolate_path("/coupons/{coupon_id}/unique_coupon_codes", coupon_id: coupon_id)
  pager(path, **options)
end
list_usage(subscription_id:, add_on_id:, **options) click to toggle source

List a subscription add-on's usage records

{developers.recurly.com/api/v2021-02-25#operation/list_usage list_usage api documenation}

@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 add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param params [Hash] Optional query string parameters:

     :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+.

*Important notes:*

* The +ids+ parameter cannot be used with any other ordering or filtering
  parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
* Invalid or unknown IDs will be ignored, so you should check that the
  results correspond to your request.
* Records are returned in an arbitrary order. Since results are all
  returned at once you can sort the records yourself.

     :limit [Integer] Limit number of records 1-200.
     :order [String] Sort order.
     :sort [String] Sort field. You *really* only want to sort by +usage_timestamp+ in ascending
order. In descending order updated records will move behind the cursor and could
prevent some records from being returned.

     :begin_time [DateTime] Inclusively filter by begin_time when +sort=usage_timestamp+ or +sort=recorded_timestamp+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :end_time [DateTime] Inclusively filter by end_time when +sort=usage_timestamp+ or +sort=recorded_timestamp+.
*Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.

     :billing_status [String] Filter by usage record's billing status

@return [Pager<Resources::Usage>] A list of the subscription add-on's usage records.

# File lib/recurly/client/operations.rb, line 3602
def list_usage(subscription_id:, add_on_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/add_ons/{add_on_id}/usage", subscription_id: subscription_id, add_on_id: add_on_id)
  pager(path, **options)
end
mark_invoice_failed(invoice_id:, **options) click to toggle source

Mark an open invoice as failed

{developers.recurly.com/api/v2021-02-25#operation/mark_invoice_failed mark_invoice_failed api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Invoice] The updated invoice. @example

begin
  invoice = @client.mark_invoice_failed(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
# File lib/recurly/client/operations.rb, line 2161
def mark_invoice_failed(invoice_id:, **options)
  path = interpolate_path("/invoices/{invoice_id}/mark_failed", invoice_id: invoice_id)
  put(path, **options)
end
mark_invoice_successful(invoice_id:, **options) click to toggle source

Mark an open invoice as successful

{developers.recurly.com/api/v2021-02-25#operation/mark_invoice_successful mark_invoice_successful api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Invoice] The updated invoice. @example

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
# File lib/recurly/client/operations.rb, line 2184
def mark_invoice_successful(invoice_id:, **options)
  path = interpolate_path("/invoices/{invoice_id}/mark_successful", invoice_id: invoice_id)
  put(path, **options)
end
pause_subscription(subscription_id:, body:, **options) click to toggle source

Pause subscription

{developers.recurly.com/api/v2021-02-25#operation/pause_subscription pause_subscription api documenation}

@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 body [Requests::SubscriptionPause] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionPause} @param params [Hash] Optional query string parameters:

@return [Resources::Subscription] A subscription. @example

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
# File lib/recurly/client/operations.rb, line 3259
def pause_subscription(subscription_id:, body:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/pause", subscription_id: subscription_id)
  put(path, body, Requests::SubscriptionPause, **options)
end
preview_invoice(account_id:, body:, **options) click to toggle source

Preview new invoice for pending line items

{developers.recurly.com/api/v2021-02-25#operation/preview_invoice preview_invoice api documenation}

@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::InvoiceCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceCreate} @param params [Hash] Optional query string parameters:

@return [Resources::InvoiceCollection] Returns the invoice previews. @example

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
# File lib/recurly/client/operations.rb, line 849
def preview_invoice(account_id:, body:, **options)
  path = interpolate_path("/accounts/{account_id}/invoices/preview", account_id: account_id)
  post(path, body, Requests::InvoiceCreate, **options)
end
preview_purchase(body:, **options) click to toggle source

Preview a new purchase

{developers.recurly.com/api/v2021-02-25#operation/preview_purchase preview_purchase api documenation}

@param body [Requests::PurchaseCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PurchaseCreate} @param params [Hash] Optional query string parameters:

@return [Resources::InvoiceCollection] Returns preview of the new invoices @example

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
# File lib/recurly/client/operations.rb, line 3853
def preview_purchase(body:, **options)
  path = "/purchases/preview"
  post(path, body, Requests::PurchaseCreate, **options)
end
preview_subscription_change(subscription_id:, body:, **options) click to toggle source

Preview a new subscription change

{developers.recurly.com/api/v2021-02-25#operation/preview_subscription_change preview_subscription_change api documenation}

@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 body [Requests::SubscriptionChangeCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionChangeCreate} @param params [Hash] Optional query string parameters:

@return [Resources::SubscriptionChange] A subscription change.

# File lib/recurly/client/operations.rb, line 3408
def preview_subscription_change(subscription_id:, body:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/change/preview", subscription_id: subscription_id)
  post(path, body, Requests::SubscriptionChangeCreate, **options)
end
put_dunning_campaign_bulk_update(body:, **options) click to toggle source

Assign a dunning campaign to multiple plans

{developers.recurly.com/api/v2021-02-25#operation/put_dunning_campaign_bulk_update put_dunning_campaign_bulk_update api documenation}

@param body [Requests::DunningCampaignsBulkUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::DunningCampaignsBulkUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::DunningCampaignsBulkUpdateResponse] A list of updated plans.

# File lib/recurly/client/operations.rb, line 3947
def put_dunning_campaign_bulk_update(body:, **options)
  path = "/dunning_campaigns/{dunning_campaign_id}/bulk_update"
  put(path, body, Requests::DunningCampaignsBulkUpdate, **options)
end
reactivate_account(account_id:, **options) click to toggle source

Reactivate an inactive account

{developers.recurly.com/api/v2021-02-25#operation/reactivate_account reactivate_account api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Account] An account. @example

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
# File lib/recurly/client/operations.rb, line 350
def reactivate_account(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/reactivate", account_id: account_id)
  put(path, **options)
end
reactivate_item(item_id:, **options) click to toggle source

Reactivate an inactive item

{developers.recurly.com/api/v2021-02-25#operation/reactivate_item reactivate_item api documenation}

@param item_id [String] Item ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-red. @param params [Hash] Optional query string parameters:

@return [Resources::Item] An item. @example

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
# File lib/recurly/client/operations.rb, line 1891
def reactivate_item(item_id:, **options)
  path = interpolate_path("/items/{item_id}/reactivate", item_id: item_id)
  put(path, **options)
end
reactivate_subscription(subscription_id:, **options) click to toggle source

Reactivate a canceled subscription

{developers.recurly.com/api/v2021-02-25#operation/reactivate_subscription reactivate_subscription api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Subscription] An active subscription. @example

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
# File lib/recurly/client/operations.rb, line 3229
def reactivate_subscription(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/reactivate", subscription_id: subscription_id)
  put(path, **options)
end
reactivate_unique_coupon_code(unique_coupon_code_id:, **options) click to toggle source

Restore a unique coupon code

{developers.recurly.com/api/v2021-02-25#operation/reactivate_unique_coupon_code reactivate_unique_coupon_code api documenation}

@param unique_coupon_code_id [String] Unique Coupon Code ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-abc-8dh2-def. @param params [Hash] Optional query string parameters:

@return [Resources::UniqueCouponCode] A unique coupon code.

# File lib/recurly/client/operations.rb, line 3773
def reactivate_unique_coupon_code(unique_coupon_code_id:, **options)
  path = interpolate_path("/unique_coupon_codes/{unique_coupon_code_id}/restore", unique_coupon_code_id: unique_coupon_code_id)
  put(path, **options)
end
record_external_transaction(invoice_id:, body:, **options) click to toggle source

Record an external payment for a manual invoices.

{developers.recurly.com/api/v2021-02-25#operation/record_external_transaction record_external_transaction api documenation}

@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 body [Requests::ExternalTransaction] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ExternalTransaction} @param params [Hash] Optional query string parameters:

@return [Resources::Transaction] The recorded transaction.

# File lib/recurly/client/operations.rb, line 2245
def record_external_transaction(invoice_id:, body:, **options)
  path = interpolate_path("/invoices/{invoice_id}/transactions", invoice_id: invoice_id)
  post(path, body, Requests::ExternalTransaction, **options)
end
refund_invoice(invoice_id:, body:, **options) click to toggle source

Refund an invoice

{developers.recurly.com/api/v2021-02-25#operation/refund_invoice refund_invoice api documenation}

@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 body [Requests::InvoiceRefund] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceRefund} @param params [Hash] Optional query string parameters:

@return [Resources::Invoice] Returns the new credit invoice. @example

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
# File lib/recurly/client/operations.rb, line 2400
def refund_invoice(invoice_id:, body:, **options)
  path = interpolate_path("/invoices/{invoice_id}/refund", invoice_id: invoice_id)
  post(path, body, Requests::InvoiceRefund, **options)
end
remove_a_billing_info(account_id:, billing_info_id:, **options) click to toggle source

Remove an account's billing information

{developers.recurly.com/api/v2021-02-25#operation/remove_a_billing_info remove_a_billing_info api documenation}

@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. @param params [Hash] Optional query string parameters:

@return [Resources::Empty] Billing information deleted

# File lib/recurly/client/operations.rb, line 571
def remove_a_billing_info(account_id:, billing_info_id:, **options)
  path = interpolate_path("/accounts/{account_id}/billing_infos/{billing_info_id}", account_id: account_id, billing_info_id: billing_info_id)
  delete(path, **options)
end
remove_account_acquisition(account_id:, **options) click to toggle source

Remove an account's acquisition data

{developers.recurly.com/api/v2021-02-25#operation/remove_account_acquisition remove_account_acquisition api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Empty] Acquisition data was succesfully deleted. @example

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
# File lib/recurly/client/operations.rb, line 327
def remove_account_acquisition(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/acquisition", account_id: account_id)
  delete(path, **options)
end
remove_billing_info(account_id:, **options) click to toggle source

Remove an account's billing information

{developers.recurly.com/api/v2021-02-25#operation/remove_billing_info remove_billing_info api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Empty] Billing information deleted @example

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
# File lib/recurly/client/operations.rb, line 450
def remove_billing_info(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/billing_info", account_id: account_id)
  delete(path, **options)
end
remove_coupon_redemption(account_id:, **options) click to toggle source

Delete the active coupon redemption from an account

{developers.recurly.com/api/v2021-02-25#operation/remove_coupon_redemption remove_coupon_redemption api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::CouponRedemption] Coupon redemption deleted. @example

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
# File lib/recurly/client/operations.rb, line 695
def remove_coupon_redemption(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/coupon_redemptions/active", account_id: account_id)
  delete(path, **options)
end
remove_line_item(line_item_id:, **options) click to toggle source

Delete an uninvoiced line item

{developers.recurly.com/api/v2021-02-25#operation/remove_line_item remove_line_item api documenation}

@param line_item_id [String] Line Item ID. @param params [Hash] Optional query string parameters:

@return [Resources::Empty] Line item deleted. @example

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
# File lib/recurly/client/operations.rb, line 2498
def remove_line_item(line_item_id:, **options)
  path = interpolate_path("/line_items/{line_item_id}", line_item_id: line_item_id)
  delete(path, **options)
end
remove_measured_unit(measured_unit_id:, **options) click to toggle source

Remove a measured unit

{developers.recurly.com/api/v2021-02-25#operation/remove_measured_unit remove_measured_unit api documenation}

@param measured_unit_id [String] Measured unit ID or name. For ID no prefix is used e.g. e28zov4fw0v2. For name use prefix name-, e.g. name-Storage. @param params [Hash] Optional query string parameters:

@return [Resources::MeasuredUnit] A measured unit.

# File lib/recurly/client/operations.rb, line 1986
def remove_measured_unit(measured_unit_id:, **options)
  path = interpolate_path("/measured_units/{measured_unit_id}", measured_unit_id: measured_unit_id)
  delete(path, **options)
end
remove_plan(plan_id:, **options) click to toggle source

Remove a plan

{developers.recurly.com/api/v2021-02-25#operation/remove_plan remove_plan api documenation}

@param plan_id [String] Plan ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param params [Hash] Optional query string parameters:

@return [Resources::Plan] Plan deleted @example

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
# File lib/recurly/client/operations.rb, line 2657
def remove_plan(plan_id:, **options)
  path = interpolate_path("/plans/{plan_id}", plan_id: plan_id)
  delete(path, **options)
end
remove_plan_add_on(plan_id:, add_on_id:, **options) click to toggle source

Remove an add-on

{developers.recurly.com/api/v2021-02-25#operation/remove_plan_add_on remove_plan_add_on api documenation}

@param plan_id [String] Plan ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param params [Hash] Optional query string parameters:

@return [Resources::AddOn] Add-on deleted @example

begin
  add_on = @client.remove_plan_add_on(
    plan_id: plan_id,
    add_on_id: add_on_id
  )
  puts "Removed 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
# File lib/recurly/client/operations.rb, line 2827
def remove_plan_add_on(plan_id:, add_on_id:, **options)
  path = interpolate_path("/plans/{plan_id}/add_ons/{add_on_id}", plan_id: plan_id, add_on_id: add_on_id)
  delete(path, **options)
end
remove_shipping_address(account_id:, shipping_address_id:, **options) click to toggle source

Remove an account's shipping address

{developers.recurly.com/api/v2021-02-25#operation/remove_shipping_address remove_shipping_address api documenation}

@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 shipping_address_id [String] Shipping Address ID. @param params [Hash] Optional query string parameters:

@return [Resources::Empty] Shipping address deleted. @example

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
# File lib/recurly/client/operations.rb, line 1165
def remove_shipping_address(account_id:, shipping_address_id:, **options)
  path = interpolate_path("/accounts/{account_id}/shipping_addresses/{shipping_address_id}", account_id: account_id, shipping_address_id: shipping_address_id)
  delete(path, **options)
end
remove_subscription_change(subscription_id:, **options) click to toggle source

Delete the pending subscription change

{developers.recurly.com/api/v2021-02-25#operation/remove_subscription_change remove_subscription_change api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Empty] Subscription change was deleted. @example

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
# File lib/recurly/client/operations.rb, line 3393
def remove_subscription_change(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/change", subscription_id: subscription_id)
  delete(path, **options)
end
remove_usage(usage_id:, **options) click to toggle source

Delete a usage record.

{developers.recurly.com/api/v2021-02-25#operation/remove_usage remove_usage api documenation}

@param usage_id [String] Usage Record ID. @param params [Hash] Optional query string parameters:

@return [Resources::Empty] Usage was successfully deleted.

# File lib/recurly/client/operations.rb, line 3661
def remove_usage(usage_id:, **options)
  path = interpolate_path("/usage/{usage_id}", usage_id: usage_id)
  delete(path, **options)
end
reopen_invoice(invoice_id:, **options) click to toggle source

Reopen a closed, manual invoice

{developers.recurly.com/api/v2021-02-25#operation/reopen_invoice reopen_invoice api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Invoice] The updated invoice. @example

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
# File lib/recurly/client/operations.rb, line 2207
def reopen_invoice(invoice_id:, **options)
  path = interpolate_path("/invoices/{invoice_id}/reopen", invoice_id: invoice_id)
  put(path, **options)
end
restore_coupon(coupon_id:, body:, **options) click to toggle source

Restore an inactive coupon

{developers.recurly.com/api/v2021-02-25#operation/restore_coupon restore_coupon api documenation}

@param coupon_id [String] Coupon ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-10off. @param body [Requests::CouponUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::Coupon] The restored coupon.

# File lib/recurly/client/operations.rb, line 1554
def restore_coupon(coupon_id:, body:, **options)
  path = interpolate_path("/coupons/{coupon_id}/restore", coupon_id: coupon_id)
  put(path, body, Requests::CouponUpdate, **options)
end
resume_subscription(subscription_id:, **options) click to toggle source

Resume subscription

{developers.recurly.com/api/v2021-02-25#operation/resume_subscription resume_subscription api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Subscription] A subscription. @example

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
# File lib/recurly/client/operations.rb, line 3284
def resume_subscription(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}/resume", subscription_id: subscription_id)
  put(path, **options)
end
terminate_subscription(subscription_id:, **options) click to toggle source

Terminate a subscription

{developers.recurly.com/api/v2021-02-25#operation/terminate_subscription terminate_subscription api documenation}

@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 params [Hash] Optional query string parameters:

     :refund [String] The type of refund to perform:

* +full+ - Performs a full refund of the last invoice for the current subscription term.
* +partial+ - Prorates a refund based on the amount of time remaining in the current bill cycle.
* +none+ - Terminates the subscription without a refund.

In the event that the most recent invoice is a $0 invoice paid entirely by credit, Recurly will apply the credit back to the customer’s account.

You may also terminate a subscription with no refund and then manually refund specific invoices.

     :charge [Boolean] Applicable only if the subscription has usage based add-ons and unbilled usage logged for the current billing cycle. If true, current billing cycle unbilled usage is billed on the final invoice. If false, Recurly will create a negative usage record for current billing cycle usage that will zero out the final invoice line items.

@return [Resources::Subscription] An expired subscription. @example

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
# File lib/recurly/client/operations.rb, line 3178
def terminate_subscription(subscription_id:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}", subscription_id: subscription_id)
  delete(path, **options)
end
update_a_billing_info(account_id:, billing_info_id:, body:, **options) click to toggle source

Update an account's billing information

{developers.recurly.com/api/v2021-02-25#operation/update_a_billing_info update_a_billing_info api documenation}

@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. @param body [Requests::BillingInfoCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoCreate} @param params [Hash] Optional query string parameters:

@return [Resources::BillingInfo] Updated billing information.

# File lib/recurly/client/operations.rb, line 556
def update_a_billing_info(account_id:, billing_info_id:, body:, **options)
  path = interpolate_path("/accounts/{account_id}/billing_infos/{billing_info_id}", account_id: account_id, billing_info_id: billing_info_id)
  put(path, body, Requests::BillingInfoCreate, **options)
end
update_account(account_id:, body:, **options) click to toggle source

Update an account

{developers.recurly.com/api/v2021-02-25#operation/update_account update_account api documenation}

@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::AccountUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AccountUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::Account] An account. @example

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
# File lib/recurly/client/operations.rb, line 222
def update_account(account_id:, body:, **options)
  path = interpolate_path("/accounts/{account_id}", account_id: account_id)
  put(path, body, Requests::AccountUpdate, **options)
end
update_account_acquisition(account_id:, body:, **options) click to toggle source

Update an account's acquisition data

{developers.recurly.com/api/v2021-02-25#operation/update_account_acquisition update_account_acquisition api documenation}

@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::AccountAcquisitionUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AccountAcquisitionUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::AccountAcquisition] An account's updated acquisition data. @example

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
# File lib/recurly/client/operations.rb, line 304
def update_account_acquisition(account_id:, body:, **options)
  path = interpolate_path("/accounts/{account_id}/acquisition", account_id: account_id)
  put(path, body, Requests::AccountAcquisitionUpdate, **options)
end
update_billing_info(account_id:, body:, **options) click to toggle source

Set an account's billing information

{developers.recurly.com/api/v2021-02-25#operation/update_billing_info update_billing_info api documenation}

@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::BillingInfoCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoCreate} @param params [Hash] Optional query string parameters:

@return [Resources::BillingInfo] Updated billing information. @example

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
# File lib/recurly/client/operations.rb, line 427
def update_billing_info(account_id:, body:, **options)
  path = interpolate_path("/accounts/{account_id}/billing_info", account_id: account_id)
  put(path, body, Requests::BillingInfoCreate, **options)
end
update_coupon(coupon_id:, body:, **options) click to toggle source

Update an active coupon

{developers.recurly.com/api/v2021-02-25#operation/update_coupon update_coupon api documenation}

@param coupon_id [String] Coupon ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-10off. @param body [Requests::CouponUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::Coupon] The updated coupon. @example

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
# File lib/recurly/client/operations.rb, line 1501
def update_coupon(coupon_id:, body:, **options)
  path = interpolate_path("/coupons/{coupon_id}", coupon_id: coupon_id)
  put(path, body, Requests::CouponUpdate, **options)
end
update_invoice(invoice_id:, body:, **options) click to toggle source

Update an invoice

{developers.recurly.com/api/v2021-02-25#operation/update_invoice update_invoice api documenation}

@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 body [Requests::InvoiceUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::Invoice] An invoice. @example

begin
  invoice_update = {
    customer_notes: "New Notes",
    terms_and_conditions: "New Terms and Conditions"
  }
  invoice = @client.update_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
# File lib/recurly/client/operations.rb, line 2088
def update_invoice(invoice_id:, body:, **options)
  path = interpolate_path("/invoices/{invoice_id}", invoice_id: invoice_id)
  put(path, body, Requests::InvoiceUpdate, **options)
end
update_item(item_id:, body:, **options) click to toggle source

Update an active item

{developers.recurly.com/api/v2021-02-25#operation/update_item update_item api documenation}

@param item_id [String] Item ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-red. @param body [Requests::ItemUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ItemUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::Item] The updated item. @example

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
# File lib/recurly/client/operations.rb, line 1845
def update_item(item_id:, body:, **options)
  path = interpolate_path("/items/{item_id}", item_id: item_id)
  put(path, body, Requests::ItemUpdate, **options)
end
update_measured_unit(measured_unit_id:, body:, **options) click to toggle source

Update a measured unit

{developers.recurly.com/api/v2021-02-25#operation/update_measured_unit update_measured_unit api documenation}

@param measured_unit_id [String] Measured unit ID or name. For ID no prefix is used e.g. e28zov4fw0v2. For name use prefix name-, e.g. name-Storage. @param body [Requests::MeasuredUnitUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::MeasuredUnitUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::MeasuredUnit] The updated measured_unit.

# File lib/recurly/client/operations.rb, line 1972
def update_measured_unit(measured_unit_id:, body:, **options)
  path = interpolate_path("/measured_units/{measured_unit_id}", measured_unit_id: measured_unit_id)
  put(path, body, Requests::MeasuredUnitUpdate, **options)
end
update_plan(plan_id:, body:, **options) click to toggle source

Update a plan

{developers.recurly.com/api/v2021-02-25#operation/update_plan update_plan api documenation}

@param plan_id [String] Plan ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param body [Requests::PlanUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PlanUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::Plan] A plan. @example

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
# File lib/recurly/client/operations.rb, line 2634
def update_plan(plan_id:, body:, **options)
  path = interpolate_path("/plans/{plan_id}", plan_id: plan_id)
  put(path, body, Requests::PlanUpdate, **options)
end
update_plan_add_on(plan_id:, add_on_id:, body:, **options) click to toggle source

Update an add-on

{developers.recurly.com/api/v2021-02-25#operation/update_plan_add_on update_plan_add_on api documenation}

@param plan_id [String] Plan ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-gold. @param body [Requests::AddOnUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AddOnUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::AddOn] An add-on. @example

begin
  add_on_update = {
    name: "A quality grinder for your finest beans"
  }
  add_on = @client.update_plan_add_on(
    plan_id: plan_id,
    add_on_id: add_on_id,
    body: add_on_update
  )
  puts "Updated 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
# File lib/recurly/client/operations.rb, line 2800
def update_plan_add_on(plan_id:, add_on_id:, body:, **options)
  path = interpolate_path("/plans/{plan_id}/add_ons/{add_on_id}", plan_id: plan_id, add_on_id: add_on_id)
  put(path, body, Requests::AddOnUpdate, **options)
end
update_shipping_address(account_id:, shipping_address_id:, body:, **options) click to toggle source

Update an account's shipping address

{developers.recurly.com/api/v2021-02-25#operation/update_shipping_address update_shipping_address api documenation}

@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 shipping_address_id [String] Shipping Address ID. @param body [Requests::ShippingAddressUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingAddressUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::ShippingAddress] The updated shipping address. @example

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
# File lib/recurly/client/operations.rb, line 1138
def update_shipping_address(account_id:, shipping_address_id:, body:, **options)
  path = interpolate_path("/accounts/{account_id}/shipping_addresses/{shipping_address_id}", account_id: account_id, shipping_address_id: shipping_address_id)
  put(path, body, Requests::ShippingAddressUpdate, **options)
end
update_shipping_method(shipping_method_id:, body:, **options) click to toggle source

Update an active Shipping Method

{developers.recurly.com/api/v2021-02-25#operation/update_shipping_method update_shipping_method api documenation}

@param shipping_method_id [String] Shipping Method ID or code. For ID no prefix is used e.g. e28zov4fw0v2. For code use prefix code-, e.g. code-usps_2-day. @param body [Requests::ShippingMethodUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingMethodUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::ShippingMethod] The updated shipping method.

# File lib/recurly/client/operations.rb, line 2988
def update_shipping_method(shipping_method_id:, body:, **options)
  path = interpolate_path("/shipping_methods/{shipping_method_id}", shipping_method_id: shipping_method_id)
  put(path, body, Requests::ShippingMethodUpdate, **options)
end
update_subscription(subscription_id:, body:, **options) click to toggle source

Update a subscription

{developers.recurly.com/api/v2021-02-25#operation/update_subscription update_subscription api documenation}

@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 body [Requests::SubscriptionUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionUpdate} @param params [Hash] Optional query string parameters:

@return [Resources::Subscription] A subscription. @example

begin
  subscription_update = {
    customer_notes: "New Notes",
    terms_and_conditions: "New ToC"
  }
  subscription = @client.update_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
# File lib/recurly/client/operations.rb, line 3142
def update_subscription(subscription_id:, body:, **options)
  path = interpolate_path("/subscriptions/{subscription_id}", subscription_id: subscription_id)
  put(path, body, Requests::SubscriptionUpdate, **options)
end
update_usage(usage_id:, body:, **options) click to toggle source

Update a usage record

{developers.recurly.com/api/v2021-02-25#operation/update_usage update_usage api documenation}

@param usage_id [String] Usage Record ID. @param body [Requests::UsageCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::UsageCreate} @param params [Hash] Optional query string parameters:

@return [Resources::Usage] The updated usage record.

# File lib/recurly/client/operations.rb, line 3647
def update_usage(usage_id:, body:, **options)
  path = interpolate_path("/usage/{usage_id}", usage_id: usage_id)
  put(path, body, Requests::UsageCreate, **options)
end
verify_billing_info(account_id:, **options) click to toggle source

Verify an account's credit card billing information

{developers.recurly.com/api/v2021-02-25#operation/verify_billing_info verify_billing_info api documenation}

@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 params [Hash] Optional query string parameters:

:body [Requests::BillingInfoVerify] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoVerify}

@return [Resources::Transaction] Transaction information from verify. @example

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
# File lib/recurly/client/operations.rb, line 474
def verify_billing_info(account_id:, **options)
  path = interpolate_path("/accounts/{account_id}/billing_info/verify", account_id: account_id)
  post(path, options[:body], Requests::BillingInfoVerify, **options)
end
void_invoice(invoice_id:, **options) click to toggle source

Void a credit invoice.

{developers.recurly.com/api/v2021-02-25#operation/void_invoice void_invoice api documenation}

@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 params [Hash] Optional query string parameters:

@return [Resources::Invoice] The updated invoice. @example

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
# File lib/recurly/client/operations.rb, line 2230
def void_invoice(invoice_id:, **options)
  path = interpolate_path("/invoices/{invoice_id}/void", invoice_id: invoice_id)
  put(path, **options)
end

Protected Instance Methods

delete(path, **options) click to toggle source
# File lib/recurly/client.rb, line 143
def delete(path, **options)
  validate_options!(**options)
  request = Net::HTTP::Delete.new build_url(path, options)
  set_headers(request, options[:headers])
  http_response = run_request(request, options)
  handle_response! request, http_response
end
get(path, **options) click to toggle source
# File lib/recurly/client.rb, line 108
def get(path, **options)
  validate_options!(**options)
  request = Net::HTTP::Get.new build_url(path, options)
  set_headers(request, options[:headers])
  http_response = run_request(request, options)
  handle_response! request, http_response
end
head(path, **options) click to toggle source
# File lib/recurly/client.rb, line 100
def head(path, **options)
  validate_options!(**options)
  request = Net::HTTP::Head.new build_url(path, options)
  set_headers(request, options[:headers])
  http_response = run_request(request, options)
  handle_response! request, http_response
end
pager(path, **options) click to toggle source
# File lib/recurly/client.rb, line 92
def pager(path, **options)
  Pager.new(
    client: self,
    path: path,
    options: options,
  )
end
post(path, request_data = nil, request_class = nil, **options) click to toggle source
# File lib/recurly/client.rb, line 116
def post(path, request_data = nil, request_class = nil, **options)
  validate_options!(**options)
  request = Net::HTTP::Post.new build_url(path, options)
  request.set_content_type(JSON_CONTENT_TYPE)
  set_headers(request, options[:headers])
  if request_data
    request_class.new(request_data).validate!
    request.body = JSON.dump(request_data)
  end
  http_response = run_request(request, options)
  handle_response! request, http_response
end
put(path, request_data = nil, request_class = nil, **options) click to toggle source
# File lib/recurly/client.rb, line 129
def put(path, request_data = nil, request_class = nil, **options)
  validate_options!(**options)
  request = Net::HTTP::Put.new build_url(path, options)
  request.set_content_type(JSON_CONTENT_TYPE)
  set_headers(request, options[:headers])
  if request_data
    request_class.new(request_data).validate!
    json_body = JSON.dump(request_data)
    request.body = json_body
  end
  http_response = run_request(request, options)
  handle_response! request, http_response
end

Private Instance Methods

build_url(path, options) click to toggle source
# File lib/recurly/client.rb, line 341
def build_url(path, options)
  path = scope_by_site(path, options)
  query_params = map_array_params(options.fetch(:params, {}))
  if query_params.any?
    "#{path}?#{URI.encode_www_form(query_params)}"
  else
    path
  end
end
generate_idempotency_key(n = 16) click to toggle source

from github.com/rails/rails/blob/6-0-stable/activesupport/lib/active_support/core_ext/securerandom.rb

# File lib/recurly/client.rb, line 236
def generate_idempotency_key(n = 16)
  SecureRandom.random_bytes(n).unpack("C*").map do |byte|
    idx = byte % 64
    idx = SecureRandom.random_number(36) if idx >= 36
    BASE36_ALPHABET[idx]
  end.join
end
handle_response!(request, http_response) click to toggle source
# File lib/recurly/client.rb, line 249
def handle_response!(request, http_response)
  response = HTTP::Response.new(http_response, request)
  raise_api_error!(http_response, response) unless http_response.kind_of?(Net::HTTPSuccess)
  resource = if response.body
      if http_response.content_type&.include?(JSON_CONTENT_TYPE)
        JSONParser.parse(self, response.body)
      elsif BINARY_TYPES.include?(http_response.content_type)
        FileParser.parse(response.body)
      else
        raise Recurly::Errors::InvalidContentTypeError, "Unexpected content type: #{http_response.content_type}"
      end
    else
      Resources::Empty.new
    end
  # Keep this interface "private"
  resource.instance_variable_set(:@response, response)
  resource
end
interpolate_path(path, **options) click to toggle source
# File lib/recurly/client.rb, line 327
def interpolate_path(path, **options)
  validate_path_parameters!(**options)
  options.each do |k, v|
    # We need to encode the values for the url
    options[k] = ERB::Util.url_encode(v.to_s)
  end
  path = path.gsub("{", "%{")
  path % options
end
map_array_params(params) click to toggle source

Converts array parameters to CSV strings to maintain consistency with how the server expects the request to be formatted while providing the developer with an array type to maintain developer happiness!

# File lib/recurly/client.rb, line 354
def map_array_params(params)
  params.map do |key, param|
    [key, param.is_a?(Array) ? param.join(",") : param]
  end.to_h
end
raise_api_error!(http_response, response) click to toggle source
# File lib/recurly/client.rb, line 268
def raise_api_error!(http_response, response)
  if response.content_type.include?(JSON_CONTENT_TYPE)
    error = JSONParser.parse(self, response.body)
    begin
      error_class = Errors::APIError.error_class(error.type)
      raise error_class.new(error.message, response, error)
    rescue NameError
      error_class = Errors::APIError.from_response(http_response)
      raise error_class.new("Unknown Error", response, error)
    end
  end

  error_class = Errors::APIError.from_response(http_response)

  if error_class <= Recurly::Errors::APIError
    error = Recurly::Resources::Error.new(message: "#{http_response.code}: #{http_response.message}")
    raise error_class.new(error.message, response, error)
  else
    raise error_class, "#{http_response.code}: #{http_response.message}"
  end
end
read_headers(response) click to toggle source
# File lib/recurly/client.rb, line 290
def read_headers(response)
  if !@_ignore_deprecation_warning && response.headers["Recurly-Deprecated"]&.upcase == "TRUE"
    log_warn("DEPRECTATION WARNING", message: "Your current API version \"#{api_version}\" is deprecated and will be sunset on #{response.headers["Recurly-Sunset-Date"]}")
  end
  response
end
run_request(request, options = {}) click to toggle source
# File lib/recurly/client.rb, line 160
def run_request(request, options = {})
  self.class.connection_pool.with_connection do |http|
    set_http_options(http, options)

    retries = 0

    begin
      http.start unless http.started?
      log_attrs = {
        method: request.method,
        path: request.path,
      }
      if @logger.level < Logger::INFO
        log_attrs[:request_body] = request.body
        # No need to log the authorization header
        headers = request.to_hash.reject { |k, _| k&.downcase == "authorization" }
        log_attrs[:request_headers] = headers
      end

      log_info("Request", **log_attrs)
      start = Time.now
      response = http.request(request)
      elapsed = Time.now - start

      # GETs are safe to retry after a server error, requests with an Idempotency-Key will return the prior response
      if response.kind_of?(Net::HTTPServerError) && request.is_a?(Net::HTTP::Get)
        retries += 1
        log_info("Retrying", retries: retries, **log_attrs)
        start = Time.now
        response = http.request(request) if retries < MAX_RETRIES
        elapsed = Time.now - start
      end

      if @logger.level < Logger::INFO
        log_attrs[:response_body] = response.body
        log_attrs[:response_headers] = response.to_hash
      end
      log_info("Response", time_ms: (elapsed * 1_000).floor, status: response.code, **log_attrs)

      response
    rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ECONNABORTED,
           Errno::EPIPE, Errno::ETIMEDOUT, Net::OpenTimeout, EOFError, SocketError => ex
      retries += 1
      if retries < MAX_RETRIES
        retry
      end

      if ex.kind_of?(Net::OpenTimeout) || ex.kind_of?(Errno::ETIMEDOUT)
        raise Recurly::Errors::TimeoutError, "Request timed out"
      end

      raise Recurly::Errors::ConnectionFailedError, "Failed to connect to Recurly: #{ex.message}"
    rescue Timeout::Error
      raise Recurly::Errors::TimeoutError, "Request timed out"
    rescue OpenSSL::SSL::SSLError => ex
      raise Recurly::Errors::SSLError, ex.message
    rescue StandardError => ex
      raise Recurly::Errors::NetworkError, ex.message
    end
  end
end
scope_by_site(path, options) click to toggle source
# File lib/recurly/client.rb, line 360
def scope_by_site(path, options)
  if site = site_id || options[:site_id]
    # Ensure that we are only including the site_id once because the Pager operations
    # will use the cursor returned from the API which may already have these components
    path.start_with?("/sites/#{site}") ? path : "/sites/#{site}#{path}"
  else
    path
  end
end
set_api_key(api_key) click to toggle source
# File lib/recurly/client.rb, line 337
def set_api_key(api_key)
  @api_key = api_key.to_s
end
set_headers(request, additional_headers = {}) click to toggle source
# File lib/recurly/client.rb, line 222
def set_headers(request, additional_headers = {})
  # TODO this is undocumented until we finalize it
  additional_headers.each { |header, v| request[header] = v } if additional_headers

  request["Accept"] = "application/vnd.recurly.#{api_version}".chomp # got this method from operations.rb
  request["Authorization"] = "Basic #{Base64.encode64(@api_key)}".chomp
  request["User-Agent"] = "Recurly/#{VERSION}; #{RUBY_DESCRIPTION}"

  unless request.is_a?(Net::HTTP::Get) || request.is_a?(Net::HTTP::Head)
    request["Idempotency-Key"] ||= generate_idempotency_key
  end
end
set_http_options(http, options) click to toggle source
# File lib/recurly/client.rb, line 244
def set_http_options(http, options)
  http.open_timeout = options[:open_timeout] || 20
  http.read_timeout = options[:read_timeout] || 60
end
validate_options!(**options) click to toggle source
# File lib/recurly/client.rb, line 297
def validate_options!(**options)
  invalid_options = options.keys.reject do |k|
    ALLOWED_OPTIONS.include?(k)
  end
  if invalid_options.any?
    joinedKeys = invalid_options.join(", ")
    joinedOptions = ALLOWED_OPTIONS.join(", ")
    raise ArgumentError, "Invalid options: '#{joinedKeys}'. Allowed options: '#{joinedOptions}'"
  end
end
validate_path_parameters!(**options) click to toggle source
# File lib/recurly/client.rb, line 308
def validate_path_parameters!(**options)
  # Check to see that we are passing the correct data types
  # This prevents a confusing error if the user passes in a non-primitive by mistake
  options.each do |k, v|
    unless [String, Symbol, Integer, Float].include?(v.class)
      message = "We cannot build the url with the given argument #{k}=#{v.inspect}."
      if k =~ /_id$/
        message << " Since this appears to be an id, perhaps you meant to pass in a String?"
      end
      raise ArgumentError, message
    end
  end
  # Check to make sure that parameters are not empty string values
  empty_strings = options.select { |_, v| v.is_a?(String) && v.strip.empty? }
  if empty_strings.any?
    raise ArgumentError, "#{empty_strings.keys.join(", ")} cannot be an empty string"
  end
end