Class: Tagstand::Tag
- Inherits:
-
Object
- Object
- Tagstand::Tag
- Defined in:
- lib/tagstand/tag.rb
Overview
Represents a tag
Class Method Summary collapse
-
.create(tag = nil) ⇒ Object
TODO: document this method TODO: POST body causing error.
-
.destroy(id) ⇒ Object
TODO: document this method id can be either a number (Int) or URL key (String).
-
.list(args = {}) ⇒ Object
TODO: document this method Args: order, name_prefix_filter, data_type_filter, number_filter, page, num_per_page.
-
.show(id) ⇒ Object
TODO: document this method id can be either a number (Int) or URL key (String).
-
.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.
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) = {query: {api_key: Tagstand.api_key}} .merge!(body: "tag=#{tag.to_json}") if tag response = Tagstand.post "/tag_create", 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) = {query: query} response = Tagstand.get "/tag_destroy", 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={}) = {query: {api_key: Tagstand.api_key}} .merge!(args) unless args.empty? response = Tagstand.get "/tag_list", 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) = {query: query} response = Tagstand.get "/tag_show", 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) = {query: query} .merge!(body: "tag=#{tag.to_json}") if tag response = Tagstand.post "/tag_update", Hashie::Mash.new(response) end |