-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/cuenta bancaria #129
Changes from all commits
9291917
b6b445c
1df7acc
6eb418c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { RequestManager } from '../../managers/requestManager'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class GirosHelper { | ||
constructor(private rqManager: RequestManager) {} | ||
|
||
// Terceros | ||
|
||
public getCuentasBancarias(parameters?: { id?: any, query?: any, fields?: string[], sortby?: string[], order?: string[], limit?: number, offset?: number }) { | ||
this.rqManager.setPath('GIROS_CRUD_SERVICE'); | ||
return this.rqManager.getv2('cuenta_bancaria', parameters); | ||
} | ||
|
||
public createCuentaBancaria(element: any) { | ||
this.rqManager.setPath('GIROS_CRUD_SERVICE'); | ||
return this.rqManager.post('cuenta_bancaria/', element); | ||
} | ||
|
||
public updateCuentaBancaria(id: number, element: any) { | ||
this.rqManager.setPath('GIROS_CRUD_SERVICE'); | ||
return this.rqManager.put('cuenta_bancaria/', element, id); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { RequestManager } from '../../managers/requestManager'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class TercerosHelper { | ||
constructor(private rqManager: RequestManager) {} | ||
|
||
// Tercero | ||
|
||
public getTerceros(parameters?: { id?: any, query?: any, fields?: string[], sortby?: string[], order?: string[], limit?: number, offset?: number }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ver lo comentado en src/app/@core/helpers/giros/girosHelper.ts |
||
this.rqManager.setPath('TERCEROS_CRUD_SERVICE'); | ||
return this.rqManager.getv2('tercero', parameters); | ||
} | ||
|
||
public createTercero(element: any) { | ||
this.rqManager.setPath('TERCEROS_CRUD_SERVICE'); | ||
return this.rqManager.post('tercero/', element); | ||
} | ||
|
||
public updateTercero(id: number, element: any) { | ||
this.rqManager.setPath('TERCEROS_CRUD_SERVICE'); | ||
return this.rqManager.put('tercero/', element, id); | ||
} | ||
|
||
// Tercero_tipo_tercero | ||
public getTerceroTipoTercero(parameters?: { id?: any, query?: any, fields?: string[], sortby?: string[], order?: string[], limit?: number, offset?: number }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ver lo comentado en src/app/@core/helpers/giros/girosHelper.ts |
||
this.rqManager.setPath('TERCEROS_CRUD_SERVICE'); | ||
return this.rqManager.getv2('tercero_tipo_tercero', parameters); | ||
} | ||
|
||
public createTerceroTipoTercero(element: any) { | ||
this.rqManager.setPath('TERCEROS_CRUD_SERVICE'); | ||
return this.rqManager.post('tercero_tipo_tercero/', element); | ||
} | ||
|
||
public updateTerceroTipoTercero(id: number, element: any) { | ||
this.rqManager.setPath('TERCEROS_CRUD_SERVICE'); | ||
return this.rqManager.put('tercero_tipo_tercero/', element, id); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { RequestManager } from '../../managers/requestManager'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class TesoreriaHelper { | ||
constructor(private rqManager: RequestManager) {} | ||
|
||
// tesoreria_mid | ||
|
||
public getCuentasBancarias(parameters?: { id?: any, limit?: number, offset?: number }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Posiblemente se pueda hacer algo similar a lo comentado en src/app/@core/helpers/giros/girosHelper.ts |
||
this.rqManager.setPath('TESORERIA_MID_SERVICE'); | ||
return this.rqManager.getv2('cuenta_bancaria_banco', parameters); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,13 @@ export class RequestManager { | |
private path: string; | ||
public httpOptions: any; | ||
constructor(private http: HttpClient, private errManager: HttpErrorManager) { | ||
this.initHttpOptions(); | ||
} | ||
|
||
/** | ||
* Set http options to initial state | ||
*/ | ||
private initHttpOptions() { | ||
this.httpOptions = { | ||
headers: new HttpHeaders({ | ||
'Accept': 'application/json', | ||
|
@@ -25,7 +32,6 @@ export class RequestManager { | |
}; | ||
} | ||
|
||
|
||
/** | ||
* Use for set the source path of the service (service's name must be present at src/app/app-config.ts) | ||
* @param service: string | ||
|
@@ -34,6 +40,37 @@ export class RequestManager { | |
this.path = environment[service]; | ||
} | ||
|
||
/** | ||
* | ||
* @param endpoint service's end-point | ||
* @param id object id | ||
* @param query (a Key, Value object with que query params for the request) | ||
* @param fields array of strings with field names | ||
* @param sortby array of strings with field names | ||
* @param order array of strings with asc, desc for each sortby field names | ||
* @param limit Limit the size of result set. Must be an integer | ||
* @param offset Start position of result set. Must be an integer | ||
* @returns | ||
*/ | ||
getv2(endpoint: string, parameters?: { id?: any, query?: any, fields?: string[], sortby?: string[], order?: string[], limit?: number, offset?: number }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ver lo comentado en src/app/@core/helpers/giros/girosHelper.ts respecto a |
||
const params = {}; | ||
const id = parameters ? parameters.id : undefined; | ||
if (parameters) { | ||
if (parameters.query) { | ||
let queryParams = ''; | ||
for (const [key, value] of Object.entries(parameters.query)) | ||
queryParams += `${key}:${value},`; | ||
queryParams = queryParams.substr(0, queryParams.length - 1); | ||
params['query'] = queryParams; | ||
} | ||
if (parameters.fields) params['fields'] = parameters.fields.join(','); | ||
if (parameters.sortby) params['sortby'] = parameters.sortby.join(','); | ||
if (parameters.order) params['order'] = parameters.order; | ||
if (parameters.limit !== null && parameters.limit !== undefined) params['limit'] = parameters.limit; | ||
if (parameters.offset != null && parameters.offset !== undefined) params['offset'] = parameters.offset; | ||
} | ||
return this.get(endpoint + (id ? `/${id}` : ''), params); | ||
} | ||
|
||
/** | ||
* Perform a GET http request | ||
|
@@ -42,10 +79,10 @@ export class RequestManager { | |
* @returns Observable<any> | ||
*/ | ||
get(endpoint, params?) { | ||
const queryParams = new HttpParams(); | ||
let queryParams = new HttpParams(); | ||
if (params) { | ||
for (const [key, value] of Object.entries(params)) { | ||
queryParams.append(key, value + ''); | ||
queryParams = queryParams.append(key, value + ''); | ||
} | ||
|
||
} | ||
|
@@ -76,6 +113,7 @@ export class RequestManager { | |
* @returns Observable<any> | ||
*/ | ||
post(endpoint, element) { | ||
this.initHttpOptions(); | ||
return this.http.post<any>(`${this.path}${endpoint}`, element, this.httpOptions).pipe( | ||
catchError(this.errManager.handleError), | ||
map( | ||
|
@@ -98,6 +136,7 @@ export class RequestManager { | |
* @returns Observable<any> | ||
*/ | ||
put(endpoint, element, id) { | ||
this.initHttpOptions(); | ||
return this.http.put<any>(`${this.path}${endpoint}${id}`, JSON.stringify(element), this.httpOptions).pipe( | ||
catchError(this.errManager.handleError), | ||
); | ||
|
@@ -110,6 +149,7 @@ export class RequestManager { | |
* @returns Observable<any> | ||
*/ | ||
putParams(endpoint, element) { | ||
this.initHttpOptions(); | ||
return this.http.put<any>(`${this.path}${endpoint}`, element, this.httpOptions).pipe( | ||
catchError(this.errManager.handleError), | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ export const environment = { | |
PLAN_CUENTAS_MONGO_SERVICE: 'https://autenticacion.portaloas.udistrital.edu.co/apioas/plan_cuentas_mongo_crud/v1/', | ||
CUENTAS_CONTABLES_SERVICE: 'https://autenticacion.portaloas.udistrital.edu.co/apioas/cuentas_contables_crud/v1/', | ||
CONFIGURACION_SERVICE: 'https://autenticacion.portaloas.udistrital.edu.co/apioas/configuracion_crud_api/v1/', | ||
TESORERIA_MID_SERVICE: 'http://pruebasapi2.intranetoas.udistrital.edu.co:8214/v1/', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revisar lo comentado en src/environments/environment.ts |
||
CONF_MENU_SERVICE: 'https://autenticacion.portaloas.udistrital.edu.co/apioas/configuracion_crud_api/v1/menu_opcion_padre/ArbolMenus/', | ||
TOKEN: { | ||
AUTORIZATION_URL: 'https://autenticacion.portaloas.udistrital.edu.co/oauth2/authorize', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ export const environment = { | |
WSO2_SERVICE: 'https://autenticacion.portaloas.udistrital.edu.co/apioas/', | ||
PLAN_CUENTAS_MONGO_SERVICE: 'https://autenticacion.portaloas.udistrital.edu.co/apioas/plan_cuentas_mongo_crud/v1/', | ||
CUENTAS_CONTABLES_SERVICE: 'https://autenticacion.portaloas.udistrital.edu.co/apioas/cuentas_contables_crud/v1/', | ||
TESORERIA_MID_SERVICE: 'http://pruebasapi2.intranetoas.udistrital.edu.co:8214/v1/', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
CONFIGURACION_SERVICE: 'https://autenticacion.portaloas.udistrital.edu.co/apioas/configuracion_crud_api/v1/', | ||
CONF_MENU_SERVICE: 'https://autenticacion.portaloas.udistrital.edu.co/apioas/configuracion_crud_api/v1/menu_opcion_padre/ArbolMenus/', | ||
TOKEN: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Se observa que
{ id?: any, query?: any, fields?: string[], sortby?: string[], order?: string[], limit?: number, offset?: number }
se repite en varias partes.Guardar esta estructura como un nuevo modelo de datos, por ejemplo, algo como
BeegoQueryParams
:De tal manera que el
getCuentasBancarias
(y dondesea que se use esta misma estructura) se pueda reescribir como(Si no funciona con
interface
usar simplementeclass
)