2019-09-18 15:02:21 +09:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
2019-09-26 15:31:19 +09:00
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { map, take } from 'rxjs/operators';
|
|
|
|
|
|
|
|
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
|
|
|
import {
|
|
|
|
SVC_TYPE_INFO,
|
|
|
|
SSVC_TYPE_INFO_USER_REQ,
|
|
|
|
SSVC_TYPE_INFO_STATE_REQ,
|
|
|
|
SSVC_TYPE_INFO_USER_OPTION_REQ,
|
|
|
|
SSVC_TYPE_INFO_USER_OPTION_UPD_REQ
|
|
|
|
} from '../types/service';
|
|
|
|
import {
|
|
|
|
UserRequest,
|
|
|
|
encodeUser,
|
|
|
|
UserResponse,
|
|
|
|
decodeUser
|
2019-10-07 10:08:14 +09:00
|
|
|
} from '../protocols/user';
|
2019-09-26 15:31:19 +09:00
|
|
|
import {
|
|
|
|
StatusRequest,
|
|
|
|
StatusResponse,
|
|
|
|
encodeStatus,
|
|
|
|
decodeStatus
|
2019-10-07 10:08:14 +09:00
|
|
|
} from '../protocols/status';
|
2019-09-26 15:31:19 +09:00
|
|
|
import {
|
|
|
|
UserOptionResponse,
|
|
|
|
decodeUserOption,
|
|
|
|
UserOptionUpdateRequest,
|
|
|
|
encodeUserOptionUpdate,
|
|
|
|
UserOptionUpdateResponse,
|
|
|
|
decodeUserOptionUpdate
|
2019-10-07 10:08:14 +09:00
|
|
|
} from '../protocols/user-option';
|
2019-09-26 15:31:19 +09:00
|
|
|
|
2019-09-18 15:02:21 +09:00
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class InfoProtocolService {
|
2019-09-26 15:31:19 +09:00
|
|
|
constructor(private protocolService: ProtocolService) {}
|
|
|
|
|
|
|
|
public user(req: UserRequest): Observable<UserResponse> {
|
|
|
|
return this.protocolService
|
|
|
|
.call(SVC_TYPE_INFO, SSVC_TYPE_INFO_USER_REQ, ...encodeUser(req))
|
|
|
|
.pipe(
|
|
|
|
take(1),
|
|
|
|
map(res => decodeUser(res))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public status(req: StatusRequest): Observable<StatusResponse> {
|
|
|
|
return this.protocolService
|
|
|
|
.call(SVC_TYPE_INFO, SSVC_TYPE_INFO_STATE_REQ, ...encodeStatus(req))
|
|
|
|
.pipe(
|
|
|
|
take(1),
|
|
|
|
map(res => decodeStatus(res))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public userOption(): Observable<UserOptionResponse> {
|
|
|
|
return this.protocolService
|
|
|
|
.call(SVC_TYPE_INFO, SSVC_TYPE_INFO_USER_OPTION_REQ)
|
|
|
|
.pipe(
|
|
|
|
take(1),
|
|
|
|
map(res => decodeUserOption(res))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public userOptionUpdate(
|
|
|
|
req: UserOptionUpdateRequest
|
|
|
|
): Observable<UserOptionUpdateResponse> {
|
|
|
|
return this.protocolService
|
|
|
|
.call(
|
|
|
|
SVC_TYPE_INFO,
|
|
|
|
SSVC_TYPE_INFO_USER_OPTION_UPD_REQ,
|
|
|
|
...encodeUserOptionUpdate(req)
|
|
|
|
)
|
|
|
|
.pipe(
|
|
|
|
take(1),
|
|
|
|
map(res => decodeUserOptionUpdate(res))
|
|
|
|
);
|
|
|
|
}
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|