Sha256: 06a4dc6e945d7cf22ac30aae04f6213ffac9e37cd085b8e1dc8a0d9966670d47
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
require 'cgi' module Gerry module Api module Changes # Get changes visible to the caller. # # @param [Array] options the query parameters. # @return [Hash] the changes. def changes(options = []) endpoint = '/changes/' url = endpoint if !options.empty? url += '?' + map_options(options) end response = get(url) return response if response.empty? || !response.last.delete('_more_changes') # Get the original start parameter, if any, else start from 0. query = URI.parse(url).query query = query ? CGI.parse(query) : { 'S' => ['0'] } start = query['S'].join.to_i # Keep getting data until there are no more changes. loop do # Replace the start parameter, using the original start as an offset. query['S'] = ["#{start + response.size}"] url = endpoint + '?' + map_options(query) response.concat(get(url)) return response if response.empty? || !response.last.delete('_more_changes') end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gerry-0.1.6 | lib/gerry/api/changes.rb |