2019-11-13 13:55:28 +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 '../config/token';
|
|
|
|
import { ModuleConfig } from '../config/module-config';
|
|
|
|
import { UrlConfig } from '@ucap-webmessenger/core';
|
|
|
|
import { Urls } from '../config/urls';
|
2019-11-13 15:42:30 +09:00
|
|
|
import {
|
|
|
|
RetrieveRequest,
|
|
|
|
RetrieveSendResponse,
|
|
|
|
encodeRetrieve,
|
|
|
|
decodeRetrieveSend
|
|
|
|
} from '../apis/retrieve-send';
|
2019-11-13 13:55:28 +09:00
|
|
|
|
|
|
|
@Injectable({
|
2019-11-13 15:42:30 +09:00
|
|
|
providedIn: 'root'
|
2019-11-13 13:55:28 +09:00
|
|
|
})
|
|
|
|
export class MessageApiService {
|
|
|
|
readonly urls: Urls;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig,
|
|
|
|
private httpClient: HttpClient
|
|
|
|
) {
|
|
|
|
this.urls = UrlConfig.getUrls(
|
|
|
|
this.moduleConfig.hostConfig,
|
|
|
|
this.moduleConfig.urls
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-11-13 15:42:30 +09:00
|
|
|
public retrieveSendMessage(
|
|
|
|
req: RetrieveRequest
|
|
|
|
): Observable<RetrieveSendResponse> {
|
2019-11-13 13:55:28 +09:00
|
|
|
return this.httpClient
|
|
|
|
.post<any>(
|
2019-11-13 15:42:30 +09:00
|
|
|
this.urls.retrieveSendMessageList,
|
2019-11-13 13:55:28 +09:00
|
|
|
{},
|
|
|
|
{
|
2019-11-13 15:42:30 +09:00
|
|
|
params: encodeRetrieve(req)
|
2019-11-13 13:55:28 +09:00
|
|
|
}
|
|
|
|
)
|
2019-11-13 15:42:30 +09:00
|
|
|
.pipe(map(res => decodeRetrieveSend(res)));
|
2019-11-13 13:55:28 +09:00
|
|
|
}
|
|
|
|
}
|