// Dependencies import humps from 'humps'; import autobind from 'autobind-decorator'; import { ChannelsResponse } from './dto/channelsResponse'; import { DialogClient } from './clientDefinition'; function process(target: unknown, propertyKey: string, descriptor: PropertyDescriptor) { const originalMethod = descriptor.value; function overridedMethod(...args: unknown[]) { const newArgs = args.map((arg) => humps.decamelizeKeys(arg)); console.log('newArgs', newArgs); return originalMethod(newArgs) .then((a: unknown) => { console.log('response', a); return humps.camelizeKeys(a); }); } Object.assign(descriptor, { value: overridedMethod }); } /** * Chat channels. * @class ChannelService * @author Daniel Mejia */ @autobind export class Channels { channelsClient: DialogClient; constructor(channelsClient: DialogClient) { this.channelsClient = channelsClient; } @process getChannels(): Promise { return this.channelsClient.list(); } } export default Channels;