-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathdynamics-web-api.min.js
2 lines (2 loc) · 23.5 KB
/
dynamics-web-api.min.js
1
2
/*! dynamics-web-api v1.3.3 (c) 2017 Aleksandr Rogov */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("DynamicsWebApi",[],t):"object"==typeof exports?exports.DynamicsWebApi=t():e.DynamicsWebApi=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var a=r[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t){var r={Types:{ResponseBase:function(){this.oDataContext=""},Response:function(){r.Types.ResponseBase.call(this),this.value={}},ReferenceResponse:function(){r.Types.ResponseBase.call(this),this.id="",this.collection=""},MultipleResponse:function(){r.Types.ResponseBase.call(this),this.oDataNextLink="",this.oDataCount=0,this.value=[]},FetchXmlResponse:function(){r.Types.ResponseBase.call(this),this.value=[],this.PagingInfo={cookie:"",page:0,nextPage:1}}},Prefer:{ReturnRepresentation:"return=representation",Annotations:{AssociatedNavigationProperty:"Microsoft.Dynamics.CRM.associatednavigationproperty",LookupLogicalName:"Microsoft.Dynamics.CRM.lookuplogicalname",All:"*",FormattedValue:"OData.Community.Display.V1.FormattedValue",FetchXmlPagingCookie:"Microsoft.Dynamics.CRM.fetchxmlpagingcookie"}}};e.exports=r},function(e,t){function r(e,t,r){throw new Error(r?e+" requires the "+t+" parameter to be of type "+r:e+" requires the "+t+" parameter.")}var n={handleErrorResponse:function(e){throw new Error("Error: "+e.status+": "+e.message)},parameterCheck:function(e,t,n,a){void 0!==e&&null!==e&&""!=e||r(t,n,a)},stringParameterCheck:function(e,t,n){"string"!=typeof e&&r(t,n,"String")},arrayParameterCheck:function(e,t,n){e.constructor!==Array&&r(t,n,"Array")},stringOrArrayParameterCheck:function(e,t,n){e.constructor!==Array&&"string"!=typeof e&&r(t,n,"String or Array")},numberParameterCheck:function(e,t,n){if("number"!=typeof e){if("string"==typeof e&&e&&!isNaN(parseInt(e)))return;r(t,n,"Number")}},boolParameterCheck:function(e,t,n){"boolean"!=typeof e&&r(t,n,"Boolean")},guidParameterCheck:function(e,t,n){try{return/[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}/i.exec(e)[0]}catch(e){r(t,n,"GUID String")}},callbackParameterCheck:function(e,t,n){"function"!=typeof e&&r(t,n,"Function")}};e.exports=n},function(e,t){String.prototype.endsWith=function(e,t){var r=this.toString();("number"!=typeof t||!isFinite(t)||Math.floor(t)!==t||t>r.length)&&(t=r.length),t-=e.length;var n=r.lastIndexOf(e,t);return-1!==n&&n===t},String.prototype.startsWith=function(e,t){return t=t||0,this.substr(t,e.length)===e}},function(e,t,r){function n(){var e=(new Date).getTime();return"undefined"!=typeof performance&&"function"==typeof performance.now&&(e+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?r:3&r|8).toString(16)})}function a(e){return e.Accept="application/json",e["OData-MaxVersion"]="4.0",e["OData-Version"]="4.0",e["Content-Type"]="application/json; charset=utf-8",e}function i(e,t){var r;return e&&(r=JSON.stringify(e,function(e,r){return e.endsWith("@odata.bind")&&"string"==typeof r&&(/\(\{[\w\d-]+\}\)/g.test(r)&&(r=r.replace(/(.+)\(\{([\w\d-]+)\}\)/g,"$1($2)")),r.startsWith(t.webApiUrl)||(r=t.webApiUrl+r.replace(/^\\/,""))),r}),r=r.replace(/[\u007F-\uFFFF]/g,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).substr(-4)})),r}r(0);e.exports=function(e,t,o,c,s,u,l,p){s||(s={}),s=a(s);var h=i(c,o);if(t.length>2e3){var m="dwa_batch_"+n(),f=[];f.push("--"+m),f.push("Content-Type: application/http"),f.push("Content-Transfer-Encoding: binary\n"),f.push(e+" "+o.webApiUrl+t+" HTTP/1.1");for(var d in s)f.push(d+": "+s[d]),delete s[d];f.push("\n--"+m+"--"),h=f.join("\n"),s=a(s),s["Content-Type"]="multipart/mixed;boundary="+m,t="$batch",e="POST"}o.impersonate&&!s.MSCRMCallerID&&(s.MSCRMCallerID=o.impersonate);var y;"undefined"!=typeof XMLHttpRequest&&(y=r(10));var g=function(r){r&&(s||(s={}),s.Authorization="Bearer "+r.accessToken),y(e,o.webApiUrl+t,h,s,u,l,p)};o.onTokenRefresh&&(!s||s&&!s.Authorization)?o.onTokenRefresh(g):g()}},function(e,t,r){function n(e,t,r,a,i){var s={},u=[];if(a=null!=a?a:"&",e){e.navigationProperty&&(o.stringParameterCheck(e.navigationProperty,"DynamicsWebApi."+t,"request.navigationProperty"),r+="/"+e.navigationProperty),null!=e.select&&e.select.length&&(o.arrayParameterCheck(e.select,"DynamicsWebApi."+t,"request.select"),"retrieve"==t&&1==e.select.length&&e.select[0].endsWith("/$ref")?r+="/"+e.select[0]:(e.select[0].startsWith("/")&&"retrieve"==t&&(null==e.navigationProperty?r+=e.select.shift():e.select.shift()),e.select.length&&u.push("$select="+e.select.join(",")))),e.filter&&(o.stringParameterCheck(e.filter,"DynamicsWebApi."+t,"request.filter"),u.push("$filter="+e.filter)),e.savedQuery&&u.push("savedQuery="+o.guidParameterCheck(e.savedQuery,"DynamicsWebApi."+t,"request.savedQuery")),e.userQuery&&u.push("userQuery="+o.guidParameterCheck(e.userQuery,"DynamicsWebApi."+t,"request.userQuery")),e.count&&(o.boolParameterCheck(e.count,"DynamicsWebApi."+t,"request.count"),u.push("$count="+e.count)),e.top&&e.top>0&&(o.numberParameterCheck(e.top,"DynamicsWebApi."+t,"request.top"),u.push("$top="+e.top)),null!=e.orderBy&&e.orderBy.length&&(o.arrayParameterCheck(e.orderBy,"DynamicsWebApi."+t,"request.orderBy"),u.push("$orderby="+e.orderBy.join(",")));var l=c(e,t,i);if(l.length&&(s.Prefer=l),null!=e.ifmatch&&null!=e.ifnonematch)throw new Error("DynamicsWebApi."+t+". Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.");if(e.ifmatch&&(o.stringParameterCheck(e.ifmatch,"DynamicsWebApi."+t,"request.ifmatch"),s["If-Match"]=e.ifmatch),e.ifnonematch&&(o.stringParameterCheck(e.ifnonematch,"DynamicsWebApi."+t,"request.ifnonematch"),s["If-None-Match"]=e.ifnonematch),e.impersonate&&(o.stringParameterCheck(e.impersonate,"DynamicsWebApi."+t,"request.impersonate"),s.MSCRMCallerID=o.guidParameterCheck(e.impersonate,"DynamicsWebApi."+t,"request.impersonate")),e.token&&(o.stringParameterCheck(e.token,"DynamicsWebApi."+t,"request.token"),s.Authorization="Bearer "+e.token),e.expand&&e.expand.length)if(o.stringOrArrayParameterCheck(e.expand,"DynamicsWebApi."+t,"request.expand"),"string"==typeof e.expand)u.push("$expand="+e.expand);else{for(var p=[],h=0;h<e.expand.length;h++)if(e.expand[h].property){var m=n(e.expand[h],t+" $expand",null,";"),f=m.query;f&&f.length&&(f="("+f+")"),p.push(e.expand[h].property+f)}p.length&&u.push("$expand="+p.join(","))}}return{url:r,query:u.join(a),headers:s}}function a(e){return["EntityDefinitions"].indexOf(e)>-1?e:e.toLowerCase()}function i(e,t,r){e.collection?o.stringParameterCheck(e.collection,"DynamicsWebApi."+t,"request.collection"):o.parameterCheck(e.collection,"DynamicsWebApi."+t,"request.collection");var i=a(e.collection);e.id&&(e.id=o.guidParameterCheck(e.id,"DynamicsWebApi."+t,"request.id"),i+="("+e.id+")");var c=n(e,t,i,"&",r);return c.query&&(c.url+="?"+encodeURI(c.query)),e.hasOwnProperty("async")&&null!=e.async?(o.boolParameterCheck(e.async,"DynamicsWebApi."+t,"request.async"),c.async=e.async):c.async=!0,{url:c.url,headers:c.headers,async:c.async}}var o=(r(0),r(1)),c=r(12),s={convertRequestOptions:n,convertRequest:i};e.exports=s},function(e,t,r){var n={buildFunctionParameters:r(11),getFetchXmlPagingCookie:r(14),convertToReferenceObject:r(13)};e.exports=n},function(e,t,r){function n(e){var t={webApiVersion:"8.0",webApiUrl:null,impersonate:null,onTokenRefresh:null,includeAnnotations:null,maxPageSize:null,returnRepresentation:null};e||(e=t);var r=function(){if("undefined"!=typeof GetGlobalContext)return GetGlobalContext();if("undefined"!=typeof Xrm)return Xrm.Page.context;throw new Error("Xrm Context is not available.")},u=function(){var e=r();if(e){var t=e.getClientUrl();return t.match(/\/$/)&&(t=t.substring(0,t.length-1)),t}return""},l=function(){return u()+"/api/data/v"+t.webApiVersion+"/"};this.setConfig=function(e){e.webApiVersion&&(c.stringParameterCheck(e.webApiVersion,"DynamicsWebApi.setConfig","config.webApiVersion"),t.webApiVersion=e.webApiVersion),e.webApiUrl?(c.stringParameterCheck(e.webApiUrl,"DynamicsWebApi.setConfig","config.webApiUrl"),t.webApiUrl=e.webApiUrl):t.webApiUrl=l(),e.impersonate&&(t.impersonate=c.guidParameterCheck(e.impersonate,"DynamicsWebApi.setConfig","config.impersonate")),e.onTokenRefresh&&(c.callbackParameterCheck(e.onTokenRefresh,"DynamicsWebApi.setConfig","config.onTokenRefresh"),t.onTokenRefresh=e.onTokenRefresh),e.includeAnnotations&&(c.stringParameterCheck(e.includeAnnotations,"DynamicsWebApi.setConfig","config.includeAnnotations"),t.includeAnnotations=e.includeAnnotations),e.maxPageSize&&(c.numberParameterCheck(e.maxPageSize,"DynamicsWebApi.setConfig","config.maxPageSize"),t.maxPageSize=e.maxPageSize),e.returnRepresentation&&(c.boolParameterCheck(e.returnRepresentation,"DynamicsWebApi.setConfig","config.returnRepresentation"),t.returnRepresentation=e.returnRepresentation)},this.setConfig(e);var p=function(e,r,n,a,i){return new Promise(function(o,c){s(e,r,t,n,a,o,c,i)})};this.create=function(e,r,n,a){c.parameterCheck(e,"DynamicsWebApi.create","object"),c.stringParameterCheck(r,"DynamicsWebApi.create","collection"),n&&c.stringOrArrayParameterCheck(n,"DynamicsWebApi.create","prefer"),a&&c.arrayParameterCheck(a,"DynamicsWebApi.create","select");var i={collection:r,select:a,prefer:n},s=o.convertRequest(i,"create",t);return p("POST",s.url,e,s.headers,s.async).then(function(e){return e.data?e.data:/[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}/i.exec(e.headers["OData-EntityId"]?e.headers["OData-EntityId"]:e.headers["odata-entityid"])[0]})},this.retrieveRequest=function(e){c.parameterCheck(e,"DynamicsWebApi.retrieve","request");var r=o.convertRequest(e,"retrieve",t),n=e.select;return p("GET",r.url,null,r.headers,r.async).then(function(e){return null!=n&&1==n.length&&n[0].endsWith("/$ref")&&null!=e.data["@odata.id"]?i.convertToReferenceObject(e.data):e.data})},this.retrieve=function(e,t,r,n){c.stringParameterCheck(e,"DynamicsWebApi.retrieve","id"),e=c.guidParameterCheck(e,"DynamicsWebApi.retrieve","id"),c.stringParameterCheck(t,"DynamicsWebApi.retrieve","collection"),r&&r.length&&c.arrayParameterCheck(r,"DynamicsWebApi.retrieve","select"),n&&n.length&&c.stringOrArrayParameterCheck(n,"DynamicsWebApi.retrieve","expand");var a={collection:t,id:e,select:r,expand:n};return this.retrieveRequest(a)},this.updateRequest=function(e){c.parameterCheck(e,"DynamicsWebApi.update","request"),c.parameterCheck(e.entity,"DynamicsWebApi.update","request.entity"),null==e.ifmatch&&(e.ifmatch="*");var r=o.convertRequest(e,"update",t),n=e.ifmatch;return p("PATCH",r.url,e.entity,r.headers,r.async).then(function(e){return!e.data||e.data}).catch(function(e){if(n&&412==e.status)return!1;throw e})},this.update=function(e,t,r,n,a){c.stringParameterCheck(e,"DynamicsWebApi.update","id"),e=c.guidParameterCheck(e,"DynamicsWebApi.update","id"),c.parameterCheck(r,"DynamicsWebApi.update","object"),c.stringParameterCheck(t,"DynamicsWebApi.update","collection"),n&&c.stringOrArrayParameterCheck(n,"DynamicsWebApi.update","prefer"),a&&c.arrayParameterCheck(a,"DynamicsWebApi.update","select");var i={collection:t,id:e,select:a,prefer:n,entity:r};return this.updateRequest(i)},this.updateSingleProperty=function(e,r,n,a,i){c.stringParameterCheck(e,"DynamicsWebApi.updateSingleProperty","id"),e=c.guidParameterCheck(e,"DynamicsWebApi.updateSingleProperty","id"),c.parameterCheck(n,"DynamicsWebApi.updateSingleProperty","keyValuePair"),c.stringParameterCheck(r,"DynamicsWebApi.updateSingleProperty","collection");var s=Object.keys(n)[0],u=n[s];a&&c.stringOrArrayParameterCheck(a,"DynamicsWebApi.updateSingleProperty","prefer"),i&&c.arrayParameterCheck(i,"DynamicsWebApi.updateSingleProperty","select");var l={collection:r,id:e,select:i,prefer:a,navigationProperty:s},h=o.convertRequest(l,"updateSingleProperty",t);return p("PUT",h.url,{value:u},h.headers,h.async).then(function(e){if(e.data)return e.data})},this.deleteRequest=function(e){c.parameterCheck(e,"DynamicsWebApi.delete","request");var r=o.convertRequest(e,"deleteRequest",t),n=e.ifmatch;return p("DELETE",r.url,null,r.headers,r.async).then(function(){return!0}).catch(function(e){if(n&&412==e.status)return!1;throw e})},this.deleteRecord=function(e,t,r){c.stringParameterCheck(e,"DynamicsWebApi.deleteRecord","id"),e=c.guidParameterCheck(e,"DynamicsWebApi.deleteRecord","id"),c.stringParameterCheck(t,"DynamicsWebApi.deleteRecord","collection"),null!=r&&c.stringParameterCheck(r,"DynamicsWebApi.deleteRecord","propertyName");var n=t.toLowerCase()+"("+e+")";return null!=r&&(n+="/"+r),p("DELETE",n,null,null,!0).then(function(){})},this.upsertRequest=function(e){c.parameterCheck(e,"DynamicsWebApi.upsert","request"),c.parameterCheck(e.entity,"DynamicsWebApi.upsert","request.entity");var r=o.convertRequest(e,"upsert",t),n=e.ifnonematch,a=e.ifmatch;return p("PATCH",r.url,e.entity,r.headers,r.async).then(function(e){if(e.headers["OData-EntityId"]||e.headers["odata-entityid"]){return/[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}/i.exec(e.headers["OData-EntityId"]?e.headers["OData-EntityId"]:e.headers["odata-entityid"])[0]}if(e.data)return e.data}).catch(function(e){if(!(n&&412==e.status||a&&404==e.status))throw e})},this.upsert=function(e,t,r,n,a){c.stringParameterCheck(e,"DynamicsWebApi.upsert","id"),e=c.guidParameterCheck(e,"DynamicsWebApi.upsert","id"),c.parameterCheck(r,"DynamicsWebApi.upsert","object"),c.stringParameterCheck(t,"DynamicsWebApi.upsert","collection"),n&&c.stringOrArrayParameterCheck(n,"DynamicsWebApi.upsert","prefer"),a&&c.arrayParameterCheck(a,"DynamicsWebApi.upsert","select");var i={collection:t,id:e,select:a,prefer:n,entity:r};return this.upsertRequest(i)};var h=function(e,r){r&&!e.collection&&(e.collection="any");var n=o.convertRequest(e,"retrieveMultiple",t);r&&(c.stringParameterCheck(r,"DynamicsWebApi.retrieveMultiple","nextPageLink"),n.url=r.replace(t.webApiUrl,""));var a=e.count;return p("GET",n.url,null,n.headers,n.async).then(function(e){return a&&(e.data.oDataCount=e.data.oDataCount||0),e.data})};this.retrieveMultipleRequest=h;var m=function(e,t,r){var r=r||[];return h(e,t).then(function(t){return r=r.concat(t.value),t.oDataNextLink?m(e,t.oDataNextLink,r):{value:r}})};this.retrieveAllRequest=function(e){return m(e)},this.count=function(e,t){return null==t||null!=t&&!t.length?(c.stringParameterCheck(e,"DynamicsWebApi.count","collection"),p("GET",e.toLowerCase()+"/$count").then(function(e){return e.data?parseInt(e.data):0})):this.retrieveMultipleRequest({collection:e,filter:t,count:!0},null).then(function(e){return e.oDataCount?e.oDataCount:0})},this.countAll=function(e,t,r){return m({collection:e,filter:t,select:r}).then(function(e){return e&&e.value?e.value.length:0})},this.retrieveMultiple=function(e,t,r,n){return this.retrieveMultipleRequest({collection:e,select:t,filter:r},n)},this.retrieveAll=function(e,t,r){return m({collection:e,select:t,filter:r})};var f=function(e,r,n,s,u,l){c.stringParameterCheck(e,"DynamicsWebApi.executeFetchXml","type"),c.stringParameterCheck(r,"DynamicsWebApi.executeFetchXml","fetchXml"),s=s||1,c.numberParameterCheck(s,"DynamicsWebApi.executeFetchXml","pageNumber");var h='$1 page="'+s+'"';null!=u&&(c.stringParameterCheck(u,"DynamicsWebApi.executeFetchXml","pagingCookie"),h+=' paging-cookie="'+u+'"'),r=r.replace(/^(<fetch[\w\d\s'"=]+)/,h),n&&c.stringParameterCheck(n,"DynamicsWebApi.executeFetchXml","includeAnnotations"),l&&(l=c.guidParameterCheck(l,"DynamicsWebApi.executeFetchXml","impersonateUserId"));var m={collection:e,includeAnnotations:n,impersonate:l},f=o.convertRequest(m,"executeFetchXml",t),d=encodeURIComponent(r);return p("GET",f.url+"?fetchXml="+d,null,f.headers,f.async).then(function(e){return null!=e.data["@"+a.Prefer.Annotations.FetchXmlPagingCookie]&&(e.data.PagingInfo=i.getFetchXmlPagingCookie(e.data["@"+a.Prefer.Annotations.FetchXmlPagingCookie],s)),e.data})};this.fetch=this.executeFetchXml=f;var d=function(e,t,r,n,a,i,o){var o=o||[];return f(e,t,r,n,a,i).then(function(n){return o=o.concat(n.value),n.PagingInfo?d(e,t,r,n.PagingInfo.nextPage,n.PagingInfo.cookie,i,o):{value:o}})};this.fetchAll=this.executeFetchXmlAll=function(e,t,r,n){return d(e,t,r,null,null,n)},this.associate=function(e,r,n,a,i,o){c.stringParameterCheck(e,"DynamicsWebApi.associate","primarycollection"),c.stringParameterCheck(a,"DynamicsWebApi.associate","relatedcollection"),c.stringParameterCheck(n,"DynamicsWebApi.associate","relationshipName"),r=c.guidParameterCheck(r,"DynamicsWebApi.associate","primaryId"),i=c.guidParameterCheck(i,"DynamicsWebApi.associate","relatedId");var s={};return null!=o&&(o=c.guidParameterCheck(o,"DynamicsWebApi.associate","impersonateUserId"),s.MSCRMCallerID=o),p("POST",e+"("+r+")/"+n+"/$ref",{"@odata.id":t.webApiUrl+a+"("+i+")"},s).then(function(){})},this.disassociate=function(e,t,r,n,a){c.stringParameterCheck(e,"DynamicsWebApi.disassociate","primarycollection"),c.stringParameterCheck(r,"DynamicsWebApi.disassociate","relationshipName"),t=c.guidParameterCheck(t,"DynamicsWebApi.disassociate","primaryId"),n=c.guidParameterCheck(n,"DynamicsWebApi.disassociate","relatedId");var i={};return null!=a&&(a=c.guidParameterCheck(a,"DynamicsWebApi.associate","impersonateUserId"),i.MSCRMCallerID=a),p("DELETE",e+"("+t+")/"+r+"("+n+")/$ref",null,i).then(function(){})},this.associateSingleValued=function(e,r,n,a,i,o){c.stringParameterCheck(e,"DynamicsWebApi.associateSingleValued","collection"),r=c.guidParameterCheck(r,"DynamicsWebApi.associateSingleValued","id"),i=c.guidParameterCheck(i,"DynamicsWebApi.associateSingleValued","relatedId"),c.stringParameterCheck(n,"DynamicsWebApi.associateSingleValued","singleValuedNavigationPropertyName"),c.stringParameterCheck(a,"DynamicsWebApi.associateSingleValued","relatedcollection");var s={};return null!=o&&(o=c.guidParameterCheck(o,"DynamicsWebApi.associate","impersonateUserId"),s.MSCRMCallerID=o),p("PUT",e+"("+r+")/"+n+"/$ref",{"@odata.id":t.webApiUrl+a+"("+i+")"},s).then(function(){})},this.disassociateSingleValued=function(e,t,r,n){c.stringParameterCheck(e,"DynamicsWebApi.disassociateSingleValued","collection"),t=c.guidParameterCheck(t,"DynamicsWebApi.disassociateSingleValued","id"),c.stringParameterCheck(r,"DynamicsWebApi.disassociateSingleValued","singleValuedNavigationPropertyName");var a={};return null!=n&&(n=c.guidParameterCheck(n,"DynamicsWebApi.associate","impersonateUserId"),a.MSCRMCallerID=n),p("DELETE",e+"("+t+")/"+r+"/$ref",null,a).then(function(){})},this.executeUnboundFunction=function(e,t,r){return y(e,t,null,null,r)},this.executeBoundFunction=function(e,t,r,n,a){return y(r,n,t,e,a)};var y=function(e,t,r,n,a){c.stringParameterCheck(e,"DynamicsWebApi.executeFunction","functionName");var o=e+i.buildFunctionParameters(t);null!=r&&(c.stringParameterCheck(r,"DynamicsWebApi.executeFunction","collection"),n=c.guidParameterCheck(n,"DynamicsWebApi.executeFunction","id"),o=r+"("+n+")/"+o);var s={};return a&&(s.MSCRMCallerID=c.guidParameterCheck(a,"DynamicsWebApi.executeFunction","impersonateUserId")),p("GET",o,null,s).then(function(e){if(e.data)return e.data})};this.executeUnboundAction=function(e,t,r){return g(e,t,null,null,r)},this.executeBoundAction=function(e,t,r,n,a){return g(r,n,t,e,a)};var g=function(e,t,r,n,a){c.stringParameterCheck(e,"DynamicsWebApi.executeAction","actionName");var i=e;null!=r&&(c.stringParameterCheck(r,"DynamicsWebApi.executeAction","collection"),n=c.guidParameterCheck(n,"DynamicsWebApi.executeAction","id"),i=r+"("+n+")/"+i);var o={};return null!=a&&(a=c.guidParameterCheck(a,"DynamicsWebApi.executeAction","impersonateUserId"),o.MSCRMCallerID=a),p("POST",i,t,o).then(function(e){if(e.data)return e.data})};this.initializeInstance=function(e){return e||(e=t),new n(e)}}var a=r(0),i=r(5),o=r(4),c=r(1),s=r(3);String.prototype.endsWith&&String.prototype.startsWith||r(2),e.exports=n},function(e,t){e.exports=function(e,t){return"string"==typeof t&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.exec(t)?new Date(t):t}},function(e,t,r){function n(e){var t=e.substr(0,e.indexOf("\r\n")),r=e.split(t);r.shift(),r.pop();for(var n=[],a=0;a<r.length;a++){var i=r[a],c=i.substring(i.indexOf("{"),i.lastIndexOf("}")+1);n.push(JSON.parse(c,o))}return n}function a(e){for(var t=Object.keys(e),r=0;r<t.length;r++){if(null!=e[t[r]]&&e[t[r]].constructor===Array)for(var n=0;n<e[t[r]].length;n++)e[t[r]][n]=a(e[t[r]][n]);if(-1!=t[r].indexOf("@")){var o=t[r].split("@"),c=null;switch(o[1]){case"odata.context":c="oDataContext";break;case"odata.count":c="oDataCount",e[t[r]]=null!=e[t[r]]?parseInt(e[t[r]]):0;break;case"odata.nextLink":c="oDataNextLink";break;case i.Prefer.Annotations.FormattedValue:c=o[0]+"_Formatted";break;case i.Prefer.Annotations.AssociatedNavigationProperty:c=o[0]+"_NavigationProperty";break;case i.Prefer.Annotations.LookupLogicalName:c=o[0]+"_LogicalName"}c&&(e[c]=e[t[r]])}}return e}var i=r(0),o=r(7);String.prototype.endsWith&&String.prototype.startsWith||r(2),e.exports=function(e){var t=null;return e.length&&(t=t=e.indexOf("--batchresponse_")>-1?n(e)[0]:JSON.parse(e,o),t=a(t)),t}},function(e,t){e.exports=function(e){var t={};if(!e)return t;for(var r=e.split("\r\n"),n=0,a=r.length;n<a;n++){var i=r[n],o=i.indexOf(": ");o>0&&(t[i.substring(0,o)]=i.substring(o+2))}return t}},function(e,t,r){var n=r(8),a=r(9),i=function(e,t,r,i,o,c,s){var u=new XMLHttpRequest;u.open(e,t,s);for(var l in i)u.setRequestHeader(l,i[l]);u.onreadystatechange=function(){if(4===u.readyState){switch(u.status){case 200:case 201:case 204:case 304:var e=n(u.responseText),t={data:e,headers:a(u.getAllResponseHeaders()),status:u.status};o(t);break;default:var r;try{r=JSON.parse(u.response).error}catch(e){r=u.response.length>0?{message:u.response}:{message:"Unexpected Error"}}r.status=u.status,c(r)}u=null}},u.onerror=function(){c({message:"Network Error"}),u=null},u.ontimeout=function(e){c({message:"Request Timed Out"}),u=null},r?u.send(r):u.send()};e.exports=i},function(e,t){e.exports=function(e){if(e){for(var t=Object.keys(e),r="",n="",a=1;a<=t.length;a++){var i=t[a-1],o=e[i];a>1&&(r+=",",n+="&"),r+=i+"=@p"+a,n+="@p"+a+"="+("string"==typeof o?"'"+o+"'":o)}return"("+r+")?"+n}return"()"}},function(e,t,r){var n=r(0),a=r(1);e.exports=function(e,t,r){var i=e.returnRepresentation,o=e.includeAnnotations,c=e.maxPageSize;if(e.prefer&&e.prefer.length){a.stringOrArrayParameterCheck(e.prefer,"DynamicsWebApi."+t,"request.prefer");var s=e.prefer;"string"==typeof s&&(s=s.split(","));for(var u in s){var l=s[u].trim();l===n.Prefer.ReturnRepresentation?i=!0:l.startsWith("odata.include-annotations=")?o=l.replace("odata.include-annotations=","").replace(/"/g,""):l.startsWith("odata.maxpagesize=")&&(c=l.replace("odata.maxpagesize=","").replace(/"/g,""))}}r&&(null==i&&(i=r.returnRepresentation),o=o||r.includeAnnotations,c=c||r.maxPageSize);var s=[];return i&&(a.boolParameterCheck(i,"DynamicsWebApi."+t,"request.returnRepresentation"),s.push(n.Prefer.ReturnRepresentation)),o&&(a.stringParameterCheck(o,"DynamicsWebApi."+t,"request.includeAnnotations"),s.push('odata.include-annotations="'+o+'"')),c&&c>0&&(a.numberParameterCheck(c,"DynamicsWebApi."+t,"request.maxPageSize"),s.push("odata.maxpagesize="+c)),s.join(",")}},function(e,t){e.exports=function(e){var t=/\/(\w+)\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(e["@odata.id"]);return{id:t[2],collection:t[1],oDataContext:e["@odata.context"]}}},function(e,t){e.exports=function(e,t){e=e||"",t=t||1,e=unescape(unescape(e));var r=/pagingcookie="(<cookie page="(\d+)".+<\/cookie>)/.exec(e);if(null!=r){var n=parseInt(r[2]);return{cookie:r[1].replace(/</g,"<").replace(/>/g,">").replace(/\"/g,"'").replace(/\'/g,"""),page:n,nextPage:n+1}}return{cookie:"",page:t,nextPage:t+1}}}])});