feat(router): added dispute accept api, file module apis and dispute evidence submission api (#900)

Co-authored-by: Sangamesh <sangamesh.kulkarni@juspay.in>
Co-authored-by: sai harsha <sai.harsha@sai.harsha-MacBookPro>
Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
Sai Harsha Vardhan
2023-04-25 01:05:21 +05:30
committed by GitHub
parent bcbf4c882c
commit bdf1e5147e
54 changed files with 2822 additions and 34 deletions

View File

@ -0,0 +1,125 @@
use actix_multipart::Multipart;
use actix_web::{web, HttpRequest, HttpResponse};
use router_env::{instrument, tracing, Flow};
pub mod transformers;
use super::app::AppState;
use crate::{
core::files::*,
services::{api, authentication as auth},
types::api::files,
};
/// Files - Create
///
/// To create a file
#[utoipa::path(
post,
path = "/files",
request_body=MultipartRequestWithFile,
responses(
(status = 200, description = "File created", body = CreateFileResponse),
(status = 400, description = "Bad Request")
),
tag = "Files",
operation_id = "Create a File",
security(("api_key" = []))
)]
#[instrument(skip_all, fields(flow = ?Flow::CreateFile))]
pub async fn files_create(
state: web::Data<AppState>,
req: HttpRequest,
payload: Multipart,
) -> HttpResponse {
let flow = Flow::CreateFile;
let create_file_request_result = transformers::get_create_file_request(payload).await;
let create_file_request = match create_file_request_result {
Ok(valid_request) => valid_request,
Err(err) => return api::log_and_return_error_response(err),
};
api::server_wrap(
flow,
state.get_ref(),
&req,
create_file_request,
files_create_core,
auth::auth_type(&auth::ApiKeyAuth, &auth::JWTAuth, req.headers()),
)
.await
}
/// Files - Delete
///
/// To delete a file
#[utoipa::path(
delete,
path = "/files/{file_id}",
params(
("file_id" = String, Path, description = "The identifier for file")
),
responses(
(status = 200, description = "File deleted"),
(status = 404, description = "File not found")
),
tag = "Files",
operation_id = "Delete a File",
security(("api_key" = []))
)]
#[instrument(skip_all, fields(flow = ?Flow::DeleteFile))]
pub async fn files_delete(
state: web::Data<AppState>,
req: HttpRequest,
path: web::Path<String>,
) -> HttpResponse {
let flow = Flow::DeleteFile;
let file_id = files::FileId {
file_id: path.into_inner(),
};
api::server_wrap(
flow,
state.get_ref(),
&req,
file_id,
files_delete_core,
auth::auth_type(&auth::ApiKeyAuth, &auth::JWTAuth, req.headers()),
)
.await
}
/// Files - Retrieve
///
/// To retrieve a file
#[utoipa::path(
get,
path = "/files/{file_id}",
params(
("file_id" = String, Path, description = "The identifier for file")
),
responses(
(status = 200, description = "File body"),
(status = 400, description = "Bad Request")
),
tag = "Files",
operation_id = "Retrieve a File",
security(("api_key" = []))
)]
#[instrument(skip_all, fields(flow = ?Flow::RetrieveFile))]
pub async fn files_retrieve(
state: web::Data<AppState>,
req: HttpRequest,
path: web::Path<String>,
) -> HttpResponse {
let flow = Flow::RetrieveFile;
let file_id = files::FileId {
file_id: path.into_inner(),
};
api::server_wrap(
flow,
state.get_ref(),
&req,
file_id,
files_retrieve_core,
auth::auth_type(&auth::ApiKeyAuth, &auth::JWTAuth, req.headers()),
)
.await
}