Class: Zelda::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/zelda/request.rb

Class Method Summary collapse

Class Method Details

.get(url) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/zelda/request.rb', line 3

def self.get(url)
  result = HTTParty.get parse_url(url)

  if result
    %w(created_at updated_at id).each do |key|
      result.delete(key) if result[key]
    end

    if result['error']
      raise result['error']
    end
  end

  result
end

.parse_url(*args) ⇒ Object



19
20
21
22
# File 'lib/zelda/request.rb', line 19

def self.parse_url(*args)
  raise "No Zelda::API_KEY specified" unless defined?(Zelda::API_KEY)
  "http://zelda.omroep.nl/#{ Zelda::API_KEY }/#{ args.join('/') }"
end