Skip to content

Commit

Permalink
refactor(adapter files): renames _params to newParams
Browse files Browse the repository at this point in the history
  • Loading branch information
Anwesha Naskar authored and Anwesha Naskar committed Mar 8, 2018
1 parent cfb364c commit 2ba85dd
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 154 deletions.
112 changes: 56 additions & 56 deletions conversation/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ class ConversationV1 extends GeneratedConversationV1 {
const missingParams = getMissingParams(params, requiredParams);
if (missingParams) { return callback(missingParams); }

const _params = extend({}, params);
_params.intent = params.old_intent;
_params.new_intent = params.intent;
_params.new_description = params.description;
_params.new_examples = params.examples;
const newParams = extend({}, params);
newParams.intent = params.old_intent;
newParams.new_intent = params.intent;
newParams.new_description = params.description;
newParams.new_examples = params.examples;

return super.updateIntent(_params, callback);
return super.updateIntent(newParams, callback);
}

getExamples(params, callback) {
Expand All @@ -88,11 +88,11 @@ class ConversationV1 extends GeneratedConversationV1 {
const missingParams = getMissingParams(params, requiredParams);
if (missingParams) { return callback(missingParams); }

const _params = extend({}, params);
_params.text = params.old_text;
_params.new_text = params.text;
const newParams = extend({}, params);
newParams.text = params.old_text;
newParams.new_text = params.text;

return super.updateExample(_params, callback);
return super.updateExample(newParams, callback);
}

getCounterExamples(params, callback) {
Expand Down Expand Up @@ -121,11 +121,11 @@ class ConversationV1 extends GeneratedConversationV1 {
const missingParams = getMissingParams(params, requiredParams);
if (missingParams) { return callback(missingParams); }

const _params = extend({}, params);
_params.text = params.old_text;
_params.new_text = params.text;
const newParams = extend({}, params);
newParams.text = params.old_text;
newParams.new_text = params.text;

return super.updateCounterexample(_params, callback);
return super.updateCounterexample(newParams, callback);
}

getEntities(params, callback) {
Expand All @@ -150,15 +150,15 @@ class ConversationV1 extends GeneratedConversationV1 {
const missingParams = getMissingParams(params, requiredParams);
if (missingParams) { return callback(missingParams); }

const _params = extend({}, params);
_params.entity = params.old_entity;
_params.new_entity = params.entity;
_params.new_description = params.description;
_params.new_metadata = params.metadata;
_params.new_fuzzy_match = params.fuzzy_match;
_params.new_values = params.values;
const newParams = extend({}, params);
newParams.entity = params.old_entity;
newParams.new_entity = params.entity;
newParams.new_description = params.description;
newParams.new_metadata = params.metadata;
newParams.new_fuzzy_match = params.fuzzy_match;
newParams.new_values = params.values;

return super.updateEntity(_params, callback);
return super.updateEntity(newParams, callback);
}

getValues(params, callback) {
Expand All @@ -183,15 +183,15 @@ class ConversationV1 extends GeneratedConversationV1 {
const missingParams = getMissingParams(params, requiredParams);
if (missingParams) { return callback(missingParams); }

const _params = extend({}, params);
_params.value = params.old_value;
_params.new_value = params.value;
_params.new_metadata = params.metadata;
_params.new_type = params.type;
_params.new_synonyms = params.synonyms;
_params.new_patterns = params.patterns;
const newParams = extend({}, params);
newParams.value = params.old_value;
newParams.new_value = params.value;
newParams.new_metadata = params.metadata;
newParams.new_type = params.type;
newParams.new_synonyms = params.synonyms;
newParams.new_patterns = params.patterns;

return super.updateValue(_params, callback);
return super.updateValue(newParams, callback);
}

getSynonyms(params, callback) {
Expand All @@ -214,11 +214,11 @@ class ConversationV1 extends GeneratedConversationV1 {
const missingParams = getMissingParams(params, requiredParams);
if (missingParams) { return callback(missingParams); }

const _params = extend({}, params);
_params.synonym = params.old_synonym;
_params.new_synonym = params.synonym;
const newParams = extend({}, params);
newParams.synonym = params.old_synonym;
newParams.new_synonym = params.synonym;

return super.updateSynonym(_params, callback);
return super.updateSynonym(newParams, callback);
}

getLogs(params, callback) {
Expand All @@ -227,11 +227,11 @@ class ConversationV1 extends GeneratedConversationV1 {
}

createDialogNode(params, callback) {
const _params = extend({}, params);
if (params && params.type && !_params.node_type) {
_params.node_type = params.type;
const newParams = extend({}, params);
if (params && params.type && !newParams.node_type) {
newParams.node_type = params.type;
}
return super.createDialogNode(_params, callback);
return super.createDialogNode(newParams, callback);
}

getDialogNodes(params, callback) {
Expand Down Expand Up @@ -265,24 +265,24 @@ class ConversationV1 extends GeneratedConversationV1 {
const missingParams = getMissingParams(params, requiredParams);
if (missingParams) { return callback(missingParams); }

const _params = extend({}, params);
_params.dialog_node = params.old_dialog_node;
_params.new_dialog_node = params.dialog_node;
_params.new_description = params.description;
_params.new_conditions = params.conditions;
_params.new_parent = params.parent;
_params.new_previous_sibling = params.previous_sibling;
_params.new_output = params.output;
_params.new_context = params.context;
_params.new_metadata = params.metadata;
_params.new_next_step = params.next_step;
_params.new_title = params.title;
_params.new_type = params.type;
_params.new_event_name = params.event_name;
_params.new_variable = params.variable;
_params.new_actions = params.actions;

return super.updateDialogNode(_params, callback);
const newParams = extend({}, params);
newParams.dialog_node = params.old_dialog_node;
newParams.new_dialog_node = params.dialog_node;
newParams.new_description = params.description;
newParams.new_conditions = params.conditions;
newParams.new_parent = params.parent;
newParams.new_previous_sibling = params.previous_sibling;
newParams.new_output = params.output;
newParams.new_context = params.context;
newParams.new_metadata = params.metadata;
newParams.new_next_step = params.next_step;
newParams.new_title = params.title;
newParams.new_type = params.type;
newParams.new_event_name = params.event_name;
newParams.new_variable = params.variable;
newParams.new_actions = params.actions;

return super.updateDialogNode(newParams, callback);
}
}

Expand Down
50 changes: 25 additions & 25 deletions dialog/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ class DialogV1 extends BaseService {
params: DialogV1.GetProfileParams,
callback: DialogV1.Callback
): NodeJS.ReadableStream | void {
const _params = params || {};
const newParams = params || {};
const parameters = {
options: {
url: '/v1/dialogs/{dialog_id}/profile',
method: 'GET',
json: true,
path: _params,
qs: pick(_params, ['client_id', 'name'])
path: newParams,
qs: pick(newParams, ['client_id', 'name'])
},
requiredParams: ['dialog_id', 'client_id'],
defaultOptions: this._options
Expand All @@ -86,13 +86,13 @@ class DialogV1 extends BaseService {
params: DialogV1.UpdateProfileParams,
callback: DialogV1.Callback
): NodeJS.ReadableStream | void {
const _params = params || {};
const newParams = params || {};
const parameters = {
options: {
url: '/v1/dialogs/{dialog_id}/profile',
method: 'PUT',
json: true,
body: pick(_params, ['name_values', 'client_id']),
body: pick(newParams, ['name_values', 'client_id']),
path: params
},
requiredParams: ['dialog_id', 'name_values'],
Expand All @@ -109,14 +109,14 @@ class DialogV1 extends BaseService {
params: DialogV1.GetConversationParams,
callback: DialogV1.Callback
): NodeJS.ReadableStream | void {
const _params = params || {};
const newParams = params || {};
const parameters = {
options: {
url: '/v1/dialogs/{dialog_id}/conversation',
method: 'GET',
json: true,
qs: omit(_params, ['dialog_id']),
path: _params
qs: omit(newParams, ['dialog_id']),
path: newParams
},
requiredParams: ['dialog_id', 'date_from', 'date_to'],
defaultOptions: this._options
Expand All @@ -133,14 +133,14 @@ class DialogV1 extends BaseService {
params: DialogV1.ConversationParams,
callback: DialogV1.Callback
): NodeJS.ReadableStream | void {
const _params = params || {};
const newParams = params || {};
const parameters = {
options: {
url: '/v1/dialogs/{dialog_id}/conversation',
method: 'POST',
json: true,
form: omit(_params, ['dialog_id']),
path: _params
form: omit(newParams, ['dialog_id']),
path: newParams
},
requiredParams: ['dialog_id'],
defaultOptions: this._options
Expand All @@ -156,20 +156,20 @@ class DialogV1 extends BaseService {
params: DialogV1.UpdateContentParams,
callback: DialogV1.Callback
): NodeJS.ReadableStream | void {
const _params = params || {};
const newParams = params || {};
const parameters = {
options: {
url: '/v1/dialogs/{dialog_id}/content',
method: 'PUT',
json: true,
path: _params
path: newParams
},
requiredParams: ['dialog_id'],
defaultOptions: extend(
true,
{},
this._options,
pick(_params, ['headers'])
pick(newParams, ['headers'])
)
};
return createRequest(parameters, callback);
Expand All @@ -183,13 +183,13 @@ class DialogV1 extends BaseService {
params: DialogV1.GetContentParams,
callback: DialogV1.Callback
): NodeJS.ReadableStream | void {
const _params = params || {};
const newParams = params || {};
const parameters = {
options: {
url: '/v1/dialogs/{dialog_id}/content',
method: 'GET',
json: true,
path: _params
path: newParams
},
requiredParams: ['dialog_id'],
defaultOptions: this._options
Expand All @@ -205,12 +205,12 @@ class DialogV1 extends BaseService {
params: DialogV1.CreateDialogParams,
callback: DialogV1.Callback
): NodeJS.ReadableStream | void {
const _params = params || {};
if (!_params['file']) {
const newParams = params || {};
if (!newParams['file']) {
callback(new Error('Missing required parameters: file'));
return;
}
if (!isStream(_params['file'])) {
if (!isStream(newParams['file'])) {
callback(new Error('file is not a standard Node.js Stream'));
return;
}
Expand All @@ -219,7 +219,7 @@ class DialogV1 extends BaseService {
url: '/v1/dialogs',
method: 'POST',
json: true,
formData: pick(_params, ['name', 'file'])
formData: pick(newParams, ['name', 'file'])
},
requiredParams: ['name'],
defaultOptions: this._options
Expand Down Expand Up @@ -273,12 +273,12 @@ class DialogV1 extends BaseService {
params: DialogV1.UpdateDialogParams,
callback: DialogV1.Callback
): NodeJS.ReadableStream | void {
const _params = params || {};
if (!_params['file']) {
const newParams = params || {};
if (!newParams['file']) {
callback(new Error('Missing required parameters: file'));
return;
}
if (!isStream(_params['file'])) {
if (!isStream(newParams['file'])) {
callback(new Error('file is not a standard Node.js Stream'));
return;
}
Expand All @@ -287,8 +287,8 @@ class DialogV1 extends BaseService {
url: '/v1/dialogs/{dialog_id}',
method: 'PUT',
json: true,
path: _params,
formData: omit(_params, ['dialog_id'])
path: newParams,
formData: omit(newParams, ['dialog_id'])
},
requiredParams: ['dialog_id'],
defaultOptions: this._options
Expand Down
Loading

0 comments on commit 2ba85dd

Please sign in to comment.