<commit_before>request = require('request')

module.exports = class API
  constructor: (apiKey) ->
    @apiKey = apiKey

  getCourseFromRoom: (building, room, done) ->
    apiURL = @apiURLForEndpoint("buildings/#{building}/#{room}/courses")

    options = {
      uri: apiURL
      headers: {'User-Agent': 'Roomular (https://github.com/christhomson/roomular)'}
    }
    request(options, (err, res, body) ->
      try
        classes = JSON.parse(body).data
        done(null, classes)
      catch e
        done(err, [])
    )

  apiURLForEndpoint: (endpoint) ->
    "http://api.uwaterloo.ca/public/v2/#{endpoint}.json?key=#{@apiKey}"<commit_msg>Update V2 API endpoint path.<commit_after>request = require('request')

module.exports = class API
  constructor: (apiKey) ->
    @apiKey = apiKey

  getCourseFromRoom: (building, room, done) ->
    apiURL = @apiURLForEndpoint("buildings/#{building}/#{room}/courses")

    options = {
      uri: apiURL
      headers: {'User-Agent': 'Roomular (https://github.com/christhomson/roomular)'}
    }
    request(options, (err, res, body) ->
      try
        classes = JSON.parse(body).data
        done(null, classes)
      catch e
        done(err, [])
    )

  apiURLForEndpoint: (endpoint) ->
    "http://api.uwaterloo.ca/v2/#{endpoint}.json?key=#{@apiKey}"
{'fraction_non_alphanumeric': 0.16436251920122888, 'fraction_numerical': 0.002304147465437788, 'mean_word_length': 3.0092307692307694, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2795022', 'n_tokens_mistral': 438, 'n_tokens_neox': 425, 'n_words': 77}