Class: Quandora::Bases

Inherits:
Request show all
Defined in:
lib/quandora/bases.rb

Instance Attribute Summary

Attributes inherited from Request

#api, #params

Instance Method Summary collapse

Methods inherited from Request

#index, #initialize, #show

Constructor Details

This class inherits a constructor from Quandora::Request

Instance Method Details

#ask(base_id, args = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/quandora/bases.rb', line 27

def ask(base_id, args = {})
  args = args.stringify_keys

  body = {
    "type": "post-question",
    "data": {
      "title": args["title"],
      "content": args["content"],
      "contentType": args["content_type"] || "markdown"
    }
  }

  resp = @conn.post("kb/#{base_id}/ask") do |req|
    req.body = body.to_json
    req.headers['Content-Type'] = 'application/json'
  end
end

#follow(base_id, args = {}) ⇒ Object



45
46
47
48
# File 'lib/quandora/bases.rb', line 45

def follow(base_id, args = {})
  @api = "kb/#{base_id}/follow"
  index
end

#listObject



2
3
4
5
# File 'lib/quandora/bases.rb', line 2

def list
  @api = "kb/"
  index
end

#mlt(base_id, args = {}) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/quandora/bases.rb', line 19

def mlt(base_id, args = {})
  args = args.stringify_keys

  @api = "kb/#{base_id}/mlt"
  @params.merge!("q": args["q"]) unless args.fetch('q', nil).nil?
  index
end

#questions(base_id, args = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/quandora/bases.rb', line 7

def questions(base_id, args = {})
  args = args.stringify_keys

  @api = "kb/#{base_id}/list"
  @params.merge!("o": args["o"]) unless args.fetch('o', nil).nil?
  @params.merge!("l": args["l"]) unless args.fetch('l', nil).nil?
  @params.merge!("q": args["q"]) unless args.fetch('q', nil).nil?
  @params.merge!("tag": args["tag"]) unless args.fetch('tag', nil).nil?
  @params.merge!("s": args["s"]) unless args.fetch('s', nil).nil?
  index
end

#report(kb_id) ⇒ Object



54
55
56
# File 'lib/quandora/bases.rb', line 54

def report(kb_id)
  Quandora::Report.new(@conn, "kb", kb_id)
end

#tag(kb_id) ⇒ Object



50
51
52
# File 'lib/quandora/bases.rb', line 50

def tag(kb_id)
  Quandora::Tag.new(@conn, "kb", kb_id)
end