1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
// The contents of this file are generated; do not modify them.
//! Merchant account represents a single business entity at SumUp.
use super::common::*;
/// An address somewhere in the world. The address fields used depend on the country conventions. For example, in Great Britain, `city` is `post_town`. In the United States, the top-level administrative unit used in addresses is `state`, whereas in Chile it's `region`.
/// Whether an address is valid or not depends on whether the locally required fields are present. Fields not supported in a country will be ignored.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Address {
#[serde(skip_serializing_if = "Option::is_none")]
pub street_address: Option<Vec<String>>,
/// The postal code (aka. zip code) of the address.
///
/// Constraints:
/// - max length: 32
#[serde(skip_serializing_if = "Option::is_none")]
pub post_code: Option<String>,
pub country: CountryCode,
/// The city of the address.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub city: Option<String>,
/// The province where the address is located. This may not be relevant in some countries.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub province: Option<String>,
/// The region where the address is located. This may not be relevant in some countries.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub region: Option<String>,
/// A county is a geographic region of a country used for administrative or other purposes in some nations. Used in countries such as Ireland, Romania, etc.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub county: Option<String>,
/// In Spain, an autonomous community is the first sub-national level of political and administrative division.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub autonomous_community: Option<String>,
/// A post town is a required part of all postal addresses in the United Kingdom and Ireland, and a basic unit of the postal delivery system.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub post_town: Option<String>,
/// Most often, a country has a single state, with various administrative divisions. The term "state" is sometimes used to refer to the federated polities that make up the federation. Used in countries such as the United States and Brazil.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
/// Locality level of the address. Used in countries such as Brazil or Chile.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub neighborhood: Option<String>,
/// In many countries, terms cognate with "commune" are used, referring to the community living in the area and the common interest. Used in countries such as Chile.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub commune: Option<String>,
/// A department (French: département, Spanish: departamento) is an administrative or political division in several countries. Used in countries such as Colombia.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub department: Option<String>,
/// A municipality is usually a single administrative division having corporate status and powers of self-government or jurisdiction as granted by national and regional laws to which it is subordinate. Used in countries such as Colombia.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub municipality: Option<String>,
/// A district is a type of administrative division that in some countries is managed by the local government. Used in countries such as Portugal.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub district: Option<String>,
/// A US system of postal codes used by the United States Postal Service (USPS).
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub zip_code: Option<String>,
/// A postal address in Ireland.
///
/// Constraints:
/// - max length: 512
#[serde(skip_serializing_if = "Option::is_none")]
pub eircode: Option<String>,
}
/// Base schema for a person associated with a merchant. This can be a legal representative, business owner (ultimate beneficial owner), or an officer. A legal representative is the person who registered the merchant with SumUp. They should always have a `user_id`.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct BasePerson {
/// The unique identifier for the person. This is a [typeid](https://github.com/sumup/typeid).
///
/// Constraints:
/// - read-only
pub id: String,
/// A corresponding identity user ID for the person, if they have a user account.
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
/// The date of birth of the individual, represented as an ISO 8601:2004 [ISO8601‑2004] YYYY-MM-DD format.
#[serde(skip_serializing_if = "Option::is_none")]
pub birthdate: Option<crate::datetime::Date>,
/// The first name(s) of the individual.
///
/// Constraints:
/// - max length: 60
#[serde(skip_serializing_if = "Option::is_none")]
pub given_name: Option<String>,
/// The last name(s) of the individual.
///
/// Constraints:
/// - max length: 60
#[serde(skip_serializing_if = "Option::is_none")]
pub family_name: Option<String>,
/// Middle name(s) of the End-User. Note that in some cultures, people can have multiple middle names; all can be present, with the names being separated by space characters. Also note that in some cultures, middle names are not used.
///
/// Constraints:
/// - max length: 60
#[serde(skip_serializing_if = "Option::is_none")]
pub middle_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub phone_number: Option<PhoneNumber>,
/// A list of roles the person has in the merchant or towards SumUp. A merchant must have at least one person with the relationship `representative`.
///
/// Constraints:
/// - min items: 1
/// - max items: 1
#[serde(skip_serializing_if = "Option::is_none")]
pub relationships: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ownership: Option<Ownership>,
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<Address>,
/// A list of country-specific personal identifiers.
///
/// Constraints:
/// - max items: 5
#[serde(skip_serializing_if = "Option::is_none")]
pub identifiers: Option<Vec<PersonalIdentifier>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub citizenship: Option<CountryCode>,
/// The persons nationality. May be an [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code, but legacy data may not conform to this standard.
#[serde(
default,
skip_serializing_if = "Option::is_none",
deserialize_with = "crate::nullable::deserialize"
)]
pub nationality: Option<crate::Nullable<String>>,
/// An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code representing the country where the person resides.
///
/// Constraints:
/// - min length: 2
/// - max length: 2
#[serde(
default,
skip_serializing_if = "Option::is_none",
deserialize_with = "crate::nullable::deserialize"
)]
pub country_of_residence: Option<crate::Nullable<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<Version>,
#[serde(skip_serializing_if = "Option::is_none")]
pub change_status: Option<ChangeStatus>,
}
/// Settings used to apply the Merchant's branding to email receipts, invoices, checkouts, and other products.
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Branding {
/// An icon for the merchant. Must be square.
///
/// Constraints:
/// - format: `uri`
#[serde(skip_serializing_if = "Option::is_none")]
pub icon: Option<String>,
/// A logo for the merchant that will be used in place of the icon and without the merchant's name next to it if there's sufficient space.
///
/// Constraints:
/// - format: `uri`
#[serde(skip_serializing_if = "Option::is_none")]
pub logo: Option<String>,
/// Data-URL encoded hero image for the merchant business.
///
/// Constraints:
/// - format: `uri`
#[serde(skip_serializing_if = "Option::is_none")]
pub hero: Option<String>,
/// A hex color value representing the primary branding color of this merchant (your brand color).
#[serde(skip_serializing_if = "Option::is_none")]
pub primary_color: Option<String>,
/// A hex color value representing the color of the text displayed on branding color of this merchant.
#[serde(skip_serializing_if = "Option::is_none")]
pub primary_color_fg: Option<String>,
/// A hex color value representing the secondary branding color of this merchant (accent color used for buttons).
#[serde(skip_serializing_if = "Option::is_none")]
pub secondary_color: Option<String>,
/// A hex color value representing the color of the text displayed on secondary branding color of this merchant.
#[serde(skip_serializing_if = "Option::is_none")]
pub secondary_color_fg: Option<String>,
/// A hex color value representing the preferred background color of this merchant.
#[serde(skip_serializing_if = "Option::is_none")]
pub background_color: Option<String>,
}
/// Business information about the merchant. This information will be visible to the merchant's customers.
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct BusinessProfile {
/// The customer-facing business name.
///
/// Constraints:
/// - min length: 1
/// - max length: 150
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// The descriptor is the text that your customer sees on their bank account statement.
/// The more recognisable your descriptor is, the less risk you have of receiving disputes (e.g. chargebacks).
///
/// Constraints:
/// - pattern: `^[a-zA-Z0-9 \-+\'_.]{0,30}$`
/// - min length: 1
/// - max length: 30
#[serde(skip_serializing_if = "Option::is_none")]
pub dynamic_descriptor: Option<String>,
/// The business's publicly available website.
///
/// Constraints:
/// - format: `uri`
/// - max length: 255
#[serde(skip_serializing_if = "Option::is_none")]
pub website: Option<String>,
/// A publicly available email address.
///
/// Constraints:
/// - max length: 255
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub phone_number: Option<PhoneNumber>,
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<Address>,
#[serde(skip_serializing_if = "Option::is_none")]
pub branding: Option<Branding>,
}
pub type ChangeStatus = String;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ClassicMerchantIdentifiers {
/// Classic (serial) merchant ID.
#[deprecated]
pub id: i64,
}
/// Information about the company or business. This is legal information that is used for verification.
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Company {
/// The company's legal name.
///
/// Constraints:
/// - min length: 1
/// - max length: 150
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// The merchant category code for the account as specified by [ISO18245](https://www.iso.org/standard/33365.html). MCCs are used to classify businesses based on the goods or services they provide.
///
/// Constraints:
/// - pattern: `^[0-9]{4}$`
#[serde(skip_serializing_if = "Option::is_none")]
pub merchant_category_code: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub legal_type: Option<LegalType>,
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<Address>,
#[serde(skip_serializing_if = "Option::is_none")]
pub trading_address: Option<Address>,
#[serde(skip_serializing_if = "Option::is_none")]
pub identifiers: Option<CompanyIdentifiers>,
#[serde(skip_serializing_if = "Option::is_none")]
pub phone_number: Option<PhoneNumber>,
/// HTTP(S) URL of the company's website.
///
/// Constraints:
/// - format: `uri`
/// - max length: 255
#[serde(
default,
skip_serializing_if = "Option::is_none",
deserialize_with = "crate::nullable::deserialize"
)]
pub website: Option<crate::Nullable<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<Attributes>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct CompanyIdentifier {
/// The unique reference for the company identifier type as defined in the country SDK.
#[serde(rename = "ref")]
pub r#ref: String,
/// The company identifier value.
///
/// Constraints:
/// - max length: 100
pub value: String,
}
pub type CompanyIdentifiers = Vec<CompanyIdentifier>;
pub type CountryCode = String;
pub type LegalType = String;
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct ListPersonsResponseBody {
pub items: Vec<Person>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Merchant {
/// Short unique identifier for the merchant.
///
/// Constraints:
/// - read-only
pub merchant_code: String,
/// ID of the organization the merchant belongs to (if any).
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
/// The business type.
/// * `sole_trader`: The business is run by an self-employed individual.
/// * `company`: The business is run as a company with one or more shareholders
/// * `partnership`: The business is run as a company with two or more shareholders that can be also other legal entities
/// * `non_profit`: The business is run as a nonprofit organization that operates for public or social benefit
/// * `government_entity`: The business is state owned and operated
#[serde(skip_serializing_if = "Option::is_none")]
pub business_type: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub company: Option<Company>,
pub country: CountryCode,
#[serde(skip_serializing_if = "Option::is_none")]
pub business_profile: Option<BusinessProfile>,
/// A user-facing small-format logo for use in dashboards and other user-facing applications. For customer-facing branding see `merchant.business_profile.branding`.
///
/// Constraints:
/// - format: `uri`
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar: Option<String>,
/// A user-facing name of the merchant account for use in dashboards and other user-facing applications. For customer-facing business name see `merchant.business_profile`.
#[serde(skip_serializing_if = "Option::is_none")]
pub alias: Option<String>,
/// Three-letter [ISO currency code](https://en.wikipedia.org/wiki/ISO_4217) representing the default currency for the account.
///
/// Constraints:
/// - read-only
/// - min length: 3
/// - max length: 3
pub default_currency: String,
/// Merchant's default locale, represented as a BCP47 [RFC5646](https://datatracker.ietf.org/doc/html/rfc5646) language tag. This is typically an ISO 639-1 Alpha-2 [ISO639‑1](https://www.iso.org/iso-639-language-code) language code in lowercase and an ISO 3166-1 Alpha-2 [ISO3166‑1](https://www.iso.org/iso-3166-country-codes.html) country code in uppercase, separated by a dash. For example, en-US or fr-CA.
/// In multilingual countries this is the merchant's preferred locale out of those, that are officially spoken in the country. In a countries with a single official language this will match the official language.
///
/// Constraints:
/// - min length: 2
/// - max length: 5
pub default_locale: String,
/// True if the merchant is a sandbox for testing.
#[serde(skip_serializing_if = "Option::is_none")]
pub sandbox: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub meta: Option<Meta>,
#[serde(skip_serializing_if = "Option::is_none")]
pub classic: Option<ClassicMerchantIdentifiers>,
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<Version>,
#[serde(skip_serializing_if = "Option::is_none")]
pub change_status: Option<ChangeStatus>,
/// The date and time when the resource was created. This is a string as defined in [RFC 3339, section 5.6](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6).
///
/// Constraints:
/// - read-only
pub created_at: crate::datetime::DateTime,
/// The date and time when the resource was last updated. This is a string as defined in [RFC 3339, section 5.6](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6).
///
/// Constraints:
/// - read-only
pub updated_at: crate::datetime::DateTime,
}
/// A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
///
/// **Warning**: Updating Meta will overwrite the existing data. Make sure to always include the complete JSON object.
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Meta {
#[serde(
flatten,
default,
skip_serializing_if = "std::collections::HashMap::is_empty"
)]
pub additional_properties: std::collections::HashMap<String, String>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Ownership {
/// The percent of ownership shares held by the person expressed in percent mille (1/100000). Only persons with the relationship `owner` can have ownership.
///
/// Constraints:
/// - value >= 25000
/// - value <= 100000
pub share: i32,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Person {
/// The unique identifier for the person. This is a [typeid](https://github.com/sumup/typeid).
///
/// Constraints:
/// - read-only
pub id: String,
/// A corresponding identity user ID for the person, if they have a user account.
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
/// The date of birth of the individual, represented as an ISO 8601:2004 [ISO8601‑2004] YYYY-MM-DD format.
#[serde(skip_serializing_if = "Option::is_none")]
pub birthdate: Option<crate::datetime::Date>,
/// The first name(s) of the individual.
///
/// Constraints:
/// - max length: 60
#[serde(skip_serializing_if = "Option::is_none")]
pub given_name: Option<String>,
/// The last name(s) of the individual.
///
/// Constraints:
/// - max length: 60
#[serde(skip_serializing_if = "Option::is_none")]
pub family_name: Option<String>,
/// Middle name(s) of the End-User. Note that in some cultures, people can have multiple middle names; all can be present, with the names being separated by space characters. Also note that in some cultures, middle names are not used.
///
/// Constraints:
/// - max length: 60
#[serde(skip_serializing_if = "Option::is_none")]
pub middle_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub phone_number: Option<PhoneNumber>,
/// A list of roles the person has in the merchant or towards SumUp. A merchant must have at least one person with the relationship `representative`.
///
/// Constraints:
/// - min items: 1
/// - max items: 1
#[serde(skip_serializing_if = "Option::is_none")]
pub relationships: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ownership: Option<Ownership>,
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<Address>,
/// A list of country-specific personal identifiers.
///
/// Constraints:
/// - max items: 5
#[serde(skip_serializing_if = "Option::is_none")]
pub identifiers: Option<Vec<PersonalIdentifier>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub citizenship: Option<CountryCode>,
/// The persons nationality. May be an [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code, but legacy data may not conform to this standard.
#[serde(
default,
skip_serializing_if = "Option::is_none",
deserialize_with = "crate::nullable::deserialize"
)]
pub nationality: Option<crate::Nullable<String>>,
/// An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code representing the country where the person resides.
///
/// Constraints:
/// - min length: 2
/// - max length: 2
#[serde(
default,
skip_serializing_if = "Option::is_none",
deserialize_with = "crate::nullable::deserialize"
)]
pub country_of_residence: Option<crate::Nullable<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<Version>,
#[serde(skip_serializing_if = "Option::is_none")]
pub change_status: Option<ChangeStatus>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PersonalIdentifier {
/// The unique reference for the personal identifier type.
///
/// Constraints:
/// - max length: 32
#[serde(rename = "ref")]
pub r#ref: String,
/// The company identifier value.
///
/// Constraints:
/// - max length: 128
pub value: String,
}
pub type PhoneNumber = String;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Timestamps {
/// The date and time when the resource was created. This is a string as defined in [RFC 3339, section 5.6](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6).
///
/// Constraints:
/// - read-only
pub created_at: crate::datetime::DateTime,
/// The date and time when the resource was last updated. This is a string as defined in [RFC 3339, section 5.6](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6).
///
/// Constraints:
/// - read-only
pub updated_at: crate::datetime::DateTime,
}
pub type Version = String;
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct GetParams {
/// The version of the resource. At the moment, the only supported value is `latest`. When provided and the requested resource's `change_status` is pending, the resource will be returned with all pending changes applied. When no changes are pending the resource is returned as is. The `change_status` in the response body will reflect the current state of the resource.
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct ListPersonsParams {
/// The version of the resource. At the moment, the only supported value is `latest`. When provided and the requested resource's `change_status` is pending, the resource will be returned with all pending changes applied. When no changes are pending the resource is returned as is. The `change_status` in the response body will reflect the current state of the resource.
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct GetPersonParams {
/// The version of the resource. At the moment, the only supported value is `latest`. When provided and the requested resource's `change_status` is pending, the resource will be returned with all pending changes applied. When no changes are pending the resource is returned as is. The `change_status` in the response body will reflect the current state of the resource.
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
use crate::client::Client;
#[derive(Debug)]
pub enum GetErrorBody {
NotFound(Problem),
}
#[derive(Debug)]
pub enum ListPersonsErrorBody {
NotFound(Problem),
InternalServerError(Problem),
}
#[derive(Debug)]
pub enum GetPersonErrorBody {
NotFound(Problem),
InternalServerError(Problem),
}
/// Client for the Merchants API endpoints.
#[derive(Debug)]
pub struct MerchantsClient<'a> {
client: &'a Client,
}
impl<'a> MerchantsClient<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
/// Returns a reference to the underlying client.
pub fn client(&self) -> &Client {
self.client
}
/// Retrieve a Merchant
///
/// Retrieve a merchant.
pub async fn get(
&self,
merchant_code: impl Into<String>,
params: GetParams,
) -> crate::error::SdkResult<Merchant, GetErrorBody> {
let path = format!("/v1/merchants/{}", merchant_code.into());
let url = format!("{}{}", self.client.base_url(), path);
let mut request = self
.client
.http_client()
.get(&url)
.header("User-Agent", crate::version::user_agent())
.timeout(self.client.timeout());
if let Some(authorization) = self.client.authorization() {
request = request.header("Authorization", format!("Bearer {}", authorization));
}
for (header_name, header_value) in self.client.runtime_headers() {
request = request.header(*header_name, header_value);
}
if let Some(ref value) = params.version {
request = request.query(&[("version", value)]);
}
let response = request.send().await?;
let status = response.status();
match status {
reqwest::StatusCode::OK => {
let data: Merchant = response.json().await?;
Ok(data)
}
reqwest::StatusCode::NOT_FOUND => {
let body: Problem = response.json().await?;
Err(crate::error::SdkError::api(GetErrorBody::NotFound(body)))
}
_ => {
let body_bytes = response.bytes().await?;
let body = crate::error::UnknownApiBody::from_bytes(body_bytes.as_ref());
Err(crate::error::SdkError::unexpected(status, body))
}
}
}
/// List Persons
///
/// Returns a list of persons related to the merchant.
pub async fn list_persons(
&self,
merchant_code: impl Into<String>,
params: ListPersonsParams,
) -> crate::error::SdkResult<ListPersonsResponseBody, ListPersonsErrorBody> {
let path = format!("/v1/merchants/{}/persons", merchant_code.into());
let url = format!("{}{}", self.client.base_url(), path);
let mut request = self
.client
.http_client()
.get(&url)
.header("User-Agent", crate::version::user_agent())
.timeout(self.client.timeout());
if let Some(authorization) = self.client.authorization() {
request = request.header("Authorization", format!("Bearer {}", authorization));
}
for (header_name, header_value) in self.client.runtime_headers() {
request = request.header(*header_name, header_value);
}
if let Some(ref value) = params.version {
request = request.query(&[("version", value)]);
}
let response = request.send().await?;
let status = response.status();
match status {
reqwest::StatusCode::OK => {
let data: ListPersonsResponseBody = response.json().await?;
Ok(data)
}
reqwest::StatusCode::NOT_FOUND => {
let body: Problem = response.json().await?;
Err(crate::error::SdkError::api(ListPersonsErrorBody::NotFound(
body,
)))
}
reqwest::StatusCode::INTERNAL_SERVER_ERROR => {
let body: Problem = response.json().await?;
Err(crate::error::SdkError::api(
ListPersonsErrorBody::InternalServerError(body),
))
}
_ => {
let body_bytes = response.bytes().await?;
let body = crate::error::UnknownApiBody::from_bytes(body_bytes.as_ref());
Err(crate::error::SdkError::unexpected(status, body))
}
}
}
/// Retrieve a Person
///
/// Returns a single person related to the merchant.
pub async fn get_person(
&self,
merchant_code: impl Into<String>,
person_id: impl Into<String>,
params: GetPersonParams,
) -> crate::error::SdkResult<Person, GetPersonErrorBody> {
let path = format!(
"/v1/merchants/{}/persons/{}",
merchant_code.into(),
person_id.into()
);
let url = format!("{}{}", self.client.base_url(), path);
let mut request = self
.client
.http_client()
.get(&url)
.header("User-Agent", crate::version::user_agent())
.timeout(self.client.timeout());
if let Some(authorization) = self.client.authorization() {
request = request.header("Authorization", format!("Bearer {}", authorization));
}
for (header_name, header_value) in self.client.runtime_headers() {
request = request.header(*header_name, header_value);
}
if let Some(ref value) = params.version {
request = request.query(&[("version", value)]);
}
let response = request.send().await?;
let status = response.status();
match status {
reqwest::StatusCode::OK => {
let data: Person = response.json().await?;
Ok(data)
}
reqwest::StatusCode::NOT_FOUND => {
let body: Problem = response.json().await?;
Err(crate::error::SdkError::api(GetPersonErrorBody::NotFound(
body,
)))
}
reqwest::StatusCode::INTERNAL_SERVER_ERROR => {
let body: Problem = response.json().await?;
Err(crate::error::SdkError::api(
GetPersonErrorBody::InternalServerError(body),
))
}
_ => {
let body_bytes = response.bytes().await?;
let body = crate::error::UnknownApiBody::from_bytes(body_bytes.as_ref());
Err(crate::error::SdkError::unexpected(status, body))
}
}
}
}