@juhuu/sdk-ts 1.0.6 → 1.0.7
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.js +27 -18
- package/dist/index.mjs +27 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -88,13 +88,13 @@ var Service = class {
|
|
88
88
|
options.refreshTokensIfNecessary = true;
|
89
89
|
}
|
90
90
|
let token = null;
|
91
|
-
if (options.accessToken === void 0) {
|
91
|
+
if (options.accessToken === void 0 || options.accessToken === null) {
|
92
92
|
token = await this.getAccessToken();
|
93
93
|
} else {
|
94
94
|
token = options.accessToken;
|
95
95
|
}
|
96
|
-
console.log("
|
97
|
-
if (token === null || void 0) {
|
96
|
+
console.log("accessToken:", token);
|
97
|
+
if ((token === null || token === void 0) && useAuthentication === true) {
|
98
98
|
console.error(
|
99
99
|
"endpoint",
|
100
100
|
url,
|
@@ -204,34 +204,43 @@ var Service = class {
|
|
204
204
|
return responseObject;
|
205
205
|
}
|
206
206
|
async sendGetRequest(token, uri) {
|
207
|
+
const headers = {
|
208
|
+
"Content-Type": "application/json",
|
209
|
+
"Client-Version": this.clientVersion
|
210
|
+
};
|
211
|
+
if (token !== void 0 && token !== null) {
|
212
|
+
headers.Authorization = `Bearer ${token}`;
|
213
|
+
}
|
207
214
|
return await fetch(uri, {
|
208
215
|
method: "GET",
|
209
|
-
headers
|
210
|
-
"Content-Type": "application/json",
|
211
|
-
"Client-Version": this.clientVersion,
|
212
|
-
Authorization: token ? `Bearer ${token}` : ""
|
213
|
-
}
|
216
|
+
headers
|
214
217
|
});
|
215
218
|
}
|
216
219
|
async sendPostRequest(token, uri, body) {
|
220
|
+
const headers = {
|
221
|
+
"Content-Type": "application/json",
|
222
|
+
"Client-Version": this.clientVersion
|
223
|
+
};
|
224
|
+
if (token !== void 0 && token !== null) {
|
225
|
+
headers.Authorization = `Bearer ${token}`;
|
226
|
+
}
|
217
227
|
return await fetch(uri, {
|
218
228
|
method: "POST",
|
219
|
-
headers
|
220
|
-
"Content-Type": "application/json",
|
221
|
-
"Client-Version": this.clientVersion,
|
222
|
-
Authorization: token ? `Bearer ${token}` : ""
|
223
|
-
},
|
229
|
+
headers,
|
224
230
|
body: JSON.stringify(body)
|
225
231
|
});
|
226
232
|
}
|
227
233
|
async sendPatchRequest(token, uri, body) {
|
234
|
+
const headers = {
|
235
|
+
"Content-Type": "application/json",
|
236
|
+
"Client-Version": this.clientVersion
|
237
|
+
};
|
238
|
+
if (token !== void 0 && token !== null) {
|
239
|
+
headers.Authorization = `Bearer ${token}`;
|
240
|
+
}
|
228
241
|
return await fetch(uri, {
|
229
242
|
method: "PATCH",
|
230
|
-
headers
|
231
|
-
"Content-Type": "application/json",
|
232
|
-
"Client-Version": this.clientVersion,
|
233
|
-
Authorization: token ? `Bearer ${token}` : ""
|
234
|
-
},
|
243
|
+
headers,
|
235
244
|
body: JSON.stringify(body)
|
236
245
|
});
|
237
246
|
}
|
package/dist/index.mjs
CHANGED
@@ -43,13 +43,13 @@ var Service = class {
|
|
43
43
|
options.refreshTokensIfNecessary = true;
|
44
44
|
}
|
45
45
|
let token = null;
|
46
|
-
if (options.accessToken === void 0) {
|
46
|
+
if (options.accessToken === void 0 || options.accessToken === null) {
|
47
47
|
token = await this.getAccessToken();
|
48
48
|
} else {
|
49
49
|
token = options.accessToken;
|
50
50
|
}
|
51
|
-
console.log("
|
52
|
-
if (token === null || void 0) {
|
51
|
+
console.log("accessToken:", token);
|
52
|
+
if ((token === null || token === void 0) && useAuthentication === true) {
|
53
53
|
console.error(
|
54
54
|
"endpoint",
|
55
55
|
url,
|
@@ -159,34 +159,43 @@ var Service = class {
|
|
159
159
|
return responseObject;
|
160
160
|
}
|
161
161
|
async sendGetRequest(token, uri) {
|
162
|
+
const headers = {
|
163
|
+
"Content-Type": "application/json",
|
164
|
+
"Client-Version": this.clientVersion
|
165
|
+
};
|
166
|
+
if (token !== void 0 && token !== null) {
|
167
|
+
headers.Authorization = `Bearer ${token}`;
|
168
|
+
}
|
162
169
|
return await fetch(uri, {
|
163
170
|
method: "GET",
|
164
|
-
headers
|
165
|
-
"Content-Type": "application/json",
|
166
|
-
"Client-Version": this.clientVersion,
|
167
|
-
Authorization: token ? `Bearer ${token}` : ""
|
168
|
-
}
|
171
|
+
headers
|
169
172
|
});
|
170
173
|
}
|
171
174
|
async sendPostRequest(token, uri, body) {
|
175
|
+
const headers = {
|
176
|
+
"Content-Type": "application/json",
|
177
|
+
"Client-Version": this.clientVersion
|
178
|
+
};
|
179
|
+
if (token !== void 0 && token !== null) {
|
180
|
+
headers.Authorization = `Bearer ${token}`;
|
181
|
+
}
|
172
182
|
return await fetch(uri, {
|
173
183
|
method: "POST",
|
174
|
-
headers
|
175
|
-
"Content-Type": "application/json",
|
176
|
-
"Client-Version": this.clientVersion,
|
177
|
-
Authorization: token ? `Bearer ${token}` : ""
|
178
|
-
},
|
184
|
+
headers,
|
179
185
|
body: JSON.stringify(body)
|
180
186
|
});
|
181
187
|
}
|
182
188
|
async sendPatchRequest(token, uri, body) {
|
189
|
+
const headers = {
|
190
|
+
"Content-Type": "application/json",
|
191
|
+
"Client-Version": this.clientVersion
|
192
|
+
};
|
193
|
+
if (token !== void 0 && token !== null) {
|
194
|
+
headers.Authorization = `Bearer ${token}`;
|
195
|
+
}
|
183
196
|
return await fetch(uri, {
|
184
197
|
method: "PATCH",
|
185
|
-
headers
|
186
|
-
"Content-Type": "application/json",
|
187
|
-
"Client-Version": this.clientVersion,
|
188
|
-
Authorization: token ? `Bearer ${token}` : ""
|
189
|
-
},
|
198
|
+
headers,
|
190
199
|
body: JSON.stringify(body)
|
191
200
|
});
|
192
201
|
}
|