From 2dea0f275ea52e61fbf3eb0ce2a9edb04e3de571 Mon Sep 17 00:00:00 2001 From: Debarshi Gupta Date: Thu, 27 Nov 2025 15:26:47 +0530 Subject: [PATCH] feat(framework): Add Smithy Annotations for Customers, Mandates (#10191) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: likhinbopanna <131246334+likhinbopanna@users.noreply.github.com> --- crates/api_models/src/customers.rs | 50 +++- crates/api_models/src/mandates.rs | 45 +++- crates/api_models/src/payments.rs | 7 +- crates/api_models/src/refunds.rs | 19 +- crates/common_enums/src/enums.rs | 2 + crates/smithy-generator/build.rs | 5 +- smithy/models/com_hyperswitch.smithy | 338 +++++++++++++++++++++++++++ smithy/smithy-build.json | 18 ++ 8 files changed, 471 insertions(+), 13 deletions(-) create mode 100644 smithy/models/com_hyperswitch.smithy create mode 100644 smithy/smithy-build.json 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, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")] + #[smithy(value_type = "Option")] pub customer_id: Option, /// 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, example = "Jon Test")] + #[smithy(value_type = "Option")] pub name: Option>, /// The customer's email address #[schema(value_type = Option, max_length = 255, example = "JonTest@test.com")] + #[smithy(value_type = "Option")] pub email: Option, /// The customer's phone number #[schema(value_type = Option, max_length = 255, example = "9123456789")] + #[smithy(value_type = "Option")] pub phone: Option>, /// An arbitrary string that you can attach to a customer object. #[schema(max_length = 255, example = "First Customer", value_type = Option)] + #[smithy(value_type = "Option")] pub description: Option, /// The country code for the customer phone number #[schema(max_length = 255, example = "+65")] + #[smithy(value_type = "Option")] pub phone_country_code: Option, /// The address for the customer #[schema(value_type = Option)] + #[smithy(value_type = "Option")] pub address: Option, /// 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,example = json!({ "city": "NY", "unit": "245" }))] + #[smithy(value_type = "Option")] pub metadata: Option, /// Customer's tax registration ID #[schema(max_length = 255, value_type = Option, example = "123456789")] + #[smithy(value_type = "Option")] pub tax_registration_id: Option>, } -#[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", http_query = "offset")] pub offset: Option, /// Limit #[schema(example = 32)] + #[smithy(value_type = "Option", http_query = "limit")] pub limit: Option, pub customer_id: Option, } @@ -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, example = "Jon Test")] + #[smithy(value_type = "Option")] pub name: crypto::OptionalEncryptableName, /// The customer's email address #[schema(value_type = Option,max_length = 255, example = "JonTest@test.com")] + #[smithy(value_type = "Option")] pub email: crypto::OptionalEncryptableEmail, /// The customer's phone number #[schema(value_type = Option,max_length = 255, example = "9123456789")] + #[smithy(value_type = "Option")] pub phone: crypto::OptionalEncryptablePhone, /// The country code for the customer phone number #[schema(max_length = 255, example = "+65")] + #[smithy(value_type = "Option")] pub phone_country_code: Option, /// An arbitrary string that you can attach to a customer object. #[schema(max_length = 255, example = "First Customer", value_type = Option)] + #[smithy(value_type = "Option")] pub description: Option, /// The address for the customer #[schema(value_type = Option)] + #[smithy(value_type = "Option")] pub address: Option, /// 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")] 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,example = json!({ "city": "NY", "unit": "245" }))] + #[smithy(value_type = "Option")] pub metadata: Option, /// The identifier for the default payment method. #[schema(max_length = 64, example = "pm_djh2837dwduh890123")] + #[smithy(value_type = "Option")] pub default_payment_method_id: Option, /// The customer's tax registration number. #[schema(max_length = 255, value_type = Option, example = "123456789")] + #[smithy(value_type = "Option")] 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, example = "Jon Test")] + #[smithy(value_type = "Option")] pub name: Option>, /// The customer's email address #[schema(value_type = Option, max_length = 255, example = "JonTest@test.com")] + #[smithy(value_type = "Option")] pub email: Option, /// The customer's phone number #[schema(value_type = Option, max_length = 255, example = "9123456789")] + #[smithy(value_type = "Option")] pub phone: Option>, /// An arbitrary string that you can attach to a customer object. #[schema(max_length = 255, example = "First Customer", value_type = Option)] + #[smithy(value_type = "Option")] pub description: Option, /// The country code for the customer phone number #[schema(max_length = 255, example = "+65")] + #[smithy(value_type = "Option")] pub phone_country_code: Option, /// The address for the customer #[schema(value_type = Option)] + #[smithy(value_type = "Option")] pub address: Option, /// 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,example = json!({ "city": "NY", "unit": "245" }))] + #[smithy(value_type = "Option")] pub metadata: Option, /// Customer's tax registration ID #[schema(max_length = 255, value_type = Option, example = "123456789")] + #[smithy(value_type = "Option")] pub tax_registration_id: Option>, } 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")] pub error_code: Option, /// 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")] pub error_message: Option, } -#[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")] pub payment_method_type: Option, /// The card details for mandate + #[smithy(value_type = "Option")] pub card: Option, /// Details about the customer’s acceptance #[schema(value_type = Option)] + #[smithy(value_type = "Option")] pub customer_acceptance: Option, } -#[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")] pub last4_digits: Option, /// The expiry month of card #[schema(value_type = Option)] + #[smithy(value_type = "Option")] pub card_exp_month: Option>, /// The expiry year of card #[schema(value_type = Option)] + #[smithy(value_type = "Option")] pub card_exp_year: Option>, /// The card holder name #[schema(value_type = Option)] + #[smithy(value_type = "Option")] pub card_holder_name: Option>, /// The token from card locker #[schema(value_type = Option)] + #[smithy(value_type = "Option")] pub card_token: Option>, /// The card scheme network for the particular card + #[smithy(value_type = "Option")] pub scheme: Option, /// The country code in in which the card was issued + #[smithy(value_type = "Option")] pub issuer_country: Option, #[schema(value_type = Option)] + #[smithy(value_type = "Option")] /// A unique identifier alias to identify a particular card pub card_fingerprint: Option>, /// The first 6 digits of card + #[smithy(value_type = "Option")] pub card_isin: Option, /// The bank that issued the card + #[smithy(value_type = "Option")] pub card_issuer: Option, /// The network that facilitates payment card transactions #[schema(value_type = Option)] + #[smithy(value_type = "Option")] pub card_network: Option, /// The type of the payment card + #[smithy(value_type = "Option")] pub card_type: Option, /// The nick_name of the card holder #[schema(value_type = Option)] + #[smithy(value_type = "Option")] pub nick_name: Option>, } -#[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", http_query = "limit")] pub limit: Option, /// offset on the number of objects to return + #[smithy(value_type = "Option", http_query = "offset")] pub offset: Option, /// status of the mandate + #[smithy(value_type = "Option", http_query = "mandate_status")] pub mandate_status: Option, /// connector linked to mandate + #[smithy(value_type = "Option", http_query = "connector")] pub connector: Option, /// The time at which mandate is created #[schema(example = "2022-09-10T10:11:12Z")] + #[smithy(value_type = "Option", http_query = "created_time")] pub created_time: Option, /// Time less than the mandate created time #[schema(example = "2022-09-10T10:11:12Z")] #[serde(rename = "created_time.lt")] + #[smithy(value_type = "Option", http_query = "created_time.lt")] pub created_time_lt: Option, /// Time greater than the mandate created time #[schema(example = "2022-09-10T10:11:12Z")] #[serde(rename = "created_time.gt")] + #[smithy(value_type = "Option", http_query = "created_time.gt")] pub created_time_gt: Option, /// 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", http_query = "created_time.lte")] pub created_time_lte: Option, /// 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", http_query = "created_time.gte")] pub created_time_gte: Option, } 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, } -#[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")] pub start_amount: Option, /// The end amount to filter list of transactions which are less than or equal to the end amount + #[smithy(value_type = "Option")] pub end_amount: Option, } 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)] + #[smithy(value_type = "Option")] pub payment_id: Option, /// The identifier for the refund + #[smithy(value_type = "Option")] pub refund_id: Option, /// The identifier for business profile #[schema(value_type = Option)] + #[smithy(value_type = "Option")] pub profile_id: Option, /// Limit on the number of objects to return + #[smithy(value_type = "Option")] pub limit: Option, /// The starting point within a list of objects + #[smithy(value_type = "Option")] pub offset: Option, /// 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, /// 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")] pub amount_filter: Option, /// The list of connectors to filter refunds list + #[smithy(value_type = "Option>")] pub connector: Option>, /// The list of merchant connector ids to filter the refunds list for selected label #[schema(value_type = Option>)] + #[smithy(value_type = "Option>")] pub merchant_connector_id: Option>, /// The list of currencies to filter refunds list #[schema(value_type = Option>)] + #[smithy(value_type = "Option>")] pub currency: Option>, /// The list of refund statuses to filter refunds list #[schema(value_type = Option>)] + #[smithy(value_type = "Option>")] pub refund_status: Option>, } #[cfg(feature = "v2")] @@ -490,13 +501,17 @@ pub struct RefundListRequest { #[schema(value_type = Option>)] pub refund_status: Option>, } -#[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")] pub data: Vec, } 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 +@aws.api#service( + 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" + } + } +}