82 lines
2.0 KiB
TypeScript
Raw Normal View History

2019-09-18 15:02:21 +09:00
import { Injectable } from '@angular/core';
2019-09-20 16:49:42 +09:00
import { Observable } from 'rxjs';
2019-09-23 15:17:48 +09:00
import { map, take } from 'rxjs/operators';
2019-09-20 16:49:42 +09:00
import { ProtocolService } from '@ucap-webmessenger/protocol';
import {
GroupAddRequest,
encodeGroupAdd,
2019-09-23 11:47:36 +09:00
decodeGroupAdd,
GroupAddResponse
2019-09-20 16:49:42 +09:00
} from '../models/group-add';
import {
SVC_TYPE_GROUP,
SSVC_TYPE_GROUP_ADD_REQ,
SSVC_TYPE_GROUP_DEL_REQ,
SSVC_TYPE_GROUP_UPD_REQ,
SSVC_TYPE_GROUP_UPD_REQ2
} from '../types/service';
import {
GroupDelRequest,
encodeGroupDel,
2019-09-23 11:47:36 +09:00
decodeGroupDel,
GroupDelResponse
2019-09-20 16:49:42 +09:00
} from '../models/group-del';
import {
GroupUpdateRequest,
encodeGroupUpdate,
decodeGroupUpdate,
encodeGroupUpdate2,
2019-09-23 11:47:36 +09:00
decodeGroupUpdate2,
GroupUpdateResponse
2019-09-20 16:49:42 +09:00
} from '../models/group-update';
2019-09-18 15:02:21 +09:00
@Injectable({
providedIn: 'root'
})
export class GroupProtocolService {
2019-09-20 16:49:42 +09:00
constructor(private protocolService: ProtocolService) {}
2019-09-23 11:47:36 +09:00
public groupAdd(req: GroupAddRequest): Observable<GroupAddResponse> {
2019-09-20 16:49:42 +09:00
return this.protocolService
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_ADD_REQ, ...encodeGroupAdd(req))
2019-09-23 15:17:48 +09:00
.pipe(
take(1),
map(res => decodeGroupAdd(res))
);
2019-09-20 16:49:42 +09:00
}
2019-09-23 11:47:36 +09:00
public groupDel(req: GroupDelRequest): Observable<GroupDelResponse> {
2019-09-20 16:49:42 +09:00
return this.protocolService
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_DEL_REQ, ...encodeGroupDel(req))
2019-09-23 15:17:48 +09:00
.pipe(
take(1),
map(res => decodeGroupDel(res))
);
2019-09-20 16:49:42 +09:00
}
2019-09-23 11:47:36 +09:00
public groupUpdate(req: GroupUpdateRequest): Observable<GroupUpdateResponse> {
2019-09-20 16:49:42 +09:00
return this.protocolService
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_UPD_REQ, ...encodeGroupUpdate(req))
2019-09-23 15:17:48 +09:00
.pipe(
take(1),
map(res => decodeGroupUpdate(res))
);
2019-09-20 16:49:42 +09:00
}
2019-09-23 11:47:36 +09:00
public groupUpdate2(
req: GroupUpdateRequest
): Observable<GroupUpdateResponse> {
2019-09-20 16:49:42 +09:00
return this.protocolService
.call(
SVC_TYPE_GROUP,
SSVC_TYPE_GROUP_UPD_REQ2,
...encodeGroupUpdate2(req)
)
2019-09-23 15:17:48 +09:00
.pipe(
take(1),
map(res => decodeGroupUpdate2(res))
);
2019-09-20 16:49:42 +09:00
}
2019-09-18 15:02:21 +09:00
}