Class: Subscriptions

Inherits:
OpenPayResource show all
Defined in:
lib/openpay/subscriptions.rb

Instance Attribute Summary

Attributes inherited from OpenPayResource

#api_hook

Instance Method Summary collapse

Methods inherited from OpenPayResource

#env, #errors?, #get_with_custom_url, #hash2json, #initialize, #json2hash, #post, #put

Constructor Details

This class inherits a constructor from OpenPayResource

Instance Method Details

#all(customer_id) ⇒ Object



20
21
22
23
# File 'lib/openpay/subscriptions.rb', line 20

def all(customer_id)
  customers=@api_hook.create(:customers)
  customers.all_subscriptions(customer_id)
end

#create(subscription, customer_id) ⇒ Object



5
6
7
8
# File 'lib/openpay/subscriptions.rb', line 5

def create(subscription, customer_id)
  customers=@api_hook.create(:customers)
  customers.create_subscription(subscription, customer_id)
end

#delete(subscription_id, customer_id) ⇒ Object



10
11
12
13
# File 'lib/openpay/subscriptions.rb', line 10

def delete(subscription_id, customer_id)
  customers=@api_hook.create(:customers)
  customers.delete_subscription(customer_id, subscription_id)
end

#delete_all(customer_id) ⇒ Object



46
47
48
49
# File 'lib/openpay/subscriptions.rb', line 46

def delete_all(customer_id)
  customers=@api_hook.create(:customers)
  customers.delete_all_subscriptions(customer_id)
end

#each(customer_id) ⇒ Object



25
26
27
28
29
30
# File 'lib/openpay/subscriptions.rb', line 25

def each(customer_id)
  customers=@api_hook.create(:customers)
  customers.each_subscription(customer_id) do |c|
    yield c
  end
end

#get(subscription_id, customer_id) ⇒ Object



15
16
17
18
# File 'lib/openpay/subscriptions.rb', line 15

def get(subscription_id, customer_id)
  customers=@api_hook.create(:customers)
  customers.get_subscription(customer_id, subscription_id)
end

#list(search_params, customer_id = nil) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/openpay/subscriptions.rb', line 32

def list(search_params,customer_id=nil)
  if customer_id
    customers=@api_hook.create(:customers)
    customers.list_subscriptions(customer_id,search_params)
  else
    super search_params
  end
end

#update(subscription_id, customer_id, params) ⇒ Object



41
42
43
44
# File 'lib/openpay/subscriptions.rb', line 41

def update(subscription_id,customer_id,params)
  customers=@api_hook.create(:customers)
  customers.update_subscription(subscription_id,customer_id,params)
end