query protocol service is implemented

This commit is contained in:
병준 박 2019-09-25 14:06:26 +09:00
parent 449240460b
commit 1eab7c36b5

View File

@ -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<AuthResponse> {
return this.protocolService
.call(SVC_TYPE_QUERY_DATA, SSVC_TYPE_QUERY_AUTH_REQ, ...encodeAuth(req))
.pipe(
take(1),
map(res => decodeAuth(res))
);
}
}