class Quandora::Tag

Public Class Methods

new(conn, api, id) click to toggle source
# File lib/quandora/tag.rb, line 2
def initialize(conn, api, id)
  @conn = conn
  @api = api
  @id = id
end

Public Instance Methods

add(tags) click to toggle source
# File lib/quandora/tag.rb, line 69
def add(tags)
  tags = tags.join(',') if tags.is_a? Array
  resp = @conn.put("/#{@api}/#{@id}/tags/#{tags}") do |req|
    req.headers['Content-Type'] = 'application/json'
  end
end
create(args) click to toggle source
# File lib/quandora/tag.rb, line 25
def create(args)
  body = {
    "type": "tag-content",
    "data": {
      "name": args[:name],
      "category": nil,
      "location": nil,
      "url": args[:url],
      "content": args[:content]
    }
  }

  resp = @conn.post("#{@api}/#{@id}/tags") do |req|
    req.body = body.to_s
    req.headers['Content-Type'] = 'application/json'
  end
end
delete(tag_name) click to toggle source
# File lib/quandora/tag.rb, line 58
def delete(tag_name)
  resp = @conn.delete("#{@api}/#{@id}/tags/#{tag_name}")
end
index(args={}) click to toggle source
# File lib/quandora/tag.rb, line 8
def index(args={})
  query = {}
  query.merge!("q": args["q"]) unless args.fetch('q', nil).nil?
  query.merge!("s": args["s"]) unless args.fetch('s', nil).nil?
  query.merge!("o": args["o"]) unless args.fetch('o', nil).nil?
  query.merge!("l": args["l"]) unless args.fetch('l', nil).nil?

  resp = @conn.get("#{@api}/#{@id}/tags") do |req|
    req.params = query
    req.headers['Content-Type'] = 'application/json'
  end
end
set(tags) click to toggle source
# File lib/quandora/tag.rb, line 62
def set(tags)
  tags = tags.join(',') if tags.is_a? Array
  resp = @conn.post("/#{@api}/#{@id}/tags/#{tags}") do |req|
    req.headers['Content-Type'] = 'application/json'
  end
end
show(tag_name, query = nil) click to toggle source
# File lib/quandora/tag.rb, line 21
def show(tag_name, query = nil)
  resp = @conn.get("#{@api}/#{@id}/tags/#{tag_name}/#{query}")
end
update(args) click to toggle source
# File lib/quandora/tag.rb, line 43
def update(args)
  body = {
    "type": "tag-content",
    "data": {
      "content": args["content"],
      "uid": args["uid"]
    }
  }

  resp = @conn.put("#{@api}/#{@id}/tags") do |req|
    req.body = body.to_s
    req.headers['Content-Type'] = 'application/json'
  end
end