Module: Recurly

Defined in:
lib/recurly.rb,
lib/recurly/js.rb,
lib/recurly/api.rb,
lib/recurly/xml.rb,
lib/recurly/plan.rb,
lib/recurly/error.rb,
lib/recurly/money.rb,
lib/recurly/usage.rb,
lib/rails/recurly.rb,
lib/recurly/add_on.rb,
lib/recurly/coupon.rb,
lib/recurly/helper.rb,
lib/recurly/address.rb,
lib/recurly/version.rb,
lib/recurly/invoice.rb,
lib/recurly/webhook.rb,
lib/recurly/account.rb,
lib/recurly/delivery.rb,
lib/recurly/resource.rb,
lib/recurly/xml/rexml.rb,
lib/recurly/gift_card.rb,
lib/recurly/adjustment.rb,
lib/recurly/api/errors.rb,
lib/recurly/redemption.rb,
lib/recurly/tax_detail.rb,
lib/recurly/transaction.rb,
lib/recurly/subscription.rb,
lib/recurly/billing_info.rb,
lib/recurly/xml/nokogiri.rb,
lib/recurly/measured_unit.rb,
lib/recurly/resource/pager.rb,
lib/recurly/account_balance.rb,
lib/recurly/resource/errors.rb,
lib/recurly/shipping_address.rb,
lib/recurly/transaction/errors.rb,
lib/recurly/subscription_add_on.rb,
lib/recurly/subscription/add_ons.rb,
lib/recurly/resource/association.rb,
lib/recurly/api/net_http_adapter.rb,
lib/recurly/webhook/notification.rb,
lib/recurly/webhook/account_notification.rb,
lib/recurly/webhook/invoice_notification.rb,
lib/recurly/webhook/new_invoice_notification.rb,
lib/recurly/webhook/new_account_notification.rb,
lib/recurly/webhook/transaction_notification.rb,
lib/recurly/webhook/subscription_notification.rb,
lib/recurly/webhook/void_payment_notification.rb,
lib/rails/generators/recurly/config_generator.rb,
lib/recurly/webhook/failed_payment_notification.rb,
lib/recurly/webhook/closed_invoice_notification.rb,
lib/recurly/webhook/new_subscription_notification.rb,
lib/recurly/webhook/past_due_invoice_notification.rb,
lib/recurly/webhook/canceled_account_notification.rb,
lib/recurly/webhook/scheduled_payment_notification.rb,
lib/recurly/webhook/successful_refund_notification.rb,
lib/recurly/webhook/successful_payment_notification.rb,
lib/recurly/webhook/processing_invoice_notification.rb,
lib/recurly/webhook/processing_payment_notification.rb,
lib/recurly/webhook/reactivated_account_notification.rb,
lib/recurly/webhook/billing_info_updated_notification.rb,
lib/recurly/webhook/renewed_subscription_notification.rb,
lib/recurly/webhook/expired_subscription_notification.rb,
lib/recurly/webhook/updated_subscription_notification.rb,
lib/recurly/webhook/canceled_subscription_notification.rb

Overview

Recurly is a Ruby client for Recurly's REST API.

Defined Under Namespace

Modules: Helper, JS, Version, Webhook Classes: API, Account, AccountBalance, AddOn, Address, Adjustment, BillingInfo, ConfigGenerator, ConfigurationError, Coupon, Delivery, Error, GiftCard, Invoice, MeasuredUnit, Money, Plan, Railtie, Redemption, Resource, ShippingAddress, Subscription, SubscriptionAddOn, TaxDetail, Transaction, Usage, XML

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.api_keyString

Returns An API key.

Returns:

  • (String)

    An API key.

Raises:



59
60
61
62
63
64
65
66
67
# File 'lib/recurly.rb', line 59

def api_key
  if Thread.current[:recurly_config] && Thread.current[:recurly_config][:api_key]
    return Thread.current[:recurly_config][:api_key]
  end

  defined? @api_key and @api_key or raise(
    ConfigurationError, "Recurly.api_key not configured"
  )
end

.default_currencyString?

Returns A default currency.

Returns:

  • (String, nil)

    A default currency.



71
72
73
74
75
76
77
78
# File 'lib/recurly.rb', line 71

def default_currency
  if Thread.current[:recurly_config] &&  Thread.current[:recurly_config][:default_currency]
    return Thread.current[:recurly_config][:default_currency]
  end

  return  @default_currency if defined? @default_currency
  @default_currency = 'USD'
end

.loggerLogger?

Assigns a logger to log requests/responses and more.

Examples:

require 'logger'
Recurly.logger = Logger.new STDOUT

Rails applications automatically log to the Rails log:

Recurly.logger = Rails.logger

Turn off logging entirely:

Recurly.logger = nil # Or Recurly.logger = Logger.new nil

Returns:

  • (Logger, nil)


96
97
98
# File 'lib/recurly.rb', line 96

def logger
  @logger
end

.subdomainString

Returns A subdomain.

Returns:

  • (String)

    A subdomain.



49
50
51
52
53
54
# File 'lib/recurly.rb', line 49

def subdomain
  if Thread.current[:recurly_config] && Thread.current[:recurly_config][:subdomain]
    return Thread.current[:recurly_config][:subdomain]
  end
  @subdomain || 'api'
end

Class Method Details

.config(config_params = nil) ⇒ Object

Set a config based on current thread context. Any default set will say in effect unless overwritten in the config_params. Call this method with out any arguments to have it unset the thread context config values.

Parameters:

  • config_params (defaults to: nil)
    • Hash with the following keys: subdomain, api_key, default_currency



44
45
46
# File 'lib/recurly.rb', line 44

def config(config_params = nil)
  Thread.current[:recurly_config] = config_params
end

.jsJS

Returns The Recurly.js module.

Returns:

  • (JS)

    The Recurly.js module.



82
83
84
# File 'lib/recurly.rb', line 82

def js
  JS
end

.log(level, message) ⇒ true?

Convenience logging method includes a Logger#progname dynamically.

Returns:

  • (true, nil)


100
101
102
# File 'lib/recurly.rb', line 100

def log level, message
  logger.send(level, name) { message }
end

Instance Method Details

#const_defined?(sym, inherit = false) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


105
106
107
108
# File 'lib/recurly.rb', line 105

def const_defined? sym, inherit = false
  raise ArgumentError, "inherit must be false" if inherit
  super sym
end

#const_get(sym, inherit = false) ⇒ Object

Raises:

  • (ArgumentError)


110
111
112
113
# File 'lib/recurly.rb', line 110

def const_get sym, inherit = false
  raise ArgumentError, "inherit must be false" if inherit
  super sym
end