services/assistant/v1-workspace-manager.js
function setWorkspaceParams(method, params, workspaceObject) {
    var workspace_id = null;
    var stash = {};

    if ('object' !== typeof workspaceObject) {
      return Promise.reject('json content expected as input on payload');
    }

    switch(method) {
    case 'updateIntent':
      if (params['old_intent']) {
        stash['old_intent'] = params['old_intent'];
      }
      break;
    case 'updateEntity':
      if (params['old_entity']) {
        stash['old_entity'] = params['old_entity'];
      }
      break;
    case 'updateEntityValue':
      if (params['old_value']) {
        stash['old_value'] = params['old_value'];
      }
      if (params['entity']) {
        stash['entity'] = params['entity'];
      }
      break;
    case 'updateDialogNode':
      if (params['old_dialog_node']) {
        stash['old_dialog_node'] = params['old_dialog_node'];
      }
      break;
    }

    switch(method) {
    case 'updateWorkspace':
    case 'createIntent':
    case 'updateIntent':
    case 'createEntity':
    case 'updateEntity':
    case 'updateEntityValue':
    case 'createDialogNode':
    case 'updateDialogNode':
      if (params['workspace_id']) {
        stash['workspace_id'] = params['workspace_id'];
      }
      break;
    }

    if (workspaceObject) {
      params = workspaceObject;
    }

    if (stash) {
      for (var k in stash) {
        params[k] = stash[k];
      }
    }

    return Promise.resolve(params);
  }
function setWorkspaceParams(method, params, workspaceObject) {
    var workspace_id = null;
    var stash = {};

    if ('object' !== typeof workspaceObject) {
      return Promise.reject('json content expected as input on payload');
    }

    switch(method) {
    case 'updateIntent':
      if (params['old_intent']) {
        stash['old_intent'] = params['old_intent'];
      }
      break;
    case 'updateEntity':
      if (params['old_entity']) {
        stash['old_entity'] = params['old_entity'];
      }
      break;
    case 'updateEntityValue':
      if (params['old_value']) {
        stash['old_value'] = params['old_value'];
      }
      if (params['entity']) {
        stash['entity'] = params['entity'];
      }
      break;
    case 'updateDialogNode':
      if (params['old_dialog_node']) {
        stash['old_dialog_node'] = params['old_dialog_node'];
      }
      break;
    }

    switch(method) {
    case 'updateWorkspace':
    case 'createIntent':
    case 'updateIntent':
    case 'createEntity':
    case 'updateEntity':
    case 'updateEntityValue':
    case 'createDialogNode':
    case 'updateDialogNode':
      if (params['workspace_id']) {
        stash['workspace_id'] = params['workspace_id'];
      }
      break;
    }

    if (workspaceObject) {
      params = workspaceObject;
    }

    if (stash) {
      for (var k in stash) {
        params[k] = stash[k];
      }
    }

    return Promise.resolve(params);
  }
function setWorkspaceParams ( method , params , workspaceObject ) { var workspace_id = null ; var stash = { } ; if ( 'object' !== typeof workspaceObject ) { return Promise . reject ( 'json content expected as input on payload' ) ; } switch ( method ) { case 'updateIntent' : if ( params [ 'old_intent' ] ) { stash [ 'old_intent' ] = params [ 'old_intent' ] ; } break ; case 'updateEntity' : if ( params [ 'old_entity' ] ) { stash [ 'old_entity' ] = params [ 'old_entity' ] ; } break ; case 'updateEntityValue' : if ( params [ 'old_value' ] ) { stash [ 'old_value' ] = params [ 'old_value' ] ; } if ( params [ 'entity' ] ) { stash [ 'entity' ] = params [ 'entity' ] ; } break ; case 'updateDialogNode' : if ( params [ 'old_dialog_node' ] ) { stash [ 'old_dialog_node' ] = params [ 'old_dialog_node' ] ; } break ; } switch ( method ) { case 'updateWorkspace' : case 'createIntent' : case 'updateIntent' : case 'createEntity' : case 'updateEntity' : case 'updateEntityValue' : case 'createDialogNode' : case 'updateDialogNode' : if ( params [ 'workspace_id' ] ) { stash [ 'workspace_id' ] = params [ 'workspace_id' ] ; } break ; } if ( workspaceObject ) { params = workspaceObject ; } if ( stash ) { for ( var k in stash ) { params [ k ] = stash [ k ] ; } } return Promise . resolve ( params ) ; }
No need to have complicated processing here Looking for individual fields in the json object, like name, language, entities etc. as these are the parameters required for this method are in the json object, at the top level of the json object. So it is safe to overwrite params. 'name', 'language', 'entities', 'intents', 'dialog_nodes', 'metadata', 'description', 'counterexamples' So will work for intent as is, for 'intent', 'description', 'examples' Just need to add the workspace id back in. For intent updates the old_intent will have already been set.
No need to have complicated processing here Looking for individual fields in the json object like name language entities etc . as these are the parameters required for this method are in the json object at the top level of the json object . So it is safe to overwrite params . name language entities intents dialog_nodes metadata description counterexamples So will work for intent as is for intent description examples Just need to add the workspace id back in . For intent updates the old_intent will have already been set .