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