Skip to content

Commit

Permalink
Merge pull request #30 from filecoin-project/endpoint/get-merged-appl…
Browse files Browse the repository at this point in the history
…ications

Endpoint/get merged applications
  • Loading branch information
jbesraa authored Oct 5, 2023
2 parents 38d20aa + 493d09f commit 914edaa
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 167 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions http-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub(crate) mod router;
/// - Propose Application
/// - Approve Application
/// - Merge Application
/// - Get All Merged Applications
/// - Get Application
/// - Get All Applications
/// Blockchain endpoints:
Expand Down Expand Up @@ -43,6 +44,7 @@ async fn main() -> std::io::Result<()> {
.service(router::application::propose_application)
.service(router::application::approve_application)
.service(router::application::merge_application)
.service(router::application::get_merged_applications)
.service(router::application::get_application)
.service(router::application::get_all_applications)
.service(router::blockchain::address_allowance)
Expand Down
33 changes: 32 additions & 1 deletion http-server/src/router/application.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use actix_web::{get, post, web, HttpResponse, Responder};
use lib::core::{CreateApplicationInfo, LDNApplication, CompleteGovernanceReviewInfo, CompleteNewApplicationProposalInfo};
use lib::core::{
CompleteGovernanceReviewInfo, CompleteNewApplicationProposalInfo, CreateApplicationInfo,
LDNApplication,
};

/// Create a new application.
///
Expand Down Expand Up @@ -258,6 +261,34 @@ pub async fn get_all_applications() -> actix_web::Result<impl Responder> {
Ok(HttpResponse::Ok().body(serde_json::to_string_pretty(&apps).unwrap()))
}

// Fetch merged applications
///
/// # Returns
/// Returns an array of contents of the files.
///
/// # Example
/// ```plaintext
/// curl http://localhost:8080/application/files
/// ```
///
/// # Response
/// ```json
/// [
/// "file content 1",
/// "file content 2",
/// ...
/// ]
/// ```
#[get("/applications/merged")]
pub async fn get_merged_applications() -> actix_web::Result<impl Responder> {
match LDNApplication::get_merged_applications().await {
Ok(apps) => Ok(HttpResponse::Ok().body(serde_json::to_string_pretty(&apps).unwrap())),
Err(e) => {
return Ok(HttpResponse::InternalServerError().body(e.to_string()));
}
}
}

/// Check the health status.
///
/// # Example
Expand Down
1 change: 1 addition & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ chrono = "0.4.26"
base64 = "0.13"
reqwest = { version = "0.11.18", features = ["json"] }
futures = "0.3.28"
tokio = { version = "1.32.0", features = ["rt", "macros"] }
3 changes: 3 additions & 0 deletions lib/src/core/application/core_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct ApplicationInfo {
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
pub struct ApplicationCoreInfo {
pub data_owner_name: String,
pub data_owner_github_handle: String,
pub data_owner_region: String,
pub data_owner_industry: String,
pub data_owner_address: String,
Expand All @@ -22,6 +23,7 @@ impl ApplicationCoreInfo {
pub fn new(
data_owner_name: String,
data_owner_region: String,
data_owner_github_handle: String,
data_owner_industry: String,
data_owner_address: String,
requested_amount: String,
Expand All @@ -31,6 +33,7 @@ impl ApplicationCoreInfo {
ApplicationCoreInfo {
data_owner_name,
data_owner_region,
data_owner_github_handle,
data_owner_address,
requested_amount,
data_owner_industry,
Expand Down
Loading

0 comments on commit 914edaa

Please sign in to comment.