Class: Tagstand::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/tagstand/tag.rb

Overview

Represents a tag

Class Method Summary collapse

Class Method Details

.create(tag = nil) ⇒ Object

TODO: document this method TODO: POST body causing error



11
12
13
14
15
16
# File 'lib/tagstand/tag.rb', line 11

def create(tag=nil)
  options = {query: {api_key: Tagstand.api_key}}
  options.merge!(body: "tag=#{tag.to_json}") if tag
  response = Tagstand.post "/tag_create", options
  Hashie::Mash.new(response)
end

.destroy(id) ⇒ Object

TODO: document this method id can be either a number (Int) or URL key (String)



20
21
22
23
24
25
26
27
# File 'lib/tagstand/tag.rb', line 20

def destroy(id)
  query = {api_key: Tagstand.api_key}
  ident = id.is_a?(Integer) ? {number: id} : {url_key: id}
  query.merge!(ident)
  options = {query: query}
  response = Tagstand.get "/tag_destroy", options
  Hashie::Mash.new(response)
end

.list(args = {}) ⇒ Object

TODO: document this method Args: order, name_prefix_filter, data_type_filter, number_filter, page, num_per_page



31
32
33
34
35
36
# File 'lib/tagstand/tag.rb', line 31

def list(args={})
  options = {query: {api_key: Tagstand.api_key}}
  options.merge!(args) unless args.empty?
  response = Tagstand.get "/tag_list", options
  Hashie::Mash.new(response)
end

.show(id) ⇒ Object

TODO: document this method id can be either a number (Int) or URL key (String)



40
41
42
43
44
45
46
47
# File 'lib/tagstand/tag.rb', line 40

def show(id)
  query = {api_key: Tagstand.api_key}
  ident = id.is_a?(Integer) ? {number: id} : {url_key: id}
  query.merge!(ident)
  options = {query: query}
  response = Tagstand.get "/tag_show", options
  Hashie::Mash.new(response)
end

.update(id, tag = nil) ⇒ Object

TODO: document this method id can be either a number (Int) or URL key (String) TODO: POST body causing error



52
53
54
55
56
57
58
59
60
# File 'lib/tagstand/tag.rb', line 52

def update(id, tag=nil)
  query = {api_key: Tagstand.api_key}
  ident = id.is_a?(Integer) ? {number: id} : {url_key: id}
  query.merge!(ident)
  options = {query: query}
  options.merge!(body: "tag=#{tag.to_json}") if tag
  response = Tagstand.post "/tag_update", options
  Hashie::Mash.new(response)
end