consumableai-sdk
Version:
## Overview
2 lines (1 loc) • 1.7 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("isomorphic-unfetch")):"function"==typeof define&&define.amd?define(["isomorphic-unfetch"],e):(t||self).consumableaiSdk=e(t.isomorphicUnfetch)}(this,function(t){function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=/*#__PURE__*/e(t);function n(){return n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},n.apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,i(t,e)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}var p,u=/*#__PURE__*/function(){function t(t){this.apiKey=void 0,this.baseUrl=void 0,this.apiKey=t.apiKey,this.baseUrl=t.baseUrl||"https://api.consumableai.com"}return t.prototype.request=function(t,e){var r=""+this.baseUrl+t+"?api_key="+this.apiKey,i=n({},e,{headers:{"Content-Type":"application/json"}});return o.default(r,i).then(function(t){if(t.ok)return t.json();throw new Error(t.statusText)})},t}(),c=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e.prototype.translate=function(t){return this.request("/api/translate",{method:"POST",body:JSON.stringify({prompt:t})})},e}(u),s=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e}(u);return p=s,[c].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(p.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})}),s});