API, PI, Protocol are refactored

This commit is contained in:
병준 박 2019-09-20 11:39:09 +09:00
parent ff33395a5f
commit a2db0ef3ca
33 changed files with 762 additions and 411 deletions

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface FileProfileSaveRequest extends APIRequest { export interface FileProfileSaveRequest extends APIRequest {
userSeq: string; userSeq: string;
@ -14,3 +20,17 @@ export interface FileProfileSaveResponse extends APIResponse {
ProfileURL?: string; ProfileURL?: string;
ProfileSubDir?: string; ProfileSubDir?: string;
} }
const fileProfileEncodeMap = {};
export const encodeFileProfileSave: APIEncoder<FileProfileSaveRequest> = (
req: FileProfileSaveRequest
) => {
return ParameterUtil.encode(fileProfileEncodeMap, req);
};
export const decodeFileProfileSave: APIDecoder<FileProfileSaveResponse> = (
res: any
) => {
return {} as FileProfileSaveResponse;
};

View File

@ -1,5 +1,5 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest } from '@ucap-webmessenger/api'; import { APIRequest, APIEncoder, ParameterUtil } from '@ucap-webmessenger/api';
export interface FileTalkDownloadRequest extends APIRequest { export interface FileTalkDownloadRequest extends APIRequest {
userSeq: string; userSeq: string;
@ -7,3 +7,11 @@ export interface FileTalkDownloadRequest extends APIRequest {
token: string; token: string;
attachmentsSeq?: string; attachmentsSeq?: string;
} }
const fileTalkDownloadEncodeMap = {};
export const encodeFileTalkDownload: APIEncoder<FileTalkDownloadRequest> = (
req: FileTalkDownloadRequest
) => {
return ParameterUtil.encode(fileTalkDownloadEncodeMap, req);
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface FileTalkSaveRequest extends APIRequest { export interface FileTalkSaveRequest extends APIRequest {
userSeq: string; userSeq: string;
@ -29,3 +35,17 @@ export interface FileTalkSaveResponse extends APIResponse {
VoiceTime?: string; VoiceTime?: string;
SynapKey?: string; SynapKey?: string;
} }
const fileTalkSaveEncodeMap = {};
export const encodeFileTalkSave: APIEncoder<FileTalkSaveRequest> = (
req: FileTalkSaveRequest
) => {
return ParameterUtil.encode(fileTalkSaveEncodeMap, req);
};
export const decodeFileTalkSave: APIDecoder<FileTalkSaveResponse> = (
res: any
) => {
return {} as FileTalkSaveResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface FileTalkShareRequest extends APIRequest { export interface FileTalkShareRequest extends APIRequest {
userSeq: string; userSeq: string;
@ -22,3 +28,17 @@ export interface FileTalkShareResponse extends APIResponse {
CompanyCode?: string; CompanyCode?: string;
SynapKey?: string; SynapKey?: string;
} }
const fileTalkShareEncodeMap = {};
export const encodeFileTalkShare: APIEncoder<FileTalkShareRequest> = (
req: FileTalkShareRequest
) => {
return ParameterUtil.encode(fileTalkShareEncodeMap, req);
};
export const decodeFileTalkShare: APIDecoder<FileTalkShareResponse> = (
res: any
) => {
return {} as FileTalkShareResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface MassTalkDownloadRequest extends APIRequest { export interface MassTalkDownloadRequest extends APIRequest {
userSeq: string; userSeq: string;
@ -13,3 +19,17 @@ export interface MassTalkDownloadResponse extends APIResponse {
UserName?: string; UserName?: string;
RegDate?: string; RegDate?: string;
} }
const massTalkDownloadEncodeMap = {};
export const encodeMassTalkDownload: APIEncoder<MassTalkDownloadRequest> = (
req: MassTalkDownloadRequest
) => {
return ParameterUtil.encode(massTalkDownloadEncodeMap, req);
};
export const decodeMassTalkDownload: APIDecoder<MassTalkDownloadResponse> = (
res: any
) => {
return {} as MassTalkDownloadResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface MassTalkSaveRequest extends APIRequest { export interface MassTalkSaveRequest extends APIRequest {
userSeq: string; userSeq: string;
@ -15,3 +21,17 @@ export interface MassTalkSaveResponse extends APIResponse {
RegDate?: string; RegDate?: string;
Content?: string; Content?: string;
} }
const massTalkSaveEncodeMap = {};
export const encodeMassTalkSave: APIEncoder<MassTalkSaveRequest> = (
req: MassTalkSaveRequest
) => {
return ParameterUtil.encode(massTalkSaveEncodeMap, req);
};
export const decodeMassTalkSave: APIDecoder<MassTalkSaveResponse> = (
res: any
) => {
return {} as MassTalkSaveResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface TransMassTalkDownloadRequest extends APIRequest { export interface TransMassTalkDownloadRequest extends APIRequest {
userSeq: string; userSeq: string;
@ -15,3 +21,17 @@ export interface TransMassTalkDownloadResponse extends APIResponse {
UserName?: string; UserName?: string;
RegDate?: string; RegDate?: string;
} }
const transMassTalkDownloadEncodeMap = {};
export const encodeTransMassTalkDownload: APIEncoder<
TransMassTalkDownloadRequest
> = (req: TransMassTalkDownloadRequest) => {
return ParameterUtil.encode(transMassTalkDownloadEncodeMap, req);
};
export const decodeTransMassTalkDownload: APIDecoder<
TransMassTalkDownloadResponse
> = (res: any) => {
return {} as TransMassTalkDownloadResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface TransMassTalkSaveRequest extends APIRequest { export interface TransMassTalkSaveRequest extends APIRequest {
userSeq: string; userSeq: string;
@ -19,3 +25,17 @@ export interface TransMassTalkSaveResponse extends APIResponse {
Original?: string; Original?: string;
Translation?: string; Translation?: string;
} }
const transMassTalkSaveEncodeMap = {};
export const encodeTransMassTalkSave: APIEncoder<TransMassTalkSaveRequest> = (
req: TransMassTalkSaveRequest
) => {
return ParameterUtil.encode(transMassTalkSaveEncodeMap, req);
};
export const decodeTransMassTalkSave: APIDecoder<TransMassTalkSaveResponse> = (
res: any
) => {
return {} as TransMassTalkSaveResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface TranslationReqRequest extends APIRequest { export interface TranslationReqRequest extends APIRequest {
userSeq: string; userSeq: string;
@ -16,3 +22,17 @@ export interface TranslationReqResponse extends APIResponse {
Original?: string; Original?: string;
Translation?: string; Translation?: string;
} }
const translationReqEncodeMap = {};
export const encodeTranslationReq: APIEncoder<TranslationReqRequest> = (
req: TranslationReqRequest
) => {
return ParameterUtil.encode(translationReqEncodeMap, req);
};
export const decodeTranslationReq: APIDecoder<TranslationReqResponse> = (
res: any
) => {
return {} as TranslationReqResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface TranslationSaveRequest extends APIRequest { export interface TranslationSaveRequest extends APIRequest {
userSeq: string; userSeq: string;
@ -20,3 +26,17 @@ export interface TranslationSaveResponse extends APIResponse {
Original?: string; Original?: string;
Translation?: string; Translation?: string;
} }
const translationSaveEncodeMap = {};
export const encodeTranslationSave: APIEncoder<TranslationSaveRequest> = (
req: TranslationSaveRequest
) => {
return ParameterUtil.encode(translationSaveEncodeMap, req);
};
export const decodeTranslationSave: APIDecoder<TranslationSaveResponse> = (
res: any
) => {
return {} as TranslationSaveResponse;
};

View File

@ -8,40 +8,61 @@ import { _MODULE_CONFIG } from '../types/token';
import { ModuleConfig } from '../types/module-config'; import { ModuleConfig } from '../types/module-config';
import { import {
FileProfileSaveRequest, FileProfileSaveRequest,
FileProfileSaveResponse FileProfileSaveResponse,
encodeFileProfileSave,
decodeFileProfileSave
} from '../models/file-profile-save'; } from '../models/file-profile-save';
import { FileTalkDownloadRequest } from '../models/file-talk-download'; import {
FileTalkDownloadRequest,
encodeFileTalkDownload
} from '../models/file-talk-download';
import { import {
FileTalkSaveRequest, FileTalkSaveRequest,
FileTalkSaveResponse FileTalkSaveResponse,
encodeFileTalkSave,
decodeFileTalkSave
} from '../models/file-talk-save'; } from '../models/file-talk-save';
import { import {
FileTalkShareRequest, FileTalkShareRequest,
FileTalkShareResponse FileTalkShareResponse,
encodeFileTalkShare,
decodeFileTalkShare
} from '../models/file-talk-share'; } from '../models/file-talk-share';
import { import {
MassTalkDownloadRequest, MassTalkDownloadRequest,
MassTalkDownloadResponse MassTalkDownloadResponse,
encodeMassTalkDownload,
decodeMassTalkDownload
} from '../models/mass-talk-download'; } from '../models/mass-talk-download';
import { import {
MassTalkSaveRequest, MassTalkSaveRequest,
MassTalkSaveResponse MassTalkSaveResponse,
encodeMassTalkSave,
decodeMassTalkSave
} from '../models/mass-talk-save'; } from '../models/mass-talk-save';
import { import {
TransMassTalkDownloadRequest, TransMassTalkDownloadRequest,
TransMassTalkDownloadResponse TransMassTalkDownloadResponse,
encodeTransMassTalkDownload,
decodeTransMassTalkDownload
} from '../models/trans-mass-talk-download'; } from '../models/trans-mass-talk-download';
import { import {
TransMassTalkSaveRequest, TransMassTalkSaveRequest,
TransMassTalkSaveResponse TransMassTalkSaveResponse,
encodeTransMassTalkSave,
decodeTransMassTalkSave
} from '../models/trans-mass-talk-save'; } from '../models/trans-mass-talk-save';
import { import {
TranslationReqRequest, TranslationReqRequest,
TranslationReqResponse TranslationReqResponse,
encodeTranslationReq,
decodeTranslationReq
} from '../models/translation-req'; } from '../models/translation-req';
import { import {
TranslationSaveRequest, TranslationSaveRequest,
TranslationSaveResponse TranslationSaveResponse,
encodeTranslationSave,
decodeTranslationSave
} from '../models/translation-save'; } from '../models/translation-save';
@Injectable({ @Injectable({
@ -61,14 +82,10 @@ export class CommonApiService {
this.moduleConfig.urls.fileProfileSave, this.moduleConfig.urls.fileProfileSave,
{}, {},
{ {
params: {} params: encodeFileProfileSave(req)
} }
) )
.pipe( .pipe(map(res => decodeFileProfileSave(res)));
map(res => {
return {} as FileProfileSaveResponse;
})
);
} }
public fileTalkDownload(req: FileTalkDownloadRequest): Observable<Blob> { public fileTalkDownload(req: FileTalkDownloadRequest): Observable<Blob> {
@ -76,7 +93,7 @@ export class CommonApiService {
this.moduleConfig.urls.fileTalkDownload, this.moduleConfig.urls.fileTalkDownload,
{ responseType: 'blob' }, { responseType: 'blob' },
{ {
params: {} params: encodeFileTalkDownload(req)
} }
); );
} }
@ -89,14 +106,10 @@ export class CommonApiService {
this.moduleConfig.urls.fileTalkSave, this.moduleConfig.urls.fileTalkSave,
{}, {},
{ {
params: {} params: encodeFileTalkSave(req)
} }
) )
.pipe( .pipe(map(res => decodeFileTalkSave(res)));
map(res => {
return {} as FileTalkSaveResponse;
})
);
} }
public fileTalkShare( public fileTalkShare(
@ -107,14 +120,10 @@ export class CommonApiService {
this.moduleConfig.urls.fileTalkShare, this.moduleConfig.urls.fileTalkShare,
{}, {},
{ {
params: {} params: encodeFileTalkShare(req)
} }
) )
.pipe( .pipe(map(res => decodeFileTalkShare(res)));
map(res => {
return {} as FileTalkShareResponse;
})
);
} }
public massTalkDownload( public massTalkDownload(
@ -125,14 +134,10 @@ export class CommonApiService {
this.moduleConfig.urls.massTalkDownload, this.moduleConfig.urls.massTalkDownload,
{}, {},
{ {
params: {} params: encodeMassTalkDownload(req)
} }
) )
.pipe( .pipe(map(res => decodeMassTalkDownload(res)));
map(res => {
return {} as MassTalkDownloadResponse;
})
);
} }
public massTalkSave( public massTalkSave(
@ -143,14 +148,10 @@ export class CommonApiService {
this.moduleConfig.urls.massTalkSave, this.moduleConfig.urls.massTalkSave,
{}, {},
{ {
params: {} params: encodeMassTalkSave(req)
} }
) )
.pipe( .pipe(map(res => decodeMassTalkSave(res)));
map(res => {
return {} as MassTalkSaveResponse;
})
);
} }
public transMassTalkDownload( public transMassTalkDownload(
@ -161,14 +162,10 @@ export class CommonApiService {
this.moduleConfig.urls.transMassTalkDownload, this.moduleConfig.urls.transMassTalkDownload,
{}, {},
{ {
params: {} params: encodeTransMassTalkDownload(req)
} }
) )
.pipe( .pipe(map(res => decodeTransMassTalkDownload(res)));
map(res => {
return {} as TransMassTalkDownloadResponse;
})
);
} }
public transMassTalkSave( public transMassTalkSave(
@ -179,14 +176,10 @@ export class CommonApiService {
this.moduleConfig.urls.transMassTalkSave, this.moduleConfig.urls.transMassTalkSave,
{}, {},
{ {
params: {} params: encodeTransMassTalkSave(req)
} }
) )
.pipe( .pipe(map(res => decodeTransMassTalkSave(res)));
map(res => {
return {} as TransMassTalkSaveResponse;
})
);
} }
public translationReq( public translationReq(
@ -197,14 +190,10 @@ export class CommonApiService {
this.moduleConfig.urls.translationReq, this.moduleConfig.urls.translationReq,
{}, {},
{ {
params: {} params: encodeTranslationReq(req)
} }
) )
.pipe( .pipe(map(res => decodeTranslationReq(res)));
map(res => {
return {} as TranslationReqResponse;
})
);
} }
public translationSave( public translationSave(
@ -215,13 +204,9 @@ export class CommonApiService {
this.moduleConfig.urls.translationSave, this.moduleConfig.urls.translationSave,
{}, {},
{ {
params: {} params: encodeTranslationSave(req)
} }
) )
.pipe( .pipe(map(res => decodeTranslationSave(res)));
map(res => {
return {} as TranslationSaveResponse;
})
);
} }
} }

View File

@ -1,4 +1,9 @@
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder
} from '@ucap-webmessenger/api';
export interface CheckUserInfoExRequest extends APIRequest { export interface CheckUserInfoExRequest extends APIRequest {
userId: string; userId: string;
@ -9,3 +14,23 @@ export interface CheckUserInfoExRequest extends APIRequest {
export interface CheckUserInfoExResponse extends APIResponse { export interface CheckUserInfoExResponse extends APIResponse {
userId?: string; userId?: string;
} }
export const encodeCheckUserInfoEx: APIEncoder<CheckUserInfoExRequest> = (
req: CheckUserInfoExRequest
) => {
return {
p_user_id: req.userId,
p_comp_code: req.companyCode,
p_user_session: req.userSession
};
};
export const decodeCheckUserInfoEx: APIDecoder<CheckUserInfoExResponse> = (
res: any
) => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
userId: res.UserID
} as CheckUserInfoExResponse;
};

View File

@ -1,5 +1,10 @@
import { AppType, DeviceType } from '@ucap-webmessenger/core'; import { AppType, DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder
} from '@ucap-webmessenger/api';
export interface CompanyListRequest extends APIRequest { export interface CompanyListRequest extends APIRequest {
userSeq?: string; userSeq?: string;
@ -21,3 +26,40 @@ export interface Company {
export interface CompanyListResponse extends APIResponse { export interface CompanyListResponse extends APIResponse {
companyList?: Company[]; companyList?: Company[];
} }
export const encodeCompanyList: APIEncoder<CompanyListRequest> = (
req: CompanyListRequest
) => {
return {
p_user_seq: req.userSeq,
p_app_type: req.appType,
p_device_type: req.deviceType,
p_token: req.token,
p_comp_group_code: req.companyGroupCode
};
};
export const decodeCompanyList: APIDecoder<CompanyListResponse> = (
res: any
) => {
let companyList: Company[] | undefined;
if (!!res.CompanyList) {
companyList = [];
for (const company of res.CompanyList) {
companyList.push({
companyCode: company.COMPANY_CODE,
companyName: company.COMPANY_NAME,
companyDomain: company.COMPANY_DOMAIN,
companyConfAuthYn: company.COMPANY_CONF_AUTH,
ucapUseYn: company.UCAP_USE_YN,
companyTimerChatAuthYn: company.COMPANY_TIMER_CHAT_AUTH
});
}
}
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
companyList
} as CompanyListResponse;
};

View File

@ -1,5 +1,10 @@
import { DeviceType, PushType } from '@ucap-webmessenger/core'; import { DeviceType, PushType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder
} from '@ucap-webmessenger/api';
export interface TokenUpdateRequest extends APIRequest { export interface TokenUpdateRequest extends APIRequest {
userSeq: string; userSeq: string;
@ -11,3 +16,21 @@ export interface TokenUpdateRequest extends APIRequest {
// tslint:disable-next-line: no-empty-interface // tslint:disable-next-line: no-empty-interface
export interface TokenUpdateResponse extends APIResponse {} export interface TokenUpdateResponse extends APIResponse {}
export const encodeTokenUpdate: APIEncoder<TokenUpdateRequest> = (
req: TokenUpdateRequest
) => {
return {
p_user_seq: req.userSeq,
p_device_type: req.deviceType,
p_token: req.token,
p_mobile_pid: req.mobilePid,
p_push_type: req.pushType
};
};
export const decodeTokenUpdate: APIDecoder<TokenUpdateResponse> = (
res: any
) => {
return {} as TokenUpdateResponse;
};

View File

@ -1,5 +1,10 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder
} from '@ucap-webmessenger/api';
export interface UrlInfoRequest extends APIRequest { export interface UrlInfoRequest extends APIRequest {
deviceType: DeviceType; deviceType: DeviceType;
@ -19,3 +24,30 @@ export interface UrlInfoResponse extends APIResponse {
uprDownloadUrl?: string; uprDownloadUrl?: string;
synapViewUrl?: string; synapViewUrl?: string;
} }
export const encodeUrlInfo: APIEncoder<UrlInfoRequest> = (
req: UrlInfoRequest
) => {
return {
p_device_type: req.deviceType
};
};
export const decodeUrlInfo: APIDecoder<UrlInfoResponse> = (res: any) => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
portCheckUrl: res.PortCheckURL,
messageUrl: res.MsgURL,
messageUrl2: res.MsgURL2,
passwordUrl: res.PasswordURL,
planUrl: res.PlanURL,
planUrl2: res.PlanURL2,
vocUrl: res.VocURL,
confUrl: res.ConfURL,
uprApiUrl: res.UprApiURL,
uprSvcUrl: res.UprSvcURL,
uprDownloadUrl: res.UprDownloadURL,
synapViewUrl: res.SynapViewURL
} as UrlInfoResponse;
};

View File

@ -8,18 +8,28 @@ import { _MODULE_CONFIG } from '../types/token';
import { ModuleConfig } from '../types/module-config'; import { ModuleConfig } from '../types/module-config';
import { import {
CheckUserInfoExRequest, CheckUserInfoExRequest,
CheckUserInfoExResponse CheckUserInfoExResponse,
encodeCheckUserInfoEx,
decodeCheckUserInfoEx
} from '../models/check-user-info-ex'; } from '../models/check-user-info-ex';
import { import {
CompanyListRequest, CompanyListRequest,
CompanyListResponse, CompanyListResponse,
Company encodeCompanyList,
decodeCompanyList
} from '../models/company-list'; } from '../models/company-list';
import { import {
TokenUpdateRequest, TokenUpdateRequest,
TokenUpdateResponse TokenUpdateResponse,
encodeTokenUpdate,
decodeTokenUpdate
} from '../models/token-update'; } from '../models/token-update';
import { UrlInfoResponse, UrlInfoRequest } from '../models/url-info'; import {
UrlInfoResponse,
UrlInfoRequest,
encodeUrlInfo,
decodeUrlInfo
} from '../models/url-info';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -38,22 +48,10 @@ export class ExternalApiService {
this.moduleConfig.urls.checkUserInfoEx, this.moduleConfig.urls.checkUserInfoEx,
{}, {},
{ {
params: { params: encodeCheckUserInfoEx(req)
p_user_id: req.userId,
p_comp_code: req.companyCode,
p_user_session: req.userSession
}
} }
) )
.pipe( .pipe(map(res => decodeCheckUserInfoEx(res)));
map(res => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
userId: res.UserID
} as CheckUserInfoExResponse;
})
);
} }
public companyList(req: CompanyListRequest): Observable<CompanyListResponse> { public companyList(req: CompanyListRequest): Observable<CompanyListResponse> {
@ -62,39 +60,10 @@ export class ExternalApiService {
this.moduleConfig.urls.companyList, this.moduleConfig.urls.companyList,
{}, {},
{ {
params: { params: encodeCompanyList(req)
p_user_seq: req.userSeq,
p_app_type: req.appType,
p_device_type: req.deviceType,
p_token: req.token,
p_comp_group_code: req.companyGroupCode
}
} }
) )
.pipe( .pipe(map(res => decodeCompanyList(res)));
map(res => {
let companyList: Company[] | undefined;
if (!!res.CompanyList) {
companyList = [];
for (const company of res.CompanyList) {
companyList.push({
companyCode: company.COMPANY_CODE,
companyName: company.COMPANY_NAME,
companyDomain: company.COMPANY_DOMAIN,
companyConfAuthYn: company.COMPANY_CONF_AUTH,
ucapUseYn: company.UCAP_USE_YN,
companyTimerChatAuthYn: company.COMPANY_TIMER_CHAT_AUTH
});
}
}
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
companyList
} as CompanyListResponse;
})
);
} }
public tokenUpdate(req: TokenUpdateRequest): Observable<TokenUpdateResponse> { public tokenUpdate(req: TokenUpdateRequest): Observable<TokenUpdateResponse> {
@ -103,20 +72,10 @@ export class ExternalApiService {
this.moduleConfig.urls.tokenUpdate, this.moduleConfig.urls.tokenUpdate,
{}, {},
{ {
params: { params: encodeTokenUpdate(req)
p_user_seq: req.userSeq,
p_device_type: req.deviceType,
p_token: req.token,
p_mobile_pid: req.mobilePid,
p_push_type: req.pushType
}
} }
) )
.pipe( .pipe(map(res => decodeTokenUpdate(res)));
map(res => {
return {} as TokenUpdateResponse;
})
);
} }
public urlInfo(req: UrlInfoRequest): Observable<UrlInfoResponse> { public urlInfo(req: UrlInfoRequest): Observable<UrlInfoResponse> {
@ -125,30 +84,9 @@ export class ExternalApiService {
this.moduleConfig.urls.urlInfo, this.moduleConfig.urls.urlInfo,
{}, {},
{ {
params: { params: encodeUrlInfo(req)
p_device_type: req.deviceType
}
} }
) )
.pipe( .pipe(map(res => decodeUrlInfo(res)));
map(res => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
portCheckUrl: res.PortCheckURL,
messageUrl: res.MsgURL,
messageUrl2: res.MsgURL2,
passwordUrl: res.PasswordURL,
planUrl: res.PlanURL,
planUrl2: res.PlanURL2,
vocUrl: res.VocURL,
confUrl: res.ConfURL,
uprApiUrl: res.UprApiURL,
uprSvcUrl: res.UprSvcURL,
uprDownloadUrl: res.UprDownloadURL,
synapViewUrl: res.SynapViewURL
} as UrlInfoResponse;
})
);
} }
} }

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface UpdateInfoRequest extends APIRequest { export interface UpdateInfoRequest extends APIRequest {
deviceType: DeviceType; deviceType: DeviceType;
@ -11,3 +17,24 @@ export interface UpdateInfoResponse extends APIResponse {
launcherAppVersion?: string; launcherAppVersion?: string;
launcherInstallUrl?: string; launcherInstallUrl?: string;
} }
const updateInfoEncodeMap = {
deviceType: 'p_device_type'
};
export const encodeUpdateInfo: APIEncoder<UpdateInfoRequest> = (
req: UpdateInfoRequest
) => {
return ParameterUtil.encode(updateInfoEncodeMap, req);
};
export const decodeUpdateInfo: APIDecoder<UpdateInfoResponse> = (res: any) => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
appVersion: res.AppVer,
installUrl: res.InstallURL,
launcherAppVersion: res.LauncherAppVer,
launcherInstallUrl: res.LauncherInstallURL
} as UpdateInfoResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api'; import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
import { SyncMode } from '../types/sync-mode.type'; import { SyncMode } from '../types/sync-mode.type';
export interface VersionInfo2Request extends APIRequest { export interface VersionInfo2Request extends APIRequest {
@ -27,3 +33,41 @@ export interface VersionInfo2Response extends APIResponse {
launcherAppVersion?: string; launcherAppVersion?: string;
launcherInstallUrl?: string; launcherInstallUrl?: string;
} }
const versionInfo2EncodeMap = {
userSeq: 'p_user_seq',
deviceType: 'p_device_type',
token: 'p_token',
companyGroupType: 'p_comp_group_type',
companyCode: 'p_comp_code',
loginId: 'p_login_id'
};
export const encodeVersionInfo2: APIEncoder<VersionInfo2Request> = (
req: VersionInfo2Request
) => {
return ParameterUtil.encode(versionInfo2EncodeMap, req);
};
export const decodeVersionInfo2: APIDecoder<VersionInfo2Response> = (
res: any
) => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
appVersion: res.AppVer,
authIp: res.AuthIP === 'Y' ? true : false,
downloadUrl: res.DownloadURL,
fileAllowSize: Number(res.FileAllowSize),
fileTerm: Number(res.FileTerm),
installUrl: res.InstallURL,
launcherAppVersion: res.LauncherAppVer,
launcherInstallUrl: res.LauncherInstallURL,
profileRoot: res.ProfileRoot,
profileUploadUrl: res.ProfileUploadURL,
protocolCode: Number(res.ProtocolCD),
serverIp: res.ServerIP,
syncMode: res.SyncMode as SyncMode,
uploadUrl: res.UploadURL
} as VersionInfo2Response;
};

View File

@ -7,25 +7,17 @@ import { map } from 'rxjs/operators';
import { _MODULE_CONFIG } from '../types/token'; import { _MODULE_CONFIG } from '../types/token';
import { import {
VersionInfo2Request, VersionInfo2Request,
VersionInfo2Response VersionInfo2Response,
encodeVersionInfo2,
decodeVersionInfo2
} from '../models/version-info2'; } from '../models/version-info2';
import { UpdateInfoRequest, UpdateInfoResponse } from '../models/update-info'; import {
UpdateInfoRequest,
UpdateInfoResponse,
encodeUpdateInfo,
decodeUpdateInfo
} from '../models/update-info';
import { ModuleConfig } from '../types/module-config'; import { ModuleConfig } from '../types/module-config';
import { ParameterUtil } from '@ucap-webmessenger/api';
import { SyncMode } from '../types/sync-mode.type';
const versionInfo2Parameters = {
userSeq: 'p_user_seq',
deviceType: 'p_device_type',
token: 'p_token',
companyGroupType: 'p_comp_group_type',
companyCode: 'p_comp_code',
loginId: 'p_login_id'
};
const updateInfoParameters = {
deviceType: 'p_device_type'
};
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -44,31 +36,10 @@ export class PublicApiService {
this.moduleConfig.urls.versionInfo2, this.moduleConfig.urls.versionInfo2,
{}, {},
{ {
params: ParameterUtil.make(versionInfo2Parameters, req) params: encodeVersionInfo2(req)
} }
) )
.pipe( .pipe(map((res: any) => decodeVersionInfo2(res)));
map((res: any) => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
appVersion: res.AppVer,
authIp: res.AuthIP === 'Y' ? true : false,
downloadUrl: res.DownloadURL,
fileAllowSize: Number(res.FileAllowSize),
fileTerm: Number(res.FileTerm),
installUrl: res.InstallURL,
launcherAppVersion: res.LauncherAppVer,
launcherInstallUrl: res.LauncherInstallURL,
profileRoot: res.ProfileRoot,
profileUploadUrl: res.ProfileUploadURL,
protocolCode: Number(res.ProtocolCD),
serverIp: res.ServerIP,
syncMode: res.SyncMode as SyncMode,
uploadUrl: res.UploadURL
} as VersionInfo2Response;
})
);
} }
public updateInfo(req: UpdateInfoRequest): Observable<UpdateInfoResponse> { public updateInfo(req: UpdateInfoRequest): Observable<UpdateInfoResponse> {
@ -77,20 +48,9 @@ export class PublicApiService {
this.moduleConfig.urls.updateInfo, this.moduleConfig.urls.updateInfo,
{}, {},
{ {
params: ParameterUtil.make(updateInfoParameters, req) params: encodeUpdateInfo(req)
} }
) )
.pipe( .pipe(map(res => decodeUpdateInfo(res)));
map(res => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
appVersion: res.AppVer,
installUrl: res.InstallURL,
launcherAppVersion: res.LauncherAppVer,
launcherInstallUrl: res.LauncherInstallURL
} as UpdateInfoResponse;
})
);
} }
} }

View File

@ -1,3 +1,5 @@
import { HttpParams } from '@angular/common/http';
import { StatusCode } from '../types/status-code.type'; import { StatusCode } from '../types/status-code.type';
export interface APIRequest { export interface APIRequest {
@ -9,3 +11,13 @@ export interface APIResponse {
statusCode: StatusCode; statusCode: StatusCode;
errorMessage: string; errorMessage: string;
} }
export type APIEncoder<REQ> = (
req: REQ
) =>
| HttpParams
| {
[param: string]: string | string[];
};
export type APIDecoder<RES> = (res: any) => RES;

View File

@ -3,7 +3,7 @@ export type Parameter = {
} | null; } | null;
export class ParameterUtil { export class ParameterUtil {
public static make(parameterMap: {}, param: {}): Parameter { public static encode(parameterMap: {}, param: {}): Parameter {
const parameter: Parameter = {}; const parameter: Parameter = {};
Object.keys(parameterMap).map(key => { Object.keys(parameterMap).map(key => {

View File

@ -9,7 +9,8 @@ import {
SVC_TYPE_LOGOUT, SVC_TYPE_LOGOUT,
SSVC_TYPE_LOGOUT_RES, SSVC_TYPE_LOGOUT_RES,
SSVC_TYPE_LOGOUT_REMOTE_NOTI, SSVC_TYPE_LOGOUT_REMOTE_NOTI,
AuthenticationProtocolService decodeLogout,
decodeLogoutRemoteNotification
} from '@ucap-webmessenger/protocol-authentication'; } from '@ucap-webmessenger/protocol-authentication';
import * as AuthenticationStore from '../store/account/authentication'; import * as AuthenticationStore from '../store/account/authentication';
@ -18,7 +19,6 @@ import * as AuthenticationStore from '../store/account/authentication';
export class AppNotificationService { export class AppNotificationService {
constructor( constructor(
private protocolService: ProtocolService, private protocolService: ProtocolService,
private authenticationProtocolService: AuthenticationProtocolService,
private store: Store<any> private store: Store<any>
) {} ) {}
@ -31,9 +31,7 @@ export class AppNotificationService {
message.subServiceType === SSVC_TYPE_LOGOUT_RES message.subServiceType === SSVC_TYPE_LOGOUT_RES
), ),
tap(message => { tap(message => {
const logoutRes = this.authenticationProtocolService.decodeLogoutResponse( const logoutRes = decodeLogout(message);
message
);
console.log('logoutRes', logoutRes); console.log('logoutRes', logoutRes);
this.store.dispatch(AuthenticationStore.logout()); this.store.dispatch(AuthenticationStore.logout());
}) })
@ -48,9 +46,7 @@ export class AppNotificationService {
message.subServiceType === SSVC_TYPE_LOGOUT_REMOTE_NOTI message.subServiceType === SSVC_TYPE_LOGOUT_REMOTE_NOTI
), ),
tap(message => { tap(message => {
const logoutRemoteNoti = this.authenticationProtocolService.decodeLogoutRemoteNotification( const logoutRemoteNoti = decodeLogoutRemoteNotification(message);
message
);
this.store.dispatch(AuthenticationStore.logout()); this.store.dispatch(AuthenticationStore.logout());
}) })
) )

View File

@ -1,3 +1,5 @@
import { ParameterUtil, APIEncoder, APIDecoder } from '@ucap-webmessenger/api';
import { PIRequest, PIResponse } from './pi'; import { PIRequest, PIResponse } from './pi';
export interface Login2Request extends PIRequest { export interface Login2Request extends PIRequest {
@ -15,3 +17,26 @@ export interface Login2Response extends PIResponse {
userName: string; userName: string;
userSeq: number; userSeq: number;
} }
const login2EncodeMap = {
companyCode: 'companyCd',
loginId: 'loginId',
loginPw: 'loginPw'
};
export const encodeLogin2: APIEncoder<Login2Request> = (req: Login2Request) => {
return ParameterUtil.encode(login2EncodeMap, req);
};
export const decodeLogin2: APIDecoder<Login2Response> = (res: any) => {
return {
status: res.STATUS,
version: res.VER,
passwordHc: res.PWD_HC,
personalInfoAgreeYn: res.PER_INFO_AGREE_YN,
companyCode: res.COMPANY_CODE,
userId: res.USER_ID,
userName: res.USER_NAME,
userSeq: res.USER_SEQ
} as Login2Response;
};

View File

@ -6,7 +6,12 @@ import { map } from 'rxjs/operators';
import { _MODULE_CONFIG } from '../types/token'; import { _MODULE_CONFIG } from '../types/token';
import { ModuleConfig } from '../types/module-config'; import { ModuleConfig } from '../types/module-config';
import { Login2Request, Login2Response } from '../models/login2'; import {
Login2Request,
Login2Response,
encodeLogin2,
decodeLogin2
} from '../models/login2';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -23,26 +28,9 @@ export class PiService {
this.moduleConfig.urls.login2, this.moduleConfig.urls.login2,
{}, {},
{ {
params: { params: encodeLogin2(req)
companyCd: req.companyCode,
loginId: req.loginId,
loginPw: req.loginPw
}
} }
) )
.pipe( .pipe(map(res => decodeLogin2(res)));
map(res => {
return {
status: res.STATUS,
version: res.VER,
passwordHc: res.PWD_HC,
personalInfoAgreeYn: res.PER_INFO_AGREE_YN,
companyCode: res.COMPANY_CODE,
userId: res.USER_ID,
userName: res.USER_NAME,
userSeq: res.USER_SEQ
} as Login2Response;
})
);
} }
} }

View File

@ -1,5 +1,13 @@
import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; import { DeviceType, LocaleCode } from '@ucap-webmessenger/core';
import { ProtocolRequest, ProtocolResponse } from '@ucap-webmessenger/protocol'; import {
ProtocolRequest,
ProtocolResponse,
ProtocolEncoder,
PacketBody,
PacketBodyValue,
ProtocolDecoder,
ProtocolMessage
} from '@ucap-webmessenger/protocol';
import { SSOMode } from '../types/sso-mode'; import { SSOMode } from '../types/sso-mode';
import { RoleCode } from '../types/role-code'; import { RoleCode } from '../types/role-code';
@ -79,3 +87,79 @@ export interface LoginResponse extends ProtocolResponse {
permissionsForViewSchedule: string; permissionsForViewSchedule: string;
havePermissionsForDevice: boolean; havePermissionsForDevice: boolean;
} }
export const encodeLogin: ProtocolEncoder<LoginRequest> = (
req: LoginRequest
) => {
const bodyList: PacketBody[] = [];
bodyList.push(
{ type: PacketBodyValue.String, value: req.loginId },
{ type: PacketBodyValue.String, value: req.loginPw },
{ type: PacketBodyValue.String, value: req.deviceType },
{ type: PacketBodyValue.String, value: req.deviceId },
{ type: PacketBodyValue.String, value: req.token },
{ type: PacketBodyValue.String, value: req.localeCode },
{ type: PacketBodyValue.String, value: req.pushId },
{ type: PacketBodyValue.String, value: req.companyCode },
{ type: PacketBodyValue.Integer, value: req.passwordEncodingType },
{ type: PacketBodyValue.String, value: req.clientVersion },
{ type: PacketBodyValue.String, value: req.reconnect ? 'Y' : 'N' },
{ type: PacketBodyValue.String, value: req.ip },
{ type: PacketBodyValue.String, value: req.hostName },
{ type: PacketBodyValue.Integer, value: req.encriptionData ? 2 : 1 },
{ type: PacketBodyValue.String, value: req.userSpecificInformation },
{ type: PacketBodyValue.String, value: req.productId },
{ type: PacketBodyValue.String, value: req.productName }
);
if (req.encriptionData) {
bodyList.push(
{ type: PacketBodyValue.String, value: req.encriptionData },
{ type: PacketBodyValue.String, value: req.accessToken }
);
}
return bodyList;
};
export const decodeLogin: ProtocolDecoder<LoginResponse> = (
message: ProtocolMessage
) => {
return {
loginId: message.bodyList[0],
userSeq: message.bodyList[1],
userInfo: message.bodyList[2],
token: message.bodyList[3],
companyCode: message.bodyList[4],
departmentCode: message.bodyList[5],
userId: message.bodyList[6],
passwordEncodingType: message.bodyList[7],
encriptionKey: message.bodyList[8],
existingPid: message.bodyList[9] === 'Y' ? true : false,
roleCode: message.bodyList[10] as RoleCode,
statusMessage1: message.bodyList[11],
statusMessage2: message.bodyList[12],
statusMessage3: message.bodyList[13],
fileDownloadAllow: message.bodyList[14] === 'Y' ? true : false,
fileRetentionPeriod: message.bodyList[15],
passwordValidityPeriod: message.bodyList[16],
privateInformationAgree: message.bodyList[17] === 'Y' ? true : false,
madn: message.bodyList[18],
hardPhoneSadn: message.bodyList[19],
fmcSadn: message.bodyList[20],
pbxIndex: message.bodyList[21],
passwordExpired: message.bodyList[22] === 'Y' ? true : false,
validAccount: message.bodyList[23] === 'Y' ? true : false,
validDevice: message.bodyList[24] === 'Y' ? true : false,
useableDevice: message.bodyList[25] === 'Y' ? true : false,
deviceScreenForcedLock: message.bodyList[26] === 'Y' ? true : false,
tokenString: message.bodyList[27],
havePermissionsForIntegratedMessageBox:
message.bodyList[28] === 'Y' ? true : false,
talkWithMeBotSeq: message.bodyList[29],
pinCode: message.bodyList[30],
permissionsForViewSchedule: message.bodyList[31],
havePermissionsForDevice: message.bodyList[32] === 'Y' ? true : false
} as LoginResponse;
};

View File

@ -0,0 +1,52 @@
import { DeviceType } from '@ucap-webmessenger/core';
import {
ProtocolRequest,
ProtocolResponse,
ProtocolNotification,
ProtocolEncoder,
PacketBody,
ProtocolDecoder,
ProtocolMessage,
PacketBodyValue
} from '@ucap-webmessenger/protocol';
export interface LogoutRemoteRequest extends ProtocolRequest {
targetDeviceType?: DeviceType;
requestDeviceType?: DeviceType;
}
export interface LogoutRemoteResponse extends ProtocolResponse {
targetDeviceType?: DeviceType;
resultCode?: number;
}
export interface LogoutRemoteNotification extends ProtocolNotification {
requestDeviceType?: DeviceType;
}
export const encodeLogoutRemote: ProtocolEncoder<LogoutRemoteRequest> = (
req: LogoutRemoteRequest
) => {
const bodyList: PacketBody[] = [];
bodyList.push(
{ type: PacketBodyValue.String, value: req.targetDeviceType },
{ type: PacketBodyValue.String, value: req.requestDeviceType }
);
return bodyList;
};
export const decodeLogoutRemote: ProtocolDecoder<LogoutRemoteResponse> = (
message: ProtocolMessage
) => {
return {
targetDeviceType: message.bodyList[0],
resultCode: message.bodyList[1]
} as LogoutRemoteResponse;
};
export const decodeLogoutRemoteNotification: ProtocolDecoder<
LogoutRemoteNotification
> = (message: ProtocolMessage) => {
return { requestDeviceType: message.bodyList[0] } as LogoutRemoteNotification;
};

View File

@ -1,8 +1,10 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { import {
ProtocolRequest, ProtocolRequest,
ProtocolResponse, ProtocolResponse,
ProtocolNotification ProtocolEncoder,
ProtocolDecoder,
ProtocolMessage,
PacketBody
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
// tslint:disable-next-line: no-empty-interface // tslint:disable-next-line: no-empty-interface
@ -12,15 +14,16 @@ export interface LogoutResponse extends ProtocolResponse {
reasonCode?: number; reasonCode?: number;
} }
export interface LogoutRemoteRequest extends ProtocolRequest { export const encodeLogout: ProtocolEncoder<LogoutRequest> = (
targetDeviceType?: DeviceType; req: LogoutRequest
requestDeviceType?: DeviceType; ) => {
} const bodyList: PacketBody[] = [];
export interface LogoutRemoteResponse extends ProtocolResponse {
targetDeviceType?: DeviceType;
resultCode?: number;
}
export interface LogoutRemoteNotification extends ProtocolNotification { return bodyList;
requestDeviceType?: DeviceType; };
}
export const decodeLogout: ProtocolDecoder<LogoutResponse> = (
message: ProtocolMessage
) => {
return { reasonCode: message.bodyList[0] } as LogoutResponse;
};

View File

@ -3,13 +3,13 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { ProtocolService } from '@ucap-webmessenger/protocol';
import { import {
ProtocolService, LoginRequest,
PacketBody, LoginResponse,
PacketBodyValue, encodeLogin,
ServerMessage decodeLogin
} from '@ucap-webmessenger/protocol'; } from '../models/login';
import { LoginRequest, LoginResponse } from '../models/login';
import { import {
SVC_TYPE_LOGIN, SVC_TYPE_LOGIN,
SSVC_TYPE_LOGIN_REQ, SSVC_TYPE_LOGIN_REQ,
@ -17,14 +17,18 @@ import {
SSVC_TYPE_LOGOUT_REQ, SSVC_TYPE_LOGOUT_REQ,
SSVC_TYPE_LOGOUT_REMOTE_REQ SSVC_TYPE_LOGOUT_REMOTE_REQ
} from '../types/service'; } from '../types/service';
import { RoleCode } from '../types/role-code';
import { import {
LogoutRequest, LogoutRequest,
LogoutResponse, LogoutResponse,
LogoutRemoteRequest, encodeLogout,
LogoutRemoteResponse, decodeLogout
LogoutRemoteNotification
} from '../models/logout'; } from '../models/logout';
import {
encodeLogoutRemote,
decodeLogoutRemote,
LogoutRemoteRequest,
LogoutRemoteResponse
} from '../models/logout-remote';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -33,132 +37,26 @@ export class AuthenticationProtocolService {
constructor(private protocolService: ProtocolService) {} constructor(private protocolService: ProtocolService) {}
public login(req: LoginRequest): Observable<LoginResponse> { public login(req: LoginRequest): Observable<LoginResponse> {
const bodyList: PacketBody[] = [];
bodyList.push(
{ type: PacketBodyValue.String, value: req.loginId },
{ type: PacketBodyValue.String, value: req.loginPw },
{ type: PacketBodyValue.String, value: req.deviceType },
{ type: PacketBodyValue.String, value: req.deviceId },
{ type: PacketBodyValue.String, value: req.token },
{ type: PacketBodyValue.String, value: req.localeCode },
{ type: PacketBodyValue.String, value: req.pushId },
{ type: PacketBodyValue.String, value: req.companyCode },
{ type: PacketBodyValue.Integer, value: req.passwordEncodingType },
{ type: PacketBodyValue.String, value: req.clientVersion },
{ type: PacketBodyValue.String, value: req.reconnect ? 'Y' : 'N' },
{ type: PacketBodyValue.String, value: req.ip },
{ type: PacketBodyValue.String, value: req.hostName },
{ type: PacketBodyValue.Integer, value: req.encriptionData ? 2 : 1 },
{ type: PacketBodyValue.String, value: req.userSpecificInformation },
{ type: PacketBodyValue.String, value: req.productId },
{ type: PacketBodyValue.String, value: req.productName }
);
if (req.encriptionData) {
bodyList.push(
{ type: PacketBodyValue.String, value: req.encriptionData },
{ type: PacketBodyValue.String, value: req.accessToken }
);
}
return this.protocolService return this.protocolService
.call(SVC_TYPE_LOGIN, SSVC_TYPE_LOGIN_REQ, ...bodyList) .call(SVC_TYPE_LOGIN, SSVC_TYPE_LOGIN_REQ, ...encodeLogin(req))
.pipe( .pipe(map(res => decodeLogin(res)));
map(res => {
return this.decodeLoginResponse(res);
})
);
}
public decodeLoginResponse(message: ServerMessage): LoginResponse {
return {
loginId: message.bodyList[0],
userSeq: message.bodyList[1],
userInfo: message.bodyList[2],
token: message.bodyList[3],
companyCode: message.bodyList[4],
departmentCode: message.bodyList[5],
userId: message.bodyList[6],
passwordEncodingType: message.bodyList[7],
encriptionKey: message.bodyList[8],
existingPid: message.bodyList[9] === 'Y' ? true : false,
roleCode: message.bodyList[10] as RoleCode,
statusMessage1: message.bodyList[11],
statusMessage2: message.bodyList[12],
statusMessage3: message.bodyList[13],
fileDownloadAllow: message.bodyList[14] === 'Y' ? true : false,
fileRetentionPeriod: message.bodyList[15],
passwordValidityPeriod: message.bodyList[16],
privateInformationAgree: message.bodyList[17] === 'Y' ? true : false,
madn: message.bodyList[18],
hardPhoneSadn: message.bodyList[19],
fmcSadn: message.bodyList[20],
pbxIndex: message.bodyList[21],
passwordExpired: message.bodyList[22] === 'Y' ? true : false,
validAccount: message.bodyList[23] === 'Y' ? true : false,
validDevice: message.bodyList[24] === 'Y' ? true : false,
useableDevice: message.bodyList[25] === 'Y' ? true : false,
deviceScreenForcedLock: message.bodyList[26] === 'Y' ? true : false,
tokenString: message.bodyList[27],
havePermissionsForIntegratedMessageBox:
message.bodyList[28] === 'Y' ? true : false,
talkWithMeBotSeq: message.bodyList[29],
pinCode: message.bodyList[30],
permissionsForViewSchedule: message.bodyList[31],
havePermissionsForDevice: message.bodyList[32] === 'Y' ? true : false
} as LoginResponse;
} }
public logout(req: LogoutRequest): Observable<LogoutResponse> { public logout(req: LogoutRequest): Observable<LogoutResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_REQ) .call(SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_REQ, ...encodeLogout(req))
.pipe( .pipe(map(res => decodeLogout(res)));
map(res => {
return this.decodeLogoutResponse(res);
})
);
}
public decodeLogoutResponse(message: ServerMessage): LogoutResponse {
return {
reasonCode: message.bodyList[0]
} as LogoutResponse;
} }
public logoutRemote( public logoutRemote(
req: LogoutRemoteRequest req: LogoutRemoteRequest
): Observable<LogoutRemoteResponse> { ): Observable<LogoutRemoteResponse> {
const bodyList: PacketBody[] = [];
bodyList.push(
{ type: PacketBodyValue.String, value: req.targetDeviceType },
{ type: PacketBodyValue.String, value: req.requestDeviceType }
);
return this.protocolService return this.protocolService
.call(SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_REMOTE_REQ, ...bodyList) .call(
.pipe( SVC_TYPE_LOGOUT,
map(res => { SSVC_TYPE_LOGOUT_REMOTE_REQ,
return this.decodeLogoutRemoteResponse(res); ...encodeLogoutRemote(req)
}) )
); .pipe(map(res => decodeLogoutRemote(res)));
}
public decodeLogoutRemoteResponse(
message: ServerMessage
): LogoutRemoteResponse {
return {
targetDeviceType: message.bodyList[0],
resultCode: message.bodyList[1]
} as LogoutRemoteResponse;
}
public decodeLogoutRemoteNotification(
message: ServerMessage
): LogoutRemoteNotification {
return {
requestDeviceType: message.bodyList[0]
} as LogoutRemoteNotification;
} }
} }

View File

@ -5,6 +5,7 @@
export * from './lib/models/fmc'; export * from './lib/models/fmc';
export * from './lib/models/login'; export * from './lib/models/login';
export * from './lib/models/logout'; export * from './lib/models/logout';
export * from './lib/models/logout-remote';
export * from './lib/services/authentication-protocol.service'; export * from './lib/services/authentication-protocol.service';

View File

@ -1,8 +1,26 @@
import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; import {
import { ProtocolRequest, ProtocolResponse } from '@ucap-webmessenger/protocol'; ProtocolRequest,
ProtocolResponse,
ProtocolEncoder,
PacketBody,
ProtocolDecoder,
ProtocolMessage
} from '@ucap-webmessenger/protocol';
// tslint:disable-next-line: no-empty-interface // tslint:disable-next-line: no-empty-interface
export interface ConnRequest extends ProtocolRequest {} export interface ConnRequest extends ProtocolRequest {}
// tslint:disable-next-line: no-empty-interface // tslint:disable-next-line: no-empty-interface
export interface ConnResponse extends ProtocolResponse {} export interface ConnResponse extends ProtocolResponse {}
export const encodeConn: ProtocolEncoder<ConnRequest> = (req: ConnRequest) => {
const bodyList: PacketBody[] = [];
return bodyList;
};
export const decodeConn: ProtocolDecoder<ConnResponse> = (
message: ProtocolMessage
) => {
return {} as ConnResponse;
};

View File

@ -5,7 +5,12 @@ import { map } from 'rxjs/operators';
import { ProtocolService } from '@ucap-webmessenger/protocol'; import { ProtocolService } from '@ucap-webmessenger/protocol';
import { ConnResponse, ConnRequest } from '../models/conn'; import {
ConnResponse,
ConnRequest,
encodeConn,
decodeConn
} from '../models/conn';
import { SVC_TYPE_INNER, SSVC_TYPE_CONN_REQ } from '../types/service'; import { SVC_TYPE_INNER, SSVC_TYPE_CONN_REQ } from '../types/service';
@Injectable({ @Injectable({
@ -15,10 +20,8 @@ export class InnerProtocolService {
constructor(private protocolService: ProtocolService) {} constructor(private protocolService: ProtocolService) {}
public conn(req: ConnRequest): Observable<ConnResponse> { public conn(req: ConnRequest): Observable<ConnResponse> {
return this.protocolService.call(SVC_TYPE_INNER, SSVC_TYPE_CONN_REQ).pipe( return this.protocolService
map(res => { .call(SVC_TYPE_INNER, SSVC_TYPE_CONN_REQ, ...encodeConn(req))
return {} as ConnResponse; .pipe(map(res => decodeConn(res)));
})
);
} }
} }

View File

@ -1,3 +1,5 @@
import { PacketBody } from './packet';
export interface ProtocolRequest { export interface ProtocolRequest {
_id?: string; _id?: string;
} }
@ -8,3 +10,14 @@ export interface ProtocolResponse {
// tslint:disable-next-line: no-empty-interface // tslint:disable-next-line: no-empty-interface
export interface ProtocolNotification {} export interface ProtocolNotification {}
export interface ProtocolMessage {
serviceType: number;
subServiceType: number;
senderSeq: number;
bodyList: any[];
}
export type ProtocolEncoder<REQ> = (req: REQ) => PacketBody[];
export type ProtocolDecoder<RES> = (message: ProtocolMessage) => RES;

View File

@ -20,16 +20,10 @@ import {
} from '../types/packet-body-divider'; } from '../types/packet-body-divider';
import { PacketBodyValue } from '../types/packet-body-value.type'; import { PacketBodyValue } from '../types/packet-body-value.type';
import { SSVC_TYPE_ERROR_RES, ServerErrorCode } from '../types/service'; import { SSVC_TYPE_ERROR_RES, ServerErrorCode } from '../types/service';
import { ProtocolMessage } from '../models/protocol';
export interface ServerMessage {
serviceType: number;
subServiceType: number;
senderSeq: number;
bodyList: any[];
}
interface RequestState { interface RequestState {
subject: Subject<ServerMessage>; subject: Subject<ProtocolMessage>;
request: { request: {
serviceType: number; serviceType: number;
subServiceType: number; subServiceType: number;
@ -48,8 +42,8 @@ export class ProtocolService {
private socket$: Observable<GetWebSocketResponses<any>>; private socket$: Observable<GetWebSocketResponses<any>>;
private messages$: Observable<any>; private messages$: Observable<any>;
private messagesSubscription: Subscription | null = null; private messagesSubscription: Subscription | null = null;
private serverMessageSubject: Subject<ServerMessage> | null = null; private serverMessageSubject: Subject<ProtocolMessage> | null = null;
private serverMessage$: Observable<ServerMessage> | null = null; private serverMessage$: Observable<ProtocolMessage> | null = null;
constructor(@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig) { constructor(@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig) {
this.pendingRequests = new Map(); this.pendingRequests = new Map();
@ -131,7 +125,7 @@ export class ProtocolService {
this.messagesSubscription.unsubscribe(); this.messagesSubscription.unsubscribe();
} }
public get serverMessage(): Observable<ServerMessage> { public get serverMessage(): Observable<ProtocolMessage> {
return this.serverMessage$; return this.serverMessage$;
} }
@ -139,7 +133,7 @@ export class ProtocolService {
serviceType: number | null, serviceType: number | null,
subServiceType: number | null, subServiceType: number | null,
...bodyList: PacketBody[] ...bodyList: PacketBody[]
): Observable<ServerMessage> { ): Observable<ProtocolMessage> {
return this.sendInternal(true, serviceType, subServiceType, bodyList); return this.sendInternal(true, serviceType, subServiceType, bodyList);
} }
@ -156,9 +150,9 @@ export class ProtocolService {
serviceType: number, serviceType: number,
subServiceType: number, subServiceType: number,
bodyList: PacketBody[] bodyList: PacketBody[]
): Observable<ServerMessage> | undefined { ): Observable<ProtocolMessage> | undefined {
let packet: string; let packet: string;
let responseSubject: Subject<ServerMessage> | null = null; let responseSubject: Subject<ProtocolMessage> | null = null;
if (hasResponse) { if (hasResponse) {
const requestId = this.requestId; const requestId = this.requestId;
@ -168,7 +162,7 @@ export class ProtocolService {
{ type: PacketBodyValue.RequestId, value: requestId } { type: PacketBodyValue.RequestId, value: requestId }
]); ]);
responseSubject = new Subject<ServerMessage>(); responseSubject = new Subject<ProtocolMessage>();
this.pendingRequests.set(requestId, { this.pendingRequests.set(requestId, {
subject: responseSubject, subject: responseSubject,
request: { serviceType, subServiceType, bodyList } request: { serviceType, subServiceType, bodyList }
@ -195,7 +189,7 @@ export class ProtocolService {
private decodePacket( private decodePacket(
arg: string[] arg: string[]
): { requestId: number; message: ServerMessage } | null { ): { requestId: number; message: ProtocolMessage } | null {
const cmdArg = arg[0].split(PacketBodyValueDivider); const cmdArg = arg[0].split(PacketBodyValueDivider);
if (2 > cmdArg.length) { if (2 > cmdArg.length) {
// OnError(3); // OnError(3);