Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(framework): Add Smithy Annotations for Customers, Mandates (#10191)

Debarshi Gupta2dea0f275ea5
diff --git a/crates/api_models/src/customers.rs b/crates/api_models/src/customers.rs
index 5bc9d1fd3d..69087e5758 100644
--- a/crates/api_models/src/customers.rs
+++ b/crates/api_models/src/customers.rs
@@ -2,16 +2,19 @@ use common_types::primitive_wrappers::CustomerListLimit;
use common_utils::{crypto, custom_serde, id_type, pii, types::Description};
use masking::Secret;
use serde::{Deserialize, Serialize};
+use smithy::SmithyModel;
use utoipa::ToSchema;
use crate::payments;
/// The customer details
#[cfg(feature = "v1")]
-#[derive(Debug, Default, Clone, Deserialize, Serialize, ToSchema)]
+#[derive(Debug, Default, Clone, Deserialize, Serialize, ToSchema, SmithyModel)]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct CustomerRequest {
/// The identifier for the customer object. If not provided the customer ID will be autogenerated.
#[schema(value_type = Option<String>, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
+ #[smithy(value_type = "Option<String>")]
pub customer_id: Option<id_type::CustomerId>,
/// The identifier for the Merchant Account
#[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44")]
@@ -19,39 +22,50 @@ pub struct CustomerRequest {
pub merchant_id: id_type::MerchantId,
/// The customer's name
#[schema(max_length = 255, value_type = Option<String>, example = "Jon Test")]
+ #[smithy(value_type = "Option<String>")]
pub name: Option<Secret<String>>,
/// The customer's email address
#[schema(value_type = Option<String>, max_length = 255, example = "[email protected]")]
+ #[smithy(value_type = "Option<String>")]
pub email: Option<pii::Email>,
/// The customer's phone number
#[schema(value_type = Option<String>, max_length = 255, example = "9123456789")]
+ #[smithy(value_type = "Option<String>")]
pub phone: Option<Secret<String>>,
/// An arbitrary string that you can attach to a customer object.
#[schema(max_length = 255, example = "First Customer", value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
pub description: Option<Description>,
/// The country code for the customer phone number
#[schema(max_length = 255, example = "+65")]
+ #[smithy(value_type = "Option<String>")]
pub phone_country_code: Option<String>,
/// The address for the customer
#[schema(value_type = Option<AddressDetails>)]
+ #[smithy(value_type = "Option<AddressDetails>")]
pub address: Option<payments::AddressDetails>,
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500
/// characters long. Metadata is useful for storing additional, structured information on an
/// object.
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
+ #[smithy(value_type = "Option<Object>")]
pub metadata: Option<pii::SecretSerdeValue>,
/// Customer's tax registration ID
#[schema(max_length = 255, value_type = Option<String>, example = "123456789")]
+ #[smithy(value_type = "Option<String>")]
pub tax_registration_id: Option<Secret<String>>,
}
-#[derive(Debug, Default, Clone, Deserialize, Serialize, ToSchema)]
+#[derive(Debug, Default, Clone, Deserialize, Serialize, ToSchema, SmithyModel)]
+#[smithy(namespace = "com.hyperswitch.smithy.types", mixin = true)]
pub struct CustomerListRequest {
/// Offset
#[schema(example = 32)]
+ #[smithy(value_type = "Option<u32>", http_query = "offset")]
pub offset: Option<u32>,
/// Limit
#[schema(example = 32)]
+ #[smithy(value_type = "Option<u16>", http_query = "limit")]
pub limit: Option<u16>,
pub customer_id: Option<id_type::CustomerId>,
}
@@ -147,43 +161,55 @@ impl CustomerRequest {
}
#[cfg(feature = "v1")]
-#[derive(Debug, Clone, Serialize, ToSchema)]
+#[derive(Debug, Clone, Serialize, ToSchema, SmithyModel)]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct CustomerResponse {
/// The identifier for the customer object
#[schema(value_type = String, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
+ #[smithy(value_type = "String")]
pub customer_id: id_type::CustomerId,
/// The customer's name
#[schema(max_length = 255, value_type = Option<String>, example = "Jon Test")]
+ #[smithy(value_type = "Option<String>")]
pub name: crypto::OptionalEncryptableName,
/// The customer's email address
#[schema(value_type = Option<String>,max_length = 255, example = "[email protected]")]
+ #[smithy(value_type = "Option<String>")]
pub email: crypto::OptionalEncryptableEmail,
/// The customer's phone number
#[schema(value_type = Option<String>,max_length = 255, example = "9123456789")]
+ #[smithy(value_type = "Option<String>")]
pub phone: crypto::OptionalEncryptablePhone,
/// The country code for the customer phone number
#[schema(max_length = 255, example = "+65")]
+ #[smithy(value_type = "Option<String>")]
pub phone_country_code: Option<String>,
/// An arbitrary string that you can attach to a customer object.
#[schema(max_length = 255, example = "First Customer", value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
pub description: Option<Description>,
/// The address for the customer
#[schema(value_type = Option<AddressDetails>)]
+ #[smithy(value_type = "Option<AddressDetails>")]
pub address: Option<payments::AddressDetails>,
/// A timestamp (ISO 8601 code) that determines when the customer was created
#[schema(value_type = PrimitiveDateTime,example = "2023-01-18T11:04:09.922Z")]
#[serde(with = "custom_serde::iso8601")]
+ #[smithy(value_type = "Option<String>")]
pub created_at: time::PrimitiveDateTime,
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500
/// characters long. Metadata is useful for storing additional, structured information on an
/// object.
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
+ #[smithy(value_type = "Option<Object>")]
pub metadata: Option<pii::SecretSerdeValue>,
/// The identifier for the default payment method.
#[schema(max_length = 64, example = "pm_djh2837dwduh890123")]
+ #[smithy(value_type = "Option<String>")]
pub default_payment_method_id: Option<String>,
/// The customer's tax registration number.
#[schema(max_length = 255, value_type = Option<String>, example = "123456789")]
+ #[smithy(value_type = "Option<String>")]
pub tax_registration_id: crypto::OptionalEncryptableSecretString,
}
@@ -257,19 +283,24 @@ impl CustomerResponse {
}
#[cfg(feature = "v1")]
-#[derive(Debug, Deserialize, Serialize, ToSchema)]
+#[derive(Debug, Deserialize, Serialize, ToSchema, SmithyModel)]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct CustomerDeleteResponse {
/// The identifier for the customer object
#[schema(value_type = String, max_length = 255, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
+ #[smithy(value_type = "String")]
pub customer_id: id_type::CustomerId,
/// Whether customer was deleted or not
#[schema(example = false)]
+ #[smithy(value_type = "bool")]
pub customer_deleted: bool,
/// Whether address was deleted or not
#[schema(example = false)]
+ #[smithy(value_type = "bool")]
pub address_deleted: bool,
/// Whether payment methods deleted or not
#[schema(example = false)]
+ #[smithy(value_type = "bool")]
pub payment_methods_deleted: bool,
}
@@ -300,7 +331,8 @@ pub struct CustomerDeleteResponse {
/// The identifier for the customer object. If not provided the customer ID will be autogenerated.
#[cfg(feature = "v1")]
-#[derive(Debug, Default, Clone, Deserialize, Serialize, ToSchema)]
+#[derive(Debug, Default, Clone, Deserialize, Serialize, ToSchema, SmithyModel)]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct CustomerUpdateRequest {
/// The identifier for the Merchant Account
#[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44")]
@@ -308,29 +340,37 @@ pub struct CustomerUpdateRequest {
pub merchant_id: id_type::MerchantId,
/// The customer's name
#[schema(max_length = 255, value_type = Option<String>, example = "Jon Test")]
+ #[smithy(value_type = "Option<String>")]
pub name: Option<Secret<String>>,
/// The customer's email address
#[schema(value_type = Option<String>, max_length = 255, example = "[email protected]")]
+ #[smithy(value_type = "Option<String>")]
pub email: Option<pii::Email>,
/// The customer's phone number
#[schema(value_type = Option<String>, max_length = 255, example = "9123456789")]
+ #[smithy(value_type = "Option<String>")]
pub phone: Option<Secret<String>>,
/// An arbitrary string that you can attach to a customer object.
#[schema(max_length = 255, example = "First Customer", value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
pub description: Option<Description>,
/// The country code for the customer phone number
#[schema(max_length = 255, example = "+65")]
+ #[smithy(value_type = "Option<String>")]
pub phone_country_code: Option<String>,
/// The address for the customer
#[schema(value_type = Option<AddressDetails>)]
+ #[smithy(value_type = "Option<AddressDetails>")]
pub address: Option<payments::AddressDetails>,
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500
/// characters long. Metadata is useful for storing additional, structured information on an
/// object.
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
+ #[smithy(value_type = "Option<Object>")]
pub metadata: Option<pii::SecretSerdeValue>,
/// Customer's tax registration ID
#[schema(max_length = 255, value_type = Option<String>, example = "123456789")]
+ #[smithy(value_type = "Option<String>")]
pub tax_registration_id: Option<Secret<String>>,
}
diff --git a/crates/api_models/src/mandates.rs b/crates/api_models/src/mandates.rs
index 3abcb93689..71b5be50f8 100644
--- a/crates/api_models/src/mandates.rs
+++ b/crates/api_models/src/mandates.rs
@@ -12,107 +12,144 @@ pub struct MandateId {
pub mandate_id: String,
}
-#[derive(Default, Debug, Deserialize, Serialize, ToSchema)]
+#[derive(Default, Debug, Deserialize, Serialize, ToSchema, SmithyModel)]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct MandateRevokedResponse {
/// The identifier for mandate
+ #[smithy(value_type = "String")]
pub mandate_id: String,
/// The status for mandates
#[schema(value_type = MandateStatus)]
+ #[smithy(value_type = "MandateStatus")]
pub status: api_enums::MandateStatus,
/// If there was an error while calling the connectors the code is received here
#[schema(example = "E0001")]
+ #[smithy(value_type = "Option<String>")]
pub error_code: Option<String>,
/// If there was an error while calling the connector the error message is received here
#[schema(example = "Failed while verifying the card")]
+ #[smithy(value_type = "Option<String>")]
pub error_message: Option<String>,
}
-#[derive(Default, Debug, Deserialize, Serialize, ToSchema, Clone)]
+#[derive(Default, Debug, Deserialize, Serialize, ToSchema, Clone, SmithyModel)]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct MandateResponse {
/// The identifier for mandate
+ #[smithy(value_type = "String")]
pub mandate_id: String,
/// The status for mandates
#[schema(value_type = MandateStatus)]
+ #[smithy(value_type = "MandateStatus")]
pub status: api_enums::MandateStatus,
/// The identifier for payment method
+ #[smithy(value_type = "String")]
pub payment_method_id: String,
/// The payment method
+ #[smithy(value_type = "String")]
pub payment_method: String,
/// The payment method type
+ #[smithy(value_type = "Option<String>")]
pub payment_method_type: Option<String>,
/// The card details for mandate
+ #[smithy(value_type = "Option<MandateCardDetails>")]
pub card: Option<MandateCardDetails>,
/// Details about the customer’s acceptance
#[schema(value_type = Option<CustomerAcceptance>)]
+ #[smithy(value_type = "Option<CustomerAcceptance>")]
pub customer_acceptance: Option<common_payments_types::CustomerAcceptance>,
}
-#[derive(Default, Debug, Deserialize, Serialize, ToSchema, Clone)]
+#[derive(Default, Debug, Deserialize, Serialize, ToSchema, Clone, SmithyModel)]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct MandateCardDetails {
/// The last 4 digits of card
+ #[smithy(value_type = "Option<String>")]
pub last4_digits: Option<String>,
/// The expiry month of card
#[schema(value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
pub card_exp_month: Option<Secret<String>>,
/// The expiry year of card
#[schema(value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
pub card_exp_year: Option<Secret<String>>,
/// The card holder name
#[schema(value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
pub card_holder_name: Option<Secret<String>>,
/// The token from card locker
#[schema(value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
pub card_token: Option<Secret<String>>,
/// The card scheme network for the particular card
+ #[smithy(value_type = "Option<String>")]
pub scheme: Option<String>,
/// The country code in in which the card was issued
+ #[smithy(value_type = "Option<String>")]
pub issuer_country: Option<String>,
#[schema(value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
/// A unique identifier alias to identify a particular card
pub card_fingerprint: Option<Secret<String>>,
/// The first 6 digits of card
+ #[smithy(value_type = "Option<String>")]
pub card_isin: Option<String>,
/// The bank that issued the card
+ #[smithy(value_type = "Option<String>")]
pub card_issuer: Option<String>,
/// The network that facilitates payment card transactions
#[schema(value_type = Option<CardNetwork>)]
+ #[smithy(value_type = "Option<CardNetwork>")]
pub card_network: Option<api_enums::CardNetwork>,
/// The type of the payment card
+ #[smithy(value_type = "Option<String>")]
pub card_type: Option<String>,
/// The nick_name of the card holder
#[schema(value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
pub nick_name: Option<Secret<String>>,
}
-#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]
+#[derive(Clone, Debug, Deserialize, ToSchema, Serialize, SmithyModel)]
#[serde(deny_unknown_fields)]
+#[smithy(namespace = "com.hyperswitch.smithy.types", mixin = true)]
pub struct MandateListConstraints {
/// limit on the number of objects to return
+ #[smithy(value_type = "Option<i64>", http_query = "limit")]
pub limit: Option<i64>,
/// offset on the number of objects to return
+ #[smithy(value_type = "Option<i64>", http_query = "offset")]
pub offset: Option<i64>,
/// status of the mandate
+ #[smithy(value_type = "Option<MandateStatus>", http_query = "mandate_status")]
pub mandate_status: Option<api_enums::MandateStatus>,
/// connector linked to mandate
+ #[smithy(value_type = "Option<String>", http_query = "connector")]
pub connector: Option<String>,
/// The time at which mandate is created
#[schema(example = "2022-09-10T10:11:12Z")]
+ #[smithy(value_type = "Option<String>", http_query = "created_time")]
pub created_time: Option<PrimitiveDateTime>,
/// Time less than the mandate created time
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(rename = "created_time.lt")]
+ #[smithy(value_type = "Option<String>", http_query = "created_time.lt")]
pub created_time_lt: Option<PrimitiveDateTime>,
/// Time greater than the mandate created time
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(rename = "created_time.gt")]
+ #[smithy(value_type = "Option<String>", http_query = "created_time.gt")]
pub created_time_gt: Option<PrimitiveDateTime>,
/// Time less than or equals to the mandate created time
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(rename = "created_time.lte")]
+ #[smithy(value_type = "Option<String>", http_query = "created_time.lte")]
pub created_time_lte: Option<PrimitiveDateTime>,
/// Time greater than or equals to the mandate created time
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(rename = "created_time.gte")]
+ #[smithy(value_type = "Option<String>", http_query = "created_time.gte")]
pub created_time_gte: Option<PrimitiveDateTime>,
}
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 3124331976..ad952c1c16 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -8587,11 +8587,16 @@ pub struct PaymentsAggregateResponse {
pub status_with_count: HashMap<enums::IntentStatus, i64>,
}
-#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
+#[derive(
+ Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema, SmithyModel,
+)]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct AmountFilter {
/// The start amount to filter list of transactions which are greater than or equal to the start amount
+ #[smithy(value_type = "Option<i64>")]
pub start_amount: Option<i64>,
/// The end amount to filter list of transactions which are less than or equal to the end amount
+ #[smithy(value_type = "Option<i64>")]
pub end_amount: Option<i64>,
}
diff --git a/crates/api_models/src/refunds.rs b/crates/api_models/src/refunds.rs
index eddfb733eb..8000f36df4 100644
--- a/crates/api_models/src/refunds.rs
+++ b/crates/api_models/src/refunds.rs
@@ -429,35 +429,46 @@ pub struct RefundErrorDetails {
}
#[cfg(feature = "v1")]
-#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)]
+#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema, SmithyModel)]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct RefundListRequest {
/// The identifier for the payment
#[schema(value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
pub payment_id: Option<common_utils::id_type::PaymentId>,
/// The identifier for the refund
+ #[smithy(value_type = "Option<String>")]
pub refund_id: Option<String>,
/// The identifier for business profile
#[schema(value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
pub profile_id: Option<common_utils::id_type::ProfileId>,
/// Limit on the number of objects to return
+ #[smithy(value_type = "Option<i64>")]
pub limit: Option<i64>,
/// The starting point within a list of objects
+ #[smithy(value_type = "Option<i64>")]
pub offset: Option<i64>,
/// The time range for which objects are needed. TimeRange has two fields start_time and end_time from which objects can be filtered as per required scenarios (created_at, time less than, greater than etc)
#[serde(flatten)]
pub time_range: Option<TimeRange>,
/// The amount to filter reufnds list. Amount takes two option fields start_amount and end_amount from which objects can be filtered as per required scenarios (less_than, greater_than, equal_to and range)
+ #[smithy(value_type = "Option<AmountFilter>")]
pub amount_filter: Option<AmountFilter>,
/// The list of connectors to filter refunds list
+ #[smithy(value_type = "Option<Vec<String>>")]
pub connector: Option<Vec<String>>,
/// The list of merchant connector ids to filter the refunds list for selected label
#[schema(value_type = Option<Vec<String>>)]
+ #[smithy(value_type = "Option<Vec<String>>")]
pub merchant_connector_id: Option<Vec<common_utils::id_type::MerchantConnectorAccountId>>,
/// The list of currencies to filter refunds list
#[schema(value_type = Option<Vec<Currency>>)]
+ #[smithy(value_type = "Option<Vec<Currency>>")]
pub currency: Option<Vec<enums::Currency>>,
/// The list of refund statuses to filter refunds list
#[schema(value_type = Option<Vec<RefundStatus>>)]
+ #[smithy(value_type = "Option<Vec<RefundStatus>>")]
pub refund_status: Option<Vec<enums::RefundStatus>>,
}
#[cfg(feature = "v2")]
@@ -490,13 +501,17 @@ pub struct RefundListRequest {
#[schema(value_type = Option<Vec<RefundStatus>>)]
pub refund_status: Option<Vec<enums::RefundStatus>>,
}
-#[derive(Debug, Clone, Eq, PartialEq, Serialize, ToSchema)]
+#[derive(Debug, Clone, Eq, PartialEq, Serialize, ToSchema, SmithyModel)]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct RefundListResponse {
/// The number of refunds included in the list
+ #[smithy(value_type = "usize")]
pub count: usize,
/// The total number of refunds in the list
+ #[smithy(value_type = "i64")]
pub total_count: i64,
/// The List of refund response object
+ #[smithy(value_type = "Vec<RefundResponse>")]
pub data: Vec<RefundResponse>,
}
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index c6bae1e679..fb4c126bdd 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -2796,6 +2796,7 @@ pub enum FrmTransactionType {
Default,
serde::Deserialize,
serde::Serialize,
+ SmithyModel,
strum::Display,
strum::EnumIter,
strum::EnumString,
@@ -2804,6 +2805,7 @@ pub enum FrmTransactionType {
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub enum MandateStatus {
#[default]
Active,
diff --git a/crates/smithy-generator/build.rs b/crates/smithy-generator/build.rs
index b339e72172..a517c4e07e 100644
--- a/crates/smithy-generator/build.rs
+++ b/crates/smithy-generator/build.rs
@@ -338,7 +338,10 @@ fn scan_rust_file(
let enabled_features = feature_resolver.get_enabled_crate_features(crate_name);
// Special handling for items that have multiple definitions with different derives
- if item_name == "FeatureMetadata" {
+ if item_name == "FeatureMetadata"
+ || item_name == "CustomerRequest"
+ || item_name == "CustomerUpdateRequest"
+ {
// FeatureMetadata only has SmithyModel in v1 version
if !enabled_features.contains("v1") {
continue;
diff --git a/smithy/models/com_hyperswitch.smithy b/smithy/models/com_hyperswitch.smithy
new file mode 100644
index 0000000000..e3353c14ef
--- /dev/null
+++ b/smithy/models/com_hyperswitch.smithy
@@ -0,0 +1,338 @@
+$version: "2"
+
+namespace com.hyperswitch
+
+use com.hyperswitch.smithy.types#PaymentsRequest
+use com.hyperswitch.smithy.types#PaymentsResponse
+use com.hyperswitch.smithy.types#RefundRequest
+use com.hyperswitch.smithy.types#RefundResponse
+use com.hyperswitch.smithy.types#RefundUpdateRequest
+use com.hyperswitch.smithy.types#RefundListRequest
+use com.hyperswitch.smithy.types#RefundListResponse
+use com.hyperswitch.smithy.types#PaymentsCaptureRequest
+use com.hyperswitch.smithy.types#PaymentsCancelRequest
+use com.hyperswitch.smithy.types#CustomerRequest
+use com.hyperswitch.smithy.types#CustomerResponse
+use com.hyperswitch.smithy.types#CustomerUpdateRequest
+use com.hyperswitch.smithy.types#CustomerDeleteResponse
+use com.hyperswitch.smithy.types#CustomerListRequest
+use com.hyperswitch.smithy.types#MandateRevokedResponse
+use com.hyperswitch.smithy.types#MandateResponse
+use com.hyperswitch.smithy.types#MandateListConstraints
+
+use aws.protocols#restJson1
+
+/// The Hyperswitch API.
+@restJson1
+ sdkId: "hyperswitch",
+ arnNamespace: "hyperswitch",
+ cloudFormationName: "Hyperswitch",
+ endpointPrefix: "api"
+)
+service Hyperswitch {
+ version: "2024-07-31",
+ operations: [PaymentsCreate, PaymentsConfirm, PaymentsUpdate, PaymentsRetrieve, PaymentsCapture, PaymentsCancel, RefundsCreate, RefundsRetrieve, RefundsUpdate, RefundsList, CustomersCreate, CustomersRetrieve, CustomersUpdate, CustomersDelete, CustomersList, MandatesRevoke, MandatesRetrieve, MandatesList]
+}
+
+/// Structure for creating a payment
+structure PaymentsCreateRequest {
+ /// The payment request details
+ @required
+ @httpPayload
+ payload: PaymentsRequest
+}
+
+@documentation("Create a payment with the specified details.")
+@http(method: "POST", uri: "/payments")
+operation PaymentsCreate {
+ input: PaymentsCreateRequest,
+ output: PaymentsResponse,
+}
+
+/// Structure for confirming a payment
+structure PaymentsConfirmRequest {
+ /// The unique identifier for the payment to confirm
+ @required
+ @httpLabel
+ payment_id: smithy.api#String
+
+ /// The payment confirmation request details
+ @required
+ @httpPayload
+ payload: PaymentsRequest
+}
+
+@documentation("Confirm a payment using the payment_id.")
+@http(method: "POST", uri: "/payments/{payment_id}/confirm")
+operation PaymentsConfirm {
+ input: PaymentsConfirmRequest,
+ output: PaymentsResponse,
+}
+
+/// Structure for updating a payment
+structure PaymentsUpdateRequest {
+ /// The unique identifier for the payment to update
+ @required
+ @httpLabel
+ payment_id: smithy.api#String
+
+ /// The payment update request details
+ @required
+ @httpPayload
+ payload: PaymentsRequest
+}
+
+@documentation("Update a payment using the payment_id.")
+@http(method: "POST", uri: "/payments/{payment_id}")
+operation PaymentsUpdate {
+ input: PaymentsUpdateRequest,
+ output: PaymentsResponse,
+}
+
+structure PaymentsRetrieveRequest {
+ /// The unique identifier for the payment to retrieve
+ @required
+ @httpLabel
+ payment_id: smithy.api#String
+}
+
+@documentation("Retrieve a payment using the payment_id.")
+@http(method: "GET", uri: "/payments/{payment_id}")
+operation PaymentsRetrieve {
+ input: PaymentsRetrieveRequest,
+ output: PaymentsResponse,
+}
+
+/// Input structure for capturing a payment
+structure PaymentsCaptureRequestInput {
+ /// The unique identifier for the payment to capture
+ @required
+ @httpLabel
+ payment_id: smithy.api#String
+
+ /// The capture request details
+ @required
+ @httpPayload
+ payload: PaymentsCaptureRequest
+}
+
+@documentation("Capture a payment that has been previously authorized.")
+@http(method: "POST", uri: "/payments/{payment_id}/capture")
+operation PaymentsCapture {
+ input: PaymentsCaptureRequestInput,
+ output: PaymentsResponse,
+}
+
+/// Input structure for canceling a payment
+structure PaymentsCancelRequestInput {
+ /// The unique identifier for the payment to cancel
+ @required
+ @httpLabel
+ payment_id: smithy.api#String
+
+ /// The cancel request details
+ @required
+ @httpPayload
+ payload: PaymentsCancelRequest
+}
+
+@documentation("Cancel a payment using the payment_id.")
+@http(method: "POST", uri: "/payments/{payment_id}/cancel")
+operation PaymentsCancel {
+ input: PaymentsCancelRequestInput,
+ output: PaymentsResponse,
+}
+
+/// Structure for creating a refund
+structure RefundsCreateRequest {
+ /// The refund request details
+ @required
+ @httpPayload
+ payload: RefundRequest
+}
+
+@documentation("Create a refund for a payment.")
+@http(method: "POST", uri: "/refunds")
+operation RefundsCreate {
+ input: RefundsCreateRequest,
+ output: RefundResponse,
+}
+
+structure RefundsRetrieveRequest {
+ /// The unique identifier for the refund to retrieve
+ @required
+ @httpLabel
+ id: smithy.api#String
+}
+
+@documentation("Retrieve a refund using the refund_id.")
+@http(method: "GET", uri: "/refunds/{id}")
+operation RefundsRetrieve {
+ input: RefundsRetrieveRequest,
+ output: RefundResponse,
+}
+
+/// Structure for updating a refund
+structure RefundsUpdateRequest {
+ /// The unique identifier for the refund to update
+ @required
+ @httpLabel
+ id: smithy.api#String
+
+ /// The refund update request details
+ @required
+ @httpPayload
+ payload: RefundUpdateRequest
+}
+
+@documentation("Update a refund using the refund_id.")
+@http(method: "POST", uri: "/refunds/{id}")
+operation RefundsUpdate {
+ input: RefundsUpdateRequest,
+ output: RefundResponse,
+}
+
+/// Structure for listing refunds
+structure RefundsListRequestInput {
+ /// The refund list request details
+ @required
+ @httpPayload
+ payload: RefundListRequest
+}
+
+@documentation("Retrieve a list of refunds.")
+@http(method: "POST", uri: "/refunds/list")
+operation RefundsList {
+ input: RefundsListRequestInput,
+ output: RefundListResponse,
+}
+
+/// Structure for creating a customer
+structure CustomersCreateRequest {
+ /// The customer request details
+ @required
+ @httpPayload
+ payload: CustomerRequest
+}
+
+@documentation("Create a customer with the specified details.")
+@http(method: "POST", uri: "/customers")
+operation CustomersCreate {
+ input: CustomersCreateRequest,
+ output: CustomerResponse,
+}
+
+/// Structure for retrieving a customer
+structure CustomersRetrieveRequest {
+ /// The unique identifier for the customer to retrieve
+ @required
+ @httpLabel
+ customer_id: smithy.api#String
+}
+
+@documentation("Retrieve a customer using the customer_id.")
+@http(method: "GET", uri: "/customers/{customer_id}")
+operation CustomersRetrieve {
+ input: CustomersRetrieveRequest,
+ output: CustomerResponse,
+}
+
+/// Structure for updating a customer
+structure CustomersUpdateRequest {
+ /// The unique identifier for the customer to update
+ @required
+ @httpLabel
+ customer_id: smithy.api#String
+
+ /// The customer update request details
+ @required
+ @httpPayload
+ payload: CustomerUpdateRequest
+}
+
+@documentation("Update a customer using the customer_id.")
+@http(method: "POST", uri: "/customers/{customer_id}")
+operation CustomersUpdate {
+ input: CustomersUpdateRequest,
+ output: CustomerResponse,
+}
+
+/// Structure for deleting a customer
+structure CustomersDeleteRequest {
+ /// The unique identifier for the customer to delete
+ @required
+ @httpLabel
+ customer_id: smithy.api#String
+}
+
+@documentation("Delete a customer using the customer_id.")
+@http(method: "DELETE", uri: "/customers/{customer_id}")
+operation CustomersDelete {
+ input: CustomersDeleteRequest,
+ output: CustomerDeleteResponse,
+}
+
+list CustomerResponseList {
+ member: CustomerResponse
+}
+
+structure CustomersListRequestInput with [CustomerListRequest] {
+}
+
+@documentation("Retrieve a list of customers.")
+@http(method: "GET", uri: "/customers/list")
+operation CustomersList {
+ input: CustomersListRequestInput,
+ output:= {
+ @httpPayload
+ customers_list: smithy.api#Document
+ },
+}
+
+/// Structure for revoking a mandate
+structure MandatesRevokeRequest {
+ /// The unique identifier for the mandate to revoke
+ @required
+ @httpLabel
+ id: smithy.api#String
+}
+
+@documentation("Revoke a mandate using the mandate_id.")
+@http(method: "POST", uri: "/mandates/revoke/{id}")
+operation MandatesRevoke {
+ input: MandatesRevokeRequest,
+ output: MandateRevokedResponse,
+}
+
+/// Structure for retrieving a mandate
+structure MandatesRetrieveRequest {
+ /// The unique identifier for the mandate to retrieve
+ @required
+ @httpLabel
+ id: smithy.api#String
+}
+
+@documentation("Retrieve a mandate using the mandate_id.")
+@http(method: "GET", uri: "/mandates/{id}")
+operation MandatesRetrieve {
+ input: MandatesRetrieveRequest,
+ output: MandateResponse,
+}
+
+list MandateResponseList {
+ member: MandateResponse
+}
+
+structure MandatesListRequestInput with [MandateListConstraints] {
+}
+
+@documentation("Retrieve a list of mandates.")
+@http(method: "GET", uri: "/mandates/list")
+operation MandatesList {
+ input: MandatesListRequestInput,
+ output:= {
+ @httpPayload
+ mandates_list: smithy.api#Document
+ },
+}
diff --git a/smithy/smithy-build.json b/smithy/smithy-build.json
new file mode 100644
index 0000000000..db496ef002
--- /dev/null
+++ b/smithy/smithy-build.json
@@ -0,0 +1,18 @@
+{
+ "version": "1.0",
+ "sources": ["models/"],
+ "outputDirectory": "openapi",
+ "maven": {
+ "dependencies": [
+ "software.amazon.smithy:smithy-openapi:1.63.0",
+ "software.amazon.smithy:smithy-aws-traits:1.63.0"
+ ]
+ },
+ "plugins": {
+ "openapi": {
+ "service": "com.hyperswitch#Hyperswitch",
+ "protocol": "aws.protocols#restJson1",
+ "version": "3.1.0"
+ }
+ }
+}