Skip to content

Commit 22435dc

Browse files
committed
fix: comments
1 parent 3cf499e commit 22435dc

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

crates/common_utils/src/keymanager.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::str::FromStr;
44

55
use error_stack::ResultExt;
6+
use http::Method;
67
use http::{HeaderMap, HeaderName, HeaderValue, StatusCode};
78
#[cfg(feature = "keymanager_mtls")]
89
use masking::PeekInterface;
@@ -63,6 +64,7 @@ pub async fn send_encryption_request<T>(
6364
state: &KeyManagerState,
6465
headers: HeaderMap,
6566
url: String,
67+
method: Method,
6668
request_body: T,
6769
) -> errors::CustomResult<reqwest::Response, errors::KeyManagerClientError>
6870
where
@@ -73,7 +75,7 @@ where
7375
.change_context(errors::KeyManagerClientError::UrlEncodingFailed)?;
7476

7577
client
76-
.post(url)
78+
.request(method, url)
7779
.json(&request_body)
7880
.headers(headers)
7981
.send()
@@ -87,6 +89,7 @@ where
8789
#[instrument(skip_all)]
8890
pub async fn call_encryption_service<T, R>(
8991
state: &KeyManagerState,
92+
method: Method,
9093
endpoint: &str,
9194
request_body: T,
9295
) -> errors::CustomResult<R, errors::KeyManagerClientError>
@@ -108,6 +111,7 @@ where
108111
.into_iter(),
109112
),
110113
url,
114+
method,
111115
request_body,
112116
)
113117
.await
@@ -150,7 +154,7 @@ pub async fn create_key_in_key_manager(
150154
state: &KeyManagerState,
151155
request_body: EncryptionCreateRequest,
152156
) -> errors::CustomResult<DataKeyCreateResponse, errors::KeyManagerError> {
153-
call_encryption_service(state, "key/create", request_body)
157+
call_encryption_service(state, Method::POST, "key/create", request_body)
154158
.await
155159
.change_context(errors::KeyManagerError::KeyAddFailed)
156160
}
@@ -161,7 +165,7 @@ pub async fn transfer_key_to_key_manager(
161165
state: &KeyManagerState,
162166
request_body: EncryptionTransferRequest,
163167
) -> errors::CustomResult<DataKeyCreateResponse, errors::KeyManagerError> {
164-
call_encryption_service(state, "key/transfer", request_body)
168+
call_encryption_service(state, Method::POST, "key/transfer", request_body)
165169
.await
166170
.change_context(errors::KeyManagerError::KeyTransferFailed)
167171
}

crates/router/src/routes/admin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,16 @@ pub async fn merchant_account_toggle_kv(
446446
.await
447447
}
448448

449-
/// Merchant Account - Toggle KV
449+
/// Merchant Account - Transfer Keys
450450
///
451-
/// Toggle KV mode for all Merchant Accounts
451+
/// Transfer Merchant Encryption key to keymanager
452452
#[instrument(skip_all)]
453453
pub async fn merchant_account_toggle_all_kv(
454454
state: web::Data<AppState>,
455455
req: HttpRequest,
456456
json_payload: web::Json<admin::ToggleAllKVRequest>,
457457
) -> HttpResponse {
458-
let flow = Flow::ConfigKeyUpdate;
458+
let flow = Flow::MerchantTransferKey;
459459
let payload = json_payload.into_inner();
460460

461461
api::server_wrap(

crates/router/src/routes/lock_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ impl From<Flow> for ApiIdentifier {
4545
| Flow::MerchantsAccountRetrieve
4646
| Flow::MerchantsAccountUpdate
4747
| Flow::MerchantsAccountDelete
48+
| Flow::MerchantTransferKey
4849
| Flow::MerchantAccountList => Self::MerchantAccount,
4950

5051
Flow::RoutingCreateConfig

crates/router_env/src/logger/types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ pub enum Flow {
8181
MerchantConnectorsDelete,
8282
/// Merchant Connectors list flow.
8383
MerchantConnectorsList,
84+
/// Merchant Transfer Keys
85+
MerchantTransferKey,
8486
/// ConfigKey create flow.
8587
ConfigKeyCreate,
8688
/// ConfigKey fetch flow.

0 commit comments

Comments
 (0)