Module: Assistly::Client::Article

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

Overview

Defines methods related to articles

Instance Method Summary collapse

Instance Method Details

#article(id, *args) ⇒ Object

Returns extended information on a single article

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

See Also:

Requires Authentication:

  • true

Supported formats:

  • :json



32
33
34
35
36
# File 'lib/assistly/client/article.rb', line 32

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

#articles(id, *args) ⇒ Object

Returns extended information of articles for a topic

@param id [Integer] a article ID @option options [Boolean, String, Integer] @example Return extended information for 12345 Assistly.articles Assistly.articles(:count => 5) Assistly.articles(:count => 5, :page => 3)

See Also:

Requires Authentication:

  • true

Supported formats:

  • :json



16
17
18
19
20
# File 'lib/assistly/client/article.rb', line 16

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

#create_article(topic_id, *args) ⇒ Object

Creates a new article

@param id [Integer] a article ID @param id [Integer] a article ID @param id [Integer] a article ID @option options [Hash] @example Creates a new article Assistly.create_article(1, :subject => "API Tips", :main_content => "Tips on using our API")

See Also:

Requires Authentication:

  • true

Supported formats:

  • :json



49
50
51
52
53
54
55
56
57
# File 'lib/assistly/client/article.rb', line 49

def create_article(topic_id, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = post("topics/#{topic_id}/articles",options)
  if response['success']
    return response['results']['article']
  else
    return response
  end
end

#delete_article(id) ⇒ Object

Deletes a single article

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

See Also:

Requires Authentication:

  • true

Supported formats:

  • :json



86
87
88
89
# File 'lib/assistly/client/article.rb', line 86

def delete_article(id)
  response = delete("articles/#{id}")
  response
end

#update_article(id, *args) ⇒ Object

Updates a single article

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

See Also:

Requires Authentication:

  • true

Supported formats:

  • :json



68
69
70
71
72
73
74
75
76
# File 'lib/assistly/client/article.rb', line 68

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