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/purchase.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/updated_account_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, Purchase, 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.

Returns:

  • (String)

    An API key.

Raises:



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

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.



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

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)


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

def logger
  @logger
end

.subdomainString

Returns A subdomain.

Returns:

  • (String)

    A subdomain.



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

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



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

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

.jsJS

Returns The Recurly.js module.

Returns:

  • (JS)

    The Recurly.js module.



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

def js
  JS
end

.log(level, message) ⇒ true?

Convenience logging method includes a Logger#progname dynamically.

Returns:

  • (true, nil)


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

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

Instance Method Details

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

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


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

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)


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

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