Module: Recurly

Defined in:
lib/recurly.rb,
lib/recurly/js.rb,
lib/recurly/api.rb,
lib/recurly/xml.rb,
lib/recurly/plan.rb,
lib/rails/recurly.rb,
lib/recurly/error.rb,
lib/recurly/money.rb,
lib/recurly/usage.rb,
lib/recurly/add_on.rb,
lib/recurly/coupon.rb,
lib/recurly/helper.rb,
lib/recurly/account.rb,
lib/recurly/address.rb,
lib/recurly/invoice.rb,
lib/recurly/version.rb,
lib/recurly/webhook.rb,
lib/recurly/delivery.rb,
lib/recurly/resource.rb,
lib/recurly/tax_type.rb,
lib/recurly/gift_card.rb,
lib/recurly/xml/rexml.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/billing_info.rb,
lib/recurly/juris_detail.rb,
lib/recurly/subscription.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/api/net_http_adapter.rb,
lib/recurly/resource/association.rb,
lib/recurly/subscription/add_ons.rb,
lib/recurly/webhook/notification.rb,
lib/recurly/webhook/account_notification.rb,
lib/recurly/webhook/dunning_notification.rb,
lib/recurly/webhook/invoice_notification.rb,
lib/recurly/webhook/new_account_notification.rb,
lib/recurly/webhook/new_invoice_notification.rb,
lib/recurly/webhook/transaction_notification.rb,
lib/rails/generators/recurly/config_generator.rb,
lib/recurly/webhook/subscription_notification.rb,
lib/recurly/webhook/void_payment_notification.rb,
lib/recurly/webhook/closed_invoice_notification.rb,
lib/recurly/webhook/failed_payment_notification.rb,
lib/recurly/webhook/canceled_account_notification.rb,
lib/recurly/webhook/new_subscription_notification.rb,
lib/recurly/webhook/past_due_invoice_notification.rb,
lib/recurly/webhook/new_dunning_event_notification.rb,
lib/recurly/webhook/scheduled_payment_notification.rb,
lib/recurly/webhook/successful_refund_notification.rb,
lib/recurly/webhook/processing_invoice_notification.rb,
lib/recurly/webhook/processing_payment_notification.rb,
lib/recurly/webhook/successful_payment_notification.rb,
lib/recurly/webhook/reactivated_account_notification.rb,
lib/recurly/webhook/billing_info_updated_notification.rb,
lib/recurly/webhook/expired_subscription_notification.rb,
lib/recurly/webhook/renewed_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, JurisDetail, MeasuredUnit, Money, Plan, Railtie, Redemption, Resource, ShippingAddress, Subscription, SubscriptionAddOn, TaxDetail, TaxType, Transaction, Usage, XML

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.api_keyString

Returns An API key.

Raises:



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

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?



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

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


98
99
100
# File 'lib/recurly.rb', line 98

def logger
  @logger
end

.subdomainString



51
52
53
54
55
56
# File 'lib/recurly.rb', line 51

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.



46
47
48
# File 'lib/recurly.rb', line 46

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

.jsJS



84
85
86
# File 'lib/recurly.rb', line 84

def js
  JS
end

.log(level, message) ⇒ true?

Convenience logging method includes a Logger#progname dynamically.



102
103
104
# File 'lib/recurly.rb', line 102

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

Instance Method Details

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

Raises:

  • (ArgumentError)


107
108
109
110
# File 'lib/recurly.rb', line 107

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)


112
113
114
115
# File 'lib/recurly.rb', line 112

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