1+ using FiscalApi . Abstractions ;
2+ using System . Collections . Generic ;
3+ using System . Threading . Tasks ;
4+ using FiscalApi . Common ;
5+ using FiscalApi . Http ;
6+
7+ namespace FiscalApi . Services
8+ {
9+ public class CatalogService : BaseFiscalApiService < CatalogDto > , ICatalogService
10+ {
11+ public CatalogService ( IFiscalApiHttpClient httpClient , string apiVersion )
12+ : base ( httpClient , "catalogs" , apiVersion )
13+ {
14+ }
15+
16+ /// <summary>
17+ /// No se implementa la paginación.
18+ /// </summary>
19+ /// <param name="pageNumber"></param>
20+ /// <param name="pageSize"></param>
21+ /// <returns></returns>
22+ /// <exception cref="System.NotImplementedException"></exception>
23+ public override Task < ApiResponse < PagedList < CatalogDto > > > GetListAsync ( int pageNumber , int pageSize )
24+ {
25+ throw new System . NotImplementedException ( ) ;
26+ }
27+
28+ /// <summary>
29+ /// No se implementa la paginación.
30+ /// </summary>
31+ /// <param name="id"></param>
32+ /// <param name="entity"></param>
33+ /// <returns></returns>
34+ /// <exception cref="System.NotImplementedException"></exception>
35+ public override Task < ApiResponse < CatalogDto > > UpdateAsync ( string id , CatalogDto entity )
36+ {
37+ throw new System . NotImplementedException ( ) ;
38+ }
39+
40+ /// <summary>
41+ /// No se implementa la paginación.
42+ /// </summary>
43+ /// <param name="entity"></param>
44+ /// <returns></returns>
45+ /// <exception cref="System.NotImplementedException"></exception>
46+ public override Task < ApiResponse < CatalogDto > > CreateAsync ( CatalogDto entity )
47+ {
48+ throw new System . NotImplementedException ( ) ;
49+ }
50+
51+ /// <summary>
52+ /// No se implementa la paginación.
53+ /// </summary>
54+ /// <param name="id"></param>
55+ /// <returns></returns>
56+ /// <exception cref="System.NotImplementedException"></exception>
57+ public override Task < ApiResponse < bool > > DeleteAsync ( string id )
58+ {
59+ throw new System . NotImplementedException ( ) ;
60+ }
61+
62+
63+ /// <summary>
64+ /// Recupera todos los nombres de los catálogos disponibles para realizar búsquedas.
65+ /// </summary>
66+ /// <returns></returns>
67+ public Task < ApiResponse < List < string > > > GetListAsync ( )
68+ {
69+ return HttpClient . GetAsync < List < string > > ( BuildEndpoint ( ) ) ;
70+ }
71+
72+ /// <summary>
73+ /// Busca en un catálogo.
74+ /// </summary>
75+ /// <param name="catalogName">Catalog name. Must be a catalog retrieved from GetListAsync() </param>
76+ /// <param name="searchText">Criterio de búsqueda. Debe tener 4 caracteres de longitud como mínimo.</param>
77+ /// <param name="pageNumber">Numero de pagina a recuperar</param>
78+ /// <param name="pageSize">Tamaño de la página entre 1 y 100 registros por página. </param>
79+ /// <returns></returns>
80+ public async Task < ApiResponse < PagedList < CatalogDto > > > SearchCatalogAsync ( string catalogName , string searchText ,
81+ int pageNumber = 1 , int pageSize = 50 )
82+ {
83+ var path = $ "{ catalogName } /{ searchText } ";
84+ var queryParams = new Dictionary < string , string >
85+ {
86+ { "pageNumber" , pageNumber . ToString ( ) } ,
87+ { "pageSize" , pageSize . ToString ( ) }
88+ } ;
89+
90+ var endpoint = BuildEndpoint ( path , queryParams ) ;
91+
92+ var response = await HttpClient . GetAsync < PagedList < CatalogDto > > ( endpoint ) ;
93+ return response ;
94+ }
95+ }
96+ }
0 commit comments