Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Commit dd9db10

Browse files
authored
Merge pull request #27 from Virtual-Finland-Development/VFD-220-luodaan-testbed-api-projektiin-endpointit-nsg-datamaarittelyja-varten
Added endpoints for NSG data products
2 parents f89dfd8 + 4082c45 commit dd9db10

6 files changed

Lines changed: 140 additions & 1 deletion

File tree

src/lib/api_app/src/api/routes/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ pub mod testbed;
3434
testbed::productizers::person::basic_information::get_basic_information,
3535
testbed::productizers::person::basic_information::write_basic_information,
3636
testbed::productizers::person::job_applicant_profile::get_job_applicant_profile,
37-
testbed::productizers::person::job_applicant_profile::write_job_applicant_profile
37+
testbed::productizers::person::job_applicant_profile::write_job_applicant_profile,
38+
testbed::productizers::non_listed_company::establishment::write_establishment,
39+
testbed::productizers::non_listed_company::beneficial_owners::get_beneficial_owners,
40+
testbed::productizers::non_listed_company::signatory_rights::get_signatory_rights
3841
),
3942
components(schemas( // @TODO: would be very nice to auto-generate schemas
4043
testbed::ProxyRequestInput,

src/lib/api_app/src/api/routes/testbed/productizers/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub mod figure;
88
pub mod job;
99
pub mod person;
1010
pub mod user;
11+
pub mod non_listed_company;
1112

1213
/**
1314
* Parses the authorization headers from the input request
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use app::{
2+
responses::APIResponse,
3+
router::ParsedRequest
4+
};
5+
6+
#[utoipa::path(
7+
post,
8+
path = "/testbed/productizer/non-listed-company/beneficial-owners",
9+
request_body(
10+
content = Object,
11+
description = "Get beneficial owners information",
12+
examples(( "Success" = (
13+
summary = "JSON example",
14+
value = json!("Loading..."),
15+
external_value = "https://raw.githubusercontent.com/Virtual-Finland/definitions/main/DataProducts/draft/NSG/Agent/LegalEntity/NonListedCompany/BeneficialOwners.json"
16+
)))
17+
),
18+
responses((
19+
status = 200,
20+
body = Object,
21+
description = "Beneficial owners response",
22+
examples(( "Success" = (
23+
summary = "JSON example",
24+
value = json!("Loading..."),
25+
external_value = "https://raw.githubusercontent.com/Virtual-Finland/definitions/main/DataProducts/draft/NSG/Agent/LegalEntity/NonListedCompany/BeneficialOwners.json"
26+
)))
27+
)),
28+
security(( "BearerAuth" = [] ))
29+
)]
30+
pub async fn get_beneficial_owners(request: ParsedRequest) -> APIResponse {
31+
let data_product = "draft/NSG/Agent/LegalEntity/NonListedCompany/BeneficialOwners";
32+
let data_source = "virtualfinland";
33+
let result = super::post_data_product(data_product, data_source, request).await?;
34+
Ok(result)
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use app::{
2+
responses::APIResponse,
3+
router::ParsedRequest
4+
};
5+
6+
#[utoipa::path(
7+
post,
8+
path = "/testbed/productizer/non-listed-company/establishment",
9+
request_body(
10+
content = Object,
11+
description = "Write company establishment information",
12+
examples(( "Success" = (
13+
summary = "JSON example",
14+
value = json!("Loading..."),
15+
external_value = "https://raw.githubusercontent.com/Virtual-Finland/definitions/main/DataProducts/draft/NSG/Agent/LegalEntity/NonListedCompany/Establishment/Write.json"
16+
)))
17+
),
18+
responses((
19+
status = 200,
20+
body = Object,
21+
description = "Company establishment response",
22+
examples(( "Success" = (
23+
summary = "JSON example",
24+
value = json!("Loading..."),
25+
external_value = "https://raw.githubusercontent.com/Virtual-Finland/definitions/main/DataProducts/draft/NSG/Agent/LegalEntity/NonListedCompany/Establishment/Write.json"
26+
)))
27+
)),
28+
security(( "BearerAuth" = [] ))
29+
)]
30+
pub async fn write_establishment(request: ParsedRequest) -> APIResponse {
31+
let data_product = "draft/NSG/Agent/LegalEntity/NonListedCompany/Establishment/Write";
32+
let data_source = "virtualfinland";
33+
let result = super::post_data_product(data_product, data_source, request).await?;
34+
Ok(result)
35+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use serde_json::{json, Value as JSONValue};
2+
3+
use app::{
4+
requests::post_json_request,
5+
responses::APIResponse,
6+
router::ParsedRequest
7+
};
8+
9+
use super::{build_data_product_uri, parse_testbed_request_headers};
10+
11+
pub mod signatory_rights;
12+
pub mod establishment;
13+
pub mod beneficial_owners;
14+
15+
pub async fn post_data_product(
16+
data_product: &str,
17+
data_source: &str,
18+
request: ParsedRequest,
19+
) -> APIResponse {
20+
let request_input: JSONValue =
21+
serde_json::from_str(request.body.as_str()).unwrap_or_else(|_| json!({}));
22+
let request_headers = parse_testbed_request_headers(request)?;
23+
let response = post_json_request::<JSONValue, JSONValue>(
24+
build_data_product_uri(data_product, data_source),
25+
&request_input,
26+
request_headers,
27+
)
28+
.await?;
29+
Ok(response)
30+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use app::{
2+
responses::APIResponse,
3+
router::ParsedRequest
4+
};
5+
6+
#[utoipa::path(
7+
post,
8+
path = "/testbed/productizer/non-listed-company/signatory-rights",
9+
request_body(
10+
content = Object,
11+
description = "Get beneficial owners information",
12+
examples(( "Success" = (
13+
summary = "JSON example",
14+
value = json!("Loading..."),
15+
external_value = "https://raw.githubusercontent.com/Virtual-Finland/definitions/main/DataProducts/draft/NSG/Agent/LegalEntity/NonListedCompany/SignatoryRights.json"
16+
)))
17+
),
18+
responses((
19+
status = 200,
20+
body = Object,
21+
description = "Beneficial owners response",
22+
examples(( "Success" = (
23+
summary = "JSON example",
24+
value = json!("Loading..."),
25+
external_value = "https://raw.githubusercontent.com/Virtual-Finland/definitions/main/DataProducts/draft/NSG/Agent/LegalEntity/NonListedCompany/SignatoryRights.json"
26+
)))
27+
)),
28+
security(( "BearerAuth" = [] ))
29+
)]
30+
pub async fn get_signatory_rights(request: ParsedRequest) -> APIResponse {
31+
let data_product = "draft/NSG/Agent/LegalEntity/NonListedCompany/SignatoryRights";
32+
let data_source = "virtualfinland";
33+
let result = super::post_data_product(data_product, data_source, request).await?;
34+
Ok(result)
35+
}

0 commit comments

Comments
 (0)