Class: ReamazeAPI::Article
- Defined in:
- lib/reamaze_api/article.rb
Instance Method Summary collapse
-
#all(params = {}) ⇒ Object
Retrieves KB articles.
-
#articles_path(topic_slug = nil) ⇒ Object
private
Private: Articles API path.
-
#create(params) ⇒ Object
Create a new KB article.
-
#find(slug) ⇒ Object
Retrieves a specific KB article.
-
#update(slug, params) ⇒ Object
Update an existing KB article.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from ReamazeAPI::Resource
Instance Method Details
#all(params = {}) ⇒ Object
Retrieves KB articles.
15 16 17 18 19 20 |
# File 'lib/reamaze_api/article.rb', line 15 def all(params = {}) params = Utils.symbolize_hash(params) url = articles_path(params.delete(:topic)) paginate url, :articles, params end |
#articles_path(topic_slug = nil) ⇒ Object (private)
Private: Articles API path. If a topic slug is supplied the returned path is prefixed with “/topic/#topic”.
79 80 81 82 83 84 85 |
# File 'lib/reamaze_api/article.rb', line 79 def articles_path(topic_slug = nil) if topic_slug "/topics/#{topic_slug}/articles" else "/articles" end end |
#create(params) ⇒ Object
Create a new KB article.
49 50 51 52 53 |
# File 'lib/reamaze_api/article.rb', line 49 def create(params) params = Utils.symbolize_hash(params) post articles_path(params.delete(:topic)), params end |
#find(slug) ⇒ Object
Retrieves a specific KB article.
33 34 35 |
# File 'lib/reamaze_api/article.rb', line 33 def find(slug) get "/articles/#{slug}" end |
#update(slug, params) ⇒ Object
Update an existing KB article.
67 68 69 |
# File 'lib/reamaze_api/article.rb', line 67 def update(slug, params) put "/articles/#{slug}", params end |