{"version":3,"sources":["webpack:///./node_modules/@abaco/portal-global-state/src/modules/global-state/api/ImportApi.ts"],"names":["ImportApi","http","fakeData","this","object_type_id","paging","get","params","offset","count","only_active","sort","res","data","import_method_id","records","import_id","parameterValues","pk_cuaa","notes","paramsString","forEach","pv","parameter_value","concat","parameter_name","toString","formData","FormData","append","post","put","objectImportId"],"mappings":"uMAWqBA,G,6DAGjB,WAAYC,GAAgB,uBAgCpB,KAAAC,UAAW,EA/BfC,KAAKF,KAAOA,E,gHAGhB,WAAuBG,EAAwBC,GAA/C,uGACsBF,KAAKF,KAAKK,IAAV,0DAAiEF,EAAjE,YAA2F,CACzGG,OAAQ,CACJC,OAAQH,EAAOG,OACfC,MAAOJ,EAAOI,MACdC,aAAa,EACbC,KAAM,uBANlB,cACUC,EADV,yBAUWA,EAAIC,MAVf,gD,gJAaA,WAAoBT,EAAwBU,GAA5C,uGACsBX,KAAKF,KAAKK,IAAV,0DACqCF,EADrC,oBAC+DU,EAD/D,eAEd,CACIP,OAAQ,CACJC,OAAQ,EACRC,MAAO,IACPE,KAAM,aAPtB,cACUC,EADV,yBAYWA,EAAIC,KAAKE,SAZpB,gD,oJAiBA,WACIX,EACAU,EACAE,EACAX,GAJJ,uGAO0BF,KAAKF,KAAKK,IAAV,0DACqCF,EADrC,oBAC+DU,EAD/D,oBAC2FE,EAD3F,SAEd,CACIT,OAAQ,CACJC,OAAQH,EAAOG,OACfC,MAAOJ,EAAOI,SAZlC,cAOcG,EAPd,yBAgBeA,EAAIC,MAhBnB,gD,mJAyDA,WACIT,EACAU,EACAG,EACAC,EACAC,GALJ,kGAOQC,EAAe,GACnBH,EAAgBI,SAAQ,SAACC,GACjBA,EAAGC,kBACHH,EAAeA,EAAaI,OAAb,UAAuBF,EAAGG,eAA1B,YAA4CH,EAAGC,gBAA/C,UAGpBL,IACCE,EAAeA,EAAaI,OAAb,qBAAkCN,EAAQQ,cAEvDC,EAAW,IAAIC,SACrBD,EAASE,OAAO,SAAUT,GAC1BO,EAASE,OAAO,iBAAkBzB,GAClCuB,EAASE,OAAO,mBAAoBf,GAChCK,GACAQ,EAASE,OAAO,QAASV,GArBjC,UAyB0BhB,KAAKF,KAAK6B,KAAV,0DACqC1B,EADrC,oBAC+DU,EAD/D,YAEda,GA3BZ,eAyBcf,EAzBd,yBA6BeA,EAAIC,MA7BnB,iD,sJAkEA,WAAoBT,EAAwBU,EAA0BE,GAAtE,uGAE0Bb,KAAKF,KAAK8B,IAAV,0DACqC3B,EADrC,oBAC+DU,EAD/D,oBAC2FE,IAHrH,cAEcJ,EAFd,yBAKeA,EAAIC,MALnB,gD,yJA0CA,WACImB,EACAlB,EACAE,GAHJ,uGAM0Bb,KAAKF,KAAKK,IAAV,0DACqC0B,EADrC,oBAC+DlB,EAD/D,oBAC2FE,IAPrH,cAMcJ,EANd,yBASeA,EAAIC,MATnB,gD","file":"js/chunk-2d0dd08f.b6ddd4fa.js","sourcesContent":["import {\n ImportMethod,\n ImportParameter,\n ParameterOut,\n ImportResult,\n ImportMessage,\n ImportProgression,\n} from \"./../models/Import\";\nimport { PagingParams, PagedResults } from \"@abaco/web-common/src/Paging\";\nimport { HTTPClient } from \"@abaco/web-common/src/HTTP\";\n\nexport default class ImportApi {\n private http: HTTPClient;\n\n constructor(http: HTTPClient) {\n this.http = http;\n }\n\n async getImportMethods(object_type_id: string, paging: PagingParams): Promise> {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/services/import/${object_type_id}/imports`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n only_active: true,\n sort: \"+ds_import_method\",\n },\n });\n\n return res.data;\n }\n\n async getParameters(object_type_id: string, import_method_id: string): Promise {\n const res = await this.http.get(\n `/sitiagri-rest-api/api_basic/v1/services/import/${object_type_id}/imports/${import_method_id}/parameters`,\n {\n params: {\n offset: 0,\n count: 300,\n sort: \"p_order\",\n },\n }\n );\n\n return res.data.records;\n }\n\n private fakeData = false;\n\n async getImportMessages(\n object_type_id: string,\n import_method_id: string,\n import_id: number,\n paging: PagingParams\n ): Promise> {\n // if (!this.fakeData) {\n const res = await this.http.get(\n `/sitiagri-rest-api/api_basic/v1/services/import/${object_type_id}/imports/${import_method_id}/imports/${import_id}/logs`,\n {\n params: {\n offset: paging.offset,\n count: paging.count,\n },\n }\n );\n return res.data;\n // } else {\n // console.log(\"WARNING: TEST VALUE\");\n // const testResult: PagedResults = {\n // totalcount: 3,\n // offset: 0,\n // count: 3,\n // records: [\n // {\n // message: \"Hello world, this is an info message\",\n // code: \"aaa\",\n // id_imp_log: 0,\n // id_import: 0,\n // is_info: 1,\n // is_error: 0,\n // is_warning: 0,\n // },\n // {\n // message: \"Hello world, this is an error message\",\n // code: \"aaa\",\n // id_imp_log: 0,\n // id_import: 0,\n // is_info: 0,\n // is_error: 1,\n // is_warning: 0,\n // },\n // {\n // message: \"Hello world, this is an warning message\",\n // code: \"aaa\",\n // id_imp_log: 0,\n // id_import: 0,\n // is_info: 0,\n // is_error: 0,\n // is_warning: 1,\n // },\n // ],\n // };\n // return testResult;\n // }\n }\n\n async verifyImport(\n object_type_id: string,\n import_method_id: string,\n parameterValues: ParameterOut[],\n pk_cuaa: number | null,\n notes?: string\n ): Promise {\n let paramsString = \"\";\n parameterValues.forEach((pv) => {\n if (pv.parameter_value) {\n paramsString = paramsString.concat(`${pv.parameter_name}=${pv.parameter_value}|`);\n }\n });\n if(pk_cuaa){\n paramsString = paramsString.concat(`SUBJECT_ID=${pk_cuaa.toString()}`);\n }\n const formData = new FormData();\n formData.append(\"params\", paramsString);\n formData.append(\"object_type_id\", object_type_id);\n formData.append(\"import_method_id\", import_method_id);\n if (notes) {\n formData.append(\"notes\", notes);\n }\n\n // if (!this.fakeData) {\n const res = await this.http.post(\n `/sitiagri-rest-api/api_basic/v1/services/import/${object_type_id}/imports/${import_method_id}/imports`,\n formData\n );\n return res.data;\n // } else {\n // console.log(\"WARNING: TEST VALUE\");\n // await new Promise((resolve) => setTimeout(resolve, 1000));\n // const testResult: ImportResult = {\n // parameters: \"aaa\",\n // notes: \"aaa\",\n // subject_id: 0,\n // fg_active: \"aaa\",\n // fg_asynchronous: 1,\n // cod_source: \"aaa\",\n // sco_source: \"aaa\",\n // imported_counter: 1,\n // staging_table: \"aaa\",\n // import_id: -1,\n // request_date: new Date(),\n // read_date: new Date(),\n // update_date: null,\n // user_id: \"aaa\",\n // ds_source: \"aaa\",\n // de_source: \"aaa\",\n // fg_end_valid: \"aaa\",\n // has_errors: 0,\n // has_warnings: 0,\n // has_info: 0,\n // import_method_id: \"COPIA_PLOTS_DA_A\",\n // ds_import_method: \"Copia appezzamenti da altra campagna (ASINCRONO)\",\n // de_import_method: \"aaa\",\n // fg_update_dossier: \"aaa\",\n // fg_start_valid: \"aaa\",\n // fg_move_dossier: \"aaa\",\n // imports_in_progress: [],\n // };\n // return testResult;\n // }\n }\n\n async executeImport(object_type_id: string, import_method_id: string, import_id: number): Promise {\n // if (!this.fakeData) {\n const res = await this.http.put(\n `/sitiagri-rest-api/api_basic/v1/services/import/${object_type_id}/imports/${import_method_id}/imports/${import_id}`\n );\n return res.data;\n // } else {\n // console.log(\"WARNING: TEST VALUE\");\n // await new Promise((resolve) => setTimeout(resolve, 1000));\n // const testResult: ImportResult = {\n // parameters: \"aaa\",\n // notes: \"aaa\",\n // subject_id: 0,\n // fg_active: \"aaa\",\n // fg_asynchronous: 1,\n // cod_source: \"aaa\",\n // sco_source: \"aaa\",\n // imported_counter: 1,\n // staging_table: \"aaa\",\n // import_id: 0,\n // request_date: new Date(),\n // read_date: new Date(),\n // update_date: null,\n // user_id: \"aaa\",\n // ds_source: \"aaa\",\n // de_source: \"aaa\",\n // fg_end_valid: \"aaa\",\n // has_errors: 0,\n // has_warnings: 0,\n // has_info: 1,\n // import_method_id: \"COPIA_PLOTS_DA_A\",\n // ds_import_method: \"Copia appezzamenti da altra campagna (ASINCRONO)\",\n // de_import_method: \"aaa\",\n // fg_update_dossier: \"aaa\",\n // fg_start_valid: \"aaa\",\n // fg_move_dossier: \"aaa\",\n // imports_in_progress: [],\n // };\n // return testResult;\n // }\n }\n\n async getImportProgression(\n objectImportId: string,\n import_method_id: string,\n import_id: number\n ): Promise {\n // if (!this.fakeData) {\n const res = await this.http.get(\n `/sitiagri-rest-api/api_basic/v1/services/import/${objectImportId}/imports/${import_method_id}/imports/${import_id}`\n );\n return res.data;\n // } else {\n // console.log(\"WARNING: TEST VALUE\");\n // await new Promise((resolve) => setTimeout(resolve, 1000));\n // const testResult: ImportProgression = {\n // parameters: \"aaa\",\n // progress: [\n // {\n // done: 0,\n // progr: 0,\n // ds_progr: \"Copiando appezzamenti\",\n // todo: 100,\n // status: \"aaa\",\n // },\n // ],\n // notes: \"aaa\",\n // fg_asynchronous: 1,\n // import_method_id: \"COPIA_PLOTS_DA_A\",\n // ds_import_method: \"Copia appezzamenti da altra campagna (ASINCRONO)\",\n // cod_source: \"aaa\",\n // sco_source: \"aaa\",\n // fg_active: \"aaa\",\n // fg_start_valid: \"aaa\",\n // imports_in_progress: [],\n // staging_table: \"aaa\",\n // imported_counter: 1,\n // subject_id: 0,\n // user_id: \"aaa\",\n // de_import_method: \"aaa\",\n // fg_update_dossier: \"aaa\",\n // fg_end_valid: \"aaa\",\n // fg_move_dossier: \"aaa\",\n // import_id: 0,\n // request_date: 0,\n // read_date: 0,\n // update_date: null,\n // ds_source: \"aaa\",\n // de_source: \"aaa\",\n // has_errors: 0,\n // has_warnings: 0,\n // has_info: 1,\n // };\n // return testResult;\n // }\n }\n}\n"],"sourceRoot":""}