feat(events): add extracted fields based on req/res types (#2795)

This commit is contained in:
Sampras Lopes
2023-11-08 21:31:53 +05:30
committed by GitHub
parent 25a73c29a4
commit 89857941b0
40 changed files with 664 additions and 69 deletions

View File

@ -149,8 +149,8 @@ pub async fn refund_update(
path: web::Path<String>,
form_payload: web::Form<types::StripeUpdateRefundRequest>,
) -> HttpResponse {
let refund_id = path.into_inner();
let payload = form_payload.into_inner();
let mut payload = form_payload.into_inner();
payload.refund_id = path.into_inner();
let create_refund_update_req: refund_types::RefundUpdateRequest = payload.into();
let flow = Flow::RefundsUpdate;
@ -169,9 +169,7 @@ pub async fn refund_update(
state.into_inner(),
&req,
create_refund_update_req,
|state, auth, req| {
refunds::refund_update_core(state, auth.merchant_account, &refund_id, req)
},
|state, auth, req| refunds::refund_update_core(state, auth.merchant_account, req),
&auth::ApiKeyAuth,
api_locking::LockAction::NotApplicable,
))

View File

@ -17,6 +17,8 @@ pub struct StripeCreateRefundRequest {
#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
pub struct StripeUpdateRefundRequest {
#[serde(skip)]
pub refund_id: String,
pub metadata: Option<pii::SecretSerdeValue>,
}
@ -58,6 +60,7 @@ impl From<StripeCreateRefundRequest> for refunds::RefundRequest {
impl From<StripeUpdateRefundRequest> for refunds::RefundUpdateRequest {
fn from(req: StripeUpdateRefundRequest) -> Self {
Self {
refund_id: req.refund_id,
metadata: req.metadata,
reason: None,
}

View File

@ -7,6 +7,7 @@ use serde::Serialize;
use crate::{
core::{api_locking, errors},
events::api_logs::ApiEventMetric,
routes::{app::AppStateInfo, metrics},
services::{self, api, authentication as auth, logger},
};
@ -25,12 +26,12 @@ where
F: Fn(A, U, T) -> Fut,
Fut: Future<Output = CustomResult<api::ApplicationResponse<Q>, E2>>,
E2: ErrorSwitch<E> + std::error::Error + Send + Sync + 'static,
Q: Serialize + std::fmt::Debug + 'a,
Q: Serialize + std::fmt::Debug + 'a + ApiEventMetric,
S: TryFrom<Q> + Serialize,
E: Serialize + error_stack::Context + actix_web::ResponseError + Clone,
error_stack::Report<E>: services::EmbedError,
errors::ApiErrorResponse: ErrorSwitch<E>,
T: std::fmt::Debug + Serialize,
T: std::fmt::Debug + Serialize + ApiEventMetric,
A: AppStateInfo + Clone,
{
let request_method = request.method().as_str();