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