<commit_before>module Gibbon
  class ExportRequest
    attr_accessor :api_key, :timeout

    DEFAULT_TIMEOUT = 30

    def initialize(api_key: nil, timeout: nil)
      @api_key = api_key || self.class.api_key || ENV['MAILCHIMP_API_KEY']
      @api_key = @api_key.strip if @api_key
      @timeout = timeout || self.class.timeout || DEFAULT_TIMEOUT
    end
    
    def list(id: nil, status: nil, segment: nil, since: nil, &block)
      validate_api_key
      validate_id

      params = {}
      params[:id] = id if id
      params[:status] = status if status
      params[:segment] = segment if segment
      params[:since] = since if since
      post("list", params, &block)
    end

    def ecomm_orders(since: nil, &block)
      validate_api_key

      params = {}
      params[:since] = since if since
      post("ecommOrders", params, &block)
    end

    def campaign_subscriber_activity(id: nil, include_empty: false, since: nil, &block)
      validate_api_key
      validate_id
      
      params = {}
      params[:id] = id if id
      params[:include_empty] = include_empty if include_empty
      params[:since] = since if since
      post("campaignSubscriberActivity", params, &block)
    end

    protected
    
    def validate_api_key
      api_key = self.api_key
      unless api_key && (api_key["-"] || self.api_endpoint)
        raise Gibbon::GibbonError, "You must set an api_key prior to making a request"
      end
    end
  
    def validate_id
      unless params[:id] || params["id"]
        raise Gibbon::GibbonError, "You must pass a list id when making a request"<commit_msg>actually pass id<commit_after>module Gibbon
  class ExportRequest
    attr_accessor :api_key, :timeout

    DEFAULT_TIMEOUT = 30

    def initialize(api_key: nil, timeout: nil)
      @api_key = api_key || self.class.api_key || ENV['MAILCHIMP_API_KEY']
      @api_key = @api_key.strip if @api_key
      @timeout = timeout || self.class.timeout || DEFAULT_TIMEOUT
    end
    
    def list(id: nil, status: nil, segment: nil, since: nil, &block)
      validate_api_key
      validate_id(id)

      params = {}
      params[:id] = id if id
      params[:status] = status if status
      params[:segment] = segment if segment
      params[:since] = since if since
      post("list", params, &block)
    end

    def ecomm_orders(since: nil, &block)
      validate_api_key

      params = {}
      params[:since] = since if since
      post("ecommOrders", params, &block)
    end

    def campaign_subscriber_activity(id: nil, include_empty: false, since: nil, &block)
      validate_api_key
      validate_id(id)
      
      params = {}
      params[:id] = id if id
      params[:include_empty] = include_empty if include_empty
      params[:since] = since if since
      post("campaignSubscriberActivity", params, &block)
    end

    protected
    
    def validate_api_key
      api_key = self.api_key
      unless api_key && (api_key["-"] || self.api_endpoint)
        raise Gibbon::GibbonError, "You must set an api_key prior to making a request"
      end
    end
  
    def validate_id(id)
      unless id
        raise Gibbon::GibbonError, "You must pass a list id when making a request"
{'fraction_non_alphanumeric': 0.0973700688791484, 'fraction_numerical': 0.0012523481527864746, 'mean_word_length': 2.7022016222479723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6512028', 'n_tokens_mistral': 1001, 'n_tokens_neox': 979, 'n_words': 282}