2024-07-24 13:37:02 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { HttpService } from 'src/app/services/http.service';
|
|
|
|
|
import { environment } from 'src/environments/environment';
|
|
|
|
|
import { IProfilePictureInputDTO } from '../dto/profilePictureInputDTO';
|
|
|
|
|
import { HttpHeaders } from '@angular/common/http';
|
2024-07-31 09:35:35 +01:00
|
|
|
import { TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
|
2024-11-06 09:13:36 +01:00
|
|
|
import { HttpAdapter } from 'src/app/infra/http/adapter';
|
2024-12-05 19:14:11 +01:00
|
|
|
import { IUserRepositoryLoginParams, UserRefreshTokenInputDTO } from 'src/app/core/user/repository/user-remote-repository';
|
2024-11-06 09:13:36 +01:00
|
|
|
import { UserLoginOutput } from 'src/app/core/user/use-case/user-login-use-case.service';
|
2024-11-07 11:15:01 +01:00
|
|
|
import { SessionStore } from 'src/app/store/session.service';
|
2024-07-24 13:37:02 +01:00
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
|
|
|
|
export class UserRemoteRepositoryService {
|
|
|
|
|
|
2024-11-06 09:13:36 +01:00
|
|
|
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2'; // Your base URL
|
|
|
|
|
|
2024-07-24 13:37:02 +01:00
|
|
|
constructor(
|
2024-11-06 09:13:36 +01:00
|
|
|
private httpService: HttpService,
|
|
|
|
|
private http: HttpAdapter,
|
2024-07-24 13:37:02 +01:00
|
|
|
) { }
|
|
|
|
|
|
2024-11-06 09:13:36 +01:00
|
|
|
|
|
|
|
|
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
|
|
|
|
async login(input: IUserRepositoryLoginParams) {
|
|
|
|
|
|
|
|
|
|
return await this.http.post<UserLoginOutput>(`${this.baseUrl}/Users/login`, input)
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 11:15:01 +01:00
|
|
|
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
|
|
|
|
async logout() {
|
|
|
|
|
|
|
|
|
|
return await this.http.post<UserLoginOutput>(`${this.baseUrl}/Users/${SessionStore.user.UserId}/logout`, {})
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-05 19:14:11 +01:00
|
|
|
async refreshToken(input: UserRefreshTokenInputDTO) {
|
|
|
|
|
|
|
|
|
|
return await this.http.post<UserLoginOutput>(`${this.baseUrl}/Users/RefreshToken`, input)
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-31 09:35:35 +01:00
|
|
|
getUserProfilePhoto(guid: string, tracing?: TracingType) {
|
2024-07-24 13:37:02 +01:00
|
|
|
const geturl = environment.apiURL + 'UserAuthentication/GetPhoto';
|
2024-07-31 09:35:35 +01:00
|
|
|
|
2024-07-24 13:37:02 +01:00
|
|
|
const params = {
|
|
|
|
|
UserPhoto: guid
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-31 09:35:35 +01:00
|
|
|
return this.httpService.get<string>(`${geturl}`, params, tracing);
|
2024-07-24 13:37:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addUserProfilePhoto(data: IProfilePictureInputDTO) {
|
|
|
|
|
const geturl = environment.apiURL + 'UserAuthentication/AddPhoto';
|
|
|
|
|
|
|
|
|
|
let http = new HttpHeaders();
|
|
|
|
|
|
|
|
|
|
http = http.set('content-type', "application/json");
|
|
|
|
|
http = http.set('accept', "application/json");
|
|
|
|
|
let options = {
|
|
|
|
|
headers: http
|
|
|
|
|
};
|
2024-07-31 09:35:35 +01:00
|
|
|
|
2024-07-24 13:37:02 +01:00
|
|
|
return this.httpService.post<string>(`${geturl}`, data, options);
|
|
|
|
|
}
|
|
|
|
|
}
|