Sha256: ccd8f7adfaeba083878b164c924617db42f278d034fbc8bef3ff73e46ac8408c
Contents?: true
Size: 863 Bytes
Versions: 2
Compression:
Stored size: 863 Bytes
Contents
require 'json' module Alephant module Publisher module Request class DataMapper attr_reader :connection, :context def initialize(connection, context = {}) @connection = connection @context = context end def data raise NotImplementedError end protected def get(uri) response = connection.get(uri) raise InvalidApiResponse, "Status: #{response.status}" unless response.status == 200 JSON::parse(response.body, :symbolize_names => true) rescue Faraday::ConnectionFailed raise ConnectionFailed rescue JSON::ParserError raise InvalidApiResponse, "JSON parsing error: #{response.body}" rescue StandardError => e raise ApiError, e.message end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alephant-publisher-request-0.0.3 | lib/alephant/publisher/request/data_mapper.rb |
alephant-publisher-request-0.0.2 | lib/alephant/publisher/request/data_mapper.rb |