class Apibanca::Routine

Public Class Methods

new(client, bank, source_hash = nil, default = nil, &block) click to toggle source
Calls superclass method Apibanca::ProxyBase::new
# File lib/apibanca/client/routine.rb, line 46
def initialize(client, bank, source_hash = nil, default = nil, &block)
        super(client, source_hash, default, &block)
        @obj_bank = bank
end

Public Instance Methods

delete() click to toggle source
# File lib/apibanca/client/routine.rb, line 36
def delete
        obj_client.delete url
        self.obj_bank.routines.select! { |r| r.id != self.id } if self.obj_bank.routines.any?
        true
end
load_tasks() click to toggle source
# File lib/apibanca/client/routine.rb, line 31
def load_tasks
        r = obj_client.get url("tasks")
        self.tasks = r.body
end
obj_bank() click to toggle source
# File lib/apibanca/client/routine.rb, line 51
def obj_bank
        @obj_bank
end
refresh!() click to toggle source
# File lib/apibanca/client/routine.rb, line 5
def refresh!
        r = obj_client.get url
        self.merge! r.body
end
schedule(params) click to toggle source
# File lib/apibanca/client/routine.rb, line 25
def schedule params
        raise ArgumentError, "Los parĂ¡metros deben ser ApiBanca::Routine::ScheduleParams" unless params.is_a? Apibanca::Routine::ScheduleParams
        r = obj_client.patch url("schedule"), params.to_hash
        self.merge! r.body
end
set_callback(type, uri, options=nil) click to toggle source
# File lib/apibanca/client/routine.rb, line 20
def set_callback type, uri, options=nil
        r = obj_client.patch url("set_callback"), { cb_type: type, uri: uri, options: options }
        self.merge! r.body
end
to_s() click to toggle source
# File lib/apibanca/client/routine.rb, line 42
def to_s
        "(Rutina #{id}) #{nombre} #{target ? "#{what_to_do}:#{target}" : ""} tasks=#{scheduled_tasks} #{!active ? "INACTIVE" : ""}"
end
turn_off() click to toggle source
# File lib/apibanca/client/routine.rb, line 15
def turn_off
        r = obj_client.patch url("turn_off")
        self.merge! r.body
end
turn_on() click to toggle source
# File lib/apibanca/client/routine.rb, line 10
def turn_on
        r = obj_client.patch url("turn_on")
        self.merge! r.body
end