payjp_core/tenant/
requests.rs

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        /// テナントのリストを取得します。
24#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
25pub struct ListTenant {
26 inner: ListTenantBuilder,
27
28}
29impl ListTenant {
30    /// Construct a new `ListTenant`.
31pub fn new() -> Self {
32    Self {
33        inner: ListTenantBuilder::new()
34    }
35}
36    /// 取得するデータ数の最大値(1~100まで)。指定がない場合は 10 となる。
37pub fn limit(mut self, limit: impl Into<i64>) -> Self {
38    self.inner.limit = Some(limit.into());
39    self
40}
41    /// 基準点からのデータ取得を行う開始位置。指定がない場合は 0 となる。
42pub fn offset(mut self, offset: impl Into<i64>) -> Self {
43    self.inner.offset = Some(offset.into());
44    self
45}
46    /// ここに指定したタイムスタンプ以降に作成されたデータを取得
47pub fn since(mut self, since: impl Into<i64>) -> Self {
48    self.inner.since = Some(since.into());
49    self
50}
51    /// ここに指定したタイムスタンプ以前に作成されたデータを取得
52pub 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    /// Send the request and return the deserialized response.
64    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    /// Send the request and return the deserialized response, blocking until completion.
69    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        /// 名前やIDなどを指定してテナントを作成します。
121    ///
122    /// 作成したテナントはあとから更新・削除することができます。
123#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
124pub struct CreateTenant {
125 inner: CreateTenantBuilder,
126
127}
128impl CreateTenant {
129    /// Construct a new `CreateTenant`.
130pub 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    /// 口座名義(Payouts型アカウントの場合は必須)
136pub 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    /// 口座番号(Payouts型アカウントの場合は必須)
141pub 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    /// 預金種別(Payouts型アカウントの場合は必須)
146pub 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    /// 3桁の支店コード(Payouts型アカウントの場合は必須)
151pub 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    /// 4桁の銀行コード(Payouts型アカウントの場合は必須)
156pub fn bank_code(mut self, bank_code: impl Into<String>) -> Self {
157    self.inner.bank_code = Some(bank_code.into());
158    self
159}
160        /// テナントIDとなる任意の文字列。一意にならないとエラーになります。また、未指定時は自動生成されます。.
161pub 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    /// 最低入金額。デフォルトは1万円で下限は1000円。
170pub 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        /// テナントのプラットフォーム利用料にPAY.JP決済手数料を含めるかどうか。デフォルトはfalse。作成時にのみ指定可能で、あとから変更はできません。.
175pub 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    /// Send the request and return the deserialized response.
183    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    /// Send the request and return the deserialized response, blocking until completion.
188    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    /// テナント情報を取得します。
204#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
205pub struct RetrieveTenant {
206 tenant: String,
207
208}
209impl RetrieveTenant {
210    /// Construct a new `RetrieveTenant`.
211pub fn new(tenant:impl Into<String>) -> Self {
212    Self {
213        tenant: tenant.into(),
214    }
215}
216
217}
218    impl RetrieveTenant {
219    /// Send the request and return the deserialized response.
220    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    /// Send the request and return the deserialized response, blocking until completion.
225    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        /// 生成したテナント情報を更新することができます。
272#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
273pub struct UpdateTenant {
274 inner: UpdateTenantBuilder,
275 tenant: String,
276
277}
278impl UpdateTenant {
279    /// Construct a new `UpdateTenant`.
280pub fn new(tenant:impl Into<String>) -> Self {
281    Self {
282        tenant: tenant.into(),inner: UpdateTenantBuilder::new()
283    }
284}
285    /// 口座名義
286pub 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    /// 口座番号
291pub 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    /// 預金種別
296pub 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    /// 3桁の支店コード
301pub 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    /// 4桁の銀行コード
306pub 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    /// 最低入金額。デフォルトは1万円で下限は1000円。
315pub 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    /// テナント名
320pub fn name(mut self, name: impl Into<String>) -> Self {
321    self.inner.name = Some(name.into());
322    self
323}
324        /// テナントのプラットフォーム利用料率(%)。小数点以下2桁まで入力可能。最大95%.
325pub 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    /// Send the request and return the deserialized response.
333    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    /// Send the request and return the deserialized response, blocking until completion.
338    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    /// 生成したテナント情報を削除します。
355    ///
356        /// 削除したテナントと同じIDのテナントをもう一度生成することができますが、削除したテナントとは別のテナントとして扱われます。.
357#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
358pub struct DeleteTenant {
359 tenant: String,
360
361}
362impl DeleteTenant {
363    /// Construct a new `DeleteTenant`.
364pub fn new(tenant:impl Into<String>) -> Self {
365    Self {
366        tenant: tenant.into(),
367    }
368}
369
370}
371    impl DeleteTenant {
372    /// Send the request and return the deserialized response.
373    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    /// Send the request and return the deserialized response, blocking until completion.
378    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        /// (Marketplace型アカウントのみ利用可能)テナントの審査申請ページのURLを作成します。.
395    ///
396        /// テストモードの場合、実際の審査は行われず情報が保存されない為、常に新規申請になります。.
397#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
398pub struct ApplicationUrlsTenant {
399 tenant: String,
400
401}
402impl ApplicationUrlsTenant {
403    /// Construct a new `ApplicationUrlsTenant`.
404pub fn new(tenant:impl Into<String>) -> Self {
405    Self {
406        tenant: tenant.into(),
407    }
408}
409
410}
411    impl ApplicationUrlsTenant {
412    /// Send the request and return the deserialized response.
413    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    /// Send the request and return the deserialized response, blocking until completion.
418    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    /// application_urlの使用期限のタイムスタンプ。発行から5分
438pub expires: i64,
439    /// 固定文字列
440pub object: ApplicationUrlsTenantReturnedObject,
441    /// テナントの審査申請URL
442pub 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/// 固定文字列
554#[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