catalogs.service.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. import { Injectable } from "@angular/core";
  2. import { of as observableOf, Observable, throwError } from "rxjs";
  3. import { HttpClient, HttpHeaders } from "@angular/common/http";
  4. import { retry, catchError, map, timeout } from "rxjs/operators";
  5. import { environment } from "@environments/environment";
  6. @Injectable({
  7. providedIn: "root"
  8. })
  9. export class CatalogsService {
  10. time: number = 6000;
  11. constructor(private http: HttpClient) {}
  12. getCatalogInfo(url: string) {
  13. return this.http
  14. .get<any>(`${environment.productionApiUrl}/${url}`, {})
  15. .pipe(
  16. map(response => {
  17. return response;
  18. }),
  19. catchError(this.errorHandl)
  20. );
  21. }
  22. // paises
  23. getCountries() {
  24. return this.http
  25. .get<any>(`${environment.productionApiUrl}/paises`, {})
  26. .pipe(
  27. map(response => {
  28. return response;
  29. }),
  30. catchError(this.errorHandl)
  31. );
  32. }
  33. // empresas
  34. getCompanies() {
  35. return this.http
  36. .get<any>(`${environment.productionApiUrl}/empresas`, {})
  37. .pipe(
  38. map(response => {
  39. return response;
  40. }),
  41. catchError(this.errorHandl)
  42. );
  43. }
  44. // entidades-financieras
  45. getFinancialEntities() {
  46. return this.http
  47. .get<any>(`${environment.productionApiUrl}/entidades-financieras`, {})
  48. .pipe(
  49. map(response => {
  50. return response;
  51. }),
  52. catchError(this.errorHandl)
  53. );
  54. }
  55. // origenes-fondos
  56. getFundsOrigins() {
  57. return this.http
  58. .get<any>(`${environment.productionApiUrl}/origenes-fondos`, {})
  59. .pipe(
  60. map(response => {
  61. return response;
  62. }),
  63. catchError(this.errorHandl)
  64. );
  65. }
  66. // periodicidades
  67. getPeriodicities() {
  68. return this.http
  69. .get<any>(`${environment.productionApiUrl}/periodicidades`, {})
  70. .pipe(
  71. map(response => {
  72. return response;
  73. }),
  74. catchError(this.errorHandl)
  75. );
  76. }
  77. // plazos
  78. getPaymentTerms() {
  79. return this.http
  80. .get<any>(`${environment.productionApiUrl}/plazos`, {})
  81. .pipe(
  82. map(response => {
  83. return response;
  84. }),
  85. catchError(this.errorHandl)
  86. );
  87. }
  88. // tipos-bases
  89. getBaseTypes() {
  90. return this.http
  91. .get<any>(`${environment.productionApiUrl}/tipos-bases`, {})
  92. .pipe(
  93. map(response => {
  94. return response;
  95. }),
  96. catchError(this.errorHandl)
  97. );
  98. }
  99. // tipos-emisores
  100. getEmitterTypes() {
  101. return this.http
  102. .get<any>(`${environment.productionApiUrl}/tipos-emisores`, {})
  103. .pipe(
  104. map(response => {
  105. return response;
  106. }),
  107. catchError(this.errorHandl)
  108. );
  109. }
  110. // tipos-entidades
  111. getEntityTypes() {
  112. return this.http
  113. .get<any>(`${environment.productionApiUrl}/tipos-entidades`, {})
  114. .pipe(
  115. map(response => {
  116. return response;
  117. }),
  118. catchError(this.errorHandl)
  119. );
  120. }
  121. // tipos-instrumentos
  122. getInstrumentTypes() {
  123. return this.http
  124. .get<any>(`${environment.productionApiUrl}/tipos-instrumentos`, {})
  125. .pipe(
  126. map(response => {
  127. return response;
  128. }),
  129. catchError(this.errorHandl)
  130. );
  131. }
  132. // tipos-mercados
  133. getMarketTypes() {
  134. return this.http
  135. .get<any>(`${environment.productionApiUrl}/tipos-mercados`, {})
  136. .pipe(
  137. map(response => {
  138. return response;
  139. }),
  140. catchError(this.errorHandl)
  141. );
  142. }
  143. // tipos-operaciones
  144. getOperationTypes() {
  145. return this.http
  146. .get<any>(`${environment.productionApiUrl}/tipos-operaciones`, {})
  147. .pipe(
  148. map(response => {
  149. return response;
  150. }),
  151. catchError(this.errorHandl)
  152. );
  153. }
  154. // tipos-pagos
  155. getPaymentTypes() {
  156. return this.http
  157. .get<any>(`${environment.productionApiUrl}/tipos-pagos`, {})
  158. .pipe(
  159. map(response => {
  160. return response;
  161. }),
  162. catchError(this.errorHandl)
  163. );
  164. }
  165. // tipos-rentas
  166. getRevenueTypes() {
  167. return this.http
  168. .get<any>(`${environment.productionApiUrl}/tipos-rentas`, {})
  169. .pipe(
  170. map(response => {
  171. return response;
  172. }),
  173. catchError(this.errorHandl)
  174. );
  175. }
  176. // tipos-tasas
  177. getRateTypes() {
  178. return this.http
  179. .get<any>(`${environment.productionApiUrl}/tipos-tasas`, {})
  180. .pipe(
  181. map(response => {
  182. return response;
  183. }),
  184. catchError(this.errorHandl)
  185. );
  186. }
  187. // calificadoras
  188. getRateAgencies() {
  189. return this.http
  190. .get<any>(`${environment.productionApiUrl}/calificadoras`, {})
  191. .pipe(
  192. map(response => {
  193. return response;
  194. }),
  195. catchError(this.errorHandl)
  196. );
  197. }
  198. // calificaciones
  199. getScores() {
  200. return this.http
  201. .get<any>(`${environment.productionApiUrl}/calificaciones`, {})
  202. .pipe(
  203. map(response => {
  204. return response;
  205. }),
  206. catchError(this.errorHandl)
  207. );
  208. }
  209. // formato ingreso
  210. getIncomeFormat() {
  211. return this.http
  212. .get<any>(`${environment.productionApiUrl}/formato-ingresos`, {})
  213. .pipe(
  214. map(response => {
  215. return response;
  216. }),
  217. catchError(this.errorHandl)
  218. );
  219. }
  220. /**
  221. *
  222. * api/calificacion/<int:pk>
  223. ^ api/calificaciones
  224. ^ api/calificadora/<int:pk>
  225. ^ api/calificadoras
  226. ^ api/empresa/<int:pk>
  227. ^ api/empresas
  228. ^ api/entidad-financiera/<int:pk>
  229. ^ api/entidades-financieras
  230. ^ api/estado-inversion/<int:pk>
  231. ^ api/estados-inversiones
  232. *
  233. *
  234. *
  235. */
  236. //if(error.error instanceof ErrorEvent) {
  237. errorHandl(error) {
  238. let errorMessage = "";
  239. if (error.error) {
  240. // Get client-side error
  241. errorMessage = error.error;
  242. } else {
  243. // Get server-side error
  244. errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}`;
  245. }
  246. return throwError(errorMessage);
  247. }
  248. }