<commit_before>_ = require('lodash')
Canvas = require('resin-platform-api')
Promise = require('bluebird')
settings = require('../settings')
server = require('../server/server')
promisifiedServerRequest = Promise.promisify(server.request, server)

class CanvasRequestService extends Canvas(_, Promise)
	_request: (params) ->
		params.json = params.data
		params.gzip ?= true
		promisifiedServerRequest(params).spread (response, body) ->
			if 200 <= response.statusCode < 300
				return body<commit_msg>Document resin/models/_canvas<commit_after>_ = require('lodash')
Promise = require('bluebird')
Canvas = require('resin-platform-api')(_, Promise)
settings = require('../settings')
server = require('../server/server')
promisifiedServerRequest = Promise.promisify(server.request, server)

class CanvasRequestService extends Canvas

	# Trigger a request to the resin.io API
	#
	# Makes use of [pinejs-client](https://bitbucket.org/rulemotion/pinejs-client-js)
	#
	# @private
	#
	# @param {Object} params request params (same as node-request params)
	#
	# @note You shouldn't make use of this method directly, but through models
	_request: (params) ->
		params.json = params.data
		params.gzip ?= true
		promisifiedServerRequest(params).spread (response, body) ->
			if 200 <= response.statusCode < 300
				return body
{'fraction_non_alphanumeric': 0.13145896656534956, 'fraction_numerical': 0.00911854103343465, 'mean_word_length': 4.986363636363636, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 1, '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': '5978494', 'n_tokens_mistral': 432, 'n_tokens_neox': 392, 'n_words': 99}