refactor: AppState trait for utility functions (#499)

This commit is contained in:
Sangamesh Kulkarni
2023-02-06 16:34:29 +05:30
committed by GitHub
parent a2921ff835
commit 9381a37f8f
17 changed files with 147 additions and 92 deletions

View File

@ -30,7 +30,7 @@ pub async fn merchant_account_create(
json_payload: web::Json<admin::CreateMerchantAccount>,
) -> HttpResponse {
api::server_wrap(
&state,
state.get_ref(),
&req,
json_payload.into_inner(),
|state, _, req| create_merchant_account(&*state.store, req),
@ -65,7 +65,7 @@ pub async fn retrieve_merchant_account(
})
.into_inner();
api::server_wrap(
&state,
state.get_ref(),
&req,
payload,
|state, _, req| get_merchant_account(&*state.store, req),
@ -99,7 +99,7 @@ pub async fn update_merchant_account(
) -> HttpResponse {
let merchant_id = mid.into_inner();
api::server_wrap(
&state,
state.get_ref(),
&req,
json_payload.into_inner(),
|state, _, req| merchant_account_update(&*state.store, &merchant_id, req),
@ -135,7 +135,7 @@ pub async fn delete_merchant_account(
})
.into_inner();
api::server_wrap(
&state,
state.get_ref(),
&req,
payload,
|state, _, req| merchant_account_delete(&*state.store, req.merchant_id),
@ -168,7 +168,7 @@ pub async fn payment_connector_create(
) -> HttpResponse {
let merchant_id = path.into_inner();
api::server_wrap(
&state,
state.get_ref(),
&req,
json_payload.into_inner(),
|state, _, req| create_payment_connector(&*state.store, req, &merchant_id),
@ -209,7 +209,7 @@ pub async fn payment_connector_retrieve(
})
.into_inner();
api::server_wrap(
&state,
state.get_ref(),
&req,
payload,
|state, _, req| {
@ -246,7 +246,7 @@ pub async fn payment_connector_list(
) -> HttpResponse {
let merchant_id = path.into_inner();
api::server_wrap(
&state,
state.get_ref(),
&req,
merchant_id,
|state, _, merchant_id| list_payment_connectors(&*state.store, merchant_id),
@ -284,7 +284,7 @@ pub async fn payment_connector_update(
) -> HttpResponse {
let (merchant_id, merchant_connector_id) = path.into_inner();
api::server_wrap(
&state,
state.get_ref(),
&req,
json_payload.into_inner(),
|state, _, req| {
@ -327,7 +327,7 @@ pub async fn payment_connector_delete(
})
.into_inner();
api::server_wrap(
&state,
state.get_ref(),
&req,
payload,
|state, _, req| {