Module: Teamsupport::REST::Customers

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

Instance Method Summary collapse

Methods included from Utils

flat_pmap, pmap

Instance Method Details

#create_customer(options = {}) ⇒ Teamsupport::Customer

Create a customer

Examples:

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

Parameters:

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

    A customizable set of options.

Returns:

Raises:

Authentication:

  • Requires Basic Authentication



70
71
72
# File 'lib/teamsupport/rest/customers.rb', line 70

def create_customer(options = {})
  perform_post_with_object_from_collection('/api/json/customers.json', options, Teamsupport::Customer, :Customer)
end

#customer(id, options = {}) ⇒ Teamsupport::Customer

Returns a customer

Examples:

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

Parameters:

  • id (Integer)

    A customer ID.

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

    A customizable set of options.

Returns:

Raises:

Authentication:

  • Requires Basic Authentication



51
52
53
# File 'lib/teamsupport/rest/customers.rb', line 51

def customer(id, options = {})
  perform_get_with_object_from_collection("/api/json/customers/#{id}.json", options, Teamsupport::Customer, :Customer)
end

#customer_products(id, options = {}) ⇒ Array<Teamsupport::Product>

Returns the products for a customer

Examples:

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

Parameters:

  • id (Integer)

    A customer ID.

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

    A customizable set of options.

Returns:

Raises:

Authentication:

  • Requires Basic Authentication



129
130
131
132
# File 'lib/teamsupport/rest/customers.rb', line 129

def customer_products(id, options = {})
  options = options.dup
  perform_get_with_objects_from_collection("/api/json/customers/#{id}/products.json", options, Teamsupport::CustomerProduct, :OrganizationProducts)
end

#customer_tickets(id, options = {}) ⇒ Array<Teamsupport::Ticket>

Returns the tickets for a customer

Examples:

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

Parameters:

  • id (Integer)

    A customer ID.

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

    A customizable set of options.

Returns:

Raises:

Authentication:

  • Requires Basic Authentication



150
151
152
153
# File 'lib/teamsupport/rest/customers.rb', line 150

def customer_tickets(id, options = {})
  options = options.dup
  perform_get_with_objects_from_collection("/api/json/customers/#{id}/tickets.json", options, Teamsupport::Ticket, :Tickets)
end

#customers(options = {}) ⇒ Array<Teamsupport::Customer>

Returns all available customers for the TeamSupport organization

Examples:

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

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



31
32
33
# File 'lib/teamsupport/rest/customers.rb', line 31

def customers(options = {})
  perform_get_with_objects_from_collection('/api/json/customers.json', options, Teamsupport::Customer, :Customers)
end

#delete_customer(id, options = {}) ⇒ Object

Deletes the customer

Examples:

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

Parameters:

  • id (Integer)

    A customer ID.

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

    A customizable set of options.

Raises:

Authentication:

  • Requires Basic Authentication



109
110
111
# File 'lib/teamsupport/rest/customers.rb', line 109

def delete_customer(id, options = {})
  perform_delete("/api/json/customers/#{id}.json", options)
end

#update_customer(id, options = {}) ⇒ Teamsupport::Customer

Updates the customer

Examples:

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

Parameters:

  • id (Integer)

    A customer ID.

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

    A customizable set of options.

Returns:

Raises:

Authentication:

  • Requires Basic Authentication



90
91
92
93
# File 'lib/teamsupport/rest/customers.rb', line 90

def update_customer(id, options = {})
  customer_hash = customer(id).to_h
  perform_put_with_object_from_collection("/api/json/customers/#{id}.json", customer_hash.merge(options), Teamsupport::Customer, :Customer)
end