Class: Sirportly::KnowledgeBase

Inherits:
DataObject show all
Defined in:
lib/sirportly/data_objects/knowledge_base.rb

Instance Attribute Summary

Attributes inherited from DataObject

#attributes, #client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DataObject

all, #initialize, #inspect, #method_missing

Constructor Details

This class inherits a constructor from Sirportly::DataObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Sirportly::DataObject

Class Method Details

.find(client, query) ⇒ Object



6
7
8
9
# File 'lib/sirportly/data_objects/knowledge_base.rb', line 6

def self.find(client, query)
  result = client.request("knowledge/list").select { |i| i['id'] == query.to_i}.first
  self.new(client, result)
end

Instance Method Details

#create_page(params = {}) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/sirportly/data_objects/knowledge_base.rb', line 19

def create_page(params = {})
  params.merge!({:kb => self.attributes['id']})
  if req = @client.request('knowledge/add_page', params)
    KnowledgeBasePage.new(@client, req)
  else
    false
  end
end

#page(path) ⇒ Object



11
12
13
# File 'lib/sirportly/data_objects/knowledge_base.rb', line 11

def page(path)
  KnowledgeBasePage.new(client, client.request('knowledge/page', :kb => attributes['id'], :path => path))
end

#treeObject



15
16
17
# File 'lib/sirportly/data_objects/knowledge_base.rb', line 15

def tree
  client.request('knowledge/tree', :kb => attributes['id']).map { |i| KnowledgeBasePage.new(client, i) }
end