<commit_before>import { ServerResponse } from 'http';
import { Client } from 'node-rest-client';
type ClientCallback = (json:any, res:ServerResponse) => void;

function ClientMethod(target:ExtendedClient, key:string, descriptor:PropertyDescriptor) {
	/* istanbul ignore next */
    if(descriptor === undefined) {
      descriptor = Object.getOwnPropertyDescriptor(target, key) as PropertyDescriptor;
	}
	const original = descriptor.value;
    descriptor.value = function (route:string, data?:any, filter?:any) {
		const parent:any = this;
		return new Promise<any>(function(resolve) {
			parent.client[key](...parent.prepare(route, data, filter), (json:any) => {
				resolve(json);
			});
		});
    };
    return descriptor;
}

export class ExtendedClient {
	[property:string]: any
	client: any;
	url:string;
	private Authorization: string;
	constructor (url:string, Authorization:string) {
		this.client = new Client();
		this.url = url;
		this.Authorization = Authorization;
	}
	prepare(url:string, data:any, filter:any) {
		let args:any = {
			headers: {
				Authorization: this.Authorization
			}
		};
		if(filter) {
			args.headers['X-Filter'] = JSON.stringify(filter);
		}<commit_msg>fix: delete methods will work correctly<commit_after>import { ServerResponse } from 'http';
import { Client } from 'node-rest-client';
type ClientCallback = (json:any, res:ServerResponse) => void;

function ClientMethod(target:ExtendedClient, key:string, descriptor:PropertyDescriptor) {
	/* istanbul ignore next */
    if(descriptor === undefined) {
      descriptor = Object.getOwnPropertyDescriptor(target, key) as PropertyDescriptor;
	}
	const original = descriptor.value;
    descriptor.value = function (route:string, data?:any, filter?:any) {
		const parent:any = this;
		return new Promise<any>(function(resolve) {
			let mth = key === 'delete' ? 'del' : key;
			parent.client[mth](...parent.prepare(route, data, filter), (json:any) => {
				resolve(json);
			});
		});
    };
    return descriptor;
}

export class ExtendedClient {
	[property:string]: any
	client: any;
	url:string;
	private Authorization: string;
	constructor (url:string, Authorization:string) {
		this.client = new Client();
		this.url = url;
		this.Authorization = Authorization;
	}
	prepare(url:string, data:any, filter:any) {
		let args:any = {
			headers: {
				Authorization: this.Authorization
			}
		};
		if(filter) {
			args.headers['X-Filter'] = JSON.stringify(filter);
		}
{'fraction_non_alphanumeric': 0.14116687066503467, 'fraction_numerical': 0.0, 'mean_word_length': 4.485458612975392, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2449696', 'n_tokens_mistral': 796, 'n_tokens_neox': 744, 'n_words': 171}