-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Se implementa funcionalidad para filtrar los evaluadores por número de identificación, de acuerdo al Id del endpoint informacion_persona_natural del api administrativa_amazon_crud.
- Loading branch information
lud
committed
May 13, 2023
1 parent
27cda88
commit 617d420
Showing
3 changed files
with
187 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { map } from 'rxjs/operators'; | ||
import { HttpErrorResponse } from '@angular/common/http'; | ||
import { throwError } from 'rxjs'; | ||
import { RequestManager } from '../../managers/requestManager'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class UserService { | ||
constructor( | ||
private rqManager: RequestManager, | ||
) { } | ||
|
||
getPersonaNaturalAmazon() { | ||
|
||
const userString = window.localStorage.getItem('user'); | ||
if (!userString || !userString.length) { | ||
return; | ||
} | ||
|
||
const user = atob(userString); | ||
if (!user) { | ||
return; | ||
} | ||
|
||
const userObj = JSON.parse(atob(userString)); | ||
|
||
if (!userObj || !userObj.userService || !userObj.userService.documento) { | ||
return; | ||
} | ||
|
||
const endpoint = 'informacion_persona_natural'; | ||
const payload = '?fields=Id,PrimerNombre,SegundoNombre,PrimerApellido,SegundoApellido,TipoDocumento,Cargo&' + | ||
'query=Id:' + userObj.userService.documento; | ||
|
||
return this.getAllInfoPersonaNatural(payload); | ||
} | ||
|
||
getAllInfoPersonaNatural(payload) { | ||
const path = 'informacion_persona_natural' | ||
this.rqManager.setPath('ADMINISTRIVA_AMAZON'); | ||
return this.rqManager.get(path + payload).pipe( | ||
map( | ||
(res) => { | ||
return res; | ||
}, | ||
), | ||
); | ||
} | ||
|
||
private handleError(error: HttpErrorResponse) { | ||
if (error.error instanceof ErrorEvent) { | ||
// A client-side or network error occurred. Handle it accordingly. | ||
console.error('An error occurred:', error.error.message); | ||
} else { | ||
// The backend returned an unsuccessful response code. | ||
// The response body may contain clues as to what went wrong, | ||
console.error( | ||
`Backend returned code ${error.status}, ` + | ||
`body was: ${error.error}`); | ||
} | ||
// return an observable with a user-facing error message | ||
return throwError({ | ||
status: error.status, | ||
message: 'Something bad happened; please try again later.', | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.