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ACR/B,EAAM+B,EACR,KAIgB,MAApBR,EAAShB,QACiB,oDAA1BgB,EAASG,aAETM,SAASC,SAAW,SAEpBjC,EAAMuB,EAEV,EACAtB,WAAwB,IAAVA,GAA+BA,GAEjD,EACAiC,SAAU,SAAUC,EAAUrC,EAAMC,EAASC,EAAOoC,GAClD,IAiBMC,EAjBFC,EAAW,WA0Bf,YAxByB,IAAdF,QAA2D,IAAvBA,EAAUE,WACvDA,EAAWF,EAAUE,UAGvBtC,EACEA,GACA,WACEb,EAAGqB,MAAMC,MAAM,CACbJ,MAAO,oBACPK,KAAM,mEAERvB,EAAGoD,KAAKC,MACV,EAEE1C,IAEFuC,EAAKlD,EAAGsD,QAAQC,UAAU5C,IACK,IAA3BqC,EAASQ,QAAQ,KACnBR,GAAY,IAAME,EAElBF,GAAY,IAAME,GAIfjD,EAAEyB,KAAK,CACZC,IAAKqB,EACLS,MAAON,EACPlB,SAAU,QACVtB,KAAMuB,KAAKC,UAAUxB,GACrBC,QAAS,SAAUwB,GAEjBxB,EAAQwB,EACV,EACAvB,MAAO,SAAUuB,GACfvB,EAAMuB,EACR,GAEJ,EACAsB,UAAW,SAAUV,EAAUpC,EAASC,GAWtC,OAVIA,EACFA,GACA,WACEb,EAAGqB,MAAMC,MAAM,CACbJ,MAAO,oBACPK,KAAM,mEAERvB,EAAGoD,KAAKC,MACV,EAEKpD,EAAEyB,KAAK,CACZC,IAAKqB,EACLf,SAAU,SACVrB,QAAS,SAAUwB,GAEjBxB,EAAQwB,EACV,EACAvB,MAAO,SAAUuB,GACfvB,EAAMuB,EACR,GAEJ,E","sources":["webpack://shipley-du-lib/./common/js/legacy/custPortal/cw/lib/cw.webservices.js"],"sourcesContent":["(function (cw, $, undefined) {\r\n  cw.webservices = {\r\n    serviceUrl: \"/api/v1.0/\",\r\n    APIKey: null,\r\n    badAPIKeyLimit: 3,\r\n    badAPIKeyCount: 0,\r\n    getJson: function (path, data, success, error, async) {\r\n      /// <summary>\r\n      /// Wrapper for Jquery Ajax call, includes automatically renewing the CSFR token(hana.apiKey)\r\n      /// </summary>\r\n      /// <param name=\"path\">The api path.</param>\r\n      /// <param name=\"data\">The data object.</param>\r\n      /// <param name=\"success\">The success callback.</param>\r\n      /// <param name=\"error\">The error callback.</param>\r\n      /// <returns>Requested Data Object</returns>\r\n      var self = this,\r\n        success = success || function () {},\r\n        error =\r\n          error ||\r\n          function (err) {\r\n            var title = \"An error occurred\";\r\n            var body = \"An unknown error occurred while attempting the last operation.\";\r\n\r\n            switch (err.status) {\r\n              case 400:\r\n                title = \"Bad Data\";\r\n                body =\r\n                  \"A malformed or incomplete request was sent to the server and could not be serviced.  If you think this message is in error please contact your system administrator and detail the steps you took to get this message.\";\r\n                break;\r\n              case 401:\r\n                title = \"Access denied\";\r\n                body =\r\n                  'You do not currently have access to the requested resource. If you have not yet logged on our your session has expired, please <a href=\"/login\">login</a>. If you are logged in and think this message is in error please contact your system administrator.';\r\n                break;\r\n              case 404:\r\n                title = \"Not found\";\r\n                body =\r\n                  \"The requested resource cannot be found. If you think this message is in error please contact customer service and detail the steps you took to get this message.\";\r\n                break;\r\n            }\r\n\r\n            cw.modal.Alert({ title: title, text: body });\r\n            cw.loadingIndicator.stop();\r\n          };\r\n\r\n      return $.ajax({\r\n        url: self.serviceUrl + path,\r\n        type: \"POST\",\r\n        beforeSend: function (request) {\r\n          request.setRequestHeader(\"X-ApiKey\", self.APIKey);\r\n        },\r\n        contentType: \"application/json; charset=utf-8\",\r\n        dataType: \"json\",\r\n        data: JSON.stringify(data),\r\n        success: function (response) {\r\n          //forward success message to callback\r\n          success(response);\r\n        },\r\n        error: function (response) {\r\n          //loop back and get a new API Key\r\n          if (\r\n            self.badAPIKeyCount <= self.badAPIKeyLimit &&\r\n            response.status === 403 &&\r\n            response.responseText === \"Invalid or expired API Key ('x-ApiKey' http header)\"\r\n          ) {\r\n            (function () {\r\n              var initialPath = path;\r\n              var initialData = data;\r\n\r\n              self.badAPIKeyCount++;\r\n\r\n              self.getJson(\r\n                \"APIKey/GetKey\",\r\n                {},\r\n                function (keyResp) {\r\n                  self.APIKey = keyResp.apiKey;\r\n\r\n                  if (self.badAPIKeyCount <= self.badAPIKeyLimit) {\r\n                    self.getJson(\r\n                      initialPath,\r\n                      initialData,\r\n                      function (innerSuccResp) {\r\n                        success(innerSuccResp);\r\n                      },\r\n                      function (innerErrResp) {\r\n                        error(innerErrResp);\r\n                      }\r\n                    );\r\n                  } else {\r\n                    error(keyResp);\r\n                  }\r\n                },\r\n                function (res) {\r\n                  error(res);\r\n                }\r\n              );\r\n            })();\r\n          } else if (\r\n            response.status === 401 &&\r\n            response.responseText === \"Please authenticate before trying this request.\"\r\n          ) {\r\n            location.pathname = \"/login\";\r\n          } else {\r\n            error(response);\r\n          }\r\n        }, //error\r\n        async: typeof async === \"undefined\" ? true : async,\r\n      });\r\n    },\r\n    getJsonp: function (fullPath, data, success, error, extraArgs) {\r\n      var callback = \"callback\";\r\n\r\n      if (typeof extraArgs !== \"undefined\" && typeof extraArgs.callback !== \"undefined\") {\r\n        callback = extraArgs.callback;\r\n      }\r\n\r\n      error =\r\n        error ||\r\n        function () {\r\n          cw.modal.Alert({\r\n            title: \"An error occurred\",\r\n            text: \"An unknown error occurred while attempting the last operation.\",\r\n          });\r\n          cw.spin.Stop();\r\n        };\r\n\r\n      if (data) {\r\n        var qs = \"\";\r\n        qs = cw.utility.serialize(data);\r\n        if (fullPath.indexOf(\"?\") === -1) {\r\n          fullPath += \"?\" + qs;\r\n        } else {\r\n          fullPath += \"&\" + qs;\r\n        }\r\n      }\r\n\r\n      return $.ajax({\r\n        url: fullPath,\r\n        jsonp: callback,\r\n        dataType: \"jsonp\",\r\n        data: JSON.stringify(data),\r\n        success: function (response) {\r\n          //forward success message to callback\r\n          success(response);\r\n        },\r\n        error: function (response) {\r\n          error(response);\r\n        }, //error\r\n      });\r\n    },\r\n    getScript: function (fullPath, success, error) {\r\n      var error =\r\n        error ||\r\n        function () {\r\n          cw.modal.Alert({\r\n            title: \"An error occurred\",\r\n            text: \"An unknown error occurred while attempting the last operation.\",\r\n          });\r\n          cw.spin.Stop();\r\n        };\r\n\r\n      return $.ajax({\r\n        url: fullPath,\r\n        dataType: \"script\",\r\n        success: function (response) {\r\n          //forward success message to callback\r\n          success(response);\r\n        },\r\n        error: function (response) {\r\n          error(response);\r\n        }, //error\r\n      });\r\n    },\r\n  };\r\n})((window.cw = window.cw || {}), jQuery);\r\n"],"names":["cw","$","window","jQuery","webservices","serviceUrl","APIKey","badAPIKeyLimit","badAPIKeyCount","getJson","path","data","success","error","async","self","this","err","title","body","status","modal","Alert","text","loadingIndicator","stop","ajax","url","type","beforeSend","request","setRequestHeader","contentType","dataType","JSON","stringify","response","initialPath","initialData","responseText","keyResp","apiKey","innerSuccResp","innerErrResp","res","location","pathname","getJsonp","fullPath","extraArgs","qs","callback","spin","Stop","utility","serialize","indexOf","jsonp","getScript"],"sourceRoot":""}