Class: Versapay::DebitAgreement

Inherits:
Object
  • Object
show all
Defined in:
lib/versapay/debit_agreement.rb

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ DebitAgreement

Returns a new instance of DebitAgreement.

Yields:

  • (_self)

Yield Parameters:



6
7
8
# File 'lib/versapay/debit_agreement.rb', line 6

def initialize(&block)
  yield self if block_given?
end

Instance Method Details

#approve(token, fund_token = nil) ⇒ Object



29
30
31
32
# File 'lib/versapay/debit_agreement.rb', line 29

def approve(token, fund_token = nil)
  args = fund_token.nil? ? {} : { :fund_token => fund_token }
  Versapay::make_request(:post, "/api/debit_agreements/#{token}/approve.json", args)
end

#cancelObject



39
40
41
# File 'lib/versapay/debit_agreement.rb', line 39

def cancel
  Versapay::make_request(:post, "/api/debit_agreements/#{token}/reject.json", {})
end

#create(email, reference = nil, message = nil) ⇒ Object



10
11
12
13
# File 'lib/versapay/debit_agreement.rb', line 10

def create(email, reference = nil, message = nil)
  args = { "email" => email, "reference" => email, "message" => message }
  Versapay::make_request(:post, "/api/debit_agreements.json", args)
end

#list_received(page = nil) ⇒ Object



20
21
22
23
# File 'lib/versapay/debit_agreement.rb', line 20

def list_received(page = nil)
  args = page.nil? ? {} : { :page => page }
  Versapay::make_request(:get, "/api/debit_agreements/received.json", args)
end

#list_sent(page = nil) ⇒ Object



15
16
17
18
# File 'lib/versapay/debit_agreement.rb', line 15

def list_sent(page = nil)
  args = page.nil? ? {} : { :page => page }
  Versapay::make_request(:get, "/api/debit_agreements/sent.json", args)
end

#reject(reason) ⇒ Object



34
35
36
37
# File 'lib/versapay/debit_agreement.rb', line 34

def reject(reason)
  ags = { "rejection_reason" => reason }
  Versapay::make_request(:post, "/api/debit_agreements/#{token}/reject.json", args)
end

#revokeObject



43
44
45
# File 'lib/versapay/debit_agreement.rb', line 43

def revoke
  Versapay::make_request(:post, "/api/debit_agreements/#{token}/reject.json", {})
end

#view(token) ⇒ Object



25
26
27
# File 'lib/versapay/debit_agreement.rb', line 25

def view(token)
  Versapay::make_request(:get, "/api/debit_agreements/#{token}.json")
end