diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/services/query-protocol.service.ts b/projects/ucap-webmessenger-protocol-query/src/lib/services/query-protocol.service.ts index 29ffd922..f2df4933 100644 --- a/projects/ucap-webmessenger-protocol-query/src/lib/services/query-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-query/src/lib/services/query-protocol.service.ts @@ -1,8 +1,30 @@ import { Injectable } from '@angular/core'; +import { ProtocolService } from '@ucap-webmessenger/protocol'; +import { Observable } from 'rxjs'; +import { take, map } from 'rxjs/operators'; +import { + AuthRequest, + AuthResponse, + encodeAuth, + decodeAuth +} from '../models/auth'; +import { + SVC_TYPE_QUERY_DATA, + SSVC_TYPE_QUERY_AUTH_REQ +} from '../types/service'; @Injectable({ providedIn: 'root' }) export class QueryProtocolService { - constructor() {} + constructor(private protocolService: ProtocolService) {} + + public auth(req: AuthRequest): Observable { + return this.protocolService + .call(SVC_TYPE_QUERY_DATA, SSVC_TYPE_QUERY_AUTH_REQ, ...encodeAuth(req)) + .pipe( + take(1), + map(res => decodeAuth(res)) + ); + } }