Module: SFKB::Knowledge

Includes:
Decoration, REST, Settings
Included in:
Client
Defined in:
lib/sfkb/knowledge.rb

Instance Method Summary collapse

Methods included from Decoration

#autodefine, #autodefine_data, #autodefine_links, #autodefine_predicates, #decorate, #define_link, #define_links, #define_predicate

Methods included from Settings

#active_languages, #defaultLanguage, #languages, #settings

Methods included from REST

#apply_endpoint, #endpoint, #index, #services_url, #url, #url?, #url_pattern

Instance Method Details

#article(id) ⇒ Object

Gets an article by ID


26
27
28
29
30
# File 'lib/sfkb/knowledge.rb', line 26

def article(id)
  url = index.knowledgeManagement.articles.article
  url = url(url, ArticleID: id)
  decorate(get(url).body) { |o| autodefine(o) }
end

#article_idsObject

Queries for all (undeleted) article IDs, returning an array.


12
13
14
# File 'lib/sfkb/knowledge.rb', line 12

def article_ids
  query('SELECT Id FROM KnowledgeArticle').map(&:Id)
end

#articlesObject

Enumerates articles


17
18
19
20
21
22
23
# File 'lib/sfkb/knowledge.rb', line 17

def articles
  Enumerator.new do |y|
    article_ids.each do |id|
      y << article(id)
    end
  end
end