UNPKG

consumableai-sdk

Version:

## Overview

2 lines (1 loc) 924 B
import t from"isomorphic-unfetch";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},e.apply(this,arguments)}class r{constructor(t){this.apiKey=void 0,this.baseUrl=void 0,this.apiKey=t.apiKey,this.baseUrl=t.baseUrl||"https://api.consumableai.com"}request(r,s){const o=`${this.baseUrl}${r}?api_key=${this.apiKey}`,a=e({},s,{headers:{"Content-Type":"application/json"}});return t(o,a).then(t=>{if(t.ok)return t.json();throw new Error(t.statusText)})}}class s extends r{}var o;o=s,[class extends r{translate(t){return this.request("/api/translate",{method:"POST",body:JSON.stringify({prompt:t})})}}].forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(e=>{Object.defineProperty(o.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})});export{s as default};