lib/tracker_api/client.rb in tracker_api-0.2.5 vs lib/tracker_api/client.rb in tracker_api-0.2.6

- old
+ new

@@ -52,10 +52,19 @@ # @return [Faraday::Response] def get(path, options = {}) request(:get, parse_query_and_convenience_headers(path, options)) end + # Make a HTTP POST request + # + # @param path [String] The path, relative to api endpoint + # @param options [Hash] Query and header params for request + # @return [Faraday::Response] + def post(path, options = {}) + request(:post, parse_query_and_convenience_headers(path, options)) + end + # Make one or more HTTP GET requests, optionally fetching # the next page of results from information passed back in headers # based on value in {#auto_paginate}. # # @param path [String] The path, relative to {#api_endpoint} @@ -65,14 +74,15 @@ # contains the contents of the requests so far and the second parameter # contains the latest response. # @return [Array] def paginate(path, options = {}, &block) opts = parse_query_and_convenience_headers path, options.dup + auto_paginate = opts[:params].delete(:auto_paginate) { |k| @auto_paginate } @last_response = request :get, opts data = @last_response.body raise TrackerApi::Errors::UnexpectedData, 'Array expected' unless data.is_a? Array - if @auto_paginate + if auto_paginate pager = Pagination.new @last_response.headers while pager.more? opts[:params].update(pager.next_page_params)