Skip to content

Commit 82a2202

Browse files
committed
refactor: cargo hack
1 parent a423e97 commit 82a2202

File tree

9 files changed

+26
-13
lines changed

9 files changed

+26
-13
lines changed

crates/api_models/src/routing.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ pub struct RoutingDictionaryRecord {
539539
pub description: String,
540540
pub created_at: i64,
541541
pub modified_at: i64,
542+
pub algorithm_for: Option<TransactionType>,
542543
}
543544

544545
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]

crates/router/src/core/admin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use api_models::{
44
admin::{self as admin_types},
55
enums as api_enums, routing as routing_types,
66
};
7-
use common_enums::{ConnectorType, TransactionType};
87
use common_utils::{
98
crypto::{generate_cryptographically_secure_random_string, OptionalSecretValue},
109
date_time,
@@ -949,8 +948,9 @@ pub async fn create_payment_connector(
949948
};
950949

951950
let transaction_type = match req.connector_type {
952-
ConnectorType::PayoutProcessor => TransactionType::Payout,
953-
_ => TransactionType::Payment,
951+
#[cfg(feature = "payouts")]
952+
api_enums::ConnectorType::PayoutProcessor => api_enums::TransactionType::Payout,
953+
_ => api_enums::TransactionType::Payment,
954954
};
955955

956956
let mut default_routing_config =

crates/router/src/core/payments/routing.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ pub async fn refresh_kgraph_cache(
637637
&& mca.connector_type != storage_enums::ConnectorType::PayoutProcessor
638638
});
639639
}
640+
#[cfg(feature = "payouts")]
640641
api_enums::TransactionType::Payout => {
641642
merchant_connector_accounts
642643
.retain(|mca| mca.connector_type == storage_enums::ConnectorType::PayoutProcessor);

crates/router/src/core/routing.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub async fn create_routing_config(
9898
merchant_account: domain::MerchantAccount,
9999
key_store: domain::MerchantKeyStore,
100100
request: routing_types::RoutingConfigRequest,
101-
#[cfg(feature = "business_profile_routing")] transaction_type: &enums::TransactionType,
101+
transaction_type: &enums::TransactionType,
102102
) -> RouterResponse<routing_types::RoutingDictionaryRecord> {
103103
metrics::ROUTING_CREATE_REQUEST_RECEIVED.add(&metrics::CONTEXT, 1, &[]);
104104
let db = state.store.as_ref();
@@ -217,6 +217,7 @@ pub async fn create_routing_config(
217217
description: description.clone(),
218218
created_at: timestamp,
219219
modified_at: timestamp,
220+
algorithm_for: Some(*transaction_type),
220221
};
221222
merchant_dictionary.records.push(new_record.clone());
222223

@@ -441,7 +442,9 @@ pub async fn retrieve_routing_config(
441442
algorithm,
442443
created_at: record.created_at,
443444
modified_at: record.modified_at,
444-
algorithm_for: record.algorithm_for,
445+
algorithm_for: record
446+
.algorithm_for
447+
.unwrap_or(enums::TransactionType::Payment),
445448
};
446449

447450
metrics::ROUTING_RETRIEVE_CONFIG_SUCCESS_RESPONSE.add(&metrics::CONTEXT, 1, &[]);
@@ -799,7 +802,9 @@ pub async fn retrieve_linked_routing_config(
799802
algorithm: the_algorithm,
800803
created_at: record.created_at,
801804
modified_at: record.modified_at,
802-
algorithm_for: record.algorithm_for,
805+
algorithm_for: record
806+
.algorithm_for
807+
.unwrap_or(enums::TransactionType::Payment),
803808
})
804809
} else {
805810
None

crates/router/src/core/routing/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ pub fn get_default_config_key(
476476
) -> String {
477477
match transaction_type {
478478
storage::enums::TransactionType::Payment => format!("routing_default_{merchant_id}"),
479-
479+
#[cfg(feature = "payouts")]
480480
storage::enums::TransactionType::Payout => format!("routing_default_po_{merchant_id}"),
481481
}
482482
}

crates/router/src/core/routing/transformers.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ impl ForeignFrom<RoutingProfileMetadata> for RoutingDictionaryRecord {
2020
#[cfg(feature = "business_profile_routing")]
2121
profile_id: value.profile_id,
2222
name: value.name,
23-
2423
kind: value.kind.foreign_into(),
2524
description: value.description.unwrap_or_default(),
2625
created_at: value.created_at.assume_utc().unix_timestamp(),
2726
modified_at: value.modified_at.assume_utc().unix_timestamp(),
27+
algorithm_for: Some(value.algorithm_for),
2828
}
2929
}
3030
}
@@ -40,6 +40,7 @@ impl ForeignFrom<RoutingAlgorithm> for RoutingDictionaryRecord {
4040
description: value.description.unwrap_or_default(),
4141
created_at: value.created_at.assume_utc().unix_timestamp(),
4242
modified_at: value.modified_at.assume_utc().unix_timestamp(),
43+
algorithm_for: Some(value.algorithm_for),
4344
}
4445
}
4546
}

crates/router/src/routes/app.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use actix_web::{web, Scope};
88
use analytics::AnalyticsConfig;
99
#[cfg(all(feature = "business_profile_routing", feature = "olap"))]
1010
use api_models::routing::RoutingRetrieveQuery;
11-
#[cfg(any(feature = "olap", feature = "payouts"))]
11+
#[cfg(feature = "olap")]
1212
use common_enums::TransactionType;
1313
#[cfg(feature = "aws_kms")]
1414
use external_services::aws_kms::{self, decrypt::AwsKmsDecrypt};
@@ -500,7 +500,6 @@ impl Routing {
500500
state,
501501
req,
502502
payload,
503-
#[cfg(feature = "business_profile_routing")]
504503
&TransactionType::Payment,
505504
)
506505
})),
@@ -596,7 +595,6 @@ impl Routing {
596595
state,
597596
req,
598597
payload,
599-
#[cfg(feature = "business_profile_routing")]
600598
&TransactionType::Payout,
601599
)
602600
})),

crates/router/src/routes/routing.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub async fn routing_create_config(
2323
state: web::Data<AppState>,
2424
req: HttpRequest,
2525
json_payload: web::Json<routing_types::RoutingConfigRequest>,
26-
#[cfg(feature = "business_profile_routing")] transaction_type: &enums::TransactionType,
26+
transaction_type: &enums::TransactionType,
2727
) -> impl Responder {
2828
let flow = Flow::RoutingCreateConfig;
2929
Box::pin(oss_api::server_wrap(
@@ -37,7 +37,6 @@ pub async fn routing_create_config(
3737
auth.merchant_account,
3838
auth.key_store,
3939
payload,
40-
#[cfg(feature = "business_profile_routing")]
4140
transaction_type,
4241
)
4342
},

openapi/openapi_spec.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15707,6 +15707,14 @@
1570715707
"modified_at": {
1570815708
"type": "integer",
1570915709
"format": "int64"
15710+
},
15711+
"algorithm_for": {
15712+
"allOf": [
15713+
{
15714+
"$ref": "#/components/schemas/TransactionType"
15715+
}
15716+
],
15717+
"nullable": true
1571015718
}
1571115719
}
1571215720
},

0 commit comments

Comments
 (0)