class ReamazeAPI::Article

Public Instance Methods

all(params = {}) click to toggle source

Public: Retrieves KB articles.

params - Hash of parameters to pass to the API

API Routes

GET /articles
GET /topics/{slug}/articles

See also: www.reamaze.com/api/get_articles

Returns a Hash.

# 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
create(params) click to toggle source

Public: Create a new KB article.

params - Hash of parameters to pass to the API

API Routes

POST /articles (no topic)
POST /topics/{slug}/articles

See also: www.reamaze.com/api/post_article

Returns a Hash.

# 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) click to toggle source

Public: Retrieves a specific KB article.

slug - Article slug

API Routes

GET /articles/{slug}

See also: www.reamaze.com/api/get_article

Returns a Hash.

# File lib/reamaze_api/article.rb, line 33
def find(slug)
  get "/articles/#{slug}"
end
update(slug, params) click to toggle source

Public: Update an existing KB article.

slug - Article slug params - Hash of parameters to pass to the API

API Routes

PUT /articles/{slug}

See also: www.reamaze.com/api/put_article

Returns a Hash.

# File lib/reamaze_api/article.rb, line 67
def update(slug, params)
  put "/articles/#{slug}", params
end

Private Instance Methods

articles_path(topic_slug = nil) click to toggle source

Private: Articles API path. If a topic slug is supplied the returned path is prefixed with “/topic/#{topic}”.

topic_slug - The topic slug

Returns a String.

# 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