Class: JeraPayment::Api::Iugu::Subscription

Inherits:
Base
  • Object
show all
Defined in:
lib/jera_payment/api/iugu/subscription.rb

Constant Summary collapse

BASE_ENDPOINT =
'subscriptions'

Class Method Summary collapse

Methods inherited from Base

delete, ensure_account_access_token, get, parse_response, post, put, set_headers

Class Method Details

.activate(id, access_token = nil) ⇒ Object



11
12
13
14
15
# File 'lib/jera_payment/api/iugu/subscription.rb', line 11

def self.activate(id, access_token = nil)
  url = "#{BASE_ENDPOINT}/#{id}/activate"

  response = post(url, nil, access_token)
end

.add_credits(id, body = {}, access_token = nil) ⇒ Object



35
36
37
38
39
# File 'lib/jera_payment/api/iugu/subscription.rb', line 35

def self.add_credits(id, body = {}, access_token = nil)
  url = "#{BASE_ENDPOINT}/#{id}/add_credits"

  response = put(url, body, access_token)
end

.change_plan(id, plan_identifier, access_token = nil) ⇒ Object



29
30
31
32
33
# File 'lib/jera_payment/api/iugu/subscription.rb', line 29

def self.change_plan(id, plan_identifier, access_token = nil)
  url = "#{BASE_ENDPOINT}/#{id}/change_plan/#{plan_identifier}"

  response = post(url, nil, access_token)
end

.change_plan_simulation(id, plan_identifier, access_token = nil) ⇒ Object



23
24
25
26
27
# File 'lib/jera_payment/api/iugu/subscription.rb', line 23

def self.change_plan_simulation(id, plan_identifier, access_token = nil)
  url = "#{BASE_ENDPOINT}/#{id}/change_plan_simulation/#{plan_identifier}"

  response = get(url, nil, access_token)
end

.create(body = {}, access_token = nil) ⇒ Object



7
8
9
# File 'lib/jera_payment/api/iugu/subscription.rb', line 7

def self.create(body = {}, access_token = nil)
  response = post(BASE_ENDPOINT, body, access_token)
end

.destroy(id, access_token = nil) ⇒ Object



53
54
55
56
57
# File 'lib/jera_payment/api/iugu/subscription.rb', line 53

def self.destroy(id, access_token = nil)
  url = "#{BASE_ENDPOINT}/#{id}"

  response = delete(url, access_token)
end

.index(query = nil, access_token = nil) ⇒ Object



65
66
67
# File 'lib/jera_payment/api/iugu/subscription.rb', line 65

def self.index(query = nil, access_token = nil)
  response = get(BASE_ENDPOINT, query, access_token)
end

.remove_credits(id, body = {}, access_token = nil) ⇒ Object



41
42
43
44
45
# File 'lib/jera_payment/api/iugu/subscription.rb', line 41

def self.remove_credits(id, body = {}, access_token = nil)
  url = "#{BASE_ENDPOINT}/#{id}/remove_credits"

  response = put(url, body, access_token)
end

.show(id, access_token = nil) ⇒ Object



59
60
61
62
63
# File 'lib/jera_payment/api/iugu/subscription.rb', line 59

def self.show(id, access_token = nil)
  url = "#{BASE_ENDPOINT}/#{id}"

  response = get(url, nil, access_token)
end

.suspend(id, access_token = nil) ⇒ Object



17
18
19
20
21
# File 'lib/jera_payment/api/iugu/subscription.rb', line 17

def self.suspend(id, access_token = nil)
  url = "#{BASE_ENDPOINT}/#{id}/suspend"

  response = post(url, nil, access_token)
end

.update(id, body = {}, access_token = nil) ⇒ Object



47
48
49
50
51
# File 'lib/jera_payment/api/iugu/subscription.rb', line 47

def self.update(id, body = {}, access_token = nil)
  url = "#{BASE_ENDPOINT}/#{id}"

  response = put(url, body, access_token)
end