<commit_before>require "qualaroo/version"
require "httparty"

module Qualaroo
  class Client
    include HTTParty
    base_uri 'app.qualaroo.com/api/v1'
    format :json

    def initialize(key, secret)
      @auth = {username: key, password: <PASSWORD>}
    end

    def responses(survey_id, options={})
      options.merge!(basic_auth: @auth)
      self.class.get "/nudges/#{survey_id}/responses.json", options
    end
  end
end<commit_msg>Add method to retrieve all the responses from a nudge<commit_after>require "qualaroo/version"
require "httparty"

module Qualaroo
  class Client
    include HTTParty
    base_uri 'app.qualaroo.com/api/v1'
    format :json

    def initialize(key, secret)
      @auth = {username: key, password: <PASSWORD>}
    end

    def responses(nudge_id, query={}, options={})
      options.merge!(basic_auth: @auth, query: query)
      self.class.get("/nudges/#{nudge_id}/responses.json", options)
    end

    def all_responses(nudge_id, query={}, options={})
      offset = 0
      all_responses = []

      while (page_responses = responses(nudge_id, query.merge(offset: offset), options)) && page_responses.any?
        all_responses += page_responses
        offset += 500
      end

      all_responses
    end
  end
end
{'fraction_non_alphanumeric': 0.1136724960254372, 'fraction_numerical': 0.0047694753577106515, 'mean_word_length': 3.239057239057239, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1596745', 'n_tokens_mistral': 422, 'n_tokens_neox': 410, 'n_words': 99}