-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmerchants.go
More file actions
executable file
·634 lines (593 loc) · 29 KB
/
Copy pathmerchants.go
File metadata and controls
executable file
·634 lines (593 loc) · 29 KB
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
// Code generated by `go-sdk-gen`. DO NOT EDIT.
package sumup
import (
"context"
"encoding/json"
"fmt"
"net/http"
"time"
"github.com/sumup/sumup-go/client"
"github.com/sumup/sumup-go/datetime"
"github.com/sumup/sumup-go/nullable"
)
// 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.
// Address documentation: https://developer.sumup.com/tools/glossary/address
type Address struct {
// In Spain, an autonomous community is the first sub-national level of political and administrative division.
// Max length: 60
AutonomousCommunity *string `json:"autonomous_community,omitempty"`
// The city of the address.
// Max length: 60
City *string `json:"city,omitempty"`
// 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.
// Max length: 60
Commune *string `json:"commune,omitempty"`
// An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
// country code. This definition users `oneOf` with a two-character string
// type to allow for support of future countries in client code.
// Min length: 2
// Max length: 2
// Pattern: ^[A-Z]{2}$
Country CountryCode `json:"country"`
// 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.
// Max length: 60
County *string `json:"county,omitempty"`
// A department (French: département, Spanish: departamento) is an administrative or political division in
// several countries. Used in countries such as Colombia.
// Max length: 60
Department *string `json:"department,omitempty"`
// A district is a type of administrative division that in some countries is managed by the local government. Used
// in countries such as Portugal.
// Max length: 60
District *string `json:"district,omitempty"`
// A postal address in Ireland.
// Max length: 10
Eircode *string `json:"eircode,omitempty"`
// 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.
// Max length: 60
Municipality *string `json:"municipality,omitempty"`
// Locality level of the address. Used in countries such as Brazil or Chile.
// Max length: 60
Neighborhood *string `json:"neighborhood,omitempty"`
// The postal code (aka. zip code) of the address.
// Max length: 10
PostCode *string `json:"post_code,omitempty"`
// 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.
// Max length: 60
PostTown *string `json:"post_town,omitempty"`
// The province where the address is located. This may not be relevant in some countries.
// Max length: 60
Province *string `json:"province,omitempty"`
// The region where the address is located. This may not be relevant in some countries.
// Max length: 60
Region *string `json:"region,omitempty"`
// 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.
// Max length: 60
State *string `json:"state,omitempty"`
// Max items: 2
StreetAddress []string `json:"street_address,omitempty"`
// A US system of postal codes used by the United States Postal Service (USPS).
// Max length: 10
ZipCode *string `json:"zip_code,omitempty"`
}
// 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`.
//
// Person documentation: https://developer.sumup.com/tools/glossary/merchant#persons
type BasePerson struct {
// 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.
// Address documentation: https://developer.sumup.com/tools/glossary/address
Address *Address `json:"address,omitempty"`
// The date of birth of the individual, represented as an ISO 8601:2004 [ISO8601‑2004] YYYY-MM-DD format.
// Format: date
Birthdate *datetime.Date `json:"birthdate,omitempty"`
// Reflects the status of changes submitted through the `PATCH` endpoints for the Merchant or Persons. If some
// changes have not been applied yet, the status will be `pending`. If all changes have been applied, the status
// `done`.
// The status is only returned after write operations or on read endpoints when the `version` query parameter is
// provided.
// Read only
ChangeStatus *ChangeStatus `json:"change_status,omitempty"`
// An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
// country code. This definition users `oneOf` with a two-character string
// type to allow for support of future countries in client code.
// Min length: 2
// Max length: 2
// Pattern: ^[A-Z]{2}$
Citizenship *CountryCode `json:"citizenship,omitempty"`
// An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code representing the country
// where the Person resides.
// Pattern: ^[A-Z]{2}$
CountryOfResidence *nullable.Field[string] `json:"country_of_residence,omitempty"`
// The last name(s) of the individual.
// Min length: 1
// Max length: 60
FamilyName *string `json:"family_name,omitempty"`
// The first name(s) of the individual.
// Min length: 1
// Max length: 60
GivenName *string `json:"given_name,omitempty"`
// The unique identifier for the Person. This is a [typeid](https://github.com/sumup/typeid).
// Read only
ID string `json:"id"`
// A list of country-specific personal identifiers.
// Max items: 32
Identifiers PersonalIdentifiers `json:"identifiers,omitempty"`
// 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.
// Min length: 1
// Max length: 60
MiddleName *string `json:"middle_name,omitempty"`
// The Person's 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.
// Pattern: ^[A-Z]{2}$
Nationality *nullable.Field[string] `json:"nationality,omitempty"`
Ownership *Ownership `json:"ownership,omitempty"`
// A publicly available phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format.
// Max length: 16
PhoneNumber *PhoneNumber `json:"phone_number,omitempty"`
// 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`.
// Min items: 1
// Max items: 1
Relationships []string `json:"relationships,omitempty"`
// A corresponding identity user ID for the Person, if they have a user account.
UserID *string `json:"user_id,omitempty"`
// The version of the resource. The version reflects a specific change submitted to the API via one of the `PATCH`
// endpoints.
Version *Version `json:"version,omitempty"`
}
// Settings used to apply the Merchant's branding to email receipts, invoices, checkouts, and other products.
type Branding struct {
// A hex color value representing the preferred background color of this merchant.
BackgroundColor *string `json:"background_color,omitempty"`
// Footer text rendered on receipts and other customer-facing products.
// Min length: 1
// Max length: 500
FooterText *string `json:"footer_text,omitempty"`
// Data-URL encoded hero image for the merchant business.
// Format: uri
Hero *string `json:"hero,omitempty"`
// An icon for the merchant. Must be square.
// Format: uri
Icon *string `json:"icon,omitempty"`
// 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.
// Format: uri
Logo *string `json:"logo,omitempty"`
// A hex color value representing the primary branding color of this merchant (your brand color).
PrimaryColor *string `json:"primary_color,omitempty"`
// A hex color value representing the color of the text displayed on branding color of this merchant.
PrimaryColorFg *string `json:"primary_color_fg,omitempty"`
// A hex color value representing the secondary branding color of this merchant (accent color used for buttons).
SecondaryColor *string `json:"secondary_color,omitempty"`
// A hex color value representing the color of the text displayed on secondary branding color of this merchant.
SecondaryColorFg *string `json:"secondary_color_fg,omitempty"`
}
// Business information about the merchant. This information will be visible to the merchant's customers.
type BusinessProfile struct {
// 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.
// Address documentation: https://developer.sumup.com/tools/glossary/address
Address *Address `json:"address,omitempty"`
// Settings used to apply the Merchant's branding to email receipts, invoices, checkouts, and other products.
Branding *Branding `json:"branding,omitempty"`
// 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).
// Min length: 1
// Max length: 30
// Pattern: ^[a-zA-Z0-9 +'_.-]+$
DynamicDescriptor *string `json:"dynamic_descriptor,omitempty"`
// A publicly available email address.
// Min length: 1
// Max length: 255
Email *string `json:"email,omitempty"`
// The customer-facing business name.
// Min length: 1
// Max length: 150
Name *string `json:"name,omitempty"`
// A publicly available phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format.
// Max length: 16
PhoneNumber *PhoneNumber `json:"phone_number,omitempty"`
// The business's publicly available website.
// Min length: 1
// Max length: 255
Website *string `json:"website,omitempty"`
}
// Reflects the status of changes submitted through the `PATCH` endpoints for the Merchant or Persons. If some
// changes have not been applied yet, the status will be `pending`. If all changes have been applied, the status
// `done`.
// The status is only returned after write operations or on read endpoints when the `version` query parameter is
// provided.
//
// Read only
type ChangeStatus string
// ClassicMerchantIdentifiers is a schema definition.
type ClassicMerchantIdentifiers struct {
// Classic (serial) merchant ID.
// Format: int64
// Deprecated: this operation is deprecated
ID int64 `json:"id"`
}
// Information about the company or business. This is legal information that is used for verification.
//
// Company documentation: https://developer.sumup.com/tools/glossary/merchant#company
type Company struct {
// 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.
// Address documentation: https://developer.sumup.com/tools/glossary/address
Address *Address `json:"address,omitempty"`
// Object attributes that are modifiable only by SumUp applications.
Attributes Attributes `json:"attributes,omitempty"`
// A list of country-specific company identifiers.
Identifiers CompanyIdentifiers `json:"identifiers,omitempty"`
// The unique legal type reference as defined in the country SDK. We do not rely on IDs as used by other services.
// Consumers of this API are expected to use the country SDK to map to any other IDs, translation keys, or
// descriptions.
// Min length: 4
// Max length: 64
// Pattern: ^[a-z]{2}\.[a-z_]+$
// The country SDK documentation for legal types.: https://developer.sumup.com/tools/glossary/merchant#legal-types
LegalType *LegalType `json:"legal_type,omitempty"`
// 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.
// Pattern: ^[0-9]{4}$
MerchantCategoryCode *string `json:"merchant_category_code,omitempty"`
// The company's legal name.
// Min length: 1
// Max length: 150
Name *string `json:"name,omitempty"`
// A publicly available phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format.
// Max length: 16
PhoneNumber *PhoneNumber `json:"phone_number,omitempty"`
// 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.
// Address documentation: https://developer.sumup.com/tools/glossary/address
TradingAddress *Address `json:"trading_address,omitempty"`
// HTTP(S) URL of the company's website.
// Min length: 1
// Max length: 255
Website *string `json:"website,omitempty"`
}
// CompanyIdentifier is a schema definition.
// Company identifier documentation: https://developer.sumup.com/tools/glossary/merchant#company-identifiers
type CompanyIdentifier struct {
// The unique reference for the company identifier type as defined in the country SDK.
// Pattern: ^[a-z]{2}\.[a-z_]+$
Ref string `json:"ref"`
// The company identifier value.
// Min length: 1
// Max length: 100
Value string `json:"value"`
}
// A list of country-specific company identifiers.
type CompanyIdentifiers []CompanyIdentifier
// An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
// country code. This definition users `oneOf` with a two-character string
// type to allow for support of future countries in client code.
// Min length: 2
// Max length: 2
// Pattern: ^[A-Z]{2}$
type CountryCode string
// The unique legal type reference as defined in the country SDK. We do not rely on IDs as used by other services.
// Consumers of this API are expected to use the country SDK to map to any other IDs, translation keys, or
// descriptions.
//
// Min length: 4
// Max length: 64
// Pattern: ^[a-z]{2}\.[a-z_]+$
// The country SDK documentation for legal types.: https://developer.sumup.com/tools/glossary/merchant#legal-types
type LegalType string
// ListPersonsResponseBody is a schema definition.
type ListPersonsResponseBody struct {
Items []Person `json:"items"`
}
// Merchant is a schema definition.
// Merchant documentation: https://developer.sumup.com/tools/glossary/merchant
type Merchant struct {
// 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`.
Alias *string `json:"alias,omitempty"`
// A user-facing small-format logo for use in dashboards and other user-facing applications. For customer-facing branding
// see `merchant.business_profile.branding`.
// Format: uri
Avatar *string `json:"avatar,omitempty"`
// Business information about the merchant. This information will be visible to the merchant's customers.
BusinessProfile *BusinessProfile `json:"business_profile,omitempty"`
// 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
BusinessType *string `json:"business_type,omitempty"`
// Reflects the status of changes submitted through the `PATCH` endpoints for the Merchant or Persons. If some
// changes have not been applied yet, the status will be `pending`. If all changes have been applied, the status
// `done`.
// The status is only returned after write operations or on read endpoints when the `version` query parameter is
// provided.
// Read only
ChangeStatus *ChangeStatus `json:"change_status,omitempty"`
Classic *ClassicMerchantIdentifiers `json:"classic,omitempty"`
// Information about the company or business. This is legal information that is used for verification.
// Company documentation: https://developer.sumup.com/tools/glossary/merchant#company
Company *Company `json:"company,omitempty"`
// An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
// country code. This definition users `oneOf` with a two-character string
// type to allow for support of future countries in client code.
// Min length: 2
// Max length: 2
// Pattern: ^[A-Z]{2}$
Country CountryCode `json:"country"`
// 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).
// Read only
CreatedAt time.Time `json:"created_at"`
// Three-letter [ISO currency code](https://en.wikipedia.org/wiki/ISO_4217) representing the default currency for
// the account.
// Read only
// Min length: 3
// Max length: 3
DefaultCurrency string `json:"default_currency"`
// 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.
// Min length: 2
// Max length: 5
DefaultLocale string `json:"default_locale"`
// Short unique identifier for the merchant.
// Read only
MerchantCode string `json:"merchant_code"`
// 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.
Meta Meta `json:"meta,omitempty"`
// ID of the organization the merchant belongs to (if any).
OrganizationID *string `json:"organization_id,omitempty"`
// True if the merchant is a sandbox for testing.
Sandbox *bool `json:"sandbox,omitempty"`
// 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).
//
// Read only
UpdatedAt time.Time `json:"updated_at"`
// The version of the resource. The version reflects a specific change submitted to the API via one of the `PATCH`
// endpoints.
Version *Version `json:"version,omitempty"`
}
// 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.
type Meta map[string]any
// Ownership is a schema definition.
type Ownership struct {
// The percent of ownership shares held by the Person expressed in percent mille (1/100000). Only Persons with
// the relationship `owner` can have ownership.
// Format: int32
// Min: 25000
// Max: 100000
Share int32 `json:"share"`
}
// Person is a schema definition.
type Person struct {
// 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.
// Address documentation: https://developer.sumup.com/tools/glossary/address
Address *Address `json:"address,omitempty"`
// The date of birth of the individual, represented as an ISO 8601:2004 [ISO8601‑2004] YYYY-MM-DD format.
// Format: date
Birthdate *datetime.Date `json:"birthdate,omitempty"`
// Reflects the status of changes submitted through the `PATCH` endpoints for the Merchant or Persons. If some
// changes have not been applied yet, the status will be `pending`. If all changes have been applied, the status
// `done`.
// The status is only returned after write operations or on read endpoints when the `version` query parameter is
// provided.
// Read only
ChangeStatus *ChangeStatus `json:"change_status,omitempty"`
// An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
// country code. This definition users `oneOf` with a two-character string
// type to allow for support of future countries in client code.
// Min length: 2
// Max length: 2
// Pattern: ^[A-Z]{2}$
Citizenship *CountryCode `json:"citizenship,omitempty"`
// An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code representing the country
// where the Person resides.
// Pattern: ^[A-Z]{2}$
CountryOfResidence *nullable.Field[string] `json:"country_of_residence,omitempty"`
// The last name(s) of the individual.
// Min length: 1
// Max length: 60
FamilyName *string `json:"family_name,omitempty"`
// The first name(s) of the individual.
// Min length: 1
// Max length: 60
GivenName *string `json:"given_name,omitempty"`
// The unique identifier for the Person. This is a [typeid](https://github.com/sumup/typeid).
// Read only
ID string `json:"id"`
// A list of country-specific personal identifiers.
// Max items: 32
Identifiers PersonalIdentifiers `json:"identifiers,omitempty"`
// 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.
// Min length: 1
// Max length: 60
MiddleName *string `json:"middle_name,omitempty"`
// The Person's 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.
// Pattern: ^[A-Z]{2}$
Nationality *nullable.Field[string] `json:"nationality,omitempty"`
Ownership *Ownership `json:"ownership,omitempty"`
// A publicly available phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format.
// Max length: 16
PhoneNumber *PhoneNumber `json:"phone_number,omitempty"`
// 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`.
// Min items: 1
// Max items: 1
Relationships []string `json:"relationships,omitempty"`
// A corresponding identity user ID for the Person, if they have a user account.
UserID *string `json:"user_id,omitempty"`
// The version of the resource. The version reflects a specific change submitted to the API via one of the `PATCH`
// endpoints.
Version *Version `json:"version,omitempty"`
}
// PersonalIdentifier is a schema definition.
type PersonalIdentifier struct {
// The unique reference for the personal identifier type.
// Max length: 32
Ref string `json:"ref"`
// The personal identifier value.
// Max length: 128
Value string `json:"value"`
}
// A list of country-specific personal identifiers.
// Max items: 32
type PersonalIdentifiers []PersonalIdentifier
// A publicly available phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format.
//
// Max length: 16
type PhoneNumber string
// Timestamps is a schema definition.
type Timestamps struct {
// 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).
// Read only
CreatedAt time.Time `json:"created_at"`
// 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).
//
// Read only
UpdatedAt time.Time `json:"updated_at"`
}
// The version of the resource. The version reflects a specific change submitted to the API via one of the `PATCH`
// endpoints.
type Version string
// MerchantsClient provides access to the Merchants API.
//
// A Merchant represents a single business which can use SumUp products like payment processing.
type MerchantsClient struct {
c *client.Client
}
func NewMerchantsClient(c *client.Client) *MerchantsClient {
return &MerchantsClient{c: c}
}
// Returns the Persons related to a Merchant.
// Persons documentation: https://developer.sumup.com/tools/models/merchant#persons
func (c *MerchantsClient) ListPersons(ctx context.Context, merchantCode string) (*ListPersonsResponseBody, error) {
path := fmt.Sprintf("/v1/merchants/%v/persons", merchantCode)
resp, err := c.c.Call(ctx, http.MethodGet, path)
if err != nil {
return nil, fmt.Errorf("call %s %s: %w", http.MethodGet, path, err)
}
defer func() {
_ = resp.Body.Close()
}()
switch resp.StatusCode {
case http.StatusOK:
var v ListPersonsResponseBody
if err := json.NewDecoder(resp.Body).Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
case http.StatusNotFound:
var apiErr Problem
if err := json.NewDecoder(resp.Body).Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
default:
return nil, fmt.Errorf("unexpected response %d: %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
}
// Returns a Merchant for a valid Merchant code.
// Merchant documentation: https://developer.sumup.com/tools/models/merchant
func (c *MerchantsClient) Get(ctx context.Context, merchantCode string) (*Merchant, error) {
path := fmt.Sprintf("/v1/merchants/%v", merchantCode)
resp, err := c.c.Call(ctx, http.MethodGet, path)
if err != nil {
return nil, fmt.Errorf("call %s %s: %w", http.MethodGet, path, err)
}
defer func() {
_ = resp.Body.Close()
}()
switch resp.StatusCode {
case http.StatusOK:
var v Merchant
if err := json.NewDecoder(resp.Body).Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
case http.StatusNotFound:
var apiErr Problem
if err := json.NewDecoder(resp.Body).Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
default:
return nil, fmt.Errorf("unexpected response %d: %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
}
// Returns a single Person related to a Merchant.
// Persons documentation: https://developer.sumup.com/tools/models/merchant#persons
func (c *MerchantsClient) GetPerson(ctx context.Context, merchantCode string, personID string) (*Person, error) {
path := fmt.Sprintf("/v1/merchants/%v/persons/%v", merchantCode, personID)
resp, err := c.c.Call(ctx, http.MethodGet, path)
if err != nil {
return nil, fmt.Errorf("call %s %s: %w", http.MethodGet, path, err)
}
defer func() {
_ = resp.Body.Close()
}()
switch resp.StatusCode {
case http.StatusOK:
var v Person
if err := json.NewDecoder(resp.Body).Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
case http.StatusNotFound:
var apiErr Problem
if err := json.NewDecoder(resp.Body).Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
default:
return nil, fmt.Errorf("unexpected response %d: %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
}