Sha256: ffddafbc7303841444ee41e1569bfb564e5458098f7e6ced1f43d4f92c6fd9a3

Contents?: true

Size: 649 Bytes

Versions: 2

Compression:

Stored size: 649 Bytes

Contents

module AppleNews
  module Request
    class Get
      attr_reader :url

      def initialize(url, config = AppleNews.config)
        @config = 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, @config)
        { 'Authorization' => security.authorization }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
apple-news-0.5.1 lib/apple-news/requests/get.rb
apple-news-0.5.0 lib/apple-news/requests/get.rb