Module: Giraffi::Client::Items
- Included in:
- Giraffi::Client
- Defined in:
- lib/giraffi/client/items.rb
Overview
Defines methods related to the items
Instance Method Summary collapse
-
#add_service_to_item(id, options = {}) ⇒ HTTParty::Response
Adds a service to the item.
-
#create_item(options = {}) ⇒ HTTParty::Response
Creates a new item.
-
#destroy_item(id) ⇒ HTTParty::Response
Deletes the item.
-
#find_agent(id) ⇒ HTTParty::Response
Returns the desired agent related to the item.
-
#find_item(id) ⇒ HTTParty::Response
Returns the desired item by the numerical ID.
-
#find_items(options = {}) ⇒ HTTParty::Response
Returns the desired items.
-
#find_services_by_item(id, options = {}) ⇒ HTTParty::Response
Returns all services related to the item.
-
#reload_items ⇒ HTTParty::Response
Reloads all items.
-
#remove_service_from_item(*args) ⇒ HTTParty::Response
Removes a service from the item.
-
#update_item(id, options = {}) ⇒ HTTParty::Response
Updates the desired item.
Instance Method Details
#add_service_to_item(id, options = {}) ⇒ HTTParty::Response
Adds a service to the item
66 67 68 |
# File 'lib/giraffi/client/items.rb', line 66 def add_service_to_item(id, ={}) self.class.post("/items/#{id}/services.json?apikey=#{apikey}", :query => { :service => }) end |
#create_item(options = {}) ⇒ HTTParty::Response
Creates a new item
48 49 50 |
# File 'lib/giraffi/client/items.rb', line 48 def create_item(={}) self.class.post("/items.json?apikey=#{apikey}", :query => { :item => }) end |
#destroy_item(id) ⇒ HTTParty::Response
Deletes the item
85 86 87 |
# File 'lib/giraffi/client/items.rb', line 85 def destroy_item(id) self.class.delete("/items/#{id}.json?apikey=#{apikey}") end |
#find_agent(id) ⇒ HTTParty::Response
Returns the desired agent related to the item
29 30 31 |
# File 'lib/giraffi/client/items.rb', line 29 def find_agent(id) # TODO end |
#find_item(id) ⇒ HTTParty::Response
Returns the desired item by the numerical ID
20 21 22 |
# File 'lib/giraffi/client/items.rb', line 20 def find_item(id) self.class.get("/items/#{id}.json?apikey=#{apikey}") end |
#find_items(options = {}) ⇒ HTTParty::Response
Returns the desired items
11 12 13 |
# File 'lib/giraffi/client/items.rb', line 11 def find_items(={}) self.class.get("/items.json?apikey=#{apikey}", :query => ) end |
#find_services_by_item(id, options = {}) ⇒ HTTParty::Response
Returns all services related to the item
39 40 41 |
# File 'lib/giraffi/client/items.rb', line 39 def find_services_by_item(id, ={}) self.class.get("/items/#{id}/services.json?apikey=#{apikey}", :query => ) end |
#reload_items ⇒ HTTParty::Response
Reloads all items
56 57 58 |
# File 'lib/giraffi/client/items.rb', line 56 def reload_items self.class.post("/items/reload.json?apikey=#{apikey}") end |
#remove_service_from_item(*args) ⇒ HTTParty::Response
Removes a service from the item
96 97 98 99 |
# File 'lib/giraffi/client/items.rb', line 96 def remove_service_from_item(*args) raise ArgumentError.new('The method `remove_service_from_item` requires 2 arguments (item-id and service-id)') if args.size != 2 self.class.delete("/items/#{args[0]}/services/#{args[-1]}.json?apikey=#{apikey}") end |
#update_item(id, options = {}) ⇒ HTTParty::Response
Updates the desired item
76 77 78 |
# File 'lib/giraffi/client/items.rb', line 76 def update_item(id, ={}) self.class.put("/items/#{id}.json?apikey=#{apikey}", :query => {:item => }, :body => {}) end |