Class: Zeit::API

Inherits:
Object
  • Object
show all
Defined in:
lib/zeit/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ API

Returns a new instance of API.

Raises:

  • (ArgumentError)


4
5
6
7
8
9
10
11
12
# File 'lib/zeit/api.rb', line 4

def initialize(params = {})
  @api_key         = params[:api_key]
  @debug           = params[:debug]
  @base_url        = params[:base_url]        || 'http://api.zeit.de/'
  @faraday_adapter = params[:faraday_adapter] || Faraday.default_adapter
  @faraday         = params[:faraday]         || default_faraday

  raise ArgumentError, ':api_key missing' unless @api_key
end

Instance Method Details

#author(opts = {}) ⇒ Object



18
19
20
# File 'lib/zeit/api.rb', line 18

def author(opts = {})
  Zeit::Resources::Author.new(connection, opts)
end

#client(opts = {}) ⇒ Object



22
23
24
# File 'lib/zeit/api.rb', line 22

def client(opts = {})
  Zeit::Resources::Client.new(connection, opts)
end

#connectionObject



14
15
16
# File 'lib/zeit/api.rb', line 14

def connection
  @faraday
end

#content(opts = {}) ⇒ Object



26
27
28
# File 'lib/zeit/api.rb', line 26

def content(opts = {})
  Zeit::Resources::Content.new(connection, opts)
end

#department(opts = {}) ⇒ Object



30
31
32
# File 'lib/zeit/api.rb', line 30

def department(opts = {})
  Zeit::Resources::Department.new(connection, opts)
end

#keyword(opts = {}) ⇒ Object



34
35
36
# File 'lib/zeit/api.rb', line 34

def keyword(opts = {})
  Zeit::Resources::Keyword.new(connection, opts)
end

#product(opts = {}) ⇒ Object



38
39
40
# File 'lib/zeit/api.rb', line 38

def product(opts = {})
  Zeit::Resources::Product.new(connection, opts)
end

#series(opts = {}) ⇒ Object



42
43
44
# File 'lib/zeit/api.rb', line 42

def series(opts = {})
  Zeit::Resources::Series.new(connection, opts)
end