Class: Iugu::Api::Subscription

Inherits:
IuguResource
  • Object
show all
Defined in:
lib/iugu-api/models/subscription.rb

Instance Method Summary collapse

Methods inherited from IuguResource

#build_options, find, #to_json, #to_xml, #virtual_attributes

Instance Method Details

#activateObject



10
11
12
# File 'lib/iugu-api/models/subscription.rb', line 10

def activate
  toggle_activation
end

#change_plan(plan_identifier) ⇒ Object

Raises:

  • (ActiveResource::ResourceNotFound)


14
15
16
17
18
19
# File 'lib/iugu-api/models/subscription.rb', line 14

def change_plan(plan_identifier)
  response = connection.post(Subscription.prefix + "subscriptions/#{self.id.to_param}/change_plan/#{plan_identifier}")
  raise ActiveResource::ResourceNotFound.new("Not Found") if response.body == 'null'
  raise ActiveResource::ResourceInvalid if JSON.parse(response.body)["errors"]
  true
end

#suspendObject



6
7
8
# File 'lib/iugu-api/models/subscription.rb', line 6

def suspend
  toggle_activation false
end