2019-09-18 15:02:21 +09:00
|
|
|
import { Injectable } from '@angular/core';
|
2019-09-25 14:06:26 +09:00
|
|
|
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';
|
2019-09-18 15:02:21 +09:00
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class QueryProtocolService {
|
2019-09-25 14:06:26 +09:00
|
|
|
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))
|
|
|
|
);
|
|
|
|
}
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|