Skip to content

Commit 7c3e163

Browse files
authored
Merge pull request #13 from Mteheran/develop
Moving changes to main
2 parents a6957d5 + 44f835b commit 7c3e163

File tree

9 files changed

+106
-22
lines changed

9 files changed

+106
-22
lines changed

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
"contributions": [
4747
"code"
4848
]
49+
},
50+
{
51+
"login": "Alejandrohv06",
52+
"name": "Alejandro Herreño",
53+
"avatar_url": "https://avatars.githubusercontent.com/u/99321349?v=4",
54+
"profile": "https://www.linkedin.com/in/alejandrohv/",
55+
"contributions": [
56+
"doc",
57+
"code"
58+
]
4959
}
5060
],
5161
"contributorsPerLine": 7,

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,4 @@ MigrationBackup/
348348

349349
# Ionide (cross platform F# VS Code tools) working folder
350350
.ionide/
351+
api/appsettings.Development.json

README.md

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,64 @@
1-
# api-colombia
2-
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
3-
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
4-
<!-- ALL-CONTRIBUTORS-BADGE:END -->
5-
public api that contains info about Colombia, departments, cities, tourists places and presidents
1+
# API-COLOMBIA
62

7-
## Contributors ✨
3+
## Introduction
4+
API Colombia is a public RESTful API that enable users to obtain a variety of public information about the country "Colombia".
85

9-
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
6+
## Project Support Features
7+
* Minimal API's endpoints to get information about:
8+
- General information about the country.
9+
- Departments/States.
10+
- Cities.
11+
- Presidents.
12+
- Tourist attractions.
13+
* Swagger documentation
14+
* Does not requiere authentication.
15+
## Versions
16+
* 1.0
17+
## Installation Guide
18+
* Clone this repository [here](https://github.com/Mteheran/api-colombia).
19+
* The develop branch is the most stable branch at any given time, ensure you're working from it.
20+
* [.NET CORE SDK ](https://dotnet.microsoft.com/en-us/download) must be installed in the machine.
21+
* Update the connection string to your prefered database in the "appsettings.json" file.
22+
* Run `dotnet build` command to generate the build of the project.
23+
24+
## Usage
25+
Public URL: TBD
26+
* Swagger documentation can be found in the URL: "{PUBLIC_URL}/swagger/index.html"
27+
28+
## API Endpoints
29+
| HTTP Verbs | Endpoints | Action |
30+
| ---------- | ------------------------------------- | -------------------------------------------------------------------- |
31+
| GET | /api/{version}/city | Get the list of all the cities |
32+
| GET | /api/{version}/city/{id} | Get the information of a city by it is id |
33+
| GET | /api/{version}/city/name/{name} | Get the information of a city by it is name |
34+
| GET | /api/{version}/country/Colombia | Get the information of Colombia |
35+
| GET | /api/{version}/Department | Get the list of all the departments in Colombia |
36+
| GET | /api/{version}/Department/{id} | Get the information of a department by it is id |
37+
| GET | /api/{version}/Department/name/{name} | Get the information of a department by it is name |
38+
| GET | /api/{version}/President | Get the list of all the presidents in Colombia |
39+
| GET | /api/{version}/President/{id} | Get the information of a president by it is id |
40+
| GET | /api/{version}/President/name/{name} | Get the information of a president by it is name |
41+
| GET | /api/{version}/President/year/{name} | Get the information of a president that ruled during a specific year |
42+
| GET | /api/{version}/TouristicAttraction | Get the list of all the touristic attractions in Colombia |
43+
| GET | /api/{version}/TouristicAttraction/{id} | Get the information of a touristic attraction by it is id |
44+
| GET | /api/{version}/TouristicAttraction/name/{name} | Get the information of a touristic attaction by it is name |
1045

46+
## Response Example
47+
* Content type: "application/json". Responses are JSON Objects.
48+
* Response header contains the HTTP CODE with the status.
49+
* Example:
50+
51+
>{"id":1,"name":"Colombia","description":"Colombia, officially the Republic of Colombia, is a country in South America with insular regions in North America—near Nicaragua's Caribbean coast—as well as in the Pacific Ocean. The Colombian mainland is bordered by the Caribbean Sea to the north, Venezuela to the east and northeast, Brazil to the southeast, Ecuador and Peru to the south and southwest, the Pacific Ocean to the west, and Panama to the northwest. Colombia is divided into 32 departments and the Capital District of Bogotá, the country's largest city. It covers an area of 1,141,748 square kilometers (440,831 sq mi), and has a population of 52 million. Colombia's cultural heritage—including language, religion, cuisine, and art—reflects its history as a Spanish colony, fusing cultural elements brought by immigration from Europe and the Middle East, with those brought by enslaved Africans, as well as with those of the various Indigenous civilizations that predate colonization. Spanish is the official state language, although English and 64 other languages are recognized regional languages.","stateCapital":"Bogotá","surface":1141748,"population":52235050,"languages":["Spanish","English"],"timeZone":"UTC-5","currency":"Colombian Peso","currencyCode":"COP","isoCode":"CO","internetDomain":".co","phonePrefix":"+57","radioPrefix":"HK","aircraftPrefix":"HK"}
52+
## Technologies Used
53+
* [.NET Core 6.*](https://dotnet.microsoft.com/en-us/) is a free, cross-platform, open source developer platform for building many kinds of applications. .NET is built on a high-performance runtime that is used in production by many high-scale apps.
54+
* [PostgreSQL](https://www.postgresql.org/) is a powerful, open source object-relational database system with over 35 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.
55+
* [Microsoft Azure](https://azure.microsoft.com/en-us/resources/cloud-computing-dictionary/what-is-azure/) The Azure cloud platform is more than 200 products and cloud services designed to help you bring new solutions to life—to solve today’s challenges and create the future. Build, run, and manage applications across multiple clouds, on-premises, and at the edge, with the tools and frameworks of your choice.
56+
57+
## Contributors ✨
58+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
59+
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)
60+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
61+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
1162
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
1263
<!-- prettier-ignore-start -->
1364
<!-- markdownlint-disable -->
@@ -18,6 +69,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
1869
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/rina-plata/"><img src="https://avatars.githubusercontent.com/u/55161289?v=4?s=100" width="100px;" alt="Rina Plata"/><br /><sub><b>Rina Plata</b></sub></a><br /><a href="https://github.com/Mteheran/api-colombia/mteheran/api-colombia/commits?author=rinaplata" title="Documentation">📖</a> <a href="#tutorial-rinaplata" title="Tutorials">✅</a></td>
1970
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/veronicaguaman/"><img src="https://avatars.githubusercontent.com/u/70024610?v=4?s=100" width="100px;" alt="Veronica Guaman"/><br /><sub><b>Veronica Guaman</b></sub></a><br /><a href="https://github.com/Mteheran/api-colombia/mteheran/api-colombia/commits?author=VeronicaGuaman" title="Code">💻</a></td>
2071
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/mariobot/"><img src="https://avatars.githubusercontent.com/u/1220191?v=4?s=100" width="100px;" alt="Mario Botero"/><br /><sub><b>Mario Botero</b></sub></a><br /><a href="https://github.com/Mteheran/api-colombia/mteheran/api-colombia/commits?author=mariobot" title="Code">💻</a></td>
72+
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/alejandrohv/"><img src="https://avatars.githubusercontent.com/u/99321349?v=4?s=100" width="100px;" alt="Alejandro Herreño"/><br /><sub><b>Alejandro Herreño</b></sub></a><br /><a href="https://github.com/Mteheran/api-colombia/mteheran/api-colombia/commits?author=Alejandrohv06" title="Documentation">📖</a> <a href="https://github.com/Mteheran/api-colombia/mteheran/api-colombia/commits?author=Alejandrohv06" title="Code">💻</a></td>
2173
</tr>
2274
</tbody>
2375
<tfoot>
@@ -36,4 +88,6 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
3688

3789
<!-- ALL-CONTRIBUTORS-LIST:END -->
3890

39-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
91+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
92+
## License
93+
*Open Source*

api/Program.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222
});
2323
});
2424

25+
builder.Services.AddCors(options =>
26+
{
27+
options.AddPolicy(name: "corsApiColombia",
28+
policy =>
29+
{
30+
policy.WithMethods("GET");
31+
policy.AllowAnyOrigin();
32+
});
33+
});
34+
35+
2536
builder.Configuration.AddEnvironmentVariables();
2637

2738
builder.Services.AddNpgsql<DBContext>(builder.Configuration.GetConnectionString("DefaultConnection"));
@@ -37,6 +48,7 @@
3748

3849
app.UseDefaultFiles();
3950
app.UseStaticFiles();
51+
app.UseCors("corsApiColombia");
4052
app.UseSwagger();
4153
app.UseSwaggerUI();
4254

api/Routes/CityRoutes.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static void RegisterCityAPI(WebApplication app)
1313
return Results.Ok(db.Cities.ToList());
1414
});
1515

16-
app.MapGet($"{API_CITY_ROUTE_COMPLETE}/{Util.QP_ID}", async (int id, DBContext db) =>
16+
app.MapGet($"{API_CITY_ROUTE_COMPLETE}/{{id}}", async (int id, DBContext db) =>
1717
{
1818
var city = await db.Cities.FindAsync(id);
1919

@@ -25,7 +25,7 @@ public static void RegisterCityAPI(WebApplication app)
2525
return Results.Ok(city);
2626
});
2727

28-
app.MapGet($"{API_CITY_ROUTE_COMPLETE}/{Util.QP_NAME}", (string name, DBContext db) =>
28+
app.MapGet($"{API_CITY_ROUTE_COMPLETE}/name/{{name}}", (string name, DBContext db) =>
2929
{
3030
var city = db.Cities.Where(x => x.Name.ToUpper().Equals(name.Trim().ToUpper())).ToList();
3131

api/Routes/DepartmentRoutes.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static void RegisterDepartmentAPI(WebApplication app)
1313
return Results.Ok(db.Departments.ToList());
1414
});
1515

16-
app.MapGet($"{API_DEPARTMENT_ROUTE_COMPLETE}/{Util.QP_ID}", async (int id, DBContext db) =>
16+
app.MapGet($"{API_DEPARTMENT_ROUTE_COMPLETE}/{{id}}", async (int id, DBContext db) =>
1717
{
1818
var departament = await db.Departments.FindAsync(id);
1919

@@ -25,7 +25,7 @@ public static void RegisterDepartmentAPI(WebApplication app)
2525
return Results.Ok(departament);
2626
});
2727

28-
app.MapGet($"{API_DEPARTMENT_ROUTE_COMPLETE}/{Util.NAME}/{Util.QP_NAME}", (string name, DBContext db) =>
28+
app.MapGet($"{API_DEPARTMENT_ROUTE_COMPLETE}/name/{{name}}", (string name, DBContext db) =>
2929
{
3030
var departments = db.Departments.Where(x => x.Name!.ToUpper().Equals(name.Trim().ToUpper())).ToList();
3131

api/Routes/PresidentRoutes.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static void RegisterPresidentApi(WebApplication app)
1313
return Results.Ok(db.Presidents.ToList());
1414
});
1515

16-
app.MapGet($"{API_DEPARTMENT_ROUTE_COMPLETE}/{Util.QP_ID}", async (int id, DBContext db) =>
16+
app.MapGet($"{API_DEPARTMENT_ROUTE_COMPLETE}/{{id}}", async (int id, DBContext db) =>
1717
{
1818
var president = await db.Presidents.FindAsync(id);
1919

@@ -25,7 +25,7 @@ public static void RegisterPresidentApi(WebApplication app)
2525
return Results.Ok(president);
2626
});
2727

28-
app.MapGet($"{API_DEPARTMENT_ROUTE_COMPLETE}/{Util.NAME}/{Util.QP_NAME}", (string name, DBContext db) =>
28+
app.MapGet($"{API_DEPARTMENT_ROUTE_COMPLETE}/name/{{name}}", (string name, DBContext db) =>
2929
{
3030
var president = db.Presidents.Where(x => x.Name!.ToUpper().Equals(name.Trim().ToUpper())).ToList();
3131

@@ -36,6 +36,16 @@ public static void RegisterPresidentApi(WebApplication app)
3636

3737
return Results.Ok(president);
3838
});
39+
40+
41+
app.MapGet($"{API_DEPARTMENT_ROUTE_COMPLETE}/year/{{year}}", async (int year, DBContext db) =>
42+
{
43+
var presidents = db.Presidents
44+
.Where(p=> p.StartPeriodDate.Year >= year
45+
&& p.EndPeriodDate.Year <= year);
46+
47+
return Results.Ok(presidents);
48+
});
3949
}
4050
}
4151
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ public static class TuristicAttactionRoutes
66
{
77
public static void RegisterTuristicAttactionAPI(WebApplication app)
88
{
9-
const string API_DEPARTMENT_ROUTE_COMPLETE = $"{Util.API_ROUTE}{Util.API_VERSION}{Util.TURISTIC_ROUTE}";
9+
const string API_TOURISTIC_ROUTE_COMPLETE = $"{Util.API_ROUTE}{Util.API_VERSION}{Util.TOURISTIC_ROUTE}";
1010

11-
app.MapGet(API_DEPARTMENT_ROUTE_COMPLETE, (DBContext db) =>
11+
app.MapGet(API_TOURISTIC_ROUTE_COMPLETE, (DBContext db) =>
1212
{
1313
return Results.Ok(db.TouristAttractions.ToList());
1414
});
1515

16-
app.MapGet($"{API_DEPARTMENT_ROUTE_COMPLETE}/{Util.QP_ID}", async (int id, DBContext db) =>
16+
app.MapGet($"{API_TOURISTIC_ROUTE_COMPLETE}/{{id}}", async (int id, DBContext db) =>
1717
{
1818
var turisticAtt = await db.TouristAttractions.FindAsync(id);
1919

@@ -25,7 +25,7 @@ public static void RegisterTuristicAttactionAPI(WebApplication app)
2525
return Results.Ok(turisticAtt);
2626
});
2727

28-
app.MapGet($"{API_DEPARTMENT_ROUTE_COMPLETE}/{Util.NAME}/{Util.QP_NAME}", (string name, DBContext db) =>
28+
app.MapGet($"{API_TOURISTIC_ROUTE_COMPLETE}/name/{{name}}", (string name, DBContext db) =>
2929
{
3030
var turisticAtt = db.TouristAttractions.Where(x => x.Name!.ToUpper().Equals(name.ToUpper())).ToList();
3131

api/Utils/Util.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@ public static class Util
66
public const string COUNTRY_ROUTE = "Country";
77
public const string DEPARTMENT_ROUTE = "Department";
88
public const string PRESIDENT_ROUTE = "President";
9-
public const string TURISTIC_ROUTE = "TurusticAttaction";
9+
public const string TOURISTIC_ROUTE = "TouristicAttraction";
1010

1111
public const string API_ROUTE = "api/";
1212
public const string API_VERSION = "v1/";
13-
public const string NAME = "Name";
14-
public const string QP_ID = "Name";
15-
public const string QP_NAME = "name";
1613

1714
public const string COLOMBIA = "Colombia";
1815
}

0 commit comments

Comments
 (0)