class ForemLite::Client

Public Class Methods

new(api_key = nil) click to toggle source

Create a new client object with your Forem API key.

@param [String] api_key <Forem/Dev.to API Key>

# File lib/forem_lite/client.rb, line 11
def initialize(api_key = nil)
  self.class.default_options[:headers] = {"api-key" => api_key} if api_key
end

Public Instance Methods

article(id) click to toggle source

Retrieve a single published article given its id.

@param [Integer, String] id <a string or integer representing the article id>

@return [Object] a FormCli::Article object

# File lib/forem_lite/client.rb, line 31
def article(id)
  ForemLite::Article.new(self.class.get("/articles/#{id}"))
end
articles() click to toggle source

Retrieve a list of articles.

@return [Array<Object>] collection of ForemLite::Article objects

# File lib/forem_lite/client.rb, line 20
def articles
  self.class.get("/articles").tap { |z| ForemLite::Article.new(z) }
end