1use payjp_client_core::{PayjpClient, BlockingClient, PayjpRequest, RequestBuilder, PayjpMethod};
2
3#[derive(Copy,Clone,Debug,)]#[derive(serde::Serialize)]
4 struct ListCustomerBuilder {
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 ListCustomerBuilder {
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 ListCustomer {
26 inner: ListCustomerBuilder,
27
28}
29impl ListCustomer {
30 pub fn new() -> Self {
32 Self {
33 inner: ListCustomerBuilder::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 ListCustomer {
59 fn default() -> Self {
60 Self::new()
61 }
62}impl ListCustomer {
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::Customer>> {
74
75 payjp_client_core::ListPaginator::new_list("/customers", &self.inner)
76}
77
78}
79
80impl PayjpRequest for ListCustomer {
81 type Output = payjp_types::List<payjp_core::Customer>;
82
83 fn build(&self) -> RequestBuilder {
84 RequestBuilder::new(PayjpMethod::Get, "/customers").query(&self.inner)
85}
86
87}
88#[derive(Clone,Debug,serde::Serialize)]
89 struct CreateCustomerBuilder {
90#[serde(skip_serializing_if = "Option::is_none")]
91 card: Option<String>,
92#[serde(skip_serializing_if = "Option::is_none")]
93 description: Option<String>,
94#[serde(skip_serializing_if = "Option::is_none")]
95 email: Option<String>,
96#[serde(skip_serializing_if = "Option::is_none")]
97 id: Option<String>,
98#[serde(skip_serializing_if = "Option::is_none")]
99 metadata: Option<std::collections::HashMap<String, String>>,
100
101}
102impl CreateCustomerBuilder {
103 fn new() -> Self {
104 Self {
105 card: None,description: None,email: None,id: None,metadata: None,
106 }
107}
108
109}
110 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
112pub struct CreateCustomer {
113 inner: CreateCustomerBuilder,
114
115}
116impl CreateCustomer {
117 pub fn new() -> Self {
119 Self {
120 inner: CreateCustomerBuilder::new()
121 }
122}
123 pub fn card(mut self, card: impl Into<String>) -> Self {
125 self.inner.card = Some(card.into());
126 self
127}
128 pub fn description(mut self, description: impl Into<String>) -> Self {
130 self.inner.description = Some(description.into());
131 self
132}
133 pub fn email(mut self, email: impl Into<String>) -> Self {
135 self.inner.email = Some(email.into());
136 self
137}
138 pub fn id(mut self, id: impl Into<String>) -> Self {
140 self.inner.id = Some(id.into());
141 self
142}
143pub fn metadata(mut self,
144 metadata: impl Into<std::collections::HashMap<String, String>>
145) -> Self {
146 self.inner.metadata = Some(metadata.into());
147 self
148}
149
150}
151 impl Default for CreateCustomer {
152 fn default() -> Self {
153 Self::new()
154 }
155}impl CreateCustomer {
156 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
158 self.customize().send(client).await
159 }
160
161 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
163 self.customize().send_blocking(client)
164 }
165
166
167}
168
169impl PayjpRequest for CreateCustomer {
170 type Output = payjp_core::Customer;
171
172 fn build(&self) -> RequestBuilder {
173 RequestBuilder::new(PayjpMethod::Post, "/customers").form(&self.inner)
174}
175
176}
177 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
179pub struct RetrieveCustomer {
180 customer: payjp_core::CustomerId,
181
182}
183impl RetrieveCustomer {
184 pub fn new(customer:impl Into<payjp_core::CustomerId>) -> Self {
186 Self {
187 customer: customer.into(),
188 }
189}
190
191}
192 impl RetrieveCustomer {
193 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
195 self.customize().send(client).await
196 }
197
198 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
200 self.customize().send_blocking(client)
201 }
202
203
204}
205
206impl PayjpRequest for RetrieveCustomer {
207 type Output = payjp_core::Customer;
208
209 fn build(&self) -> RequestBuilder {
210 let customer = &self.customer;
211RequestBuilder::new(PayjpMethod::Get, format!("/customers/{customer}"))
212}
213
214}
215#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
216 struct UpdateCustomerBuilder {
217#[serde(skip_serializing_if = "Option::is_none")]
218 card: Option<String>,
219#[serde(skip_serializing_if = "Option::is_none")]
220 default_card: Option<String>,
221#[serde(skip_serializing_if = "Option::is_none")]
222 description: Option<String>,
223#[serde(skip_serializing_if = "Option::is_none")]
224 email: Option<String>,
225#[serde(skip_serializing_if = "Option::is_none")]
226metadata: Option<std::collections::HashMap<String, String>>,
227
228}
229impl UpdateCustomerBuilder {
230 fn new() -> Self {
231 Self {
232 card: None,default_card: None,description: None,email: None,metadata: None,
233 }
234}
235
236}
237 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
239pub struct UpdateCustomer {
240 inner: UpdateCustomerBuilder,
241 customer: payjp_core::CustomerId,
242
243}
244impl UpdateCustomer {
245 pub fn new(customer:impl Into<payjp_core::CustomerId>) -> Self {
247 Self {
248 customer: customer.into(),inner: UpdateCustomerBuilder::new()
249 }
250}
251 pub fn card(mut self, card: impl Into<String>) -> Self {
253 self.inner.card = Some(card.into());
254 self
255}
256 pub fn default_card(mut self, default_card: impl Into<String>) -> Self {
258 self.inner.default_card = Some(default_card.into());
259 self
260}
261 pub fn description(mut self, description: impl Into<String>) -> Self {
263 self.inner.description = Some(description.into());
264 self
265}
266 pub fn email(mut self, email: impl Into<String>) -> Self {
268 self.inner.email = Some(email.into());
269 self
270}
271pub fn metadata(mut self,
272 metadata: impl Into<std::collections::HashMap<String, String>>
273) -> Self {
274 self.inner.metadata = Some(metadata.into());
275 self
276}
277
278}
279 impl UpdateCustomer {
280 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
282 self.customize().send(client).await
283 }
284
285 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
287 self.customize().send_blocking(client)
288 }
289
290
291}
292
293impl PayjpRequest for UpdateCustomer {
294 type Output = payjp_core::Customer;
295
296 fn build(&self) -> RequestBuilder {
297 let customer = &self.customer;
298RequestBuilder::new(PayjpMethod::Post, format!("/customers/{customer}")).form(&self.inner)
299}
300
301}
302 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
304pub struct DeleteCustomer {
305 customer: payjp_core::CustomerId,
306
307}
308impl DeleteCustomer {
309 pub fn new(customer:impl Into<payjp_core::CustomerId>) -> Self {
311 Self {
312 customer: customer.into(),
313 }
314}
315
316}
317 impl DeleteCustomer {
318 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
320 self.customize().send(client).await
321 }
322
323 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
325 self.customize().send_blocking(client)
326 }
327
328
329}
330
331impl PayjpRequest for DeleteCustomer {
332 type Output = payjp_shared::DeleteResponse;
333
334 fn build(&self) -> RequestBuilder {
335 let customer = &self.customer;
336RequestBuilder::new(PayjpMethod::Delete, format!("/customers/{customer}"))
337}
338
339}
340#[derive(Copy,Clone,Debug,)]#[derive(serde::Serialize)]
341 struct ListCardCustomerBuilder {
342#[serde(skip_serializing_if = "Option::is_none")]
343 limit: Option<i64>,
344#[serde(skip_serializing_if = "Option::is_none")]
345 offset: Option<i64>,
346#[serde(skip_serializing_if = "Option::is_none")]
347 since: Option<i64>,
348#[serde(skip_serializing_if = "Option::is_none")]
349 until: Option<i64>,
350
351}
352impl ListCardCustomerBuilder {
353 fn new() -> Self {
354 Self {
355 limit: None,offset: None,since: None,until: None,
356 }
357}
358
359}
360 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
362pub struct ListCardCustomer {
363 inner: ListCardCustomerBuilder,
364 customer: payjp_core::CustomerId,
365
366}
367impl ListCardCustomer {
368 pub fn new(customer:impl Into<payjp_core::CustomerId>) -> Self {
370 Self {
371 customer: customer.into(),inner: ListCardCustomerBuilder::new()
372 }
373}
374 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
376 self.inner.limit = Some(limit.into());
377 self
378}
379 pub fn offset(mut self, offset: impl Into<i64>) -> Self {
381 self.inner.offset = Some(offset.into());
382 self
383}
384 pub fn since(mut self, since: impl Into<i64>) -> Self {
386 self.inner.since = Some(since.into());
387 self
388}
389 pub fn until(mut self, until: impl Into<i64>) -> Self {
391 self.inner.until = Some(until.into());
392 self
393}
394
395}
396 impl ListCardCustomer {
397 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
399 self.customize().send(client).await
400 }
401
402 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
404 self.customize().send_blocking(client)
405 }
406
407 pub fn paginate(&self) -> payjp_client_core::ListPaginator<payjp_types::List<payjp_core::Card>> {
408 let customer = &self.customer;
409
410 payjp_client_core::ListPaginator::new_list(format!("/customers/{customer}/cards"), &self.inner)
411}
412
413}
414
415impl PayjpRequest for ListCardCustomer {
416 type Output = payjp_types::List<payjp_core::Card>;
417
418 fn build(&self) -> RequestBuilder {
419 let customer = &self.customer;
420RequestBuilder::new(PayjpMethod::Get, format!("/customers/{customer}/cards")).query(&self.inner)
421}
422
423}
424#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
425 struct CreateCardCustomerBuilder {
426#[serde(skip_serializing_if = "Option::is_none")]
427 card: Option<String>,
428#[serde(skip_serializing_if = "Option::is_none")]
429 default: Option<bool>,
430#[serde(skip_serializing_if = "Option::is_none")]
431metadata: Option<std::collections::HashMap<String, String>>,
432
433}
434impl CreateCardCustomerBuilder {
435 fn new() -> Self {
436 Self {
437 card: None,default: None,metadata: None,
438 }
439}
440
441}
442 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
444pub struct CreateCardCustomer {
445 inner: CreateCardCustomerBuilder,
446 customer: payjp_core::CustomerId,
447
448}
449impl CreateCardCustomer {
450 pub fn new(customer:impl Into<payjp_core::CustomerId>) -> Self {
452 Self {
453 customer: customer.into(),inner: CreateCardCustomerBuilder::new()
454 }
455}
456 pub fn card(mut self, card: impl Into<String>) -> Self {
458 self.inner.card = Some(card.into());
459 self
460}
461 pub fn default(mut self, default: impl Into<bool>) -> Self {
463 self.inner.default = Some(default.into());
464 self
465}
466pub fn metadata(mut self,
467 metadata: impl Into<std::collections::HashMap<String, String>>,
468) -> Self {
469 self.inner.metadata = Some(metadata.into());
470 self
471}
472
473}
474 impl CreateCardCustomer {
475 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
477 self.customize().send(client).await
478 }
479
480 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
482 self.customize().send_blocking(client)
483 }
484
485
486}
487
488impl PayjpRequest for CreateCardCustomer {
489 type Output = payjp_core::Card;
490
491 fn build(&self) -> RequestBuilder {
492 let customer = &self.customer;
493RequestBuilder::new(PayjpMethod::Post, format!("/customers/{customer}/cards")).form(&self.inner)
494}
495
496}
497 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
499pub struct RetrieveCardCustomer {
500 customer: payjp_core::CustomerId,
501 card: String,
502
503}
504impl RetrieveCardCustomer {
505 pub fn new(customer:impl Into<payjp_core::CustomerId>,card:impl Into<String>) -> Self {
507 Self {
508 customer: customer.into(),card: card.into(),
509 }
510}
511
512}
513 impl RetrieveCardCustomer {
514 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
516 self.customize().send(client).await
517 }
518
519 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
521 self.customize().send_blocking(client)
522 }
523
524
525}
526
527impl PayjpRequest for RetrieveCardCustomer {
528 type Output = payjp_core::Card;
529
530 fn build(&self) -> RequestBuilder {
531 let customer = &self.customer;
532let card = &self.card;
533RequestBuilder::new(PayjpMethod::Get, format!("/customers/{customer}/cards/{card}"))
534}
535
536}
537#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
538 struct UpdateCardCustomerBuilder {
539#[serde(skip_serializing_if = "Option::is_none")]
540 address_city: Option<String>,
541#[serde(skip_serializing_if = "Option::is_none")]
542 address_line1: Option<String>,
543#[serde(skip_serializing_if = "Option::is_none")]
544 address_line2: Option<String>,
545#[serde(skip_serializing_if = "Option::is_none")]
546 address_state: Option<String>,
547#[serde(skip_serializing_if = "Option::is_none")]
548 address_zip: Option<String>,
549#[serde(skip_serializing_if = "Option::is_none")]
550 country: Option<String>,
551#[serde(skip_serializing_if = "Option::is_none")]
552 email: Option<String>,
553#[serde(skip_serializing_if = "Option::is_none")]
554metadata: Option<std::collections::HashMap<String, String>>,
555#[serde(skip_serializing_if = "Option::is_none")]
556 name: Option<String>,
557#[serde(skip_serializing_if = "Option::is_none")]
558 phone: Option<String>,
559
560}
561impl UpdateCardCustomerBuilder {
562 fn new() -> Self {
563 Self {
564 address_city: None,address_line1: None,address_line2: None,address_state: None,address_zip: None,country: None,email: None,metadata: None,name: None,phone: None,
565 }
566}
567
568}
569 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
571pub struct UpdateCardCustomer {
572 inner: UpdateCardCustomerBuilder,
573 customer: payjp_core::CustomerId,
574 card: String,
575
576}
577impl UpdateCardCustomer {
578 pub fn new(customer:impl Into<payjp_core::CustomerId>,card:impl Into<String>) -> Self {
580 Self {
581 customer: customer.into(),card: card.into(),inner: UpdateCardCustomerBuilder::new()
582 }
583}
584 pub fn address_city(mut self, address_city: impl Into<String>) -> Self {
586 self.inner.address_city = Some(address_city.into());
587 self
588}
589 pub fn address_line1(mut self, address_line1: impl Into<String>) -> Self {
591 self.inner.address_line1 = Some(address_line1.into());
592 self
593}
594 pub fn address_line2(mut self, address_line2: impl Into<String>) -> Self {
596 self.inner.address_line2 = Some(address_line2.into());
597 self
598}
599 pub fn address_state(mut self, address_state: impl Into<String>) -> Self {
601 self.inner.address_state = Some(address_state.into());
602 self
603}
604 pub fn address_zip(mut self, address_zip: impl Into<String>) -> Self {
606 self.inner.address_zip = Some(address_zip.into());
607 self
608}
609 pub fn country(mut self, country: impl Into<String>) -> Self {
611 self.inner.country = Some(country.into());
612 self
613}
614 pub fn email(mut self, email: impl Into<String>) -> Self {
616 self.inner.email = Some(email.into());
617 self
618}
619pub fn metadata(mut self,
620 metadata: impl Into<std::collections::HashMap<String, String>>,
621) -> Self {
622 self.inner.metadata = Some(metadata.into());
623 self
624}
625 pub fn name(mut self, name: impl Into<String>) -> Self {
627 self.inner.name = Some(name.into());
628 self
629}
630 pub fn phone(mut self, phone: impl Into<String>) -> Self {
632 self.inner.phone = Some(phone.into());
633 self
634}
635
636}
637 impl UpdateCardCustomer {
638 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
640 self.customize().send(client).await
641 }
642
643 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
645 self.customize().send_blocking(client)
646 }
647
648
649}
650
651impl PayjpRequest for UpdateCardCustomer {
652 type Output = payjp_core::Card;
653
654 fn build(&self) -> RequestBuilder {
655 let customer = &self.customer;
656let card = &self.card;
657RequestBuilder::new(PayjpMethod::Post, format!("/customers/{customer}/cards/{card}")).form(&self.inner)
658}
659
660}
661 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
663pub struct DeleteCardCustomer {
664 customer: payjp_core::CustomerId,
665 card: String,
666
667}
668impl DeleteCardCustomer {
669 pub fn new(customer:impl Into<payjp_core::CustomerId>,card:impl Into<String>) -> Self {
671 Self {
672 customer: customer.into(),card: card.into(),
673 }
674}
675
676}
677 impl DeleteCardCustomer {
678 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
680 self.customize().send(client).await
681 }
682
683 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
685 self.customize().send_blocking(client)
686 }
687
688
689}
690
691impl PayjpRequest for DeleteCardCustomer {
692 type Output = payjp_shared::DeleteResponse;
693
694 fn build(&self) -> RequestBuilder {
695 let customer = &self.customer;
696let card = &self.card;
697RequestBuilder::new(PayjpMethod::Delete, format!("/customers/{customer}/cards/{card}"))
698}
699
700}
701