22using System . Collections . Generic ;
33using System . Net . Http ;
44using System . Threading . Tasks ;
5+ using System . Threading ;
56
67namespace Facturapi . Wrappers
78{
@@ -11,72 +12,72 @@ internal CatalogWrapper(string apiKey, string apiVersion, HttpClient httpClient)
1112 {
1213 }
1314
14- public async Task < SearchResult < CatalogItem > > SearchProducts ( Dictionary < string , object > query = null )
15+ public async Task < SearchResult < CatalogItem > > SearchProducts ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
1516 {
16- return await this . SearchCatalogAsync ( Router . SearchProductKeys ( query ) ) ;
17+ return await this . SearchCatalogAsync ( Router . SearchProductKeys ( query ) , cancellationToken ) ;
1718 }
1819
19- public async Task < SearchResult < CatalogItem > > SearchUnits ( Dictionary < string , object > query = null )
20+ public async Task < SearchResult < CatalogItem > > SearchUnits ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
2021 {
21- return await this . SearchCatalogAsync ( Router . SearchUnitKeys ( query ) ) ;
22+ return await this . SearchCatalogAsync ( Router . SearchUnitKeys ( query ) , cancellationToken ) ;
2223 }
2324
2425 // Carta Porte catalogs
25- public async Task < SearchResult < CatalogItem > > SearchAirTransportCodes ( Dictionary < string , object > query = null )
26+ public async Task < SearchResult < CatalogItem > > SearchAirTransportCodes ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
2627 {
27- return await this . SearchCatalogAsync ( Router . SearchCartaporteAirTransportCodes ( query ) ) ;
28+ return await this . SearchCatalogAsync ( Router . SearchCartaporteAirTransportCodes ( query ) , cancellationToken ) ;
2829 }
2930
30- public async Task < SearchResult < CatalogItem > > SearchTransportConfigs ( Dictionary < string , object > query = null )
31+ public async Task < SearchResult < CatalogItem > > SearchTransportConfigs ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
3132 {
32- return await this . SearchCatalogAsync ( Router . SearchCartaporteTransportConfigs ( query ) ) ;
33+ return await this . SearchCatalogAsync ( Router . SearchCartaporteTransportConfigs ( query ) , cancellationToken ) ;
3334 }
3435
35- public async Task < SearchResult < CatalogItem > > SearchRightsOfPassage ( Dictionary < string , object > query = null )
36+ public async Task < SearchResult < CatalogItem > > SearchRightsOfPassage ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
3637 {
37- return await this . SearchCatalogAsync ( Router . SearchCartaporteRightsOfPassage ( query ) ) ;
38+ return await this . SearchCatalogAsync ( Router . SearchCartaporteRightsOfPassage ( query ) , cancellationToken ) ;
3839 }
3940
40- public async Task < SearchResult < CatalogItem > > SearchCustomsDocuments ( Dictionary < string , object > query = null )
41+ public async Task < SearchResult < CatalogItem > > SearchCustomsDocuments ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
4142 {
42- return await this . SearchCatalogAsync ( Router . SearchCartaporteCustomsDocuments ( query ) ) ;
43+ return await this . SearchCatalogAsync ( Router . SearchCartaporteCustomsDocuments ( query ) , cancellationToken ) ;
4344 }
4445
45- public async Task < SearchResult < CatalogItem > > SearchPackagingTypes ( Dictionary < string , object > query = null )
46+ public async Task < SearchResult < CatalogItem > > SearchPackagingTypes ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
4647 {
47- return await this . SearchCatalogAsync ( Router . SearchCartaportePackagingTypes ( query ) ) ;
48+ return await this . SearchCatalogAsync ( Router . SearchCartaportePackagingTypes ( query ) , cancellationToken ) ;
4849 }
4950
50- public async Task < SearchResult < CatalogItem > > SearchTrailerTypes ( Dictionary < string , object > query = null )
51+ public async Task < SearchResult < CatalogItem > > SearchTrailerTypes ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
5152 {
52- return await this . SearchCatalogAsync ( Router . SearchCartaporteTrailerTypes ( query ) ) ;
53+ return await this . SearchCatalogAsync ( Router . SearchCartaporteTrailerTypes ( query ) , cancellationToken ) ;
5354 }
5455
55- public async Task < SearchResult < CatalogItem > > SearchHazardousMaterials ( Dictionary < string , object > query = null )
56+ public async Task < SearchResult < CatalogItem > > SearchHazardousMaterials ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
5657 {
57- return await this . SearchCatalogAsync ( Router . SearchCartaporteHazardousMaterials ( query ) ) ;
58+ return await this . SearchCatalogAsync ( Router . SearchCartaporteHazardousMaterials ( query ) , cancellationToken ) ;
5859 }
5960
60- public async Task < SearchResult < CatalogItem > > SearchNavalAuthorizations ( Dictionary < string , object > query = null )
61+ public async Task < SearchResult < CatalogItem > > SearchNavalAuthorizations ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
6162 {
62- return await this . SearchCatalogAsync ( Router . SearchCartaporteNavalAuthorizations ( query ) ) ;
63+ return await this . SearchCatalogAsync ( Router . SearchCartaporteNavalAuthorizations ( query ) , cancellationToken ) ;
6364 }
6465
65- public async Task < SearchResult < CatalogItem > > SearchPortStations ( Dictionary < string , object > query = null )
66+ public async Task < SearchResult < CatalogItem > > SearchPortStations ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
6667 {
67- return await this . SearchCatalogAsync ( Router . SearchCartaportePortStations ( query ) ) ;
68+ return await this . SearchCatalogAsync ( Router . SearchCartaportePortStations ( query ) , cancellationToken ) ;
6869 }
6970
70- public async Task < SearchResult < CatalogItem > > SearchMarineContainers ( Dictionary < string , object > query = null )
71+ public async Task < SearchResult < CatalogItem > > SearchMarineContainers ( Dictionary < string , object > query = null , CancellationToken cancellationToken = default )
7172 {
72- return await this . SearchCatalogAsync ( Router . SearchCartaporteMarineContainers ( query ) ) ;
73+ return await this . SearchCatalogAsync ( Router . SearchCartaporteMarineContainers ( query ) , cancellationToken ) ;
7374 }
7475
75- private async Task < SearchResult < CatalogItem > > SearchCatalogAsync ( string url )
76+ private async Task < SearchResult < CatalogItem > > SearchCatalogAsync ( string url , CancellationToken cancellationToken )
7677 {
77- using ( var response = await client . GetAsync ( url ) )
78+ using ( var response = await client . GetAsync ( url , cancellationToken ) )
7879 {
79- await this . ThrowIfErrorAsync ( response ) ;
80+ await this . ThrowIfErrorAsync ( response , cancellationToken ) ;
8081 var resultString = await response . Content . ReadAsStringAsync ( ) ;
8182 var searchResult = JsonConvert . DeserializeObject < SearchResult < CatalogItem > > ( resultString , this . jsonSettings ) ;
8283 return searchResult ;
0 commit comments