Module: Assistly::Client::Topic

Included in:
Assistly::Client
Defined in:
lib/assistly/client/topic.rb

Overview

Defines methods related to topics

Instance Method Summary collapse

Instance Method Details

#create_topic(name, *args) ⇒ Object

Creates a new topic

@param name [String] A topic name @option options [Hash] @example Creates a new topic Assistly.create_topic("name") Assistly.create_topic("name", :description => "description")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



47
48
49
50
51
52
53
54
55
# File 'lib/assistly/client/topic.rb', line 47

def create_topic(name, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = post("topics",options)
  if response['success']
    return response['results']['topic']
  else
    return response
  end
end

#delete_topic(id) ⇒ Object

Deletes a single topic

@param id [Integer] a topic ID @example Deletes topic 12345 Assistly.update_topic(12345, :subject => "New Subject")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



84
85
86
87
# File 'lib/assistly/client/topic.rb', line 84

def delete_topic(id)
  response = delete("topics/#{id}")
  response
end

#topic(id, *args) ⇒ Object

Returns extended information on a single topic

@param id [Integer] a topic ID @option options [Hash] @example Return extended information for 12345 Assistly.topic(12345) Assistly.topic(12345, :by => "external_id")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



31
32
33
34
35
# File 'lib/assistly/client/topic.rb', line 31

def topic(id, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = get("topics/#{id}",options)
  response.topic
end

#topics(*args) ⇒ Object

Returns extended information of topics

@option options [Boolean, String, Integer] @example Return extended information for 12345 Assistly.topics Assistly.topics(:count => 5) Assistly.topics(:count => 5, :page => 3)

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



15
16
17
18
19
# File 'lib/assistly/client/topic.rb', line 15

def topics(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = get("topics",options)
  response
end

#update_topic(id, *args) ⇒ Object

Updates a single topic

@param id [Integer] a topic ID @option options [String] @example Updates information for topic 12345 Assistly.update_topic(12345, :subject => "New Subject")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



66
67
68
69
70
71
72
73
74
# File 'lib/assistly/client/topic.rb', line 66

def update_topic(id, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = put("topics/#{id}",options)
  if response['success']
    return response['results']['topic']
  else
    return response
  end
end