refactord payload creatn for template & param save

refactored payload creation for saving template and param artifacts to
APPC using createPayloadForSave method in utility.service.ts

Issue-ID: APPC-1105
Change-Id: I2dd446aebdbcbc1ffc070993ee53d09e25eeae6b
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
index dc40704..a3d55ba 100644
--- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
@@ -40,7 +40,8 @@
 import { NgxSpinnerService } from 'ngx-spinner';
 import { UtilityService } from '../../../../shared/services/utilityService/utility.service';
 declare var $: any
-
+const PARAM_DATA:string="param_data";
+const TEMPLATE_DATA:string="template_data";
 @Component({ selector: 'app-golden-configuration', templateUrl: './template-configuration.component.html', styleUrls: ['./template-configuration.component.css'] })
 export class GoldenConfigurationComponent implements OnInit {
   @ViewChild('templateeditor') templateeditor;
@@ -99,6 +100,7 @@
   }
   public replaceWord;
   public enableDownloadButtons: boolean = false;
+   
   constructor(
     private buildDesignComponent: BuildDesignComponent, 
     private paramShareService: ParamShareService, 
@@ -354,27 +356,7 @@
         let vnfType = this.vnfType;
         let Json = [paramsKeyValueFromEditor];
         let slashedPayload = this.appendSlashes(JSON.stringify(Json));
-        let newPayload =
-          {
-            "userID": this.userId,
-            "vnf-type": this.vnfType,
-            "action": action,
-            "artifact-name": fileName,
-            "artifact-type": "APPC-CONFIG",
-            "artifact-version": this.templateVersionNo,
-            "artifact-contents": slashedPayload
-          }
-        let data =
-          {
-            "input": {
-              "design-request": {
-                "request-id": this.apiToken,
-                "action": "uploadArtifact",
-                "payload": JSON.stringify(newPayload)
-
-              }
-            }
-          }
+        let data = this.utilityService.createPayLoadForSave(PARAM_DATA, this.vnfType, action, fileName, this.templateVersionNo, slashedPayload);
         this.appDataObject.template.nameValueData = data;
       }
       if (this.configMappingEditorContent) {
@@ -398,28 +380,7 @@
           fileName = this.artifactName;
         }
         let vnfType = this.vnfType;
-        let newPayload =
-          {
-            "userID": this.userId,
-            "vnf-type": this.vnfType,
-            "action": action,
-            "artifact-name": fileName,
-            "artifact-type": "APPC-CONFIG",
-            "artifact-version": this.templateVersionNo,
-            "artifact-contents": this.configMappingEditorContent.replace(/\(([^()]|(R))*\)=\(/g, '').replace(/\)}/g, '}')
-
-          }
-        let data =
-          {
-            "input": {
-              "design-request": {
-                "request-id": this.apiToken,
-                "action": "uploadArtifact",
-                "payload": JSON.stringify(newPayload)
-
-              }
-            }
-          }
+        let data = this.utilityService.createPayLoadForSave(TEMPLATE_DATA, this.vnfType, action, fileName, this.templateVersionNo, this.configMappingEditorContent.replace(/\(([^()]|(R))*\)=\(/g, '').replace(/\)}/g, '}'));
         this.appDataObject.template.templateData = data;
         this.mappingEditorService.initialise(this.templateeditor.getEditor(), actualContent, this.modal);
       }