Class: Spreedly::SubscriptionPlan

Inherits:
Resource
  • Object
show all
Defined in:
lib/spreedly.rb,
lib/spreedly/mock.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

attributes, attributes=, #id, #initialize, #method_missing

Constructor Details

This class inherits a constructor from Spreedly::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Spreedly::Resource

Class Method Details

.allObject

Returns all of the subscription plans defined in your site.



205
206
207
# File 'lib/spreedly.rb', line 205

def self.all
  Spreedly.get('/subscription_plans.xml')['subscription_plans'].collect{|data| new(data)}
end

.find(id) ⇒ Object

Returns the subscription plan with the given id.



210
211
212
# File 'lib/spreedly.rb', line 210

def self.find(id)
  all.detect{|e| e.id.to_s == id.to_s}
end

.plansObject



150
151
152
153
154
155
156
# File 'lib/spreedly/mock.rb', line 150

def self.plans
  @plans ||= {
    1 => new(:id => 1, :name => 'Default mock plan', :duration_quantity => 1, :duration_units => 'days'),
    2 => new(:id => 2, :name => 'Test Free Trial Plan', :plan_type => 'free_trial', :duration_quantity => 1, :duration_units => 'days'),
    3 => new(:id => 3, :name => 'Test Regular Plan', :duration_quantity => 1, :duration_units => 'days'),
  }
end

Instance Method Details

#trial?Boolean

Convenience method for determining if this plan is a free trial plan or not.

Returns:

  • (Boolean)


215
216
217
# File 'lib/spreedly.rb', line 215

def trial?
  (plan_type == 'free_trial')
end