Skip to content

Commit 7f75f94

Browse files
authored
refactor(api_models): rename Card struct for payouts to avoid overrides in auto generated open API spec (#4861)
1 parent 0ac20d2 commit 7f75f94

File tree

5 files changed

+87
-15
lines changed

5 files changed

+87
-15
lines changed

crates/api_models/src/payouts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,19 @@ pub struct PayoutCreateRequest {
153153
#[derive(Debug, Clone, Deserialize, Serialize, ToSchema)]
154154
#[serde(rename_all = "snake_case")]
155155
pub enum PayoutMethodData {
156-
Card(Card),
156+
Card(CardPayout),
157157
Bank(Bank),
158158
Wallet(Wallet),
159159
}
160160

161161
impl Default for PayoutMethodData {
162162
fn default() -> Self {
163-
Self::Card(Card::default())
163+
Self::Card(CardPayout::default())
164164
}
165165
}
166166

167167
#[derive(Default, Eq, PartialEq, Clone, Debug, Deserialize, Serialize, ToSchema)]
168-
pub struct Card {
168+
pub struct CardPayout {
169169
/// The card number
170170
#[schema(value_type = String, example = "4242424242424242")]
171171
pub card_number: CardNumber,

crates/openapi/src/openapi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ Never share your secret api keys. Keep them guarded and secure.
440440
api_models::payments::GiftCardData,
441441
api_models::payments::GiftCardDetails,
442442
api_models::payments::Address,
443-
api_models::payouts::Card,
443+
api_models::payouts::CardPayout,
444444
api_models::payouts::Wallet,
445445
api_models::payouts::Paypal,
446446
api_models::payouts::Venmo,

crates/router/src/connector/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ pub trait CardData {
12021202
}
12031203

12041204
#[cfg(feature = "payouts")]
1205-
impl CardData for payouts::Card {
1205+
impl CardData for payouts::CardPayout {
12061206
fn get_card_expiry_year_2_digit(&self) -> Result<Secret<String>, errors::ConnectorError> {
12071207
let binding = self.expiry_year.clone();
12081208
let year = binding.peek();

crates/router/src/types/api/payouts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub use api_models::payouts::{
2-
AchBankTransfer, BacsBankTransfer, Bank as BankPayout, Card as CardPayout, PayoutActionRequest,
2+
AchBankTransfer, BacsBankTransfer, Bank as BankPayout, CardPayout, PayoutActionRequest,
33
PayoutCreateRequest, PayoutCreateResponse, PayoutListConstraints, PayoutListFilterConstraints,
44
PayoutListFilters, PayoutListResponse, PayoutMethodData, PayoutRequest, PayoutRetrieveBody,
55
PayoutRetrieveRequest, PixBankTransfer, SepaBankTransfer, Wallet as WalletPayout,

openapi/openapi_spec.json

Lines changed: 81 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7054,28 +7054,71 @@
70547054
"type": "object",
70557055
"required": [
70567056
"card_number",
7057-
"expiry_month",
7058-
"expiry_year",
7059-
"card_holder_name"
7057+
"card_exp_month",
7058+
"card_exp_year",
7059+
"card_holder_name",
7060+
"card_cvc"
70607061
],
70617062
"properties": {
70627063
"card_number": {
70637064
"type": "string",
70647065
"description": "The card number",
70657066
"example": "4242424242424242"
70667067
},
7067-
"expiry_month": {
7068+
"card_exp_month": {
70687069
"type": "string",
7069-
"description": "The card's expiry month"
7070+
"description": "The card's expiry month",
7071+
"example": "24"
70707072
},
7071-
"expiry_year": {
7073+
"card_exp_year": {
70727074
"type": "string",
7073-
"description": "The card's expiry year"
7075+
"description": "The card's expiry year",
7076+
"example": "24"
70747077
},
70757078
"card_holder_name": {
70767079
"type": "string",
70777080
"description": "The card holder's name",
7078-
"example": "John Doe"
7081+
"example": "John Test"
7082+
},
7083+
"card_cvc": {
7084+
"type": "string",
7085+
"description": "The CVC number for the card",
7086+
"example": "242"
7087+
},
7088+
"card_issuer": {
7089+
"type": "string",
7090+
"description": "The name of the issuer of card",
7091+
"example": "chase",
7092+
"nullable": true
7093+
},
7094+
"card_network": {
7095+
"allOf": [
7096+
{
7097+
"$ref": "#/components/schemas/CardNetwork"
7098+
}
7099+
],
7100+
"nullable": true
7101+
},
7102+
"card_type": {
7103+
"type": "string",
7104+
"example": "CREDIT",
7105+
"nullable": true
7106+
},
7107+
"card_issuing_country": {
7108+
"type": "string",
7109+
"example": "INDIA",
7110+
"nullable": true
7111+
},
7112+
"bank_code": {
7113+
"type": "string",
7114+
"example": "JP_AMEX",
7115+
"nullable": true
7116+
},
7117+
"nick_name": {
7118+
"type": "string",
7119+
"description": "The card holder's nick name",
7120+
"example": "John Test",
7121+
"nullable": true
70797122
}
70807123
}
70817124
},
@@ -7256,6 +7299,35 @@
72567299
"Maestro"
72577300
]
72587301
},
7302+
"CardPayout": {
7303+
"type": "object",
7304+
"required": [
7305+
"card_number",
7306+
"expiry_month",
7307+
"expiry_year",
7308+
"card_holder_name"
7309+
],
7310+
"properties": {
7311+
"card_number": {
7312+
"type": "string",
7313+
"description": "The card number",
7314+
"example": "4242424242424242"
7315+
},
7316+
"expiry_month": {
7317+
"type": "string",
7318+
"description": "The card's expiry month"
7319+
},
7320+
"expiry_year": {
7321+
"type": "string",
7322+
"description": "The card's expiry year"
7323+
},
7324+
"card_holder_name": {
7325+
"type": "string",
7326+
"description": "The card holder's name",
7327+
"example": "John Doe"
7328+
}
7329+
}
7330+
},
72597331
"CardRedirectData": {
72607332
"oneOf": [
72617333
{
@@ -16752,7 +16824,7 @@
1675216824
],
1675316825
"properties": {
1675416826
"card": {
16755-
"$ref": "#/components/schemas/Card"
16827+
"$ref": "#/components/schemas/CardPayout"
1675616828
}
1675716829
}
1675816830
},

0 commit comments

Comments
 (0)