Skip to content

Commit 7ede184

Browse files
committed
Winforms samples updated
1 parent 7c7454f commit 7ede184

File tree

8 files changed

+118
-16
lines changed

8 files changed

+118
-16
lines changed

Abstractions/ICatalogService.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using FiscalApi.Common;
4+
5+
namespace FiscalApi.Abstractions
6+
{
7+
public interface ICatalogService : IFiscalApiService<CatalogDto>
8+
{
9+
//GET /api/v4/catalogs
10+
Task<ApiResponse<List<string>>> GetListAsync();
11+
12+
13+
//GET /api/v4/catalogs/{catalogName}/{searchText}
14+
Task<ApiResponse<PagedList<CatalogDto>>> SearchCatalogAsync(string catalogName, string searchText,
15+
int pageNumber = 1,
16+
int pageSize = 50);
17+
}
18+
}

Abstractions/IFiscalApiClient.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ public interface IFiscalApiClient
66
IPersonService Persons { get; }
77
IProductService Products { get; }
88
IApiKeyService ApiKeys { get; }
9-
10-
//IUserService Users { get; }
11-
//ICustomerService Customers { get; }
9+
ICatalogService Catalogs { get; }
1210
}
1311
}

Abstractions/IPersonService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using FiscalApi.Models;
33
using System.Threading.Tasks;
44
using FiscalApi.Common;
5-
using System.Net.Http;
65

76
namespace FiscalApi.Abstractions
87
{

Common/ApiResponse.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using Newtonsoft.Json;
2-
using System;
3-
using Newtonsoft.Json.Linq;
4-
51
namespace FiscalApi.Common
62
{
73
public class ApiResponse<T>

Models/TaxFile.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42
using FiscalApi.Common;
53
using Newtonsoft.Json;
64

Services/ApiKeyService.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Threading.Tasks;
5-
using FiscalApi.Abstractions;
6-
using FiscalApi.Common;
1+
using FiscalApi.Abstractions;
72
using FiscalApi.Http;
83
using FiscalApi.Models;
94

Services/CatalogService.cs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
}

Services/FiscalApiClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class FiscalApiClient : IFiscalApiClient
1212
public IProductService Products { get; }
1313
public IPersonService Persons { get; }
1414
public IApiKeyService ApiKeys { get; }
15+
public ICatalogService Catalogs { get; }
1516

1617

1718
private FiscalApiClient(FiscalApiOptions settings)
@@ -25,6 +26,7 @@ private FiscalApiClient(FiscalApiOptions settings)
2526
Products = new ProductService(httpClient, apiVersion);
2627
Persons = new PersonService(httpClient, apiVersion);
2728
ApiKeys = new ApiKeyService(httpClient, apiVersion);
29+
Catalogs = new CatalogService(httpClient, apiVersion);
2830
}
2931

3032
public static IFiscalApiClient Create(FiscalApiOptions settings)

0 commit comments

Comments
 (0)