Comparing version 0.1.2 to 0.1.3
@@ -7,2 +7,3 @@ const baseUrl = "https://api.truetoform.online/v1"; | ||
this.message = message || response.statusText; | ||
this.name = "ResponseError"; | ||
} | ||
@@ -33,3 +34,3 @@ } | ||
} catch (error) { | ||
if (error instanceof ResponseError) { | ||
if (error.name === "ResponseError") { | ||
throw new Error( | ||
@@ -36,0 +37,0 @@ `Error ${error.response.status}: ${error.response.message}` |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.truetoformApi=t():e.truetoformApi=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>o});class r extends Error{constructor(e,t){this.response=e,this.message=t||e.statusText}}const o=e=>{const t=(e=>{const t={"Content-Type":"application/json","X-TTF-API-KEY":e},o=async(e,o,n=null)=>{const s={method:e,headers:t,body:n?JSON.stringify(n):null},i=await fetch(`https://api.truetoform.online/v1/${o}`,s);try{const e=await i.json();if(!i.ok)throw new r(i,e.message);return e}catch(e){if(e instanceof r)throw new Error(`Error ${e.response.status}: ${e.response.message}`);return i}};return{get:e=>o("GET",e),post:(e,t)=>o("POST",e,t),put:(e,t)=>o("PUT",e,t),delete:e=>o("DELETE",e)}})(e);return{getGarment:e=>{if(!e)throw new Error("garment ID is required");return t.get(`garments/${e}`)},getSurvey:e=>{if(!e)throw new Error("survey ID is required");return t.get(`surveys/${e}`)},getScan:e=>{if(!e)throw new Error("scan ID is required");return t.get(`scans/${e}`)},getPrediction:e=>{if(!e)throw new Error("prediction ID is required");return t.get(`predictions/${e}`)},createSession:()=>t.post("sessions"),createScanPrediction:(e,r)=>t.post("predictions/scan",{sessionId:r,garmentId:e}),createSurveyPrediction:(e,r)=>t.post("predictions/survey",{...r,garmentId:e})}};return t})())); | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.truetoformApi=r():e.truetoformApi=r()}(this,(()=>(()=>{"use strict";var e={d:(r,t)=>{for(var o in t)e.o(t,o)&&!e.o(r,o)&&Object.defineProperty(r,o,{enumerable:!0,get:t[o]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{default:()=>o});class t extends Error{constructor(e,r){this.response=e,this.message=r||e.statusText,this.name="ResponseError"}}const o=e=>{const r=(e=>{const r={"Content-Type":"application/json","X-TTF-API-KEY":e},o=async(e,o,n=null)=>{const s={method:e,headers:r,body:n?JSON.stringify(n):null},i=await fetch(`https://api.truetoform.online/v1/${o}`,s);try{const e=await i.json();if(!i.ok)throw new t(i,e.message);return e}catch(e){if("ResponseError"===e.name)throw new Error(`Error ${e.response.status}: ${e.response.message}`);return i}};return{get:e=>o("GET",e),post:(e,r)=>o("POST",e,r),put:(e,r)=>o("PUT",e,r),delete:e=>o("DELETE",e)}})(e);return{getGarment:e=>{if(!e)throw new Error("garment ID is required");return r.get(`garments/${e}`)},getSurvey:e=>{if(!e)throw new Error("survey ID is required");return r.get(`surveys/${e}`)},getScan:e=>{if(!e)throw new Error("scan ID is required");return r.get(`scans/${e}`)},getPrediction:e=>{if(!e)throw new Error("prediction ID is required");return r.get(`predictions/${e}`)},createSession:()=>r.post("sessions"),createScanPrediction:(e,t)=>r.post("predictions/scan",{sessionId:t,garmentId:e}),createSurveyPrediction:(e,t)=>r.post("predictions/survey",{...t,garmentId:e})}};return r})())); |
{ | ||
"name": "ttf-api", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "The TrueToForm API SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7836
178