Class: Malartu::Schedule

Inherits:
MalartuObject show all
Defined in:
lib/malartu/schedule.rb

Overview

A schedule is what tells Malartu when to aggregate the data

Instance Attribute Summary

Attributes inherited from MalartuObject

#json

Class Method Summary collapse

Methods inherited from MalartuObject

#initialize, paginate?

Constructor Details

This class inherits a constructor from Malartu::MalartuObject

Class Method Details

.find(id = 'api') ⇒ Object



4
5
6
7
# File 'lib/malartu/schedule.rb', line 4

def self.find(id = 'api')
  res = Malartu.request('get', "/kpi/schedules/#{id}")
  Malartu::Schedule.new(res)
end

.listObject



9
10
11
12
13
14
# File 'lib/malartu/schedule.rb', line 9

def self.list
  res = Malartu.request('get', '/kpi/schedules')
  res['schedules'].map do |schedule|
    Malartu::Schedule.new(schedule)
  end
end

.update(id = 'api', active: false) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/malartu/schedule.rb', line 16

def self.update(id = 'api', active: false)
  fail 'Invalid ID' unless id == 'api'
  params = {}
  params[:active] = active unless active.nil?
  res = Malartu.request('patch', "/kpi/schedules/#{id}", params)
  Malartu::Schedule.new(res)
end