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
-
#article(id, *args) ⇒ Object
Returns extended information on a single article.
-
#articles(id, *args) ⇒ Object
Returns extended information of articles for a topic.
-
#create_article(topic_id, *args) ⇒ Object
Creates a new article.
-
#delete_article(id) ⇒ Object
Deletes a single article.
-
#update_article(id, *args) ⇒ Object
Updates a single article.
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")
32 33 34 35 36 |
# File 'lib/assistly/client/article.rb', line 32 def article(id, *args) = args.last.is_a?(Hash) ? args.pop : {} response = get("articles/#{id}",) 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)
16 17 18 19 20 |
# File 'lib/assistly/client/article.rb', line 16 def articles(id, *args) = args.last.is_a?(Hash) ? args.pop : {} response = get("topics/#{id}/articles",) 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")
49 50 51 52 53 54 55 56 57 |
# File 'lib/assistly/client/article.rb', line 49 def create_article(topic_id, *args) = args.last.is_a?(Hash) ? args.pop : {} response = post("topics/#{topic_id}/articles",) 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")
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")
68 69 70 71 72 73 74 75 76 |
# File 'lib/assistly/client/article.rb', line 68 def update_article(id, *args) = args.last.is_a?(Hash) ? args.pop : {} response = put("articles/#{id}",) if response['success'] return response['results']['article'] else return response end end |