iyzipay_rust/requests/
iyziup.rs1use bigdecimal::BigDecimal;
2
3use crate::model::InitialConsumer;
4use crate::model::OrderItem;
5use crate::requests::PKISerialize;
6use crate::requests::Request;
7use crate::requests::RequestStringBuilder;
8
9#[derive(Debug, Default, Serialize, Deserialize)]
10#[serde(rename_all = "camelCase")]
11pub struct CreateIyziupFormInitializeRequest {
12 #[serde(flatten)]
13 request: Request,
14
15 merchant_order_id: Option<String>,
16
17 payment_group: Option<String>,
18
19 payment_source: Option<String>,
20
21 #[serde(rename = "forceThreeDS")]
22 force_three_ds: Option<u8>,
23
24 enabled_installments: Option<Vec<u8>>,
25
26 enabled_card_family: Option<String>,
27
28 currency: Option<String>,
29
30 price: Option<BigDecimal>,
31
32 paid_price: Option<BigDecimal>,
33
34 shipping_price: Option<BigDecimal>,
35
36 callback_url: Option<String>,
37
38 terms_url: Option<String>,
39
40 pre_sales_contract_url: Option<String>,
41
42 order_items: Option<Vec<OrderItem>>,
43
44 initial_consumer: Option<InitialConsumer>,
45}
46
47impl CreateIyziupFormInitializeRequest {
48 pub fn new() -> Self {
49 CreateIyziupFormInitializeRequest::default()
50 }
51
52 pub fn set_merchant_order_id<T: Into<String>>(&mut self, merchant_order_id: T) {
53 self.merchant_order_id = Some(merchant_order_id.into());
54 }
55
56 pub fn set_payment_group<T: Into<String>>(&mut self, payment_group: T) {
57 self.payment_group = Some(payment_group.into());
58 }
59
60 pub fn set_payment_source<T: Into<String>>(&mut self, payment_source: T) {
61 self.payment_source = Some(payment_source.into());
62 }
63
64 pub fn set_force_three_ds<T: Into<u8>>(&mut self, force_three_ds: T) {
65 self.force_three_ds = Some(force_three_ds.into());
66 }
67
68 pub fn set_enabled_installments<T: Into<Vec<u8>>>(&mut self, enabled_installments: T) {
69 self.enabled_installments = Some(enabled_installments.into());
70 }
71
72 pub fn set_enabled_card_family<T: Into<String>>(&mut self, enabled_card_family: T) {
73 self.enabled_card_family = Some(enabled_card_family.into());
74 }
75
76 pub fn set_currency<T: Into<String>>(&mut self, currency: T) {
77 self.currency = Some(currency.into());
78 }
79
80 pub fn set_price<T: Into<BigDecimal>>(&mut self, price: T) {
81 self.price = Some(price.into());
82 }
83
84 pub fn set_paid_price<T: Into<BigDecimal>>(&mut self, paid_price: T) {
85 self.paid_price = Some(paid_price.into());
86 }
87
88 pub fn set_shipping_price<T: Into<BigDecimal>>(&mut self, shipping_price: T) {
89 self.shipping_price = Some(shipping_price.into());
90 }
91
92 pub fn set_callback_url<T: Into<String>>(&mut self, callback_url: T) {
93 self.callback_url = Some(callback_url.into());
94 }
95
96 pub fn set_terms_url<T: Into<String>>(&mut self, terms_url: T) {
97 self.terms_url = Some(terms_url.into());
98 }
99
100 pub fn set_pre_sales_contract_url<T: Into<String>>(&mut self, pre_sales_contract_url: T) {
101 self.pre_sales_contract_url = Some(pre_sales_contract_url.into());
102 }
103
104 pub fn set_order_items<T: Into<Vec<OrderItem>>>(&mut self, order_items: T) {
105 self.order_items = Some(order_items.into());
106 }
107
108 pub fn set_initial_consumer<T: Into<InitialConsumer>>(&mut self, initial_consumer: T) {
109 self.initial_consumer = Some(initial_consumer.into());
110 }
111
112 pub fn merchant_order_id(&self) -> Option<&String> {
113 self.merchant_order_id.as_ref()
114 }
115 pub fn payment_group(&self) -> Option<&String> {
116 self.payment_group.as_ref()
117 }
118 pub fn payment_source(&self) -> Option<&String> {
119 self.payment_source.as_ref()
120 }
121 pub fn force_three_ds(&self) -> Option<&u8> {
122 self.force_three_ds.as_ref()
123 }
124 pub fn enabled_installments(&self) -> Option<&Vec<u8>> {
125 self.enabled_installments.as_ref()
126 }
127 pub fn enabled_card_family(&self) -> Option<&String> {
128 self.enabled_card_family.as_ref()
129 }
130 pub fn currency(&self) -> Option<&String> {
131 self.currency.as_ref()
132 }
133 pub fn price(&self) -> Option<&BigDecimal> {
134 self.price.as_ref()
135 }
136 pub fn paid_price(&self) -> Option<&BigDecimal> {
137 self.paid_price.as_ref()
138 }
139 pub fn shipping_price(&self) -> Option<&BigDecimal> {
140 self.shipping_price.as_ref()
141 }
142 pub fn callback_url(&self) -> Option<&String> {
143 self.callback_url.as_ref()
144 }
145 pub fn terms_url(&self) -> Option<&String> {
146 self.terms_url.as_ref()
147 }
148 pub fn pre_sales_contract_url(&self) -> Option<&String> {
149 self.pre_sales_contract_url.as_ref()
150 }
151 pub fn order_items(&self) -> Option<&Vec<OrderItem>> {
152 self.order_items.as_ref()
153 }
154 pub fn initial_consumer(&self) -> Option<&InitialConsumer> {
155 self.initial_consumer.as_ref()
156 }
157}
158
159impl PKISerialize for CreateIyziupFormInitializeRequest {
160 fn serialize(&self) -> Option<String> {
161 let mut ser = RequestStringBuilder::new();
162 ser.append_option_val(self.request.serialize());
163 ser.append_option("merchantOrderId", self.merchant_order_id.as_ref());
164 ser.append_option("paymentGroup", self.payment_group.as_ref());
165 ser.append_option("paymentSource", self.payment_source.as_ref());
166 ser.append_option("forceThreeDS", self.force_three_ds.as_ref());
167 ser.append_option("enabledInstallments", self.enabled_installments.serialize());
168 ser.append_option("enabledCardFamily", self.enabled_card_family.as_ref());
169 ser.append_option("currency", self.currency.as_ref());
170 ser.append_price_option("price", self.price.as_ref());
171 ser.append_price_option("paidPrice", self.paid_price.as_ref());
172 ser.append_price_option("shippingPrice", self.shipping_price.as_ref());
173 ser.append_option("callbackUrl", self.callback_url.as_ref());
174 ser.append_option("termsUrl", self.terms_url.as_ref());
175 ser.append_option("preSalesContractUrl", self.pre_sales_contract_url.as_ref());
176 ser.append_option("orderItems", self.order_items.serialize());
177 ser.append_option("initialConsumer", self.initial_consumer.serialize());
178 Option::from(ser.build(true))
179 }
180}
181
182impl std::ops::Deref for CreateIyziupFormInitializeRequest {
183 type Target = Request;
184 fn deref(&self) -> &Self::Target {
185 &self.request
186 }
187}
188
189impl std::ops::DerefMut for CreateIyziupFormInitializeRequest {
190 fn deref_mut(&mut self) -> &mut Self::Target {
191 &mut self.request
192 }
193}
194
195#[derive(Debug, Default, Serialize, Deserialize)]
196#[serde(rename_all = "camelCase")]
197pub struct RetrieveIyziupFormRequest {
198 #[serde(flatten)]
199 request: Request,
200
201 token: Option<String>,
202}
203
204impl RetrieveIyziupFormRequest {
205 pub fn new() -> Self {
206 RetrieveIyziupFormRequest::default()
207 }
208
209 pub fn set_token<T: Into<String>>(&mut self, token: T) {
210 self.token = Some(token.into());
211 }
212
213 pub fn token(&self) -> Option<&String> {
214 self.token.as_ref()
215 }
216}
217
218impl PKISerialize for RetrieveIyziupFormRequest {
219 fn serialize(&self) -> Option<String> {
220 let mut ser = RequestStringBuilder::new();
221 ser.append_option_val(self.request.serialize());
222 ser.append_option("token", self.token.as_ref());
223 Option::from(ser.build(true))
224 }
225}
226
227impl std::ops::Deref for RetrieveIyziupFormRequest {
228 type Target = Request;
229 fn deref(&self) -> &Self::Target {
230 &self.request
231 }
232}
233
234impl std::ops::DerefMut for RetrieveIyziupFormRequest {
235 fn deref_mut(&mut self) -> &mut Self::Target {
236 &mut self.request
237 }
238}