Skip to content

Commit 6e1ad4f

Browse files
authored
Merge pull request #39 from raul-facturapi/chore/cartaporteCatalogs
feat(cartaporteCatalogs): add methods for searching cartaporte catalogs
2 parents fd35b31 + d8f1082 commit 6e1ad4f

File tree

5 files changed

+219
-1
lines changed

5 files changed

+219
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [4.11.0] = 2025-12-10
9+
10+
### Added
11+
12+
- Methods to carta porte catalogs
13+
- `SearchAirTranportCodes`, `SearchTransportConfigs`,`SearchRightsOfPassage`, `SearchCustomsDocuments`, `SearchPackagingTypes` `SearchTrailerTypes`, `SearchHazardousMaterials`, `SearchNavalAuthorizations`, `SearchPortStations`, `SearchMarineContainers`
14+
815
## [4.10.1] = 2025-10-23
916

1017
### Added

FacturapiClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class FacturapiClient
99
public Wrappers.ReceiptWrapper Receipt { get; private set; }
1010
public Wrappers.RetentionWrapper Retention { get; private set; }
1111
public Wrappers.CatalogWrapper Catalog { get; private set; }
12+
public Wrappers.CatalogWrapper CartaporteCatalog { get; private set; }
1213
public Wrappers.ToolWrapper Tool { get; private set; }
1314

1415
public FacturapiClient(string apiKey, string apiVersion = "v2")
@@ -20,6 +21,7 @@ public FacturapiClient(string apiKey, string apiVersion = "v2")
2021
this.Receipt = new Wrappers.ReceiptWrapper(apiKey, apiVersion);
2122
this.Retention = new Wrappers.RetentionWrapper(apiKey, apiVersion);
2223
this.Catalog = new Wrappers.CatalogWrapper(apiKey, apiVersion);
24+
this.CartaporteCatalog = new Wrappers.CatalogWrapper(apiKey, apiVersion);
2325
this.Tool = new Wrappers.ToolWrapper(apiKey, apiVersion);
2426
}
2527
}

Router/CartaporteCatalogRouter.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System.Collections.Generic;
2+
3+
namespace Facturapi
4+
{
5+
internal static partial class Router
6+
{
7+
// Carta Porte 3.1 catalogs
8+
public static string SearchCartaporteAirTransportCodes(Dictionary<string, object> query = null)
9+
{
10+
return UriWithQuery("catalogs/cartaporte/3.1/air-transport-codes", query);
11+
}
12+
13+
public static string SearchCartaporteTransportConfigs(Dictionary<string, object> query = null)
14+
{
15+
return UriWithQuery("catalogs/cartaporte/3.1/transport-configs", query);
16+
}
17+
18+
public static string SearchCartaporteRightsOfPassage(Dictionary<string, object> query = null)
19+
{
20+
return UriWithQuery("catalogs/cartaporte/3.1/rights-of-passage", query);
21+
}
22+
23+
public static string SearchCartaporteCustomsDocuments(Dictionary<string, object> query = null)
24+
{
25+
return UriWithQuery("catalogs/cartaporte/3.1/customs-documents", query);
26+
}
27+
28+
public static string SearchCartaportePackagingTypes(Dictionary<string, object> query = null)
29+
{
30+
return UriWithQuery("catalogs/cartaporte/3.1/packaging-types", query);
31+
}
32+
33+
public static string SearchCartaporteTrailerTypes(Dictionary<string, object> query = null)
34+
{
35+
return UriWithQuery("catalogs/cartaporte/3.1/trailer-types", query);
36+
}
37+
38+
public static string SearchCartaporteHazardousMaterials(Dictionary<string, object> query = null)
39+
{
40+
return UriWithQuery("catalogs/cartaporte/3.1/hazardous-materials", query);
41+
}
42+
43+
public static string SearchCartaporteNavalAuthorizations(Dictionary<string, object> query = null)
44+
{
45+
return UriWithQuery("catalogs/cartaporte/3.1/naval-authorizations", query);
46+
}
47+
48+
public static string SearchCartaportePortStations(Dictionary<string, object> query = null)
49+
{
50+
return UriWithQuery("catalogs/cartaporte/3.1/port-stations", query);
51+
}
52+
53+
public static string SearchCartaporteMarineContainers(Dictionary<string, object> query = null)
54+
{
55+
return UriWithQuery("catalogs/cartaporte/3.1/marine-containers", query);
56+
}
57+
}
58+
}

Wrappers/CatalogWrapper.cs

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,156 @@ public async Task<SearchResult<CatalogItem>> SearchUnits(Dictionary<string, obje
4242
var searchResult = JsonConvert.DeserializeObject<SearchResult<CatalogItem>>(resultString, this.jsonSettings);
4343
return searchResult;
4444
}
45+
46+
// Carta Porte catalogs
47+
public async Task<SearchResult<CatalogItem>> SearchAirTransportCodes(Dictionary<string, object> query = null)
48+
{
49+
var response = await client.GetAsync(Router.SearchCartaporteAirTransportCodes(query));
50+
var resultString = await response.Content.ReadAsStringAsync();
51+
52+
if (!response.IsSuccessStatusCode)
53+
{
54+
var error = JsonConvert.DeserializeObject<JObject>(resultString, this.jsonSettings);
55+
throw new FacturapiException(error["message"].ToString());
56+
}
57+
58+
var searchResult = JsonConvert.DeserializeObject<SearchResult<CatalogItem>>(resultString, this.jsonSettings);
59+
return searchResult;
60+
}
61+
62+
public async Task<SearchResult<CatalogItem>> SearchTransportConfigs(Dictionary<string, object> query = null)
63+
{
64+
var response = await client.GetAsync(Router.SearchCartaporteTransportConfigs(query));
65+
var resultString = await response.Content.ReadAsStringAsync();
66+
67+
if (!response.IsSuccessStatusCode)
68+
{
69+
var error = JsonConvert.DeserializeObject<JObject>(resultString, this.jsonSettings);
70+
throw new FacturapiException(error["message"].ToString());
71+
}
72+
73+
var searchResult = JsonConvert.DeserializeObject<SearchResult<CatalogItem>>(resultString, this.jsonSettings);
74+
return searchResult;
75+
}
76+
77+
public async Task<SearchResult<CatalogItem>> SearchRightsOfPassage(Dictionary<string, object> query = null)
78+
{
79+
var response = await client.GetAsync(Router.SearchCartaporteRightsOfPassage(query));
80+
var resultString = await response.Content.ReadAsStringAsync();
81+
82+
if (!response.IsSuccessStatusCode)
83+
{
84+
var error = JsonConvert.DeserializeObject<JObject>(resultString, this.jsonSettings);
85+
throw new FacturapiException(error["message"].ToString());
86+
}
87+
88+
var searchResult = JsonConvert.DeserializeObject<SearchResult<CatalogItem>>(resultString, this.jsonSettings);
89+
return searchResult;
90+
}
91+
92+
public async Task<SearchResult<CatalogItem>> SearchCustomsDocuments(Dictionary<string, object> query = null)
93+
{
94+
var response = await client.GetAsync(Router.SearchCartaporteCustomsDocuments(query));
95+
var resultString = await response.Content.ReadAsStringAsync();
96+
97+
if (!response.IsSuccessStatusCode)
98+
{
99+
var error = JsonConvert.DeserializeObject<JObject>(resultString, this.jsonSettings);
100+
throw new FacturapiException(error["message"].ToString());
101+
}
102+
103+
var searchResult = JsonConvert.DeserializeObject<SearchResult<CatalogItem>>(resultString, this.jsonSettings);
104+
return searchResult;
105+
}
106+
107+
public async Task<SearchResult<CatalogItem>> SearchPackagingTypes(Dictionary<string, object> query = null)
108+
{
109+
var response = await client.GetAsync(Router.SearchCartaportePackagingTypes(query));
110+
var resultString = await response.Content.ReadAsStringAsync();
111+
112+
if (!response.IsSuccessStatusCode)
113+
{
114+
var error = JsonConvert.DeserializeObject<JObject>(resultString, this.jsonSettings);
115+
throw new FacturapiException(error["message"].ToString());
116+
}
117+
118+
var searchResult = JsonConvert.DeserializeObject<SearchResult<CatalogItem>>(resultString, this.jsonSettings);
119+
return searchResult;
120+
}
121+
122+
public async Task<SearchResult<CatalogItem>> SearchTrailerTypes(Dictionary<string, object> query = null)
123+
{
124+
var response = await client.GetAsync(Router.SearchCartaporteTrailerTypes(query));
125+
var resultString = await response.Content.ReadAsStringAsync();
126+
127+
if (!response.IsSuccessStatusCode)
128+
{
129+
var error = JsonConvert.DeserializeObject<JObject>(resultString, this.jsonSettings);
130+
throw new FacturapiException(error["message"].ToString());
131+
}
132+
133+
var searchResult = JsonConvert.DeserializeObject<SearchResult<CatalogItem>>(resultString, this.jsonSettings);
134+
return searchResult;
135+
}
136+
137+
public async Task<SearchResult<CatalogItem>> SearchHazardousMaterials(Dictionary<string, object> query = null)
138+
{
139+
var response = await client.GetAsync(Router.SearchCartaporteHazardousMaterials(query));
140+
var resultString = await response.Content.ReadAsStringAsync();
141+
142+
if (!response.IsSuccessStatusCode)
143+
{
144+
var error = JsonConvert.DeserializeObject<JObject>(resultString, this.jsonSettings);
145+
throw new FacturapiException(error["message"].ToString());
146+
}
147+
148+
var searchResult = JsonConvert.DeserializeObject<SearchResult<CatalogItem>>(resultString, this.jsonSettings);
149+
return searchResult;
150+
}
151+
152+
public async Task<SearchResult<CatalogItem>> SearchNavalAuthorizations(Dictionary<string, object> query = null)
153+
{
154+
var response = await client.GetAsync(Router.SearchCartaporteNavalAuthorizations(query));
155+
var resultString = await response.Content.ReadAsStringAsync();
156+
157+
if (!response.IsSuccessStatusCode)
158+
{
159+
var error = JsonConvert.DeserializeObject<JObject>(resultString, this.jsonSettings);
160+
throw new FacturapiException(error["message"].ToString());
161+
}
162+
163+
var searchResult = JsonConvert.DeserializeObject<SearchResult<CatalogItem>>(resultString, this.jsonSettings);
164+
return searchResult;
165+
}
166+
167+
public async Task<SearchResult<CatalogItem>> SearchPortStations(Dictionary<string, object> query = null)
168+
{
169+
var response = await client.GetAsync(Router.SearchCartaportePortStations(query));
170+
var resultString = await response.Content.ReadAsStringAsync();
171+
172+
if (!response.IsSuccessStatusCode)
173+
{
174+
var error = JsonConvert.DeserializeObject<JObject>(resultString, this.jsonSettings);
175+
throw new FacturapiException(error["message"].ToString());
176+
}
177+
178+
var searchResult = JsonConvert.DeserializeObject<SearchResult<CatalogItem>>(resultString, this.jsonSettings);
179+
return searchResult;
180+
}
181+
182+
public async Task<SearchResult<CatalogItem>> SearchMarineContainers(Dictionary<string, object> query = null)
183+
{
184+
var response = await client.GetAsync(Router.SearchCartaporteMarineContainers(query));
185+
var resultString = await response.Content.ReadAsStringAsync();
186+
187+
if (!response.IsSuccessStatusCode)
188+
{
189+
var error = JsonConvert.DeserializeObject<JObject>(resultString, this.jsonSettings);
190+
throw new FacturapiException(error["message"].ToString());
191+
}
192+
193+
var searchResult = JsonConvert.DeserializeObject<SearchResult<CatalogItem>>(resultString, this.jsonSettings);
194+
return searchResult;
195+
}
45196
}
46197
}

facturapi-net.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
API Keys creando una cuenta gratuita en https://www.facturapi.io</Summary>
1212
<PackageTags>factura factura-electronica cfdi facturapi mexico conekta</PackageTags>
1313
<Title>Facturapi</Title>
14-
<Version>4.10.1</Version>
14+
<Version>4.11.0</Version>
1515
<PackageVersion>$(Version)</PackageVersion>
1616
<Owners>Facturapi</Owners>
1717
<ApplicationIcon>facturapi.ico</ApplicationIcon>

0 commit comments

Comments
 (0)