<commit_before>class CleverLibrary::Api::Client
  include HTTParty
  base_uri 'https://api.clever.com/v2.0'

  def initialize(bearer_token)
    @options = {
      headers: {
        "Authorization": "Bearer " + bearer_token
      }
    }
  end

  def get_path(path:)
    self.class.get(path, @options).parsed_response["data"]
  end

  def get_district(district_id:)
    self.class.get('/districts/' + district_id, @options).parsed_response["data"]
  end

  def get_user()
    self.class.get('/me', @options).parsed_response["data"]
  end

  def get_teacher(teacher_id:)
    self.class.get('/teachers/' + teacher_id, @options).parsed_response["data"]
  end

  def get_teacher_sections(teacher_id:)
    self.class.get('/teachers/' + teacher_id + '/sections', @options)
      .parsed_response["data"]
      .map {|section| section["data"]}
  end

  def get_section_students(section_id:)
    self.class.get('/sections/' + section_id + '/students', @options)
      .parsed_response["data"]
      .map {|section| section["data"]}
  end
end

<commit_msg>null check data in clever library sections<commit_after>class CleverLibrary::Api::Client
  include HTTParty
  base_uri 'https://api.clever.com/v2.0'

  def initialize(bearer_token)
    @options = {
      headers: {
        "Authorization": "Bearer " + bearer_token
      }
    }
  end

  def get_path(path:)
    self.class.get(path, @options).parsed_response["data"]
  end

  def get_district(district_id:)
    self.class.get('/districts/' + district_id, @options).parsed_response["data"]
  end

  def get_user()
    self.class.get('/me', @options).parsed_response["data"]
  end

  def get_teacher(teacher_id:)
    self.class.get('/teachers/' + teacher_id, @options).parsed_response["data"]
  end

  def get_teacher_sections(teacher_id:)
    self.class.get('/teachers/' + teacher_id + '/sections', @options)
      .parsed_response["data"]
      .map {|section| section["data"]}
  end

  def get_section_students(section_id:)
    data = self.class.get('/sections/' + section_id + '/students', @options)
      .parsed_response["data"]
    if data && data.length
      data.map {|section| section["data"]}
    else
      nil
    end
  end
end
{'fraction_non_alphanumeric': 0.15096065873741996, 'fraction_numerical': 0.0018298261665141812, 'mean_word_length': 3.527950310559006, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1080084', 'n_tokens_mistral': 763, 'n_tokens_neox': 744, 'n_words': 131}