diff --git a/projects/ucap-webmessenger-api-common/src/lib/models/file-profile-save.ts b/projects/ucap-webmessenger-api-common/src/lib/models/file-profile-save.ts index e66efc87..adc9979b 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/models/file-profile-save.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/models/file-profile-save.ts @@ -1,5 +1,11 @@ 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 { userSeq: string; @@ -14,3 +20,17 @@ export interface FileProfileSaveResponse extends APIResponse { ProfileURL?: string; ProfileSubDir?: string; } + +const fileProfileEncodeMap = {}; + +export const encodeFileProfileSave: APIEncoder = ( + req: FileProfileSaveRequest +) => { + return ParameterUtil.encode(fileProfileEncodeMap, req); +}; + +export const decodeFileProfileSave: APIDecoder = ( + res: any +) => { + return {} as FileProfileSaveResponse; +}; diff --git a/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-download.ts b/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-download.ts index 96398582..bcc03955 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-download.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-download.ts @@ -1,5 +1,5 @@ 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 { userSeq: string; @@ -7,3 +7,11 @@ export interface FileTalkDownloadRequest extends APIRequest { token: string; attachmentsSeq?: string; } + +const fileTalkDownloadEncodeMap = {}; + +export const encodeFileTalkDownload: APIEncoder = ( + req: FileTalkDownloadRequest +) => { + return ParameterUtil.encode(fileTalkDownloadEncodeMap, req); +}; diff --git a/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-save.ts b/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-save.ts index 8a10f9db..d370315b 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-save.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-save.ts @@ -1,5 +1,11 @@ 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 { userSeq: string; @@ -29,3 +35,17 @@ export interface FileTalkSaveResponse extends APIResponse { VoiceTime?: string; SynapKey?: string; } + +const fileTalkSaveEncodeMap = {}; + +export const encodeFileTalkSave: APIEncoder = ( + req: FileTalkSaveRequest +) => { + return ParameterUtil.encode(fileTalkSaveEncodeMap, req); +}; + +export const decodeFileTalkSave: APIDecoder = ( + res: any +) => { + return {} as FileTalkSaveResponse; +}; diff --git a/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-share.ts b/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-share.ts index 8d5d3c82..d8677f7b 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-share.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/models/file-talk-share.ts @@ -1,5 +1,11 @@ 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 { userSeq: string; @@ -22,3 +28,17 @@ export interface FileTalkShareResponse extends APIResponse { CompanyCode?: string; SynapKey?: string; } + +const fileTalkShareEncodeMap = {}; + +export const encodeFileTalkShare: APIEncoder = ( + req: FileTalkShareRequest +) => { + return ParameterUtil.encode(fileTalkShareEncodeMap, req); +}; + +export const decodeFileTalkShare: APIDecoder = ( + res: any +) => { + return {} as FileTalkShareResponse; +}; diff --git a/projects/ucap-webmessenger-api-common/src/lib/models/mass-talk-download.ts b/projects/ucap-webmessenger-api-common/src/lib/models/mass-talk-download.ts index 633c413f..ec31ac3f 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/models/mass-talk-download.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/models/mass-talk-download.ts @@ -1,5 +1,11 @@ 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 { userSeq: string; @@ -13,3 +19,17 @@ export interface MassTalkDownloadResponse extends APIResponse { UserName?: string; RegDate?: string; } + +const massTalkDownloadEncodeMap = {}; + +export const encodeMassTalkDownload: APIEncoder = ( + req: MassTalkDownloadRequest +) => { + return ParameterUtil.encode(massTalkDownloadEncodeMap, req); +}; + +export const decodeMassTalkDownload: APIDecoder = ( + res: any +) => { + return {} as MassTalkDownloadResponse; +}; diff --git a/projects/ucap-webmessenger-api-common/src/lib/models/mass-talk-save.ts b/projects/ucap-webmessenger-api-common/src/lib/models/mass-talk-save.ts index 35882482..648c3711 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/models/mass-talk-save.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/models/mass-talk-save.ts @@ -1,5 +1,11 @@ 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 { userSeq: string; @@ -15,3 +21,17 @@ export interface MassTalkSaveResponse extends APIResponse { RegDate?: string; Content?: string; } + +const massTalkSaveEncodeMap = {}; + +export const encodeMassTalkSave: APIEncoder = ( + req: MassTalkSaveRequest +) => { + return ParameterUtil.encode(massTalkSaveEncodeMap, req); +}; + +export const decodeMassTalkSave: APIDecoder = ( + res: any +) => { + return {} as MassTalkSaveResponse; +}; diff --git a/projects/ucap-webmessenger-api-common/src/lib/models/trans-mass-talk-download.ts b/projects/ucap-webmessenger-api-common/src/lib/models/trans-mass-talk-download.ts index 764884c2..f22618a5 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/models/trans-mass-talk-download.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/models/trans-mass-talk-download.ts @@ -1,5 +1,11 @@ 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 { userSeq: string; @@ -15,3 +21,17 @@ export interface TransMassTalkDownloadResponse extends APIResponse { UserName?: 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; +}; diff --git a/projects/ucap-webmessenger-api-common/src/lib/models/trans-mass-talk-save.ts b/projects/ucap-webmessenger-api-common/src/lib/models/trans-mass-talk-save.ts index 03136ef0..e1b0ff46 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/models/trans-mass-talk-save.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/models/trans-mass-talk-save.ts @@ -1,5 +1,11 @@ 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 { userSeq: string; @@ -19,3 +25,17 @@ export interface TransMassTalkSaveResponse extends APIResponse { Original?: string; Translation?: string; } + +const transMassTalkSaveEncodeMap = {}; + +export const encodeTransMassTalkSave: APIEncoder = ( + req: TransMassTalkSaveRequest +) => { + return ParameterUtil.encode(transMassTalkSaveEncodeMap, req); +}; + +export const decodeTransMassTalkSave: APIDecoder = ( + res: any +) => { + return {} as TransMassTalkSaveResponse; +}; diff --git a/projects/ucap-webmessenger-api-common/src/lib/models/translation-req.ts b/projects/ucap-webmessenger-api-common/src/lib/models/translation-req.ts index c31b9809..082ec110 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/models/translation-req.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/models/translation-req.ts @@ -1,5 +1,11 @@ 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 { userSeq: string; @@ -16,3 +22,17 @@ export interface TranslationReqResponse extends APIResponse { Original?: string; Translation?: string; } + +const translationReqEncodeMap = {}; + +export const encodeTranslationReq: APIEncoder = ( + req: TranslationReqRequest +) => { + return ParameterUtil.encode(translationReqEncodeMap, req); +}; + +export const decodeTranslationReq: APIDecoder = ( + res: any +) => { + return {} as TranslationReqResponse; +}; diff --git a/projects/ucap-webmessenger-api-common/src/lib/models/translation-save.ts b/projects/ucap-webmessenger-api-common/src/lib/models/translation-save.ts index 43843783..5020d444 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/models/translation-save.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/models/translation-save.ts @@ -1,5 +1,11 @@ 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 { userSeq: string; @@ -20,3 +26,17 @@ export interface TranslationSaveResponse extends APIResponse { Original?: string; Translation?: string; } + +const translationSaveEncodeMap = {}; + +export const encodeTranslationSave: APIEncoder = ( + req: TranslationSaveRequest +) => { + return ParameterUtil.encode(translationSaveEncodeMap, req); +}; + +export const decodeTranslationSave: APIDecoder = ( + res: any +) => { + return {} as TranslationSaveResponse; +}; diff --git a/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts b/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts index 20081b47..6c7771a6 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts @@ -8,40 +8,61 @@ import { _MODULE_CONFIG } from '../types/token'; import { ModuleConfig } from '../types/module-config'; import { FileProfileSaveRequest, - FileProfileSaveResponse + FileProfileSaveResponse, + encodeFileProfileSave, + decodeFileProfileSave } from '../models/file-profile-save'; -import { FileTalkDownloadRequest } from '../models/file-talk-download'; +import { + FileTalkDownloadRequest, + encodeFileTalkDownload +} from '../models/file-talk-download'; import { FileTalkSaveRequest, - FileTalkSaveResponse + FileTalkSaveResponse, + encodeFileTalkSave, + decodeFileTalkSave } from '../models/file-talk-save'; import { FileTalkShareRequest, - FileTalkShareResponse + FileTalkShareResponse, + encodeFileTalkShare, + decodeFileTalkShare } from '../models/file-talk-share'; import { MassTalkDownloadRequest, - MassTalkDownloadResponse + MassTalkDownloadResponse, + encodeMassTalkDownload, + decodeMassTalkDownload } from '../models/mass-talk-download'; import { MassTalkSaveRequest, - MassTalkSaveResponse + MassTalkSaveResponse, + encodeMassTalkSave, + decodeMassTalkSave } from '../models/mass-talk-save'; import { TransMassTalkDownloadRequest, - TransMassTalkDownloadResponse + TransMassTalkDownloadResponse, + encodeTransMassTalkDownload, + decodeTransMassTalkDownload } from '../models/trans-mass-talk-download'; import { TransMassTalkSaveRequest, - TransMassTalkSaveResponse + TransMassTalkSaveResponse, + encodeTransMassTalkSave, + decodeTransMassTalkSave } from '../models/trans-mass-talk-save'; import { TranslationReqRequest, - TranslationReqResponse + TranslationReqResponse, + encodeTranslationReq, + decodeTranslationReq } from '../models/translation-req'; import { TranslationSaveRequest, - TranslationSaveResponse + TranslationSaveResponse, + encodeTranslationSave, + decodeTranslationSave } from '../models/translation-save'; @Injectable({ @@ -61,14 +82,10 @@ export class CommonApiService { this.moduleConfig.urls.fileProfileSave, {}, { - params: {} + params: encodeFileProfileSave(req) } ) - .pipe( - map(res => { - return {} as FileProfileSaveResponse; - }) - ); + .pipe(map(res => decodeFileProfileSave(res))); } public fileTalkDownload(req: FileTalkDownloadRequest): Observable { @@ -76,7 +93,7 @@ export class CommonApiService { this.moduleConfig.urls.fileTalkDownload, { responseType: 'blob' }, { - params: {} + params: encodeFileTalkDownload(req) } ); } @@ -89,14 +106,10 @@ export class CommonApiService { this.moduleConfig.urls.fileTalkSave, {}, { - params: {} + params: encodeFileTalkSave(req) } ) - .pipe( - map(res => { - return {} as FileTalkSaveResponse; - }) - ); + .pipe(map(res => decodeFileTalkSave(res))); } public fileTalkShare( @@ -107,14 +120,10 @@ export class CommonApiService { this.moduleConfig.urls.fileTalkShare, {}, { - params: {} + params: encodeFileTalkShare(req) } ) - .pipe( - map(res => { - return {} as FileTalkShareResponse; - }) - ); + .pipe(map(res => decodeFileTalkShare(res))); } public massTalkDownload( @@ -125,14 +134,10 @@ export class CommonApiService { this.moduleConfig.urls.massTalkDownload, {}, { - params: {} + params: encodeMassTalkDownload(req) } ) - .pipe( - map(res => { - return {} as MassTalkDownloadResponse; - }) - ); + .pipe(map(res => decodeMassTalkDownload(res))); } public massTalkSave( @@ -143,14 +148,10 @@ export class CommonApiService { this.moduleConfig.urls.massTalkSave, {}, { - params: {} + params: encodeMassTalkSave(req) } ) - .pipe( - map(res => { - return {} as MassTalkSaveResponse; - }) - ); + .pipe(map(res => decodeMassTalkSave(res))); } public transMassTalkDownload( @@ -161,14 +162,10 @@ export class CommonApiService { this.moduleConfig.urls.transMassTalkDownload, {}, { - params: {} + params: encodeTransMassTalkDownload(req) } ) - .pipe( - map(res => { - return {} as TransMassTalkDownloadResponse; - }) - ); + .pipe(map(res => decodeTransMassTalkDownload(res))); } public transMassTalkSave( @@ -179,14 +176,10 @@ export class CommonApiService { this.moduleConfig.urls.transMassTalkSave, {}, { - params: {} + params: encodeTransMassTalkSave(req) } ) - .pipe( - map(res => { - return {} as TransMassTalkSaveResponse; - }) - ); + .pipe(map(res => decodeTransMassTalkSave(res))); } public translationReq( @@ -197,14 +190,10 @@ export class CommonApiService { this.moduleConfig.urls.translationReq, {}, { - params: {} + params: encodeTranslationReq(req) } ) - .pipe( - map(res => { - return {} as TranslationReqResponse; - }) - ); + .pipe(map(res => decodeTranslationReq(res))); } public translationSave( @@ -215,13 +204,9 @@ export class CommonApiService { this.moduleConfig.urls.translationSave, {}, { - params: {} + params: encodeTranslationSave(req) } ) - .pipe( - map(res => { - return {} as TranslationSaveResponse; - }) - ); + .pipe(map(res => decodeTranslationSave(res))); } } diff --git a/projects/ucap-webmessenger-api-external/src/lib/models/check-user-info-ex.ts b/projects/ucap-webmessenger-api-external/src/lib/models/check-user-info-ex.ts index 2166b926..838507f2 100644 --- a/projects/ucap-webmessenger-api-external/src/lib/models/check-user-info-ex.ts +++ b/projects/ucap-webmessenger-api-external/src/lib/models/check-user-info-ex.ts @@ -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 { userId: string; @@ -9,3 +14,23 @@ export interface CheckUserInfoExRequest extends APIRequest { export interface CheckUserInfoExResponse extends APIResponse { userId?: string; } + +export const encodeCheckUserInfoEx: APIEncoder = ( + req: CheckUserInfoExRequest +) => { + return { + p_user_id: req.userId, + p_comp_code: req.companyCode, + p_user_session: req.userSession + }; +}; + +export const decodeCheckUserInfoEx: APIDecoder = ( + res: any +) => { + return { + statusCode: res.StatusCode, + errorMessage: res.ErrorMessage, + userId: res.UserID + } as CheckUserInfoExResponse; +}; diff --git a/projects/ucap-webmessenger-api-external/src/lib/models/company-list.ts b/projects/ucap-webmessenger-api-external/src/lib/models/company-list.ts index 222dcfc1..441ea96a 100644 --- a/projects/ucap-webmessenger-api-external/src/lib/models/company-list.ts +++ b/projects/ucap-webmessenger-api-external/src/lib/models/company-list.ts @@ -1,5 +1,10 @@ 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 { userSeq?: string; @@ -21,3 +26,40 @@ export interface Company { export interface CompanyListResponse extends APIResponse { companyList?: Company[]; } + +export const encodeCompanyList: APIEncoder = ( + 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 = ( + 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; +}; diff --git a/projects/ucap-webmessenger-api-external/src/lib/models/token-update.ts b/projects/ucap-webmessenger-api-external/src/lib/models/token-update.ts index 3dfa56d8..ecc38112 100644 --- a/projects/ucap-webmessenger-api-external/src/lib/models/token-update.ts +++ b/projects/ucap-webmessenger-api-external/src/lib/models/token-update.ts @@ -1,5 +1,10 @@ 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 { userSeq: string; @@ -11,3 +16,21 @@ export interface TokenUpdateRequest extends APIRequest { // tslint:disable-next-line: no-empty-interface export interface TokenUpdateResponse extends APIResponse {} + +export const encodeTokenUpdate: APIEncoder = ( + 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 = ( + res: any +) => { + return {} as TokenUpdateResponse; +}; diff --git a/projects/ucap-webmessenger-api-external/src/lib/models/url-info.ts b/projects/ucap-webmessenger-api-external/src/lib/models/url-info.ts index f2f15bb0..97f4f92a 100644 --- a/projects/ucap-webmessenger-api-external/src/lib/models/url-info.ts +++ b/projects/ucap-webmessenger-api-external/src/lib/models/url-info.ts @@ -1,5 +1,10 @@ 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 { deviceType: DeviceType; @@ -19,3 +24,30 @@ export interface UrlInfoResponse extends APIResponse { uprDownloadUrl?: string; synapViewUrl?: string; } + +export const encodeUrlInfo: APIEncoder = ( + req: UrlInfoRequest +) => { + return { + p_device_type: req.deviceType + }; +}; + +export const decodeUrlInfo: APIDecoder = (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; +}; diff --git a/projects/ucap-webmessenger-api-external/src/lib/services/external-api.service.ts b/projects/ucap-webmessenger-api-external/src/lib/services/external-api.service.ts index 1444612d..f8e41abd 100644 --- a/projects/ucap-webmessenger-api-external/src/lib/services/external-api.service.ts +++ b/projects/ucap-webmessenger-api-external/src/lib/services/external-api.service.ts @@ -8,18 +8,28 @@ import { _MODULE_CONFIG } from '../types/token'; import { ModuleConfig } from '../types/module-config'; import { CheckUserInfoExRequest, - CheckUserInfoExResponse + CheckUserInfoExResponse, + encodeCheckUserInfoEx, + decodeCheckUserInfoEx } from '../models/check-user-info-ex'; import { CompanyListRequest, CompanyListResponse, - Company + encodeCompanyList, + decodeCompanyList } from '../models/company-list'; import { TokenUpdateRequest, - TokenUpdateResponse + TokenUpdateResponse, + encodeTokenUpdate, + decodeTokenUpdate } from '../models/token-update'; -import { UrlInfoResponse, UrlInfoRequest } from '../models/url-info'; +import { + UrlInfoResponse, + UrlInfoRequest, + encodeUrlInfo, + decodeUrlInfo +} from '../models/url-info'; @Injectable({ providedIn: 'root' @@ -38,22 +48,10 @@ export class ExternalApiService { this.moduleConfig.urls.checkUserInfoEx, {}, { - params: { - p_user_id: req.userId, - p_comp_code: req.companyCode, - p_user_session: req.userSession - } + params: encodeCheckUserInfoEx(req) } ) - .pipe( - map(res => { - return { - statusCode: res.StatusCode, - errorMessage: res.ErrorMessage, - userId: res.UserID - } as CheckUserInfoExResponse; - }) - ); + .pipe(map(res => decodeCheckUserInfoEx(res))); } public companyList(req: CompanyListRequest): Observable { @@ -62,39 +60,10 @@ export class ExternalApiService { this.moduleConfig.urls.companyList, {}, { - params: { - 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 - } + params: encodeCompanyList(req) } ) - .pipe( - 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; - }) - ); + .pipe(map(res => decodeCompanyList(res))); } public tokenUpdate(req: TokenUpdateRequest): Observable { @@ -103,20 +72,10 @@ export class ExternalApiService { this.moduleConfig.urls.tokenUpdate, {}, { - params: { - p_user_seq: req.userSeq, - p_device_type: req.deviceType, - p_token: req.token, - p_mobile_pid: req.mobilePid, - p_push_type: req.pushType - } + params: encodeTokenUpdate(req) } ) - .pipe( - map(res => { - return {} as TokenUpdateResponse; - }) - ); + .pipe(map(res => decodeTokenUpdate(res))); } public urlInfo(req: UrlInfoRequest): Observable { @@ -125,30 +84,9 @@ export class ExternalApiService { this.moduleConfig.urls.urlInfo, {}, { - params: { - p_device_type: req.deviceType - } + params: encodeUrlInfo(req) } ) - .pipe( - 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; - }) - ); + .pipe(map(res => decodeUrlInfo(res))); } } diff --git a/projects/ucap-webmessenger-api-public/src/lib/models/update-info.ts b/projects/ucap-webmessenger-api-public/src/lib/models/update-info.ts index 27fd7bda..a4d08e08 100644 --- a/projects/ucap-webmessenger-api-public/src/lib/models/update-info.ts +++ b/projects/ucap-webmessenger-api-public/src/lib/models/update-info.ts @@ -1,5 +1,11 @@ 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 { deviceType: DeviceType; @@ -11,3 +17,24 @@ export interface UpdateInfoResponse extends APIResponse { launcherAppVersion?: string; launcherInstallUrl?: string; } + +const updateInfoEncodeMap = { + deviceType: 'p_device_type' +}; + +export const encodeUpdateInfo: APIEncoder = ( + req: UpdateInfoRequest +) => { + return ParameterUtil.encode(updateInfoEncodeMap, req); +}; + +export const decodeUpdateInfo: APIDecoder = (res: any) => { + return { + statusCode: res.StatusCode, + errorMessage: res.ErrorMessage, + appVersion: res.AppVer, + installUrl: res.InstallURL, + launcherAppVersion: res.LauncherAppVer, + launcherInstallUrl: res.LauncherInstallURL + } as UpdateInfoResponse; +}; diff --git a/projects/ucap-webmessenger-api-public/src/lib/models/version-info2.ts b/projects/ucap-webmessenger-api-public/src/lib/models/version-info2.ts index d6762a3e..44206202 100644 --- a/projects/ucap-webmessenger-api-public/src/lib/models/version-info2.ts +++ b/projects/ucap-webmessenger-api-public/src/lib/models/version-info2.ts @@ -1,5 +1,11 @@ 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'; export interface VersionInfo2Request extends APIRequest { @@ -27,3 +33,41 @@ export interface VersionInfo2Response extends APIResponse { launcherAppVersion?: 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 = ( + req: VersionInfo2Request +) => { + return ParameterUtil.encode(versionInfo2EncodeMap, req); +}; + +export const decodeVersionInfo2: APIDecoder = ( + 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; +}; diff --git a/projects/ucap-webmessenger-api-public/src/lib/services/public-api.service.ts b/projects/ucap-webmessenger-api-public/src/lib/services/public-api.service.ts index b29f1601..37a55a45 100644 --- a/projects/ucap-webmessenger-api-public/src/lib/services/public-api.service.ts +++ b/projects/ucap-webmessenger-api-public/src/lib/services/public-api.service.ts @@ -7,25 +7,17 @@ import { map } from 'rxjs/operators'; import { _MODULE_CONFIG } from '../types/token'; import { VersionInfo2Request, - VersionInfo2Response + VersionInfo2Response, + encodeVersionInfo2, + decodeVersionInfo2 } 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 { 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({ providedIn: 'root' @@ -44,31 +36,10 @@ export class PublicApiService { this.moduleConfig.urls.versionInfo2, {}, { - params: ParameterUtil.make(versionInfo2Parameters, req) + params: encodeVersionInfo2(req) } ) - .pipe( - 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; - }) - ); + .pipe(map((res: any) => decodeVersionInfo2(res))); } public updateInfo(req: UpdateInfoRequest): Observable { @@ -77,20 +48,9 @@ export class PublicApiService { this.moduleConfig.urls.updateInfo, {}, { - params: ParameterUtil.make(updateInfoParameters, req) + params: encodeUpdateInfo(req) } ) - .pipe( - map(res => { - return { - statusCode: res.StatusCode, - errorMessage: res.ErrorMessage, - appVersion: res.AppVer, - installUrl: res.InstallURL, - launcherAppVersion: res.LauncherAppVer, - launcherInstallUrl: res.LauncherInstallURL - } as UpdateInfoResponse; - }) - ); + .pipe(map(res => decodeUpdateInfo(res))); } } diff --git a/projects/ucap-webmessenger-api/src/lib/models/api.ts b/projects/ucap-webmessenger-api/src/lib/models/api.ts index ff350839..9aec892e 100644 --- a/projects/ucap-webmessenger-api/src/lib/models/api.ts +++ b/projects/ucap-webmessenger-api/src/lib/models/api.ts @@ -1,3 +1,5 @@ +import { HttpParams } from '@angular/common/http'; + import { StatusCode } from '../types/status-code.type'; export interface APIRequest { @@ -9,3 +11,13 @@ export interface APIResponse { statusCode: StatusCode; errorMessage: string; } + +export type APIEncoder = ( + req: REQ +) => + | HttpParams + | { + [param: string]: string | string[]; + }; + +export type APIDecoder = (res: any) => RES; diff --git a/projects/ucap-webmessenger-api/src/lib/utils/parameter.util.ts b/projects/ucap-webmessenger-api/src/lib/utils/parameter.util.ts index 71d83453..e367cc93 100644 --- a/projects/ucap-webmessenger-api/src/lib/utils/parameter.util.ts +++ b/projects/ucap-webmessenger-api/src/lib/utils/parameter.util.ts @@ -3,7 +3,7 @@ export type Parameter = { } | null; export class ParameterUtil { - public static make(parameterMap: {}, param: {}): Parameter { + public static encode(parameterMap: {}, param: {}): Parameter { const parameter: Parameter = {}; Object.keys(parameterMap).map(key => { diff --git a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts index 2b55c3a5..f0ce2c7a 100644 --- a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts +++ b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts @@ -9,7 +9,8 @@ import { SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_RES, SSVC_TYPE_LOGOUT_REMOTE_NOTI, - AuthenticationProtocolService + decodeLogout, + decodeLogoutRemoteNotification } from '@ucap-webmessenger/protocol-authentication'; import * as AuthenticationStore from '../store/account/authentication'; @@ -18,7 +19,6 @@ import * as AuthenticationStore from '../store/account/authentication'; export class AppNotificationService { constructor( private protocolService: ProtocolService, - private authenticationProtocolService: AuthenticationProtocolService, private store: Store ) {} @@ -31,9 +31,7 @@ export class AppNotificationService { message.subServiceType === SSVC_TYPE_LOGOUT_RES ), tap(message => { - const logoutRes = this.authenticationProtocolService.decodeLogoutResponse( - message - ); + const logoutRes = decodeLogout(message); console.log('logoutRes', logoutRes); this.store.dispatch(AuthenticationStore.logout()); }) @@ -48,9 +46,7 @@ export class AppNotificationService { message.subServiceType === SSVC_TYPE_LOGOUT_REMOTE_NOTI ), tap(message => { - const logoutRemoteNoti = this.authenticationProtocolService.decodeLogoutRemoteNotification( - message - ); + const logoutRemoteNoti = decodeLogoutRemoteNotification(message); this.store.dispatch(AuthenticationStore.logout()); }) ) diff --git a/projects/ucap-webmessenger-pi/src/lib/models/login2.ts b/projects/ucap-webmessenger-pi/src/lib/models/login2.ts index 0a9bdd62..7e0b80d4 100644 --- a/projects/ucap-webmessenger-pi/src/lib/models/login2.ts +++ b/projects/ucap-webmessenger-pi/src/lib/models/login2.ts @@ -1,3 +1,5 @@ +import { ParameterUtil, APIEncoder, APIDecoder } from '@ucap-webmessenger/api'; + import { PIRequest, PIResponse } from './pi'; export interface Login2Request extends PIRequest { @@ -15,3 +17,26 @@ export interface Login2Response extends PIResponse { userName: string; userSeq: number; } + +const login2EncodeMap = { + companyCode: 'companyCd', + loginId: 'loginId', + loginPw: 'loginPw' +}; + +export const encodeLogin2: APIEncoder = (req: Login2Request) => { + return ParameterUtil.encode(login2EncodeMap, req); +}; + +export const decodeLogin2: APIDecoder = (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; +}; diff --git a/projects/ucap-webmessenger-pi/src/lib/services/pi.service.ts b/projects/ucap-webmessenger-pi/src/lib/services/pi.service.ts index d16b7be8..7673d6b3 100644 --- a/projects/ucap-webmessenger-pi/src/lib/services/pi.service.ts +++ b/projects/ucap-webmessenger-pi/src/lib/services/pi.service.ts @@ -6,7 +6,12 @@ import { map } from 'rxjs/operators'; import { _MODULE_CONFIG } from '../types/token'; import { ModuleConfig } from '../types/module-config'; -import { Login2Request, Login2Response } from '../models/login2'; +import { + Login2Request, + Login2Response, + encodeLogin2, + decodeLogin2 +} from '../models/login2'; @Injectable({ providedIn: 'root' @@ -23,26 +28,9 @@ export class PiService { this.moduleConfig.urls.login2, {}, { - params: { - companyCd: req.companyCode, - loginId: req.loginId, - loginPw: req.loginPw - } + params: encodeLogin2(req) } ) - .pipe( - 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; - }) - ); + .pipe(map(res => decodeLogin2(res))); } } diff --git a/projects/ucap-webmessenger-protocol-authentication/src/lib/models/login.ts b/projects/ucap-webmessenger-protocol-authentication/src/lib/models/login.ts index 6a98dc5e..497a5ebf 100644 --- a/projects/ucap-webmessenger-protocol-authentication/src/lib/models/login.ts +++ b/projects/ucap-webmessenger-protocol-authentication/src/lib/models/login.ts @@ -1,5 +1,13 @@ 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 { RoleCode } from '../types/role-code'; @@ -79,3 +87,79 @@ export interface LoginResponse extends ProtocolResponse { permissionsForViewSchedule: string; havePermissionsForDevice: boolean; } + +export const encodeLogin: ProtocolEncoder = ( + 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 = ( + 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; +}; diff --git a/projects/ucap-webmessenger-protocol-authentication/src/lib/models/logout-remote.ts b/projects/ucap-webmessenger-protocol-authentication/src/lib/models/logout-remote.ts new file mode 100644 index 00000000..9928079e --- /dev/null +++ b/projects/ucap-webmessenger-protocol-authentication/src/lib/models/logout-remote.ts @@ -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 = ( + 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 = ( + 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; +}; diff --git a/projects/ucap-webmessenger-protocol-authentication/src/lib/models/logout.ts b/projects/ucap-webmessenger-protocol-authentication/src/lib/models/logout.ts index 469b122d..5b929175 100644 --- a/projects/ucap-webmessenger-protocol-authentication/src/lib/models/logout.ts +++ b/projects/ucap-webmessenger-protocol-authentication/src/lib/models/logout.ts @@ -1,8 +1,10 @@ -import { DeviceType } from '@ucap-webmessenger/core'; import { ProtocolRequest, ProtocolResponse, - ProtocolNotification + ProtocolEncoder, + ProtocolDecoder, + ProtocolMessage, + PacketBody } from '@ucap-webmessenger/protocol'; // tslint:disable-next-line: no-empty-interface @@ -12,15 +14,16 @@ export interface LogoutResponse extends ProtocolResponse { reasonCode?: number; } -export interface LogoutRemoteRequest extends ProtocolRequest { - targetDeviceType?: DeviceType; - requestDeviceType?: DeviceType; -} -export interface LogoutRemoteResponse extends ProtocolResponse { - targetDeviceType?: DeviceType; - resultCode?: number; -} +export const encodeLogout: ProtocolEncoder = ( + req: LogoutRequest +) => { + const bodyList: PacketBody[] = []; -export interface LogoutRemoteNotification extends ProtocolNotification { - requestDeviceType?: DeviceType; -} + return bodyList; +}; + +export const decodeLogout: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { reasonCode: message.bodyList[0] } as LogoutResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-authentication/src/lib/services/authentication-protocol.service.ts b/projects/ucap-webmessenger-protocol-authentication/src/lib/services/authentication-protocol.service.ts index 717f430c..e3f50a32 100644 --- a/projects/ucap-webmessenger-protocol-authentication/src/lib/services/authentication-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-authentication/src/lib/services/authentication-protocol.service.ts @@ -3,13 +3,13 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; +import { ProtocolService } from '@ucap-webmessenger/protocol'; import { - ProtocolService, - PacketBody, - PacketBodyValue, - ServerMessage -} from '@ucap-webmessenger/protocol'; -import { LoginRequest, LoginResponse } from '../models/login'; + LoginRequest, + LoginResponse, + encodeLogin, + decodeLogin +} from '../models/login'; import { SVC_TYPE_LOGIN, SSVC_TYPE_LOGIN_REQ, @@ -17,14 +17,18 @@ import { SSVC_TYPE_LOGOUT_REQ, SSVC_TYPE_LOGOUT_REMOTE_REQ } from '../types/service'; -import { RoleCode } from '../types/role-code'; import { LogoutRequest, LogoutResponse, - LogoutRemoteRequest, - LogoutRemoteResponse, - LogoutRemoteNotification + encodeLogout, + decodeLogout } from '../models/logout'; +import { + encodeLogoutRemote, + decodeLogoutRemote, + LogoutRemoteRequest, + LogoutRemoteResponse +} from '../models/logout-remote'; @Injectable({ providedIn: 'root' @@ -33,132 +37,26 @@ export class AuthenticationProtocolService { constructor(private protocolService: ProtocolService) {} public login(req: LoginRequest): Observable { - 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 - .call(SVC_TYPE_LOGIN, SSVC_TYPE_LOGIN_REQ, ...bodyList) - .pipe( - 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; + .call(SVC_TYPE_LOGIN, SSVC_TYPE_LOGIN_REQ, ...encodeLogin(req)) + .pipe(map(res => decodeLogin(res))); } public logout(req: LogoutRequest): Observable { return this.protocolService - .call(SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_REQ) - .pipe( - map(res => { - return this.decodeLogoutResponse(res); - }) - ); - } - - public decodeLogoutResponse(message: ServerMessage): LogoutResponse { - return { - reasonCode: message.bodyList[0] - } as LogoutResponse; + .call(SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_REQ, ...encodeLogout(req)) + .pipe(map(res => decodeLogout(res))); } public logoutRemote( req: LogoutRemoteRequest ): Observable { - const bodyList: PacketBody[] = []; - - bodyList.push( - { type: PacketBodyValue.String, value: req.targetDeviceType }, - { type: PacketBodyValue.String, value: req.requestDeviceType } - ); - return this.protocolService - .call(SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_REMOTE_REQ, ...bodyList) - .pipe( - map(res => { - return this.decodeLogoutRemoteResponse(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; + .call( + SVC_TYPE_LOGOUT, + SSVC_TYPE_LOGOUT_REMOTE_REQ, + ...encodeLogoutRemote(req) + ) + .pipe(map(res => decodeLogoutRemote(res))); } } diff --git a/projects/ucap-webmessenger-protocol-authentication/src/public-api.ts b/projects/ucap-webmessenger-protocol-authentication/src/public-api.ts index d4f62e76..ea35d110 100644 --- a/projects/ucap-webmessenger-protocol-authentication/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-authentication/src/public-api.ts @@ -5,6 +5,7 @@ export * from './lib/models/fmc'; export * from './lib/models/login'; export * from './lib/models/logout'; +export * from './lib/models/logout-remote'; export * from './lib/services/authentication-protocol.service'; diff --git a/projects/ucap-webmessenger-protocol-inner/src/lib/models/conn.ts b/projects/ucap-webmessenger-protocol-inner/src/lib/models/conn.ts index dc5b908d..5547be41 100644 --- a/projects/ucap-webmessenger-protocol-inner/src/lib/models/conn.ts +++ b/projects/ucap-webmessenger-protocol-inner/src/lib/models/conn.ts @@ -1,8 +1,26 @@ -import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; -import { ProtocolRequest, ProtocolResponse } from '@ucap-webmessenger/protocol'; +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; // tslint:disable-next-line: no-empty-interface export interface ConnRequest extends ProtocolRequest {} // tslint:disable-next-line: no-empty-interface export interface ConnResponse extends ProtocolResponse {} + +export const encodeConn: ProtocolEncoder = (req: ConnRequest) => { + const bodyList: PacketBody[] = []; + + return bodyList; +}; + +export const decodeConn: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return {} as ConnResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-inner/src/lib/services/inner-protocol.service.ts b/projects/ucap-webmessenger-protocol-inner/src/lib/services/inner-protocol.service.ts index 26131ed0..12835ac5 100644 --- a/projects/ucap-webmessenger-protocol-inner/src/lib/services/inner-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-inner/src/lib/services/inner-protocol.service.ts @@ -5,7 +5,12 @@ import { map } from 'rxjs/operators'; 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'; @Injectable({ @@ -15,10 +20,8 @@ export class InnerProtocolService { constructor(private protocolService: ProtocolService) {} public conn(req: ConnRequest): Observable { - return this.protocolService.call(SVC_TYPE_INNER, SSVC_TYPE_CONN_REQ).pipe( - map(res => { - return {} as ConnResponse; - }) - ); + return this.protocolService + .call(SVC_TYPE_INNER, SSVC_TYPE_CONN_REQ, ...encodeConn(req)) + .pipe(map(res => decodeConn(res))); } } diff --git a/projects/ucap-webmessenger-protocol/src/lib/models/protocol.ts b/projects/ucap-webmessenger-protocol/src/lib/models/protocol.ts index b042de4e..6f68868e 100644 --- a/projects/ucap-webmessenger-protocol/src/lib/models/protocol.ts +++ b/projects/ucap-webmessenger-protocol/src/lib/models/protocol.ts @@ -1,3 +1,5 @@ +import { PacketBody } from './packet'; + export interface ProtocolRequest { _id?: string; } @@ -8,3 +10,14 @@ export interface ProtocolResponse { // tslint:disable-next-line: no-empty-interface export interface ProtocolNotification {} + +export interface ProtocolMessage { + serviceType: number; + subServiceType: number; + senderSeq: number; + bodyList: any[]; +} + +export type ProtocolEncoder = (req: REQ) => PacketBody[]; + +export type ProtocolDecoder = (message: ProtocolMessage) => RES; diff --git a/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts b/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts index 616bd65a..d18f3605 100644 --- a/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts +++ b/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts @@ -20,16 +20,10 @@ import { } from '../types/packet-body-divider'; import { PacketBodyValue } from '../types/packet-body-value.type'; import { SSVC_TYPE_ERROR_RES, ServerErrorCode } from '../types/service'; - -export interface ServerMessage { - serviceType: number; - subServiceType: number; - senderSeq: number; - bodyList: any[]; -} +import { ProtocolMessage } from '../models/protocol'; interface RequestState { - subject: Subject; + subject: Subject; request: { serviceType: number; subServiceType: number; @@ -48,8 +42,8 @@ export class ProtocolService { private socket$: Observable>; private messages$: Observable; private messagesSubscription: Subscription | null = null; - private serverMessageSubject: Subject | null = null; - private serverMessage$: Observable | null = null; + private serverMessageSubject: Subject | null = null; + private serverMessage$: Observable | null = null; constructor(@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig) { this.pendingRequests = new Map(); @@ -131,7 +125,7 @@ export class ProtocolService { this.messagesSubscription.unsubscribe(); } - public get serverMessage(): Observable { + public get serverMessage(): Observable { return this.serverMessage$; } @@ -139,7 +133,7 @@ export class ProtocolService { serviceType: number | null, subServiceType: number | null, ...bodyList: PacketBody[] - ): Observable { + ): Observable { return this.sendInternal(true, serviceType, subServiceType, bodyList); } @@ -156,9 +150,9 @@ export class ProtocolService { serviceType: number, subServiceType: number, bodyList: PacketBody[] - ): Observable | undefined { + ): Observable | undefined { let packet: string; - let responseSubject: Subject | null = null; + let responseSubject: Subject | null = null; if (hasResponse) { const requestId = this.requestId; @@ -168,7 +162,7 @@ export class ProtocolService { { type: PacketBodyValue.RequestId, value: requestId } ]); - responseSubject = new Subject(); + responseSubject = new Subject(); this.pendingRequests.set(requestId, { subject: responseSubject, request: { serviceType, subServiceType, bodyList } @@ -195,7 +189,7 @@ export class ProtocolService { private decodePacket( arg: string[] - ): { requestId: number; message: ServerMessage } | null { + ): { requestId: number; message: ProtocolMessage } | null { const cmdArg = arg[0].split(PacketBodyValueDivider); if (2 > cmdArg.length) { // OnError(3);