/*
 * Copyright © 2016-2018 European Support Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const {When} = require('cucumber');
const _ = require('lodash');
const util = require('../cucumber-common/utils/Utils.js');
_.templateSettings.interpolate = /{([\s\S]+?)}/g;

function getPath(path, context) {
	let compiled = _.template(path);
	return compiled(context);
}
/**
 * @module Rest_Calls
 * @description makes a GET request to the given path (path is appended after the "onboarding-api/v1.0" prefix)<br>
 * @exampleFile Example_Rest_Calls.feature
 * @step I want to get path {string}
 **/
When('I want to get path {string}', function(string)  {
	let path = getPath(string, this.context);
	return util.request(this.context, 'GET', path);
});

/**
 * @module Rest_Calls
 * @description makes a DELETE request to the given path and appends the saved property (path is appended after the "onboarding-api/v1.0" prefix)<br>
 * @exampleFile Example_Rest_Calls.feature
 * @step I want to delete for path {string} with the value from saved property {string}
 **/
When('I want to delete for path {string} with the value from saved property {string}', function(string, string2)  {
	let path = getPath(string, this.context);
	path += '/' + this.context[string2];
	return util.request(this.context, 'DELETE', path);
});

/**
 * @module Rest_Calls
 * @description makes a DELETE request to the given path and appends the saved property (path is appended after the "onboarding-api/v1.0" prefix)<br>
 * @exampleFile Example_Rest_Calls.feature
 * @step I want to delete for path {string} with the value from saved property {string}
 **/
When('I want to delete for path {string}', function (string) {
    let path = getPath(string, this.context);
    //path += '/' + this.context[string2];
    return util.request(this.context, 'DELETE', path);
});

/**
 * @module Rest_Calls
 * @description makes a PUT request to the given path and sends the input data from the context (path is appended after the "onboarding-api/v1.0" prefix)<br>
 *     @exampleFile Example_Rest_Calls.feature
 * @step I want to update for path {string} with the input data from the context
 **/
When('I want to update for path {string} with the input data from the context', function(string)  {
	let path = getPath(string, this.context);
	return util.request(this.context, 'PUT', path, this.context.inputData);
});

/**
 * @module Rest_Calls
 * @description makes a POST request to the given path and sends the input data from the context (path is appended after the "onboarding-api/v1.0" prefix)<br>
 *     @exampleFile Example_Rest_Calls.feature
 * @step I want to create for path {string} with the input data from the context
 **/
When('I want to create for path {string} with the input data from the context', function(string)  {
	let path = getPath(string, this.context);
	return util.request(this.context, 'POST', path, this.context.inputData);
});
