refactor(core): add payment method list route to payment_methods (#682)

Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
Abhishek
2023-02-28 17:04:45 +05:30
committed by GitHub
parent 2701cceb5a
commit 5449ce463b
2 changed files with 13 additions and 9 deletions

View File

@ -533,11 +533,11 @@ impl<F, T>
.response .response
.err_code .err_code
.map(|c| c.to_string()) .map(|c| c.to_string())
.unwrap_or(consts::NO_ERROR_CODE.to_string()), .unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),
message: item message: item
.response .response
.reason .reason
.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: None, reason: None,
status_code: item.http_code, status_code: item.http_code,
}), }),
@ -547,11 +547,11 @@ impl<F, T>
.response .response
.gw_error_code .gw_error_code
.map(|c| c.to_string()) .map(|c| c.to_string())
.unwrap_or(consts::NO_ERROR_CODE.to_string()), .unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),
message: item message: item
.response .response
.gw_error_reason .gw_error_reason
.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: None, reason: None,
status_code: item.http_code, status_code: item.http_code,
}), }),
@ -608,11 +608,11 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, NuveiPaymentsRespons
.response .response
.err_code .err_code
.map(|c| c.to_string()) .map(|c| c.to_string())
.unwrap_or(consts::NO_ERROR_CODE.to_string()), .unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),
message: item message: item
.response .response
.reason .reason
.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: None, reason: None,
status_code: item.http_code, status_code: item.http_code,
}), }),
@ -647,11 +647,11 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, NuveiPaymentsResponse>
.response .response
.err_code .err_code
.map(|c| c.to_string()) .map(|c| c.to_string())
.unwrap_or(consts::NO_ERROR_CODE.to_string()), .unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),
message: item message: item
.response .response
.reason .reason
.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: None, reason: None,
status_code: item.http_code, status_code: item.http_code,
}), }),

View File

@ -208,7 +208,11 @@ impl PaymentMethods {
pub fn server(state: AppState) -> Scope { pub fn server(state: AppState) -> Scope {
web::scope("/payment_methods") web::scope("/payment_methods")
.app_data(web::Data::new(state)) .app_data(web::Data::new(state))
.service(web::resource("").route(web::post().to(create_payment_method_api))) .service(
web::resource("")
.route(web::post().to(create_payment_method_api))
.route(web::get().to(list_payment_method_api)), // TODO : added for sdk compatibility for now, need to deprecate this later
)
.service( .service(
web::resource("/{payment_method_id}") web::resource("/{payment_method_id}")
.route(web::get().to(payment_method_retrieve_api)) .route(web::get().to(payment_method_retrieve_api))