Sha256: 9722faddb885cff1ad86a55bb36120399e2b6a3731cfda9f3f151f906c5d23dd

Contents?: true

Size: 623 Bytes

Versions: 13

Compression:

Stored size: 623 Bytes

Contents

module AppleNews
  module Request
    class Get
      attr_reader :url

      def initialize(url)
        @config = AppleNews.config
        @url = URI::parse(File.join(@config.api_base, url))
      end

      def call(params = {})
        http = Net::HTTP.new(@url.hostname, @url.port)
        http.use_ssl = true
        http.verify_mode = OpenSSL::SSL::VERIFY_PEER

        res = http.get(@url, headers)
        JSON.parse(res.body)
      end

      private

      def headers
        security = AppleNews::Security.new('GET', @url.to_s)
        { 'Authorization' => security.authorization }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
apple-news-0.4.2 lib/apple-news/requests/get.rb
apple-news-0.4.1 lib/apple-news/requests/get.rb
apple-news-0.4.0 lib/apple-news/requests/get.rb
apple-news-0.3.1 lib/apple-news/requests/get.rb
apple-news-0.3.0 lib/apple-news/requests/get.rb
apple-news-0.2.5 lib/apple-news/requests/get.rb
apple-news-0.2.4 lib/apple-news/requests/get.rb
apple-news-0.2.3 lib/apple-news/requests/get.rb
apple-news-0.2.2 lib/apple-news/requests/get.rb
apple-news-0.2.1 lib/apple-news/requests/get.rb
apple-news-0.2.0 lib/apple-news/requests/get.rb
apple-news-0.1.1 lib/apple-news/requests/get.rb
apple-news-0.1.0 lib/apple-news/requests/get.rb