Sha256: 873f6fb2257d358c7362e85cd1477f8163c24c17d2db3ce99b02ae8b99bef68d

Contents?: true

Size: 831 Bytes

Versions: 1

Compression:

Stored size: 831 Bytes

Contents

module ITunes
  module Request

    # @private
    private

    # Perform an HTTP GET request
    def request(request_type, params)
      url = '/WebObjects/MZStoreServices.woa/wa/ws' + request_type

      response = connection.get do |req|
        req.url url, params
        req.options.timeout = Configuration::DEFAULT_REQUEST_OPTIONS[:timeout]
        req.options.open_timeout = Configuration::DEFAULT_REQUEST_OPTIONS[:open_timeout]
      end
      response.body
    end

    def connection
      options = {
        :headers => {'Accept' => 'application/json', 'User-Agent' => user_agent},
        :url => api_endpoint,
      }

      Faraday.new(options) do |builder|
        builder.use Faraday::Response::Rashify
        builder.use Faraday::Response::ParseJson
        builder.adapter(adapter)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itunes-0.7.0 lib/itunes/request.rb