<commit_before># Require modules
moment = require 'moment'
request = require 'request'

###
Updown
Simple API wrapper for the updown.io service
###
class Updown

	###
	Constructor method
	@param {string} apiKey - Your Updown API key
	@param {object} config - A configuration object. Currently only supports the `readOnly` property
	###
	constructor: (@apiKey, config = {}) ->

		# Assign config properties
		@readOnly = config.readOnly or no


	###
	Loads an URL with the Updown API key header
	@param {string} url - The API URL to call
	@param {object} query - (optional) Parameters to be added to the querystring
	@param {function} callback - Is called when the request completes
	###
	_get: (url, query = {}, callback) ->

		# Allow for (url, callback) parameters without query
		if typeof query is 'function' and not callback?
			[callback, query] = [query, {}]

		# Initiate GET request
		request
			url: url
			method: 'GET'
			json: yes
			qs: query
			headers:
				'X-API-KEY': @apiKey

		# Handle result
		, (err, response, data) ->
			callback(err, data)


	###
	Posts data to an URL with the Updown API key header
	@param {string} method - Method for the HTTP request
	@param {string} url - The API URL to post to
	@param {object} params - Parameters to be sent in the POST body
	@param {function} callback - Is called when the request completes
	###<commit_msg>Added getTime to url to attempt to avoid caching issues<commit_after># Require modules
moment = require 'moment'
request = require 'request'

###
Updown
Simple API wrapper for the updown.io service
###
class Updown

	###
	Constructor method
	@param {string} apiKey - Your Updown API key
	@param {object} config - A configuration object. Currently only supports the `readOnly` property
	###
	constructor: (@apiKey, config = {}) ->

		# Assign config properties
		@readOnly = config.readOnly or no


	###
	Loads an URL with the Updown API key header
	@param {string} url - The API URL to call
	@param {object} query - (optional) Parameters to be added to the querystring
	@param {function} callback - Is called when the request completes
	###
	_get: (url, query = {}, callback) ->

		# Allow for (url, callback) parameters without query
		if typeof query is 'function' and not callback?
			[callback, query] = [query, {}]

		# Add getTime to urls to prevent caching
		query._t = new Date().getTime()

		# Initiate GET request
		request
			url: url
			method: 'GET'
			json: yes
			qs: query
			headers:
				'X-API-KEY': @apiKey

		# Handle result
		, (err, response, data) ->
			callback(err, data)


	###
	Posts data to an URL with the Updown API key header
	@param {string} method - Method for the HTTP request
	@param {string} url - The API URL to post to
	@param {object} params - Parameters to be sent in the POST body
	@param {function} callback - Is called when the request completes
	###
{'fraction_non_alphanumeric': 0.10118632240055828, 'fraction_numerical': 0.0, 'mean_word_length': 3.5580286168521464, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3359879', 'n_tokens_mistral': 920, 'n_tokens_neox': 836, 'n_words': 377}