Sha256: 77d186bf6b84940d4acb4e77157b4baad2a454496db247111d58267c59fa993c

Contents?: true

Size: 516 Bytes

Versions: 1

Compression:

Stored size: 516 Bytes

Contents

module Zelda
  class Request
    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

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zelda-1.4.0 lib/zelda/request.rb