shred-api-client 2.3.3 → 2.3.5-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +30 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/util/HTTPClient.ts
|
|
8
|
-
import
|
|
8
|
+
import axios from "axios";
|
|
9
9
|
var HOSTS = {
|
|
10
10
|
prod: "https://api.shreditapp.com",
|
|
11
11
|
staging: "https://api.staging.shreditapp.com",
|
|
@@ -30,37 +30,40 @@ var HTTPClient = class {
|
|
|
30
30
|
if (context?.requestId) {
|
|
31
31
|
headers["X-Request-ID"] = context.requestId;
|
|
32
32
|
}
|
|
33
|
-
const fetchOptions = {
|
|
34
|
-
method,
|
|
35
|
-
headers
|
|
36
|
-
};
|
|
37
|
-
if (method !== "GET" && data) {
|
|
38
|
-
fetchOptions.body = useLegacyApi ? new URLSearchParams(data).toString() : JSON.stringify(data);
|
|
39
|
-
}
|
|
40
33
|
try {
|
|
41
|
-
const response = await
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
34
|
+
const response = await axios.request({
|
|
35
|
+
url,
|
|
36
|
+
method,
|
|
37
|
+
headers,
|
|
38
|
+
data: method !== "GET" && data ? useLegacyApi ? new URLSearchParams(data).toString() : data : void 0,
|
|
39
|
+
transformResponse: [(raw) => raw]
|
|
40
|
+
// evita parse automático para podermos tratar manual
|
|
41
|
+
});
|
|
50
42
|
try {
|
|
51
|
-
return
|
|
43
|
+
return JSON.parse(response.data);
|
|
52
44
|
} catch {
|
|
53
|
-
return
|
|
45
|
+
return response.data;
|
|
54
46
|
}
|
|
55
|
-
} catch (
|
|
47
|
+
} catch (err) {
|
|
48
|
+
const error = err;
|
|
56
49
|
let parsedBody = {};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
if (error.response) {
|
|
51
|
+
try {
|
|
52
|
+
parsedBody = typeof error.response.data === "string" ? JSON.parse(error.response.data) : error.response.data;
|
|
53
|
+
} catch {
|
|
54
|
+
parsedBody = {
|
|
55
|
+
message: error.response.data?.message || error.response.statusText || "Unknown error"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
throw {
|
|
59
|
+
message: parsedBody.message || "Unexpected error occurred",
|
|
60
|
+
status: error.response.status,
|
|
61
|
+
body: error.response.data,
|
|
62
|
+
original: error
|
|
63
|
+
};
|
|
61
64
|
}
|
|
62
65
|
throw {
|
|
63
|
-
message:
|
|
66
|
+
message: error.message || "Network error",
|
|
64
67
|
original: error
|
|
65
68
|
};
|
|
66
69
|
}
|
|
@@ -739,20 +742,13 @@ var UserAPI = class {
|
|
|
739
742
|
);
|
|
740
743
|
return data.token;
|
|
741
744
|
}
|
|
742
|
-
async createUser(
|
|
745
|
+
async createUser(create) {
|
|
743
746
|
const endpointData = user_exports.Endpoints.CreateUser;
|
|
744
747
|
const data = await this.clientHTTP.makeRequest(
|
|
745
748
|
this.env,
|
|
746
749
|
endpointData.uri,
|
|
747
750
|
endpointData.method,
|
|
748
|
-
|
|
749
|
-
email,
|
|
750
|
-
name,
|
|
751
|
-
password,
|
|
752
|
-
passwordConfirmation,
|
|
753
|
-
profession,
|
|
754
|
-
invitationCode
|
|
755
|
-
},
|
|
751
|
+
create,
|
|
756
752
|
null
|
|
757
753
|
);
|
|
758
754
|
return data;
|