class Apibanca::Bank

Public Class Methods

create(client, bank_params) click to toggle source
# File lib/apibanca/client/bank.rb, line 6
def create client, bank_params
        raise ArgumentError, "Los parĂ¡metros deben ser ApiBanca::Bank::BankCreationParams" unless bank_params.is_a? Apibanca::Bank::BankCreationParams
        r = client.post url, { bank: bank_params.to_hash }
        bank = Apibanca::Bank.new(client, r.body)
        bank.load_routines! false
        bank
end
index(client, params=nil, recursive=false) click to toggle source
# File lib/apibanca/client/bank.rb, line 21
def index client, params=nil, recursive=false
        r = client.get url, params
        r.body.map do |raw|
                bank = Apibanca::Bank.new(client, raw)
                bank.load_routines! recursive
                bank
        end
end
load(client, id, recursive=true) click to toggle source
# File lib/apibanca/client/bank.rb, line 14
def load client, id, recursive=true
        r = client.get url("#{id}")
        bank = Apibanca::Bank.new(client, r.body)
        bank.load_routines! recursive
        bank
end

Public Instance Methods

add_routine(routine_params) click to toggle source
# File lib/apibanca/client/bank.rb, line 43
def add_routine routine_params
        raise ArgumentError, "Los parĂ¡metros deben ser ApiBanca::Bank::RoutineCreationParams" unless routine_params.is_a? Apibanca::Bank::RoutineCreationParams
        r = obj_client.post url("add_routine"), { routine: routine_params.to_hash }
        r.body.routines.each do |routine|
                next unless self.routines.any? { |r| r.id == routine.id }
                new_routine = Apibanca::Routine.new(obj_client, self, routine)
                new_routine.refresh!
                self.routines << new_routine
        end
        routines.last
end
buc() click to toggle source
# File lib/apibanca/client/bank.rb, line 76
def buc
        "#{name} / User [#{user}] / Cuenta [#{account}]"
end
buc_short() click to toggle source
# File lib/apibanca/client/bank.rb, line 80
def buc_short
        "#{name}/#{user}/#{account}"
end
change_password(new_pass) click to toggle source
# File lib/apibanca/client/bank.rb, line 38
def change_password new_pass
        r = obj_client.patch url("change_password"), pass: new_pass
        true
end
delete() click to toggle source
# File lib/apibanca/client/bank.rb, line 55
def delete
        obj_client.delete url
        true
end
load_deposits(params=nil) click to toggle source
# File lib/apibanca/client/bank.rb, line 60
def load_deposits params=nil
        r = obj_client.get url("deposits"), params
        self.deposits = r.body.map { |d| nd = Apibanca::Deposit.new(obj_client, self, d) }
end
load_jobs(params=nil) click to toggle source
# File lib/apibanca/client/bank.rb, line 65
def load_jobs params=nil
        r = obj_client.get url, params
        self.jobs = r.body.each do |raw|
                Apibanca::Job.new(obj_client, raw)
        end
end
load_routines!(recursive=true) click to toggle source
# File lib/apibanca/client/bank.rb, line 84
def load_routines! recursive=true
        self.routines.map! { |r| Apibanca::Routine.new(self.obj_client, self, r) }
        self.routines.each { |r| r.refresh! } if recursive
end
refresh!(recursive=true) click to toggle source
# File lib/apibanca/client/bank.rb, line 31
def refresh! recursive=true
        r = obj_client.get url
        self.merge! r.body
        self.load_routines! recursive
        self
end
to_s() click to toggle source
# File lib/apibanca/client/bank.rb, line 72
def to_s
        "(Banco #{id}) #{name} / #{user} / #{account}"
end