!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.swaggerAjaxClient=e()}}(function(){return function e(t,r,n){function o(a,s){if(!r[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);throw new Error("Cannot find module '"+a+"'")}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return o(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a0)){var n=r.shift();n()}},!0),function(e){r.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.on=r,n.addListener=r,n.once=r,n.off=r,n.removeListener=r,n.removeAllListeners=r,n.emit=r,n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")}},{}],2:[function(e,t,r){"use strict";var n=e("./promise/promise").Promise,o=e("./promise/polyfill").polyfill;r.Promise=n,r.polyfill=o},{"./promise/polyfill":6,"./promise/promise":7}],3:[function(e,t,r){"use strict";function n(e){var t=this;if(!o(e))throw new TypeError("You must pass an array to all.");return new t(function(t,r){function n(e){return function(t){o(e,t)}}function o(e,r){s[e]=r,0===--u&&t(s)}var a,s=[],u=e.length;0===u&&t([]);for(var c=0;cparseInt(t.maximum,10)?new c.NumberTooLargeError(e,t.maximum):void 0}function i(e){return"boolean"==typeof e||e instanceof Boolean?void 0:new c.NotABooleanError(e,typeof e)}function a(e){return null!=e?new c.NotVoidError(e,typeof e):void 0}function s(){}function u(e,t){return"string"==typeof e||e instanceof String?"enum"in t&&-1===t.enum.indexOf(e)?new c.StringNotInEnumError(e,t.enum):void 0:new c.NotAStringError(e,typeof e)}var c=e("./errorTypes");r.validateInteger=n,r.validateNumber=o,r.validateBoolean=i,r.validateVoid=a,r.validateFile=s,r.validateString=u},{"./errorTypes":13}],20:[function(e,t){"use strict";function r(e,t,r,n){if(!r)throw new o(t,e);if("header"===e.passAs)n.headers[e.keyname]=r;else if("query"===e.passAs){var i=n.url,a=e.keyname+"="+encodeURIComponent(r);-1===i.indexOf("?")?i+="?"+a:i=i.replace("?","?"+a+"&"),n.url=i}}function n(e,t,r,n,i){if(!r||!n)throw new o(t,e);var a=i.url;-1===a.indexOf("@")&&(a=a.replace("://","://"+r+":"+n+"@")),i.url=a}var o=e("./errorTypes").MissingAuthorizationError;t.exports=function(e,t,i){var a=e.authorizations;if(a||(a=e.apiObject.apiDeclaration.authorizations),a){var s=Object.keys(a).filter(function(e){return"oauth2"!==a[e].type});if(0!==s.length)if(1===s.length){var u=s[0],c=a[u];if(!t)throw new o(u,c);t[u]&&(t=t[u]),"apiKey"===c.type?r(c,u,t,i):"basicAuth"===c.type&&n(c,u,t.username,t.password,i)}else{var p=s.some(function(e){var o=a[e],s=t[e];return s?("apiKey"===o.type?r(o,e,s,i):"basicAuth"===o.type&&n(o,e,s.username,s.password,i),!0):!1});if(!p)throw new o(s.join(", "),a)}}}},{"./errorTypes":23}],21:[function(e,t){"use strict";function r(e,t){var r,s={},u="auth";e=o(e);var c=e.apis.some(function(e){return e.apiDeclaration.apis.some(function(e){var t=i(e.apiDeclaration.resourcePath||e.path);return"auth"===t?!0:e.operations.some(function(e){return"auth"===e.nickname})})});return c&&(u="authorization"),s[u]=function(){r=n(arguments)},e.apis.forEach(function(e){var o,c,p;e.apiDeclaration.resourcePath&&(o=i(e.apiDeclaration.resourcePath),c=s[o]={},c[u]=function(){p=n(arguments)}),e.apiDeclaration.apis.forEach(function(e){var f,l=o,d=c;l||(l=i(e.path),d=s[l]={},d[u]=function(){f=n(arguments)}),e.operations.forEach(function(e){function o(){return i||f||p||r}var i,s,c=e.nickname;s=a(e,o,t),s[u]=function(){i=n(arguments)},d[c]=s})})}),s}function n(e){return"string"==typeof e[0]&&"string"==typeof e[1]?{username:e[0],password:e[1]}:e[0]}function o(e){return e.apis.forEach(function(t){t.resourceListing=e,t.apiDeclaration.apis.forEach(function(e){e.resourceObject=t,e.apiDeclaration=t.apiDeclaration,e.operations.forEach(function(t){t.apiObject=e,t.parameters.forEach(function(e){e.operation=t})})})}),e}function i(e){return e=e.replace(/\W/g,"/"),e=e.replace(/(\w)\/(\w)/g,function(e,t,r){return t+r.toUpperCase()}),e=e.replace(/\//g,"")}var a=e("./createOperationHandler");t.exports=r},{"./createOperationHandler":22}],22:[function(e,t){"use strict";function r(e,t,r){function n(t,r){this.method=e.method,this.operation=e,this.errorTypes=d,this.data=t,this.options=r}var f=function(f,d){var m,y;d=d||{},null==f&&(f={}),"function"==typeof d&&(d.callback=d);try{f=o(f),f=i(e,f),f=a(e,f),m=l.operation(f,e,e.apiObject.apiDeclaration.models),y=new n(f,d),m||(y.url=u(e,f),y.headers=s(e,f,d),y.body=c(e,f,y.headers),p(e,t(),y))}catch(h){m=h}return r(m,y)};return f.Request=n,f.errorTypes=d,f.operation=e,f.validate=function(t){return l.operation(t,e,e.apiObject.apiDeclaration.models)},f}function n(){}function o(e){return JSON.parse(JSON.stringify(e))}function i(e,t){var r=e.parameters.filter(function(e){return e.required});if(r.length>1)return t;if(1!==r.length&&1!==e.parameters.length)return t;var n=r[0]||e.parameters[0];if("object"==typeof t&&void 0!==t[n.name])return t;var o,i=e.apiObject.apiDeclaration.models;try{o=l.dataType(t,n,i)}catch(a){return t}if(o)return t;var s={};return s[n.name]=t,s}function a(e,t){if(!t||"object"!=typeof t)return t;var n={};e.parameters.forEach(function(e){n[e.name]=!0});var o=Object.keys(t).filter(function(e){return!(e in n)});return r.logger.warn("Unknown parameters removed from request:",o.join(", ")),o.forEach(function(e){delete t[e]}),t}var s=e("./getRequestHeaders"),u=e("./getRequestUrl"),c=e("./getRequestBody"),p=e("./applyAuthData"),f=e("./errorTypes"),l=e("swagger-validate"),d={};Object.keys(l.errors).forEach(function(e){d[e]=l.errors[e]}),Object.keys(f).forEach(function(e){d[e]=f[e]}),t.exports=r,r.logger={debug:n,info:n,warn:n,error:n}},{"./applyAuthData":20,"./errorTypes":23,"./getRequestBody":24,"./getRequestHeaders":25,"./getRequestUrl":26,"swagger-validate":14}],23:[function(e,t,r){"use strict";function n(e){this.name="InvalidRequestError",this.message=e||"Invalid request"}function o(e,t){this.name="MissingAuthorizationError",this.message="No data found for authorization: "+e,this.authorization=t}function i(e){this.name="MissingPathParamsError",this.message="Missing the following required path parameters: "+e.join("")}function a(e,t){var r=t.apiObject.apiDeclaration,n=t.consumes||r.consumes||[];this.name="ContentTypeNotSupportedError",this.message="Operation ["+t.nickname+"] does not accept "+e+". It supports: "+n.join(", ")}function s(e,t){var r=t.apiObject.apiDeclaration,n=t.produces||r.produces||[];this.name="AcceptsNotSupportedError",this.message="Operation ["+t.nickname+"] does not produce "+e+". It supports: "+n.join(", ")}function u(e,t){this.name="OperationValidationError",this.message=e.nickname+" failed validation: \n "+t.join("\n ")}function c(e,t){this.name="ParameterValidationError",this.message=e.name+" failed validation: \n "+t.join("\n ")}function p(e){this.name="DataTypeValidationError",this.message=e||"Invalid data type"}n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,r.InvalidRequestError=n,o.prototype=Object.create(n.prototype),o.prototype.constructor=o,r.MissingAuthorizationError=o,i.prototype=Object.create(n.prototype),i.prototype.constructor=i,r.MissingPathParamsError=i,a.prototype=Object.create(n.prototype),a.prototype.constructor=a,r.ContentTypeNotSupportedError=a,s.prototype=Object.create(n.prototype),s.prototype.constructor=s,r.AcceptsNotSupportedError=s,u.prototype=Object.create(n.prototype),u.prototype.constructor=u,r.OperationValidationError=u,c.prototype=Object.create(n.prototype),c.prototype.constructor=c,r.ParameterValidationError=c,p.prototype=Object.create(Error.prototype),p.prototype.constructor=p,r.DataTypeValidationError=p},{}],24:[function(e,t){"use strict";t.exports=function(e,t,r){var n=e.parameters.filter(function(e){return"body"===e.paramType&&null!=t[e.name]}).map(function(e){return t[e.name]})[0];if(!r||!r["Content-Type"])return n;var o=r["Content-Type"],i=e.parameters.filter(function(e){return"form"===e.paramType&&null!=t[e.name]});if(-1!==o.indexOf("application/x-www-form-urlencoded"))n=i.map(function(e){var r=e.name,n=t[r];return encodeURIComponent(r)+"="+encodeURIComponent(n)}).join("&");else if(-1!==o.indexOf("multipart/form-data")){var a=Math.random().toString(16).substr(2),s="SwaggerBoundary"+a;n=i.map(function(e){var r=e.name,n=t[r],o="--"+s;return o+='\nContent-Disposition: form-data; name="'+r+'"',n.contentType&&(n.name&&(o+='; filename="'+n.name+'"'),o+="\nContent-Type: "+n.contentType),n.contentTransferEncoding&&(o+="\nContent-Transfer-Encoding: "+n.contentTransferEncoding),o+=n.body?"\n\n"+n.body:"\n\n"+n}).join("\n"),n+="\n--"+s+"--\n",r["Content-Type"]=o.replace("multipart/form-data","multipart/form-data; boundary="+s)}else-1!==o.indexOf("application/json")&&"string"!=typeof n&&(n=JSON.stringify(n));return n}},{}],25:[function(e,t,r){"use strict";function n(e,t){var r=e.parameters.some(function(e){return"body"===e.paramType&&void 0!==t[e.name]});if(r)return"application/json";var n=e.parameters.some(function(e){return"form"===e.paramType&&void 0!==t[e.name]}),o=n&&e.parameters.some(function(e){return"File"===e.type&&void 0!==t[e.name]});return o?"multipart/form-data":n?"application/x-www-form-urlencoded":void 0}function o(e,t){var r=e.apiObject.apiDeclaration,n=e.consumes||r.consumes;return n&&n.length?-1!==n.indexOf(t):!0}function i(e,t){var r=e.apiObject.apiDeclaration,n=e.produces||r.produces;return n&&n.length?-1!==n.indexOf(t):!0}var a=e("./errorTypes"),s=a.ContentTypeNotSupportedError,u=a.AcceptsNotSupportedError,c="application/json";t.exports=function(e,t,r){t=t||{},r=r||{};var a={};e.parameters.forEach(function(e){"header"===e.paramType&&null!=t[e.name]&&(a[e.name]=t[e.name])}),r.headers&&Object.keys(r.headers).forEach(function(e){a[e]=r.headers[e]});var p=r.contentType||n(e,t,r);if(p){if(!o(e,p))throw new s(p,e);a["Content-Type"]=p}var f=r.accept||c;if(f){if(!i(e,f))throw new u(f,e);a.Accept=f}return a},r.hasAccept=o,r.hasContentType=i},{"./errorTypes":23}],26:[function(e,t){"use strict";function r(e,t,r){var n=t.parameters.filter(function(e){return"path"===e.paramType}),o=n.filter(function(e){return void 0===r[e.name]});if(o.length)throw new i(o.map(function(e){return e.name}));return n.forEach(function(t){var n=t.name,o=new RegExp("{"+n+"[^}]*}","gi"),i=r[n].toString();delete r[n],i=i.split("/").map(encodeURIComponent).join("/"),e=e.replace(o,i)}),e}function n(e){var t=e.apiObject,r=t.apiDeclaration.basePath,n=t.path.replace("{format}","json");return r+n}var o=e("./errorTypes"),i=o.MissingPathParamsError;t.exports=function(e,t){var o=n(e);if(o=r(o,e,t),!t)return o;var i=e.parameters.filter(function(e){return"query"===e.paramType&&void 0!==t[e.name]}).map(function(e){var r=e.name;return encodeURIComponent(r)+"="+encodeURIComponent(t[r])}).join("&");return i&&(o+="?"+i),o}},{"./errorTypes":23}],27:[function(e,t){"use strict";function r(e,r){var o=t.exports.XMLHttpRequest;return new n(function(t,n){if(e)return n(e);var i=r.method,a=r.url,s=r.body,u=r.headers,c=r.options,p="async"in c?c.async:!0,f=new o;f.open(i,a,p),u&&Object.keys(u).forEach(function(e){f.setRequestHeader(e,u[e])}),c.withCredentials&&(f.withCredentials=c.withCredentials),c.timeout&&(f.timeout=c.timeout),c.onabort&&(f.onabort=c.onabort),c.onerror&&(f.onerror=c.onerror),c.onload&&(f.onload=c.onload),c.ontimeout&&(f.ontimeout=c.ontimeout),c.onprogress&&(f.onprogress=c.onprogress),f.onloadend=function(){var e=this.response,r=this.getResponseHeader("Content-Type");if(r&&-1!==r.indexOf("application/json"))try{e=JSON.parse(e)}catch(o){n({error:o,status:this.status,data:e})}this.status<200||this.status>=300?n({error:o,status:this.status,data:e}):t(e),c.onloadend&&c.onloadend.call(this)},f.send(s)})}var n=e("es6-promise").Promise,o=e("swagger-client-generator");t.exports=function(e){return o(e,r)},"undefined"!=typeof XMLHttpRequest&&(t.exports.XMLHttpRequest=window.XMLHttpRequest)},{"es6-promise":2,"swagger-client-generator":12}]},{},[27])(27)}); //# sourceMappingURL=swagger-ajax-client.min.js.map