2019-09-18 15:02:21 +09:00
|
|
|
import { Injectable, Inject } from '@angular/core';
|
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { map } from 'rxjs/operators';
|
|
|
|
|
|
|
|
import { _MODULE_CONFIG } from '../types/token';
|
|
|
|
import { ModuleConfig } from '../types/module-config';
|
|
|
|
import {
|
|
|
|
FileProfileSaveRequest,
|
2019-09-20 11:39:09 +09:00
|
|
|
FileProfileSaveResponse,
|
|
|
|
encodeFileProfileSave,
|
|
|
|
decodeFileProfileSave
|
2019-10-08 15:42:36 +09:00
|
|
|
} from '../apis/file-profile-save';
|
2019-09-20 11:39:09 +09:00
|
|
|
import {
|
|
|
|
FileTalkDownloadRequest,
|
|
|
|
encodeFileTalkDownload
|
2019-10-08 15:42:36 +09:00
|
|
|
} from '../apis/file-talk-download';
|
2019-09-18 15:02:21 +09:00
|
|
|
import {
|
|
|
|
FileTalkSaveRequest,
|
2019-09-20 11:39:09 +09:00
|
|
|
FileTalkSaveResponse,
|
|
|
|
encodeFileTalkSave,
|
|
|
|
decodeFileTalkSave
|
2019-10-08 15:42:36 +09:00
|
|
|
} from '../apis/file-talk-save';
|
2019-09-18 15:02:21 +09:00
|
|
|
import {
|
|
|
|
FileTalkShareRequest,
|
2019-09-20 11:39:09 +09:00
|
|
|
FileTalkShareResponse,
|
|
|
|
encodeFileTalkShare,
|
|
|
|
decodeFileTalkShare
|
2019-10-08 15:42:36 +09:00
|
|
|
} from '../apis/file-talk-share';
|
2019-09-18 15:02:21 +09:00
|
|
|
import {
|
|
|
|
MassTalkDownloadRequest,
|
2019-09-20 11:39:09 +09:00
|
|
|
MassTalkDownloadResponse,
|
|
|
|
encodeMassTalkDownload,
|
|
|
|
decodeMassTalkDownload
|
2019-10-08 15:42:36 +09:00
|
|
|
} from '../apis/mass-talk-download';
|
2019-09-18 15:02:21 +09:00
|
|
|
import {
|
|
|
|
MassTalkSaveRequest,
|
2019-09-20 11:39:09 +09:00
|
|
|
MassTalkSaveResponse,
|
|
|
|
encodeMassTalkSave,
|
|
|
|
decodeMassTalkSave
|
2019-10-08 15:42:36 +09:00
|
|
|
} from '../apis/mass-talk-save';
|
2019-09-18 15:02:21 +09:00
|
|
|
import {
|
|
|
|
TransMassTalkDownloadRequest,
|
2019-09-20 11:39:09 +09:00
|
|
|
TransMassTalkDownloadResponse,
|
|
|
|
encodeTransMassTalkDownload,
|
|
|
|
decodeTransMassTalkDownload
|
2019-10-08 15:42:36 +09:00
|
|
|
} from '../apis/trans-mass-talk-download';
|
2019-09-18 15:02:21 +09:00
|
|
|
import {
|
|
|
|
TransMassTalkSaveRequest,
|
2019-09-20 11:39:09 +09:00
|
|
|
TransMassTalkSaveResponse,
|
|
|
|
encodeTransMassTalkSave,
|
|
|
|
decodeTransMassTalkSave
|
2019-10-08 15:42:36 +09:00
|
|
|
} from '../apis/trans-mass-talk-save';
|
2019-09-18 15:02:21 +09:00
|
|
|
import {
|
|
|
|
TranslationReqRequest,
|
2019-09-20 11:39:09 +09:00
|
|
|
TranslationReqResponse,
|
|
|
|
encodeTranslationReq,
|
|
|
|
decodeTranslationReq
|
2019-10-08 15:42:36 +09:00
|
|
|
} from '../apis/translation-req';
|
2019-09-18 15:02:21 +09:00
|
|
|
import {
|
|
|
|
TranslationSaveRequest,
|
2019-09-20 11:39:09 +09:00
|
|
|
TranslationSaveResponse,
|
|
|
|
encodeTranslationSave,
|
|
|
|
decodeTranslationSave
|
2019-10-08 15:42:36 +09:00
|
|
|
} from '../apis/translation-save';
|
2019-09-18 15:02:21 +09:00
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class CommonApiService {
|
|
|
|
constructor(
|
|
|
|
@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig,
|
|
|
|
private httpClient: HttpClient
|
|
|
|
) {}
|
|
|
|
|
|
|
|
public fileProfileSave(
|
|
|
|
req: FileProfileSaveRequest
|
|
|
|
): Observable<FileProfileSaveResponse> {
|
|
|
|
return this.httpClient
|
|
|
|
.post<any>(
|
|
|
|
this.moduleConfig.urls.fileProfileSave,
|
|
|
|
{},
|
|
|
|
{
|
2019-09-20 11:39:09 +09:00
|
|
|
params: encodeFileProfileSave(req)
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
)
|
2019-09-20 11:39:09 +09:00
|
|
|
.pipe(map(res => decodeFileProfileSave(res)));
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public fileTalkDownload(req: FileTalkDownloadRequest): Observable<Blob> {
|
|
|
|
return this.httpClient.post<Blob>(
|
|
|
|
this.moduleConfig.urls.fileTalkDownload,
|
|
|
|
{ responseType: 'blob' },
|
|
|
|
{
|
2019-09-20 11:39:09 +09:00
|
|
|
params: encodeFileTalkDownload(req)
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public fileTalkSave(
|
|
|
|
req: FileTalkSaveRequest
|
|
|
|
): Observable<FileTalkSaveResponse> {
|
|
|
|
return this.httpClient
|
|
|
|
.post<any>(
|
|
|
|
this.moduleConfig.urls.fileTalkSave,
|
|
|
|
{},
|
|
|
|
{
|
2019-09-20 11:39:09 +09:00
|
|
|
params: encodeFileTalkSave(req)
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
)
|
2019-09-20 11:39:09 +09:00
|
|
|
.pipe(map(res => decodeFileTalkSave(res)));
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public fileTalkShare(
|
|
|
|
req: FileTalkShareRequest
|
|
|
|
): Observable<FileTalkShareResponse> {
|
|
|
|
return this.httpClient
|
|
|
|
.post<any>(
|
|
|
|
this.moduleConfig.urls.fileTalkShare,
|
|
|
|
{},
|
|
|
|
{
|
2019-09-20 11:39:09 +09:00
|
|
|
params: encodeFileTalkShare(req)
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
)
|
2019-09-20 11:39:09 +09:00
|
|
|
.pipe(map(res => decodeFileTalkShare(res)));
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public massTalkDownload(
|
|
|
|
req: MassTalkDownloadRequest
|
|
|
|
): Observable<MassTalkDownloadResponse> {
|
|
|
|
return this.httpClient
|
|
|
|
.post<any>(
|
|
|
|
this.moduleConfig.urls.massTalkDownload,
|
|
|
|
{},
|
|
|
|
{
|
2019-09-20 11:39:09 +09:00
|
|
|
params: encodeMassTalkDownload(req)
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
)
|
2019-09-20 11:39:09 +09:00
|
|
|
.pipe(map(res => decodeMassTalkDownload(res)));
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public massTalkSave(
|
|
|
|
req: MassTalkSaveRequest
|
|
|
|
): Observable<MassTalkSaveResponse> {
|
|
|
|
return this.httpClient
|
|
|
|
.post<any>(
|
|
|
|
this.moduleConfig.urls.massTalkSave,
|
|
|
|
{},
|
|
|
|
{
|
2019-09-20 11:39:09 +09:00
|
|
|
params: encodeMassTalkSave(req)
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
)
|
2019-09-20 11:39:09 +09:00
|
|
|
.pipe(map(res => decodeMassTalkSave(res)));
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public transMassTalkDownload(
|
|
|
|
req: TransMassTalkDownloadRequest
|
|
|
|
): Observable<TransMassTalkDownloadResponse> {
|
|
|
|
return this.httpClient
|
|
|
|
.post<any>(
|
|
|
|
this.moduleConfig.urls.transMassTalkDownload,
|
|
|
|
{},
|
|
|
|
{
|
2019-09-20 11:39:09 +09:00
|
|
|
params: encodeTransMassTalkDownload(req)
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
)
|
2019-09-20 11:39:09 +09:00
|
|
|
.pipe(map(res => decodeTransMassTalkDownload(res)));
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public transMassTalkSave(
|
|
|
|
req: TransMassTalkSaveRequest
|
|
|
|
): Observable<TransMassTalkSaveResponse> {
|
|
|
|
return this.httpClient
|
|
|
|
.post<any>(
|
|
|
|
this.moduleConfig.urls.transMassTalkSave,
|
|
|
|
{},
|
|
|
|
{
|
2019-09-20 11:39:09 +09:00
|
|
|
params: encodeTransMassTalkSave(req)
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
)
|
2019-09-20 11:39:09 +09:00
|
|
|
.pipe(map(res => decodeTransMassTalkSave(res)));
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public translationReq(
|
|
|
|
req: TranslationReqRequest
|
|
|
|
): Observable<TranslationReqResponse> {
|
|
|
|
return this.httpClient
|
|
|
|
.post<any>(
|
|
|
|
this.moduleConfig.urls.translationReq,
|
|
|
|
{},
|
|
|
|
{
|
2019-09-20 11:39:09 +09:00
|
|
|
params: encodeTranslationReq(req)
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
)
|
2019-09-20 11:39:09 +09:00
|
|
|
.pipe(map(res => decodeTranslationReq(res)));
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public translationSave(
|
|
|
|
req: TranslationSaveRequest
|
|
|
|
): Observable<TranslationSaveResponse> {
|
|
|
|
return this.httpClient
|
|
|
|
.post<any>(
|
|
|
|
this.moduleConfig.urls.translationSave,
|
|
|
|
{},
|
|
|
|
{
|
2019-09-20 11:39:09 +09:00
|
|
|
params: encodeTranslationSave(req)
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
)
|
2019-09-20 11:39:09 +09:00
|
|
|
.pipe(map(res => decodeTranslationSave(res)));
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
}
|