@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 976 B
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import e from"../../request.js";import r from"../../core/Error.js";import{join as t}from"../../core/urlUtils.js";import{isEmptyValue as s}from"./utils.js";async function a({featureService:a,templates:o,postOptions:d={}}){if(s(o))throw new r("add-shared-templates:invalid-parameters","Must supply new templates to add");if(d.useGlobalIds&&!o.every(e=>e.globalId))throw new r("add-shared-templates:invalid-parameters","useGlobalIds set, but globalId not provided for all templates.");const l=t(a.url,"sharedTemplates","add"),p=o.map(e=>{const r=e.toJSON();return r.layerId=r.layerId??e.layerIds?.[0],r}),m={method:"post",query:{sharedTemplates:JSON.stringify(p),f:"json",...d.useGlobalIds&&{useGlobalIds:"true"}},responseType:"json"};return e(l,m).then(e=>e.data).catch(e=>{throw new r("add-shared-templates:request-error","The request to add shared templates failed.",{error:e})})}export{a as addSharedTemplates};