Sha256: 44f42a7226ee6d8c5e1caad356c7c0e659119800b3281afbf63fb416309432e1

Contents?: true

Size: 837 Bytes

Versions: 8

Compression:

Stored size: 837 Bytes

Contents

module FellowshipOne

  # This adapter is the standard for all loading objects.
  class ApiReader
    attr_reader :headers

    # Retrieve an empty resource with the proper structure.
    #
    # @return a new empty resource.
    def load_new
      return if @url_new_data_path.nil?
      return _load_data(@url_new_data_path, {})
    end      

    # Loads the list
    #
    # @return the data loaded in a JSON object.
    def load_feed
      @url_data_params ||= {}
      return _load_data(@url_data_path, @url_data_params)
    end

    private

    def _load_data(url_data_path, url_data_params)
      response = FellowshipOne::api_request(:get, url_data_path, url_data_params)
      data = JSON.parse(response.body)
      @headers = response.headers
      return data.keys == ['results'] ? data['results'] : data
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fellowshipone-api-0.9.0 lib/readers/api_reader.rb
fellowshipone-api-0.8.0 lib/readers/api_reader.rb
fellowshipone-api-0.7.0 lib/readers/api_reader.rb
fellowshipone-api-0.6.4 lib/readers/api_reader.rb
fellowshipone-api-0.6.3 lib/readers/api_reader.rb
fellowshipone-api-0.6.2 lib/readers/api_reader.rb
fellowshipone-api-0.6.1 lib/readers/api_reader.rb
fellowshipone-api-0.6.0 lib/readers/api_reader.rb