Class: RSpreedly::SubscriptionPlan

Inherits:
Base
  • Object
show all
Defined in:
lib/rspreedly/subscription_plan.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#errors

Class Method Summary collapse

Methods inherited from Base

api_request, #api_request, #attributes=, do_request, #initialize, #to_xml

Constructor Details

This class inherits a constructor from RSpreedly::Base

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def amount
  @amount
end

#charge_after_first_periodObject

Returns the value of attribute charge_after_first_period.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def charge_after_first_period
  @charge_after_first_period
end

#charge_later_duration_quantityObject

Returns the value of attribute charge_later_duration_quantity.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def charge_later_duration_quantity
  @charge_later_duration_quantity
end

#charge_later_duration_unitsObject

Returns the value of attribute charge_later_duration_units.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def charge_later_duration_units
  @charge_later_duration_units
end

#created_atObject

Returns the value of attribute created_at.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def created_at
  @created_at
end

#currency_codeObject

Returns the value of attribute currency_code.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def currency_code
  @currency_code
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def description
  @description
end

#duration_quantityObject

Returns the value of attribute duration_quantity.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def duration_quantity
  @duration_quantity
end

#duration_unitsObject

Returns the value of attribute duration_units.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def duration_units
  @duration_units
end

#enabledObject

Returns the value of attribute enabled.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def enabled
  @enabled
end

#feature_levelObject

Returns the value of attribute feature_level.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def feature_level
  @feature_level
end

#force_recurringObject

Returns the value of attribute force_recurring.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def force_recurring
  @force_recurring
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def name
  @name
end

#needs_to_be_renewedObject

Returns the value of attribute needs_to_be_renewed.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def needs_to_be_renewed
  @needs_to_be_renewed
end

#plan_typeObject

Returns the value of attribute plan_type.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def plan_type
  @plan_type
end

#priceObject

Returns the value of attribute price.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def price
  @price
end

#return_urlObject

Returns the value of attribute return_url.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def return_url
  @return_url
end

#termsObject

Returns the value of attribute terms.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def terms
  @terms
end

#updated_atObject

Returns the value of attribute updated_at.



5
6
7
# File 'lib/rspreedly/subscription_plan.rb', line 5

def updated_at
  @updated_at
end

Class Method Details

.activeObject

Get a list of all active subscription plans (more) GET /api/v4/[short site name]/subscription_plans.xml



42
43
44
# File 'lib/rspreedly/subscription_plan.rb', line 42

def self.active
  all.reject { |plan| !plan.enabled }
end

.allObject

Get a list of all subscription plans (more) GET /api/v4/[short site name]/subscription_plans.xml



34
35
36
37
38
# File 'lib/rspreedly/subscription_plan.rb', line 34

def self.all
  response = api_request(:get, "/subscription_plans.xml")
  return [] unless response.has_key?("subscription_plans")
  response["subscription_plans"].collect{|data| SubscriptionPlan.new(data)}
end

.find(id) ⇒ Object

there’s no API method for just getting one plan, so we fake it!



27
28
29
30
# File 'lib/rspreedly/subscription_plan.rb', line 27

def self.find(id)
  return all if id == :all
  all.find{|plan| plan.id == id.to_i}
end