Skip to content

Commit 24a36fa

Browse files
authored
feat: Prefix all internal methods with $ to avoid name clashes (#7)
BREAKING CHANGE: We generate methods names which can be named anything
1 parent 5f6a205 commit 24a36fa

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

index.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ export class RestClient {
213213
this._baseUrl = baseUrl;
214214
}
215215

216-
public get baseUrl() {
216+
public get $baseUrl() {
217217
return this._baseUrl;
218218
}
219219

220-
public withHeader(name: string, value: string|undefined) {
220+
public $withHeader(name: string, value: string|undefined) {
221221
if (!value) {
222222
delete this._fixedHeaders[name];
223223
return this;
@@ -226,23 +226,23 @@ export class RestClient {
226226
return this;
227227
}
228228

229-
public withContentType(contentType: string|undefined) {
230-
return this.withHeader('Content-Type', contentType);
229+
public $withContentType(contentType: string|undefined) {
230+
return this.$withHeader('Content-Type', contentType);
231231
}
232232

233-
public withAuthorization(auth: string|undefined) {
234-
return this.withHeader('Authorization', auth);
233+
public $withAuthorization(auth: string|undefined) {
234+
return this.$withHeader('Authorization', auth);
235235
}
236236

237-
public withBearerToken(token: string|undefined) {
238-
return this.withAuthorization(token ? `Bearer ${token}` : token);
237+
public $withBearerToken(token: string|undefined) {
238+
return this.$withAuthorization(token ? `Bearer ${token}` : token);
239239
}
240240

241-
protected afterCreate(request: RestClientRequest):void {
241+
protected $afterCreate(request: RestClientRequest):void {
242242
// Override this method to add additional headers or similar to all requests
243243
}
244244

245-
public create<ReturnType = any>(method: RequestMethod, path: string, requestArguments: RequestArgument[]):RestClientRequest<ReturnType> {
245+
public $create<ReturnType = any>(method: RequestMethod, path: string, requestArguments: RequestArgument[]):RestClientRequest<ReturnType> {
246246
const request = new RestClientRequest<ReturnType>(this._baseUrl, method, path, requestArguments);
247247

248248
Object.entries(RestClient.globalHeaders).forEach(([key, value]) => {
@@ -253,15 +253,15 @@ export class RestClient {
253253
request.withHeader(key, value);
254254
});
255255

256-
this.afterCreate(request);
256+
this.$afterCreate(request);
257257
return request;
258258
}
259259

260260
/**
261261
* Executes a request to the specified path using the specified method.
262262
*/
263-
public execute<ReturnType = any>(method: RequestMethod, path: string, requestArguments: RequestArgument[]) {
264-
const request = this.create<ReturnType>(method, path, requestArguments);
263+
public $execute<ReturnType = any>(method: RequestMethod, path: string, requestArguments: RequestArgument[]) {
264+
const request = this.$create<ReturnType>(method, path, requestArguments);
265265

266266
return request.call()
267267
}

0 commit comments

Comments
 (0)