text: /**
   * Auto-generated action file for "Mailchimp Marketing API" API.
   *
   * Generated at: 2022-01-05T12:34:40.167Z
   * Mass generator version: 1.0.0
   *
   * : mailchimp-newcomp
   * Copyright © 2020,  AG
   *
   * All files of this connector are licensed under the Apache 2.0 License. For details
   * see the file LICENSE on the toplevel directory.
   *
   *
   * Operation: 'deleteListsIdInterestCategoriesIdInterestsId'
   * Endpoint Path: '/lists/{list_id}/interest-categories/{interest_category_id}/interests/{interest_id}'
   * Method: 'delete'
   *
   */
  
  
  
   // how to pass the transformation function... no need
   // pass the meta data 
   // create a new Object 
   // emit the message with the new emit function 
  
   // securities and auth methods   
   // check how to make the new ferryman and its transform functions functional // no need
  
  const Swagger = require('swagger-client');
  const spec = require('../spec.json');
  
  // this wrapers offers a simplified emitData(data) function
  module.exports = {process: processAction};
  
  // parameter names for this call
  const PARAMETERS = [
      "list_id",
      "interest_category_id",
      "interest_id"
  ];
  
  // mappings from connector field names to API field names
  const FIELD_MAP = {
      "list_id": "list_id",
      "interest_category_id": "interest_category_id",
      "interest_id": "interest_id"
  };
  
  function processAction(msg, cfg) {
      var isVerbose = process.env.debug || cfg.verbose;
  
      console.log("msg:",msg);
      console.log("cfg:",cfg)
  
      if (isVerbose) {
          console.log(`---MSG: ${JSON.stringify(msg)}`);
          console.log(`---CFG: ${JSON.stringify(cfg)}`);
          console.log(`---ENV: ${JSON.stringify(process.env)}`);
      }
  
      const contentType = undefined;
  
      const body = msg.data;
      mapFieldNames(body);
  
      let parameters = {};
      for(let param of PARAMETERS) {
          parameters[param] = body[param];
      }
  
      const oihUid = msg.metadata !== undefined && msg.metadata.oihUid !== undefined
      ? msg.metadata.oihUid
      : 'oihUid not set yet';
    const recordUid = msg.metadata !== undefined && msg.metadata.recordUid !== undefined
      ? msg.metadata.recordUid
      : undefined;
    const applicationUid = msg.metadata !== undefined && msg.metadata.applicationUid !== undefined
      ? msg.metadata.applicationUid
      : undefined;
  
      const newElement = {};
      const oihMeta = {
        applicationUid,
        oihUid,
        recordUid,
      };
      
      // credentials for this operation
      let securities = {};
      securities['basicAuth'] = {username: cfg.username, password: cfg.passphrase};;
  
      if(cfg.otherServer){
          if(!spec.servers){
              spec.servers = [];
          }
          spec.servers.push({"url":cfg.otherServer})
      }
      
      
      let callParams = {
          spec: spec,
          operationId: 'deleteListsIdInterestCategoriesIdInterestsId',
          pathName: '/lists/{list_id}/interest-categories/{interest_category_id}/interests/{interest_id}',
          method: 'delete',
          parameters: parameters,
          requestContentType: contentType,
          requestBody: body,
          securities: {authorized: securities},
          server: spec.servers[cfg.server] || cfg.otherServer,
      };
          if(callParams.method === 'get'){
              delete callParams.requestBody;
          }
      
  
      if (isVerbose) {
          let out = Object.assign({}, callParams);
          out.spec = '[omitted]';
          console.log(`--SWAGGER CALL: ${JSON.stringify(out)}`);
      }
  
      // Call operation via Swagger client
      return Swagger.execute(callParams).then(data => {
          // emit a single message with data
          // console.log("swagger data:",data);
          delete data.uid;
          newElement.metadata = oihMeta;
          newElement.data = data.data
          this.emit("data",newElement);
  
          // if the response contains an array of entities, you can emit them one by one:
  
          // data.obj.someItems.forEach((item) => {
          //     this.emitData(item);
          // }
      });
  }
  
  function mapFieldNames(obj) {
      if(Array.isArray(obj)) {
          obj.forEach(mapFieldNames);
      }
      else if(typeof obj === 'object' && obj) {
          obj = Object.fromEntries(Object.entries(obj).filter(([_, v]) => v != null));
  
      }
  
   }