Skip to content

Commit

Permalink
Fix numberOfRecords response
Browse files Browse the repository at this point in the history
  • Loading branch information
myrotvorets-team committed Oct 17, 2021
1 parent 0121020 commit cf64bc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/clientbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export class ClientBase {
this._transport = transport;
}

protected async _sendRequest<R extends Response>(req: FaceXRequest): Promise<R> {
protected async _sendRequest<R extends Response>(
req: FaceXRequest,
ResponseClass?: typeof Response,
status?: number,
): Promise<R> {
dbg(req);
const encoded = await this._encoder.encode(req);

Expand All @@ -53,7 +57,7 @@ export class ClientBase {
throw new BadResponseError(text);
}

const ret = responseFactory(body) as R;
const ret = (ResponseClass && +body.ans_type === status ? new ResponseClass(body) : responseFactory(body)) as R;
dbg(ret);
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/svcclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class SvcClient extends ClientBase {

public async numberOfRecords(): Promise<R.NumberOfRecords> {
const builder = this._requestBuilder.reset(AdminCommands.BASE_STATUS);
return this._sendRequest(await builder.get());
return this._sendRequest(await builder.get(), R.NumberOfRecords, AdminCommands.BASE_STATUS);
}

public async querySector(sector: string): Promise<R.QuerySectorAck> {
Expand Down

0 comments on commit cf64bc5

Please sign in to comment.