Module: Balanced

Defined in:
lib/balanced_ach.rb,
lib/balanced_ach/error.rb,
lib/balanced_ach/pager.rb,
lib/balanced_ach/utils.rb,
lib/balanced_ach/client.rb,
lib/balanced_ach/version.rb,
lib/balanced_ach/resources/debit.rb,
lib/balanced_ach/resources/credit.rb,
lib/balanced_ach/resources/resource.rb,
lib/balanced_ach/resources/bank_account.rb

Defined Under Namespace

Modules: Resource, Utils Classes: BadGateway, BadRequest, BankAccount, Client, Conflict, Credit, Debit, Error, Forbidden, GatewayTimeout, Gone, InternalServerError, MethodNotAllowed, MoreInformationRequired, NotFound, NotImplemented, Pager, PaymentRequired, ServiceUnavailable, Unauthorized

Constant Summary collapse

VERSION =
'0.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.clientObject

Returns the value of attribute client.



23
24
25
# File 'lib/balanced_ach.rb', line 23

def client
  @client
end

.configObject

Returns the value of attribute config.



24
25
26
# File 'lib/balanced_ach.rb', line 24

def config
  @config
end

Class Method Details

.configure(api_key = nil, options = {}) ⇒ Object



26
27
28
# File 'lib/balanced_ach.rb', line 26

def configure(api_key=nil, options={})
  @client = Balanced::Client.new(api_key, @config.merge(options))
end

.delete(*args, &block) ⇒ Object



76
77
78
# File 'lib/balanced_ach.rb', line 76

def delete(*args, &block)
  self.client.delete *args
end

.from_uri(uri) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/balanced_ach.rb', line 38

def from_uri uri
  split_uri = split_the_uri(uri)
  # this is such an ugly hack, basically, we're trying to
  # see if we have the symbol that matches the capitalized
  #
  class_name = Balanced::Utils.classify(split_uri[-1])
  begin
    klass = Balanced.const_get class_name
  rescue NameError
    class_name = Utils.classify(split_uri[-2])
    klass = Balanced.const_get(class_name)
  end
  klass
end

.get(*args, &block) ⇒ Object



64
65
66
# File 'lib/balanced_ach.rb', line 64

def get(*args, &block)
  self.client.get *args
end

.is_collection(uri) ⇒ Object



53
54
55
56
57
58
59
60
61
62
# File 'lib/balanced_ach.rb', line 53

def is_collection uri
  split_uri = split_the_uri(uri)
  class_name = Balanced::Utils.classify(split_uri[-1])
  begin
    Balanced.const_get class_name
  rescue NameError
    return false
  end
  true
end

.is_configured_with_api_key?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/balanced_ach.rb', line 30

def is_configured_with_api_key?
  !@client.api_key.nil?
end

.post(*args, &block) ⇒ Object



68
69
70
# File 'lib/balanced_ach.rb', line 68

def post(*args, &block)
  self.client.post *args
end

.put(*args, &block) ⇒ Object



72
73
74
# File 'lib/balanced_ach.rb', line 72

def put(*args, &block)
  self.client.put *args
end

.split_the_uri(uri) ⇒ Object



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

def split_the_uri uri
  URI.parse(uri).path.sub(/\/$/, '').split('/')
end