module Teamsupport::REST::Products

Public Instance Methods

create_product(options = {}) click to toggle source

Create a product

@example

teamsupport_api = Teamsupport::REST::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_api.create_product(Name: 'New Product')

@authentication Requires Basic Authentication

@raise [Teamsupport::Error::Unauthorized] Error raised when supplied user credentials are not valid.

@return [Teamsupport::Product] The new product.

@param options [Hash] A customizable set of options.

@api public

# File lib/teamsupport/rest/products.rb, line 69
def create_product(options = {})
  perform_post_with_object_from_collection('/api/json/products.json', options, Teamsupport::Product, :Product)
end
delete_product(id, options = {}) click to toggle source

Deletes the product

@example

teamsupport_api = Teamsupport::REST::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_api.delete_product('1')

@authentication Requires Basic Authentication

@raise [Teamsupport::Error::Unauthorized] Error raised when supplied user credentials are not valid.

@param id [Integer] A product ID. @param options [Hash] A customizable set of options.

@api public

# File lib/teamsupport/rest/products.rb, line 108
def delete_product(id, options = {})
  perform_delete("/api/json/products/#{id}.json", options)
end
product(id, options = {}) click to toggle source

Returns a product

@example

teamsupport_api = Teamsupport::REST::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_api.product('1')

@authentication Requires Basic Authentication

@raise [Teamsupport::Error::Unauthorized] Error raised when supplied user credentials are not valid.

@return [Teamsupport::Product] The requested product.

@param id [Integer] A product ID. @param options [Hash] A customizable set of options.

@api public

# File lib/teamsupport/rest/products.rb, line 50
def product(id, options = {})
  perform_get_with_object_from_collection("/api/json/products/#{id}.json", options, Teamsupport::Product, :Product)
end
products(options = {}) click to toggle source

Returns all available products for the TeamSupport organization

@see help.teamsupport.com/1/en/topic/api

@example

teamsupport_api = Teamsupport::REST::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_api.products()

@authentication Requires Basic Authentication

@raise [Teamsupport::Error::Unauthorized] Error raised when supplied API credentials are not valid.

@return [Array<Teamsupport::Product>]

@param options [Hash] A customizable set of options. @option options [Integer] :count Specifies the number of records to retrieve.

@api public

# File lib/teamsupport/rest/products.rb, line 30
def products(options = {})
  perform_get_with_objects_from_collection('/api/json/products.json', options, Teamsupport::Product, :Products)
end
update_product(id, options = {}) click to toggle source

Updates the product

@example

teamsupport_api = Teamsupport::REST::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_api.update_product('1', Name: 'Updated Product Name')

@authentication Requires Basic Authentication

@raise [Teamsupport::Error::Unauthorized] Error raised when supplied user credentials are not valid.

@return [Teamsupport::Product] The updated product.

@param id [Integer] A product ID. @param options [Hash] A customizable set of options.

@api public

# File lib/teamsupport/rest/products.rb, line 89
def update_product(id, options = {})
  product_hash = product(id).to_h
  perform_put_with_object_from_collection("/api/json/products/#{id}.json", product_hash.merge(options), Teamsupport::Product, :Product)
end