Class: GoCardless::PreAuthorization

Inherits:
Resource
  • Object
show all
Defined in:
lib/gocardless/pre_authorization.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#id, #uri

Instance Method Summary collapse

Methods inherited from Resource

creatable, creatable?, date_accessor, date_writer, find, find_with_client, #initialize, #inspect, new_with_client, #persisted?, reference_accessor, reference_reader, reference_writer, #save, #to_hash, #to_json, updatable, updatable?

Constructor Details

This class inherits a constructor from GoCardless::Resource

Instance Attribute Details

#amountObject

Returns the value of attribute amount


5
6
7
# File 'lib/gocardless/pre_authorization.rb', line 5

def amount
  @amount
end

#currencyObject

Returns the value of attribute currency


5
6
7
# File 'lib/gocardless/pre_authorization.rb', line 5

def currency
  @currency
end

#descriptionObject

Returns the value of attribute description


5
6
7
# File 'lib/gocardless/pre_authorization.rb', line 5

def description
  @description
end

#interval_lengthObject

Returns the value of attribute interval_length


5
6
7
# File 'lib/gocardless/pre_authorization.rb', line 5

def interval_length
  @interval_length
end

#interval_unitObject

Returns the value of attribute interval_unit


5
6
7
# File 'lib/gocardless/pre_authorization.rb', line 5

def interval_unit
  @interval_unit
end

#max_amountObject

Returns the value of attribute max_amount


5
6
7
# File 'lib/gocardless/pre_authorization.rb', line 5

def max_amount
  @max_amount
end

#nameObject

Returns the value of attribute name


5
6
7
# File 'lib/gocardless/pre_authorization.rb', line 5

def name
  @name
end

#remaining_amountObject

Returns the value of attribute remaining_amount


5
6
7
# File 'lib/gocardless/pre_authorization.rb', line 5

def remaining_amount
  @remaining_amount
end

#setup_feeObject

Returns the value of attribute setup_fee


5
6
7
# File 'lib/gocardless/pre_authorization.rb', line 5

def setup_fee
  @setup_fee
end

#statusObject

Returns the value of attribute status


5
6
7
# File 'lib/gocardless/pre_authorization.rb', line 5

def status
  @status
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)

38
39
40
# File 'lib/gocardless/pre_authorization.rb', line 38

def active?
  status == 'active'
end

#cancel!Object


29
30
31
32
# File 'lib/gocardless/pre_authorization.rb', line 29

def cancel!
  path = self.class.endpoint.gsub(':id', id.to_s) + '/cancel'
  client.api_put(path)
end

#cancelled?Boolean

Returns:

  • (Boolean)

42
43
44
# File 'lib/gocardless/pre_authorization.rb', line 42

def cancelled?
  status == 'cancelled'
end

#create_bill(attrs) ⇒ Bill

Create a new bill under this pre-authorization. Similar to Client#create_bill, but only requires the amount to be specified.

Parameters:

  • attrs (Hash)

    a customizable set of options

Options Hash (attrs):

  • amount (amount)

    the bill amount in pence

Returns:

  • (Bill)

    the created bill object


25
26
27
# File 'lib/gocardless/pre_authorization.rb', line 25

def create_bill(attrs)
  Bill.new_with_client(client, attrs.merge(:source => self)).save
end

#expired?Boolean

Returns:

  • (Boolean)

46
47
48
# File 'lib/gocardless/pre_authorization.rb', line 46

def expired?
  status == 'expired'
end

#inactive?Boolean

Returns:

  • (Boolean)

34
35
36
# File 'lib/gocardless/pre_authorization.rb', line 34

def inactive?
  status == 'inactive'
end