Module: Teamsupport::REST::Products

Includes:
Utils, Utils
Included in:
API
Defined in:
lib/teamsupport/rest/products.rb

Instance Method Summary collapse

Methods included from Utils

flat_pmap, pmap

Instance Method Details

#create_product(options = {}) ⇒ Teamsupport::Product

Create a product

Examples:

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

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

Raises:

Authentication:

  • Requires Basic Authentication



69
70
71
# 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 = {}) ⇒ Object

Deletes the product

Examples:

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

Parameters:

  • id (Integer)

    A product ID.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Raises:

Authentication:

  • Requires Basic Authentication



108
109
110
# 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 = {}) ⇒ Teamsupport::Product

Returns a product

Examples:

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

Parameters:

  • id (Integer)

    A product ID.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

Raises:

Authentication:

  • Requires Basic Authentication



50
51
52
# 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 = {}) ⇒ Array<Teamsupport::Product>

Returns all available products for the TeamSupport organization

Examples:

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

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :count (Integer)

    Specifies the number of records to retrieve.

Returns:

Raises:

See Also:

Authentication:

  • Requires Basic Authentication



30
31
32
# 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 = {}) ⇒ Teamsupport::Product

Updates the product

Examples:

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

Parameters:

  • id (Integer)

    A product ID.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

Raises:

Authentication:

  • Requires Basic Authentication



89
90
91
92
# 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