1use payjp_client_core::{PayjpClient, BlockingClient, PayjpRequest, RequestBuilder, PayjpMethod};
2
3#[derive(Copy,Clone,Debug,)]#[derive(serde::Serialize)]
4 struct ListTenantBuilder {
5#[serde(skip_serializing_if = "Option::is_none")]
6 limit: Option<i64>,
7#[serde(skip_serializing_if = "Option::is_none")]
8 offset: Option<i64>,
9#[serde(skip_serializing_if = "Option::is_none")]
10 since: Option<i64>,
11#[serde(skip_serializing_if = "Option::is_none")]
12 until: Option<i64>,
13
14}
15impl ListTenantBuilder {
16 fn new() -> Self {
17 Self {
18 limit: None,offset: None,since: None,until: None,
19 }
20}
21
22}
23 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
25pub struct ListTenant {
26 inner: ListTenantBuilder,
27
28}
29impl ListTenant {
30 pub fn new() -> Self {
32 Self {
33 inner: ListTenantBuilder::new()
34 }
35}
36 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
38 self.inner.limit = Some(limit.into());
39 self
40}
41 pub fn offset(mut self, offset: impl Into<i64>) -> Self {
43 self.inner.offset = Some(offset.into());
44 self
45}
46 pub fn since(mut self, since: impl Into<i64>) -> Self {
48 self.inner.since = Some(since.into());
49 self
50}
51 pub fn until(mut self, until: impl Into<i64>) -> Self {
53 self.inner.until = Some(until.into());
54 self
55}
56
57}
58 impl Default for ListTenant {
59 fn default() -> Self {
60 Self::new()
61 }
62}impl ListTenant {
63 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
65 self.customize().send(client).await
66 }
67
68 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
70 self.customize().send_blocking(client)
71 }
72
73 pub fn paginate(&self) -> payjp_client_core::ListPaginator<payjp_types::List<payjp_core::Tenant>> {
74
75 payjp_client_core::ListPaginator::new_list("/tenants", &self.inner)
76}
77
78}
79
80impl PayjpRequest for ListTenant {
81 type Output = payjp_types::List<payjp_core::Tenant>;
82
83 fn build(&self) -> RequestBuilder {
84 RequestBuilder::new(PayjpMethod::Get, "/tenants").query(&self.inner)
85}
86
87}
88#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
89 struct CreateTenantBuilder {
90#[serde(skip_serializing_if = "Option::is_none")]
91 bank_account_holder_name: Option<String>,
92#[serde(skip_serializing_if = "Option::is_none")]
93 bank_account_number: Option<String>,
94#[serde(skip_serializing_if = "Option::is_none")]
95 bank_account_type: Option<String>,
96#[serde(skip_serializing_if = "Option::is_none")]
97 bank_branch_code: Option<String>,
98#[serde(skip_serializing_if = "Option::is_none")]
99 bank_code: Option<String>,
100#[serde(skip_serializing_if = "Option::is_none")]
101 id: Option<String>,
102#[serde(skip_serializing_if = "Option::is_none")]
103 metadata: Option<payjp_shared::Metadata>,
104#[serde(skip_serializing_if = "Option::is_none")]
105 minimum_transfer_amount: Option<i64>,
106 name: String,
107#[serde(skip_serializing_if = "Option::is_none")]
108 payjp_fee_included: Option<bool>,
109 platform_fee_rate: f64,
110
111}
112impl CreateTenantBuilder {
113 fn new(name: impl Into<String>,platform_fee_rate: impl Into<f64>,) -> Self {
114 Self {
115 bank_account_holder_name: None,bank_account_number: None,bank_account_type: None,bank_branch_code: None,bank_code: None,id: None,metadata: None,minimum_transfer_amount: None,name: name.into(),payjp_fee_included: None,platform_fee_rate: platform_fee_rate.into(),
116 }
117}
118
119}
120 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
124pub struct CreateTenant {
125 inner: CreateTenantBuilder,
126
127}
128impl CreateTenant {
129 pub fn new(name:impl Into<String>,platform_fee_rate:impl Into<f64>) -> Self {
131 Self {
132 inner: CreateTenantBuilder::new(name.into(),platform_fee_rate.into(),)
133 }
134}
135 pub fn bank_account_holder_name(mut self, bank_account_holder_name: impl Into<String>) -> Self {
137 self.inner.bank_account_holder_name = Some(bank_account_holder_name.into());
138 self
139}
140 pub fn bank_account_number(mut self, bank_account_number: impl Into<String>) -> Self {
142 self.inner.bank_account_number = Some(bank_account_number.into());
143 self
144}
145 pub fn bank_account_type(mut self, bank_account_type: impl Into<String>) -> Self {
147 self.inner.bank_account_type = Some(bank_account_type.into());
148 self
149}
150 pub fn bank_branch_code(mut self, bank_branch_code: impl Into<String>) -> Self {
152 self.inner.bank_branch_code = Some(bank_branch_code.into());
153 self
154}
155 pub fn bank_code(mut self, bank_code: impl Into<String>) -> Self {
157 self.inner.bank_code = Some(bank_code.into());
158 self
159}
160 pub fn id(mut self, id: impl Into<String>) -> Self {
162 self.inner.id = Some(id.into());
163 self
164}
165pub fn metadata(mut self, metadata: impl Into<payjp_shared::Metadata>) -> Self {
166 self.inner.metadata = Some(metadata.into());
167 self
168}
169 pub fn minimum_transfer_amount(mut self, minimum_transfer_amount: impl Into<i64>) -> Self {
171 self.inner.minimum_transfer_amount = Some(minimum_transfer_amount.into());
172 self
173}
174 pub fn payjp_fee_included(mut self, payjp_fee_included: impl Into<bool>) -> Self {
176 self.inner.payjp_fee_included = Some(payjp_fee_included.into());
177 self
178}
179
180}
181 impl CreateTenant {
182 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
184 self.customize().send(client).await
185 }
186
187 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
189 self.customize().send_blocking(client)
190 }
191
192
193}
194
195impl PayjpRequest for CreateTenant {
196 type Output = payjp_core::Tenant;
197
198 fn build(&self) -> RequestBuilder {
199 RequestBuilder::new(PayjpMethod::Post, "/tenants").form(&self.inner)
200}
201
202}
203 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
205pub struct RetrieveTenant {
206 tenant: String,
207
208}
209impl RetrieveTenant {
210 pub fn new(tenant:impl Into<String>) -> Self {
212 Self {
213 tenant: tenant.into(),
214 }
215}
216
217}
218 impl RetrieveTenant {
219 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
221 self.customize().send(client).await
222 }
223
224 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
226 self.customize().send_blocking(client)
227 }
228
229
230}
231
232impl PayjpRequest for RetrieveTenant {
233 type Output = payjp_core::Tenant;
234
235 fn build(&self) -> RequestBuilder {
236 let tenant = &self.tenant;
237RequestBuilder::new(PayjpMethod::Get, format!("/tenants/{tenant}"))
238}
239
240}
241#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
242 struct UpdateTenantBuilder {
243#[serde(skip_serializing_if = "Option::is_none")]
244 bank_account_holder_name: Option<String>,
245#[serde(skip_serializing_if = "Option::is_none")]
246 bank_account_number: Option<String>,
247#[serde(skip_serializing_if = "Option::is_none")]
248 bank_account_type: Option<String>,
249#[serde(skip_serializing_if = "Option::is_none")]
250 bank_branch_code: Option<String>,
251#[serde(skip_serializing_if = "Option::is_none")]
252 bank_code: Option<String>,
253#[serde(skip_serializing_if = "Option::is_none")]
254 metadata: Option<payjp_shared::Metadata>,
255#[serde(skip_serializing_if = "Option::is_none")]
256 minimum_transfer_amount: Option<i64>,
257#[serde(skip_serializing_if = "Option::is_none")]
258 name: Option<String>,
259#[serde(skip_serializing_if = "Option::is_none")]
260 platform_fee_rate: Option<f64>,
261
262}
263impl UpdateTenantBuilder {
264 fn new() -> Self {
265 Self {
266 bank_account_holder_name: None,bank_account_number: None,bank_account_type: None,bank_branch_code: None,bank_code: None,metadata: None,minimum_transfer_amount: None,name: None,platform_fee_rate: None,
267 }
268}
269
270}
271 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
273pub struct UpdateTenant {
274 inner: UpdateTenantBuilder,
275 tenant: String,
276
277}
278impl UpdateTenant {
279 pub fn new(tenant:impl Into<String>) -> Self {
281 Self {
282 tenant: tenant.into(),inner: UpdateTenantBuilder::new()
283 }
284}
285 pub fn bank_account_holder_name(mut self, bank_account_holder_name: impl Into<String>) -> Self {
287 self.inner.bank_account_holder_name = Some(bank_account_holder_name.into());
288 self
289}
290 pub fn bank_account_number(mut self, bank_account_number: impl Into<String>) -> Self {
292 self.inner.bank_account_number = Some(bank_account_number.into());
293 self
294}
295 pub fn bank_account_type(mut self, bank_account_type: impl Into<String>) -> Self {
297 self.inner.bank_account_type = Some(bank_account_type.into());
298 self
299}
300 pub fn bank_branch_code(mut self, bank_branch_code: impl Into<String>) -> Self {
302 self.inner.bank_branch_code = Some(bank_branch_code.into());
303 self
304}
305 pub fn bank_code(mut self, bank_code: impl Into<String>) -> Self {
307 self.inner.bank_code = Some(bank_code.into());
308 self
309}
310pub fn metadata(mut self, metadata: impl Into<payjp_shared::Metadata>) -> Self {
311 self.inner.metadata = Some(metadata.into());
312 self
313}
314 pub fn minimum_transfer_amount(mut self, minimum_transfer_amount: impl Into<i64>) -> Self {
316 self.inner.minimum_transfer_amount = Some(minimum_transfer_amount.into());
317 self
318}
319 pub fn name(mut self, name: impl Into<String>) -> Self {
321 self.inner.name = Some(name.into());
322 self
323}
324 pub fn platform_fee_rate(mut self, platform_fee_rate: impl Into<f64>) -> Self {
326 self.inner.platform_fee_rate = Some(platform_fee_rate.into());
327 self
328}
329
330}
331 impl UpdateTenant {
332 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
334 self.customize().send(client).await
335 }
336
337 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
339 self.customize().send_blocking(client)
340 }
341
342
343}
344
345impl PayjpRequest for UpdateTenant {
346 type Output = payjp_core::Tenant;
347
348 fn build(&self) -> RequestBuilder {
349 let tenant = &self.tenant;
350RequestBuilder::new(PayjpMethod::Post, format!("/tenants/{tenant}")).form(&self.inner)
351}
352
353}
354 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
358pub struct DeleteTenant {
359 tenant: String,
360
361}
362impl DeleteTenant {
363 pub fn new(tenant:impl Into<String>) -> Self {
365 Self {
366 tenant: tenant.into(),
367 }
368}
369
370}
371 impl DeleteTenant {
372 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
374 self.customize().send(client).await
375 }
376
377 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
379 self.customize().send_blocking(client)
380 }
381
382
383}
384
385impl PayjpRequest for DeleteTenant {
386 type Output = payjp_shared::DeleteResponse;
387
388 fn build(&self) -> RequestBuilder {
389 let tenant = &self.tenant;
390RequestBuilder::new(PayjpMethod::Delete, format!("/tenants/{tenant}"))
391}
392
393}
394 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
398pub struct ApplicationUrlsTenant {
399 tenant: String,
400
401}
402impl ApplicationUrlsTenant {
403 pub fn new(tenant:impl Into<String>) -> Self {
405 Self {
406 tenant: tenant.into(),
407 }
408}
409
410}
411 impl ApplicationUrlsTenant {
412 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
414 self.customize().send(client).await
415 }
416
417 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
419 self.customize().send_blocking(client)
420 }
421
422
423}
424
425impl PayjpRequest for ApplicationUrlsTenant {
426 type Output = ApplicationUrlsTenantReturned;
427
428 fn build(&self) -> RequestBuilder {
429 let tenant = &self.tenant;
430RequestBuilder::new(PayjpMethod::Post, format!("/tenants/{tenant}/application_urls"))
431}
432
433}
434#[derive(Clone,Debug,)]#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
435#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
436pub struct ApplicationUrlsTenantReturned {
437 pub expires: i64,
439 pub object: ApplicationUrlsTenantReturnedObject,
441 pub url: String,
443
444}
445#[doc(hidden)]
446pub struct ApplicationUrlsTenantReturnedBuilder {
447 expires: Option<i64>,
448object: Option<ApplicationUrlsTenantReturnedObject>,
449url: Option<String>,
450
451}
452
453#[allow(unused_variables, irrefutable_let_patterns, clippy::let_unit_value, clippy::match_single_binding, clippy::single_match)]
454const _: () = {
455 use miniserde::de::{Map, Visitor};
456 use miniserde::json::Value;
457 use miniserde::{make_place, Deserialize, Result};
458 use payjp_types::{MapBuilder, ObjectDeser};
459 use payjp_types::miniserde_helpers::FromValueOpt;
460
461 make_place!(Place);
462
463 impl Deserialize for ApplicationUrlsTenantReturned {
464 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
465 Place::new(out)
466 }
467}
468
469struct Builder<'a> {
470 out: &'a mut Option<ApplicationUrlsTenantReturned>,
471 builder: ApplicationUrlsTenantReturnedBuilder,
472}
473
474impl Visitor for Place<ApplicationUrlsTenantReturned> {
475 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
476 Ok(Box::new(Builder {
477 out: &mut self.out,
478 builder: ApplicationUrlsTenantReturnedBuilder::deser_default(),
479 }))
480 }
481}
482
483impl MapBuilder for ApplicationUrlsTenantReturnedBuilder {
484 type Out = ApplicationUrlsTenantReturned;
485 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
486 Ok(match k {
487 "expires" => Deserialize::begin(&mut self.expires),
488"object" => Deserialize::begin(&mut self.object),
489"url" => Deserialize::begin(&mut self.url),
490
491 _ => <dyn Visitor>::ignore(),
492 })
493 }
494
495 fn deser_default() -> Self {
496 Self {
497 expires: Deserialize::default(),
498object: Deserialize::default(),
499url: Deserialize::default(),
500
501 }
502 }
503
504 fn take_out(&mut self) -> Option<Self::Out> {
505 let (Some(expires),
506Some(object),
507Some(url),
508) = (self.expires,
509self.object,
510self.url.take(),
511) else {
512 return None;
513 };
514 Some(Self::Out { expires,object,url })
515 }
516}
517
518impl<'a> Map for Builder<'a> {
519 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
520 self.builder.key(k)
521 }
522
523 fn finish(&mut self) -> Result<()> {
524 *self.out = self.builder.take_out();
525 Ok(())
526 }
527}
528
529impl ObjectDeser for ApplicationUrlsTenantReturned {
530 type Builder = ApplicationUrlsTenantReturnedBuilder;
531}
532
533impl FromValueOpt for ApplicationUrlsTenantReturned {
534 fn from_value(v: Value) -> Option<Self> {
535 let Value::Object(obj) = v else {
536 return None;
537 };
538 let mut b = ApplicationUrlsTenantReturnedBuilder::deser_default();
539 for (k, v) in obj {
540 match k.as_str() {
541 "expires" => b.expires = FromValueOpt::from_value(v),
542"object" => b.object = FromValueOpt::from_value(v),
543"url" => b.url = FromValueOpt::from_value(v),
544
545 _ => {}
546 }
547 }
548 b.take_out()
549 }
550}
551
552};
553#[derive(Copy,Clone,Eq, PartialEq,)]pub enum ApplicationUrlsTenantReturnedObject {
555ApplicationUrl,
556
557}
558impl ApplicationUrlsTenantReturnedObject {
559 pub fn as_str(self) -> &'static str {
560 use ApplicationUrlsTenantReturnedObject::*;
561 match self {
562ApplicationUrl => "application_url",
563
564 }
565 }
566}
567
568impl std::str::FromStr for ApplicationUrlsTenantReturnedObject {
569 type Err = payjp_types::ParseError;
570 fn from_str(s: &str) -> Result<Self, Self::Err> {
571 use ApplicationUrlsTenantReturnedObject::*;
572 match s {
573 "application_url" => Ok(ApplicationUrl),
574_ => Err(payjp_types::ParseError)
575
576 }
577 }
578}
579impl std::fmt::Display for ApplicationUrlsTenantReturnedObject {
580 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
581 f.write_str(self.as_str())
582 }
583}
584
585impl std::fmt::Debug for ApplicationUrlsTenantReturnedObject {
586 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
587 f.write_str(self.as_str())
588 }
589}
590#[cfg(feature = "serialize")]
591impl serde::Serialize for ApplicationUrlsTenantReturnedObject {
592 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
593 serializer.serialize_str(self.as_str())
594 }
595}
596impl miniserde::Deserialize for ApplicationUrlsTenantReturnedObject {
597 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
598 crate::Place::new(out)
599 }
600}
601
602impl miniserde::de::Visitor for crate::Place<ApplicationUrlsTenantReturnedObject> {
603 fn string(&mut self, s: &str) -> miniserde::Result<()> {
604 use std::str::FromStr;
605 self.out = Some(ApplicationUrlsTenantReturnedObject::from_str(s).map_err(|_| miniserde::Error)?);
606 Ok(())
607 }
608}
609
610payjp_types::impl_from_val_with_from_str!(ApplicationUrlsTenantReturnedObject);
611#[cfg(feature = "deserialize")]
612impl<'de> serde::Deserialize<'de> for ApplicationUrlsTenantReturnedObject {
613 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
614 use std::str::FromStr;
615 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
616 Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ApplicationUrlsTenantReturnedObject"))
617 }
618}
619