@juhuu/sdk-ts 1.0.5 → 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 -17
- package/dist/index.mjs +27 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -88,12 +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
|
-
|
96
|
+
console.log("accessToken:", token);
|
97
|
+
if ((token === null || token === void 0) && useAuthentication === true) {
|
97
98
|
console.error(
|
98
99
|
"endpoint",
|
99
100
|
url,
|
@@ -203,34 +204,43 @@ var Service = class {
|
|
203
204
|
return responseObject;
|
204
205
|
}
|
205
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
|
+
}
|
206
214
|
return await fetch(uri, {
|
207
215
|
method: "GET",
|
208
|
-
headers
|
209
|
-
"Content-Type": "application/json",
|
210
|
-
"Client-Version": this.clientVersion,
|
211
|
-
Authorization: token ? `Bearer ${token}` : ""
|
212
|
-
}
|
216
|
+
headers
|
213
217
|
});
|
214
218
|
}
|
215
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
|
+
}
|
216
227
|
return await fetch(uri, {
|
217
228
|
method: "POST",
|
218
|
-
headers
|
219
|
-
"Content-Type": "application/json",
|
220
|
-
"Client-Version": this.clientVersion,
|
221
|
-
Authorization: token ? `Bearer ${token}` : ""
|
222
|
-
},
|
229
|
+
headers,
|
223
230
|
body: JSON.stringify(body)
|
224
231
|
});
|
225
232
|
}
|
226
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
|
+
}
|
227
241
|
return await fetch(uri, {
|
228
242
|
method: "PATCH",
|
229
|
-
headers
|
230
|
-
"Content-Type": "application/json",
|
231
|
-
"Client-Version": this.clientVersion,
|
232
|
-
Authorization: token ? `Bearer ${token}` : ""
|
233
|
-
},
|
243
|
+
headers,
|
234
244
|
body: JSON.stringify(body)
|
235
245
|
});
|
236
246
|
}
|
package/dist/index.mjs
CHANGED
@@ -43,12 +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
|
-
|
51
|
+
console.log("accessToken:", token);
|
52
|
+
if ((token === null || token === void 0) && useAuthentication === true) {
|
52
53
|
console.error(
|
53
54
|
"endpoint",
|
54
55
|
url,
|
@@ -158,34 +159,43 @@ var Service = class {
|
|
158
159
|
return responseObject;
|
159
160
|
}
|
160
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
|
+
}
|
161
169
|
return await fetch(uri, {
|
162
170
|
method: "GET",
|
163
|
-
headers
|
164
|
-
"Content-Type": "application/json",
|
165
|
-
"Client-Version": this.clientVersion,
|
166
|
-
Authorization: token ? `Bearer ${token}` : ""
|
167
|
-
}
|
171
|
+
headers
|
168
172
|
});
|
169
173
|
}
|
170
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
|
+
}
|
171
182
|
return await fetch(uri, {
|
172
183
|
method: "POST",
|
173
|
-
headers
|
174
|
-
"Content-Type": "application/json",
|
175
|
-
"Client-Version": this.clientVersion,
|
176
|
-
Authorization: token ? `Bearer ${token}` : ""
|
177
|
-
},
|
184
|
+
headers,
|
178
185
|
body: JSON.stringify(body)
|
179
186
|
});
|
180
187
|
}
|
181
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
|
+
}
|
182
196
|
return await fetch(uri, {
|
183
197
|
method: "PATCH",
|
184
|
-
headers
|
185
|
-
"Content-Type": "application/json",
|
186
|
-
"Client-Version": this.clientVersion,
|
187
|
-
Authorization: token ? `Bearer ${token}` : ""
|
188
|
-
},
|
198
|
+
headers,
|
189
199
|
body: JSON.stringify(body)
|
190
200
|
});
|
191
201
|
}
|