Skip to content

Commit

Permalink
fix(stubs): fix stub names
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Baulig committed May 7, 2024
1 parent aaa6b76 commit dbf4826
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
8 changes: 7 additions & 1 deletion src/stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ export abstract class Stub
static cfg: any = null;
static logger: Logger = null;

abstract get type(): string;
private static getType<T extends Stub>(stub: T): string {
return stub.constructor.name;
}

get type(): string {
return Stub.getType(this);
}

constructor(
public courier: Courier,
Expand Down
6 changes: 1 addition & 5 deletions src/stubs/dhl_soap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,6 @@ class DHLSoap extends Stub {
},
};

get type(): string {
return this.constructor.name; // 'DHLSoap';
}

get clients(): ClientMap {
return DHLSoap._clients;
}
Expand Down Expand Up @@ -702,4 +698,4 @@ class DHLSoap extends Stub {
}
};

Stub.register('DHLSoap', DHLSoap);
Stub.register(DHLSoap.constructor.name, DHLSoap);
8 changes: 2 additions & 6 deletions src/stubs/dummy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { FlatAggregatedFulfillment } from '../utils.js';
import { Stub } from '../stub.js';

class DummyStub extends Stub {

get type(): string {
return this.constructor.name;
}
class Dummy extends Stub {

override async getTariffCode(
fulfillment: FlatAggregatedFulfillment
Expand Down Expand Up @@ -38,4 +34,4 @@ class DummyStub extends Stub {
}
}

Stub.register('Dummy', DummyStub);
Stub.register(Dummy.constructor.name, Dummy);

0 comments on commit dbf4826

Please sign in to comment.