-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathMandateImportEntryService.java
More file actions
1043 lines (939 loc) · 38.7 KB
/
MandateImportEntryService.java
File metadata and controls
1043 lines (939 loc) · 38.7 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
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
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package com.gocardless.services;
import com.gocardless.http.*;
import com.gocardless.resources.MandateImportEntry;
import com.google.common.collect.ImmutableMap;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import java.util.List;
import java.util.Map;
/**
* Service class for working with mandate import entry resources.
*
* Mandate Import Entries are added to a [Mandate Import](#core-endpoints-mandate-imports). Each
* entry corresponds to one mandate to be imported into GoCardless.
*
* To import a mandate you will need:
* <ol>
* <li>Identifying information about the customer (name/company and address)</li>
* <li>Bank account details, consisting of an account holder name and either an IBAN or
* <a href="#appendix-local-bank-details">local bank details</a></li>
* <li>Amendment details (SEPA only)</li>
* </ol>
*
* We suggest you provide a `record_identifier` (which is unique within the context of a single
* mandate import) to help you to identify mandates that have been created once the import has been
* processed by GoCardless. You can [list the mandate import
* entries](#mandate-import-entries-list-all-mandate-import-entries), match them up in your system
* using the `record_identifier`, and look at the `links` fields to find the mandate, customer and
* customer bank account that have been imported.
*
* <p class="restricted-notice">
* <strong>Restricted</strong>: This API is currently only available for approved integrators -
* please <a href="mailto:help@gocardless.com">get in touch</a> if you would like to use this API.
* </p>
*/
public class MandateImportEntryService {
private final HttpClient httpClient;
/**
* Constructor. Users of this library should have no need to call this - an instance of this
* class can be obtained by calling
* {@link com.gocardless.GoCardlessClient#mandateImportEntries() }.
*/
public MandateImportEntryService(HttpClient httpClient) {
this.httpClient = httpClient;
}
/**
* For an existing [mandate import](#core-endpoints-mandate-imports), this endpoint can be used
* to add individual mandates to be imported into GoCardless.
*
* You can add no more than 30,000 rows to a single mandate import. If you attempt to go over
* this limit, the API will return a `record_limit_exceeded` error.
*/
public MandateImportEntryCreateRequest create() {
return new MandateImportEntryCreateRequest(httpClient);
}
/**
* For an existing mandate import, this endpoint lists all of the entries attached.
*
* After a mandate import has been submitted, you can use this endpoint to associate records in
* your system (using the `record_identifier` that you provided when creating the mandate
* import).
*
*/
public MandateImportEntryListRequest<ListResponse<MandateImportEntry>> list() {
return new MandateImportEntryListRequest<>(httpClient,
ListRequest.<MandateImportEntry>pagingExecutor());
}
public MandateImportEntryListRequest<Iterable<MandateImportEntry>> all() {
return new MandateImportEntryListRequest<>(httpClient,
ListRequest.<MandateImportEntry>iteratingExecutor());
}
/**
* Request class for {@link MandateImportEntryService#create }.
*
* For an existing [mandate import](#core-endpoints-mandate-imports), this endpoint can be used
* to add individual mandates to be imported into GoCardless.
*
* You can add no more than 30,000 rows to a single mandate import. If you attempt to go over
* this limit, the API will return a `record_limit_exceeded` error.
*/
public static final class MandateImportEntryCreateRequest
extends PostRequest<MandateImportEntry> {
private Amendment amendment;
private BankAccount bankAccount;
private Customer customer;
private Links links;
private Mandate mandate;
private String recordIdentifier;
public MandateImportEntryCreateRequest withAmendment(Amendment amendment) {
this.amendment = amendment;
return this;
}
/**
* The creditor identifier of the direct debit originator. Required if mandate import scheme
* is `sepa`.
*
*/
public MandateImportEntryCreateRequest withAmendmentOriginalCreditorId(
String originalCreditorId) {
if (amendment == null) {
amendment = new Amendment();
}
amendment.withOriginalCreditorId(originalCreditorId);
return this;
}
/**
* Data about the original mandate to be moved or modified.
*
*/
public MandateImportEntryCreateRequest withAmendmentOriginalCreditorName(
String originalCreditorName) {
if (amendment == null) {
amendment = new Amendment();
}
amendment.withOriginalCreditorName(originalCreditorName);
return this;
}
/**
* The unique SEPA reference for the mandate being amended. Required if mandate import
* scheme is `sepa`.
*
*/
public MandateImportEntryCreateRequest withAmendmentOriginalMandateReference(
String originalMandateReference) {
if (amendment == null) {
amendment = new Amendment();
}
amendment.withOriginalMandateReference(originalMandateReference);
return this;
}
public MandateImportEntryCreateRequest withBankAccount(BankAccount bankAccount) {
this.bankAccount = bankAccount;
return this;
}
/**
* Name of the account holder, as known by the bank. The full name provided when the
* customer is created is stored and is available via the API, but is transliterated,
* upcased, and truncated to 18 characters in bank submissions. This field is required
* unless the request includes a [customer bank account
* token](#javascript-flow-customer-bank-account-tokens).
*/
public MandateImportEntryCreateRequest withBankAccountAccountHolderName(
String accountHolderName) {
if (bankAccount == null) {
bankAccount = new BankAccount();
}
bankAccount.withAccountHolderName(accountHolderName);
return this;
}
/**
* Bank account number - see [local details](#appendix-local-bank-details) for more
* information. Alternatively you can provide an `iban`.
*/
public MandateImportEntryCreateRequest withBankAccountAccountNumber(String accountNumber) {
if (bankAccount == null) {
bankAccount = new BankAccount();
}
bankAccount.withAccountNumber(accountNumber);
return this;
}
/**
* Bank account type. Required for USD-denominated bank accounts. Must not be provided for
* bank accounts in other currencies. See [local details](#local-bank-details-united-states)
* for more information.
*/
public MandateImportEntryCreateRequest withBankAccountAccountType(
BankAccount.AccountType accountType) {
if (bankAccount == null) {
bankAccount = new BankAccount();
}
bankAccount.withAccountType(accountType);
return this;
}
/**
* Bank code - see [local details](#appendix-local-bank-details) for more information.
* Alternatively you can provide an `iban`.
*/
public MandateImportEntryCreateRequest withBankAccountBankCode(String bankCode) {
if (bankAccount == null) {
bankAccount = new BankAccount();
}
bankAccount.withBankCode(bankCode);
return this;
}
/**
* Branch code - see [local details](#appendix-local-bank-details) for more information.
* Alternatively you can provide an `iban`.
*/
public MandateImportEntryCreateRequest withBankAccountBranchCode(String branchCode) {
if (bankAccount == null) {
bankAccount = new BankAccount();
}
bankAccount.withBranchCode(branchCode);
return this;
}
/**
* [ISO 3166-1 alpha-2
* code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements).
* Defaults to the country code of the `iban` if supplied, otherwise is required.
*/
public MandateImportEntryCreateRequest withBankAccountCountryCode(String countryCode) {
if (bankAccount == null) {
bankAccount = new BankAccount();
}
bankAccount.withCountryCode(countryCode);
return this;
}
/**
* International Bank Account Number. Alternatively you can provide [local
* details](#appendix-local-bank-details). IBANs are not accepted for Swedish bank accounts
* denominated in SEK - you must supply [local details](#local-bank-details-sweden).
*/
public MandateImportEntryCreateRequest withBankAccountIban(String iban) {
if (bankAccount == null) {
bankAccount = new BankAccount();
}
bankAccount.withIban(iban);
return this;
}
/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public MandateImportEntryCreateRequest withBankAccountMetadata(
Map<String, String> metadata) {
if (bankAccount == null) {
bankAccount = new BankAccount();
}
bankAccount.withMetadata(metadata);
return this;
}
public MandateImportEntryCreateRequest withCustomer(Customer customer) {
this.customer = customer;
return this;
}
/**
* The first line of the customer's address. Required if mandate import scheme is either
* `bacs` or `sepa`.
*
*/
public MandateImportEntryCreateRequest withCustomerAddressLine1(String addressLine1) {
if (customer == null) {
customer = new Customer();
}
customer.withAddressLine1(addressLine1);
return this;
}
/**
* The second line of the customer's address.
*/
public MandateImportEntryCreateRequest withCustomerAddressLine2(String addressLine2) {
if (customer == null) {
customer = new Customer();
}
customer.withAddressLine2(addressLine2);
return this;
}
/**
* The third line of the customer's address.
*/
public MandateImportEntryCreateRequest withCustomerAddressLine3(String addressLine3) {
if (customer == null) {
customer = new Customer();
}
customer.withAddressLine3(addressLine3);
return this;
}
/**
* The city of the customer's address.
*/
public MandateImportEntryCreateRequest withCustomerCity(String city) {
if (customer == null) {
customer = new Customer();
}
customer.withCity(city);
return this;
}
/**
* Customer's company name. Required unless a `given_name` and `family_name` are provided.
* For Canadian customers, the use of a `company_name` value will mean that any mandate
* created from this customer will be considered to be a "Business PAD" (otherwise, any
* mandate will be considered to be a "Personal PAD").
*/
public MandateImportEntryCreateRequest withCustomerCompanyName(String companyName) {
if (customer == null) {
customer = new Customer();
}
customer.withCompanyName(companyName);
return this;
}
/**
* [ISO 3166-1 alpha-2
* code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
*/
public MandateImportEntryCreateRequest withCustomerCountryCode(String countryCode) {
if (customer == null) {
customer = new Customer();
}
customer.withCountryCode(countryCode);
return this;
}
/**
* For Danish customers only. The civic/company number (CPR or CVR) of the customer. Must be
* supplied if the customer's bank account is denominated in Danish krone (DKK).
*/
public MandateImportEntryCreateRequest withCustomerDanishIdentityNumber(
String danishIdentityNumber) {
if (customer == null) {
customer = new Customer();
}
customer.withDanishIdentityNumber(danishIdentityNumber);
return this;
}
/**
* Customer's email address. Required in most cases, as this allows GoCardless to send
* notifications to this customer.
*/
public MandateImportEntryCreateRequest withCustomerEmail(String email) {
if (customer == null) {
customer = new Customer();
}
customer.withEmail(email);
return this;
}
/**
* Customer's surname. Required unless a `company_name` is provided.
*/
public MandateImportEntryCreateRequest withCustomerFamilyName(String familyName) {
if (customer == null) {
customer = new Customer();
}
customer.withFamilyName(familyName);
return this;
}
/**
* Customer's first name. Required unless a `company_name` is provided.
*/
public MandateImportEntryCreateRequest withCustomerGivenName(String givenName) {
if (customer == null) {
customer = new Customer();
}
customer.withGivenName(givenName);
return this;
}
/**
* [ISO 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) code. Used as the
* language for notification emails sent by GoCardless if your organisation does not send
* its own (see [compliance requirements](#appendix-compliance-requirements)). Currently
* only "en", "fr", "de", "pt", "es", "it", "nl", "da", "nb", "sl", "sv" are supported. If
* this is not provided, the language will be chosen based on the `country_code` (if
* supplied) or default to "en".
*/
public MandateImportEntryCreateRequest withCustomerLanguage(String language) {
if (customer == null) {
customer = new Customer();
}
customer.withLanguage(language);
return this;
}
/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public MandateImportEntryCreateRequest withCustomerMetadata(Map<String, String> metadata) {
if (customer == null) {
customer = new Customer();
}
customer.withMetadata(metadata);
return this;
}
/**
* [ITU E.123](https://en.wikipedia.org/wiki/E.123) formatted phone number, including
* country code.
*/
public MandateImportEntryCreateRequest withCustomerPhoneNumber(String phoneNumber) {
if (customer == null) {
customer = new Customer();
}
customer.withPhoneNumber(phoneNumber);
return this;
}
/**
* The customer's postal code. Required if mandate import scheme is either `bacs` or `sepa`.
*
*/
public MandateImportEntryCreateRequest withCustomerPostalCode(String postalCode) {
if (customer == null) {
customer = new Customer();
}
customer.withPostalCode(postalCode);
return this;
}
/**
* The customer's address region, county or department. For US customers a 2 letter
* [ISO3166-2:US](https://en.wikipedia.org/wiki/ISO_3166-2:US) state code is required (e.g.
* `CA` for California).
*/
public MandateImportEntryCreateRequest withCustomerRegion(String region) {
if (customer == null) {
customer = new Customer();
}
customer.withRegion(region);
return this;
}
/**
* For Swedish customers only. The civic/company number (personnummer, samordningsnummer, or
* organisationsnummer) of the customer. Must be supplied if the customer's bank account is
* denominated in Swedish krona (SEK). This field cannot be changed once it has been set.
*/
public MandateImportEntryCreateRequest withCustomerSwedishIdentityNumber(
String swedishIdentityNumber) {
if (customer == null) {
customer = new Customer();
}
customer.withSwedishIdentityNumber(swedishIdentityNumber);
return this;
}
public MandateImportEntryCreateRequest withLinks(Links links) {
this.links = links;
return this;
}
/**
* Unique identifier, beginning with "IM".
*/
public MandateImportEntryCreateRequest withLinksMandateImport(String mandateImport) {
if (links == null) {
links = new Links();
}
links.withMandateImport(mandateImport);
return this;
}
public MandateImportEntryCreateRequest withMandate(Mandate mandate) {
this.mandate = mandate;
return this;
}
/**
* This field is ACH specific, sometimes referred to as [SEC
* code](https://www.moderntreasury.com/learn/sec-codes).
*
* This is the way that the payer gives authorisation to the merchant. web: Authorisation is
* Internet Initiated or via Mobile Entry (maps to SEC code: WEB) telephone: Authorisation
* is provided orally over telephone (maps to SEC code: TEL) paper: Authorisation is
* provided in writing and signed, or similarly authenticated (maps to SEC code: PPD)
*
*/
public MandateImportEntryCreateRequest withMandateAuthorisationSource(
Mandate.AuthorisationSource authorisationSource) {
if (mandate == null) {
mandate = new Mandate();
}
mandate.withAuthorisationSource(authorisationSource);
return this;
}
/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public MandateImportEntryCreateRequest withMandateMetadata(Map<String, String> metadata) {
if (mandate == null) {
mandate = new Mandate();
}
mandate.withMetadata(metadata);
return this;
}
/**
* Unique reference. Different schemes have different length and [character
* set](#appendix-character-sets) requirements. GoCardless will generate a unique reference
* satisfying the different scheme requirements if this field is left blank.
*/
public MandateImportEntryCreateRequest withMandateReference(String reference) {
if (mandate == null) {
mandate = new Mandate();
}
mandate.withReference(reference);
return this;
}
/**
* A unique identifier for this entry, which you can use (once the import has been processed
* by GoCardless) to identify the records that have been created. Limited to 255 characters.
*
*/
public MandateImportEntryCreateRequest withRecordIdentifier(String recordIdentifier) {
this.recordIdentifier = recordIdentifier;
return this;
}
private MandateImportEntryCreateRequest(HttpClient httpClient) {
super(httpClient);
}
public MandateImportEntryCreateRequest withHeader(String headerName, String headerValue) {
this.addHeader(headerName, headerValue);
return this;
}
@Override
protected String getPathTemplate() {
return "mandate_import_entries";
}
@Override
protected String getEnvelope() {
return "mandate_import_entries";
}
@Override
protected Class<MandateImportEntry> getResponseClass() {
return MandateImportEntry.class;
}
@Override
protected boolean hasBody() {
return true;
}
public static class Amendment {
private String originalCreditorId;
private String originalCreditorName;
private String originalMandateReference;
/**
* The creditor identifier of the direct debit originator. Required if mandate import
* scheme is `sepa`.
*
*/
public Amendment withOriginalCreditorId(String originalCreditorId) {
this.originalCreditorId = originalCreditorId;
return this;
}
/**
* Data about the original mandate to be moved or modified.
*
*/
public Amendment withOriginalCreditorName(String originalCreditorName) {
this.originalCreditorName = originalCreditorName;
return this;
}
/**
* The unique SEPA reference for the mandate being amended. Required if mandate import
* scheme is `sepa`.
*
*/
public Amendment withOriginalMandateReference(String originalMandateReference) {
this.originalMandateReference = originalMandateReference;
return this;
}
}
public static class BankAccount {
private String accountHolderName;
private String accountNumber;
private AccountType accountType;
private String bankCode;
private String branchCode;
private String countryCode;
private String iban;
private Map<String, String> metadata;
/**
* Name of the account holder, as known by the bank. The full name provided when the
* customer is created is stored and is available via the API, but is transliterated,
* upcased, and truncated to 18 characters in bank submissions. This field is required
* unless the request includes a [customer bank account
* token](#javascript-flow-customer-bank-account-tokens).
*/
public BankAccount withAccountHolderName(String accountHolderName) {
this.accountHolderName = accountHolderName;
return this;
}
/**
* Bank account number - see [local details](#appendix-local-bank-details) for more
* information. Alternatively you can provide an `iban`.
*/
public BankAccount withAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
return this;
}
/**
* Bank account type. Required for USD-denominated bank accounts. Must not be provided
* for bank accounts in other currencies. See [local
* details](#local-bank-details-united-states) for more information.
*/
public BankAccount withAccountType(AccountType accountType) {
this.accountType = accountType;
return this;
}
/**
* Bank code - see [local details](#appendix-local-bank-details) for more information.
* Alternatively you can provide an `iban`.
*/
public BankAccount withBankCode(String bankCode) {
this.bankCode = bankCode;
return this;
}
/**
* Branch code - see [local details](#appendix-local-bank-details) for more information.
* Alternatively you can provide an `iban`.
*/
public BankAccount withBranchCode(String branchCode) {
this.branchCode = branchCode;
return this;
}
/**
* [ISO 3166-1 alpha-2
* code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements).
* Defaults to the country code of the `iban` if supplied, otherwise is required.
*/
public BankAccount withCountryCode(String countryCode) {
this.countryCode = countryCode;
return this;
}
/**
* International Bank Account Number. Alternatively you can provide [local
* details](#appendix-local-bank-details). IBANs are not accepted for Swedish bank
* accounts denominated in SEK - you must supply [local
* details](#local-bank-details-sweden).
*/
public BankAccount withIban(String iban) {
this.iban = iban;
return this;
}
/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public BankAccount withMetadata(Map<String, String> metadata) {
this.metadata = metadata;
return this;
}
public enum AccountType {
@SerializedName("savings")
SAVINGS, @SerializedName("checking")
CHECKING, @SerializedName("unknown")
UNKNOWN;
@Override
public String toString() {
return name().toLowerCase();
}
}
}
public static class Customer {
private String addressLine1;
private String addressLine2;
private String addressLine3;
private String city;
private String companyName;
private String countryCode;
private String danishIdentityNumber;
private String email;
private String familyName;
private String givenName;
private String language;
private Map<String, String> metadata;
private String phoneNumber;
private String postalCode;
private String region;
private String swedishIdentityNumber;
/**
* The first line of the customer's address. Required if mandate import scheme is either
* `bacs` or `sepa`.
*
*/
public Customer withAddressLine1(String addressLine1) {
this.addressLine1 = addressLine1;
return this;
}
/**
* The second line of the customer's address.
*/
public Customer withAddressLine2(String addressLine2) {
this.addressLine2 = addressLine2;
return this;
}
/**
* The third line of the customer's address.
*/
public Customer withAddressLine3(String addressLine3) {
this.addressLine3 = addressLine3;
return this;
}
/**
* The city of the customer's address.
*/
public Customer withCity(String city) {
this.city = city;
return this;
}
/**
* Customer's company name. Required unless a `given_name` and `family_name` are
* provided. For Canadian customers, the use of a `company_name` value will mean that
* any mandate created from this customer will be considered to be a "Business PAD"
* (otherwise, any mandate will be considered to be a "Personal PAD").
*/
public Customer withCompanyName(String companyName) {
this.companyName = companyName;
return this;
}
/**
* [ISO 3166-1 alpha-2
* code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
*/
public Customer withCountryCode(String countryCode) {
this.countryCode = countryCode;
return this;
}
/**
* For Danish customers only. The civic/company number (CPR or CVR) of the customer.
* Must be supplied if the customer's bank account is denominated in Danish krone (DKK).
*/
public Customer withDanishIdentityNumber(String danishIdentityNumber) {
this.danishIdentityNumber = danishIdentityNumber;
return this;
}
/**
* Customer's email address. Required in most cases, as this allows GoCardless to send
* notifications to this customer.
*/
public Customer withEmail(String email) {
this.email = email;
return this;
}
/**
* Customer's surname. Required unless a `company_name` is provided.
*/
public Customer withFamilyName(String familyName) {
this.familyName = familyName;
return this;
}
/**
* Customer's first name. Required unless a `company_name` is provided.
*/
public Customer withGivenName(String givenName) {
this.givenName = givenName;
return this;
}
/**
* [ISO 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) code. Used as the
* language for notification emails sent by GoCardless if your organisation does not
* send its own (see [compliance requirements](#appendix-compliance-requirements)).
* Currently only "en", "fr", "de", "pt", "es", "it", "nl", "da", "nb", "sl", "sv" are
* supported. If this is not provided, the language will be chosen based on the
* `country_code` (if supplied) or default to "en".
*/
public Customer withLanguage(String language) {
this.language = language;
return this;
}
/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public Customer withMetadata(Map<String, String> metadata) {
this.metadata = metadata;
return this;
}
/**
* [ITU E.123](https://en.wikipedia.org/wiki/E.123) formatted phone number, including
* country code.
*/
public Customer withPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
return this;
}
/**
* The customer's postal code. Required if mandate import scheme is either `bacs` or
* `sepa`.
*
*/
public Customer withPostalCode(String postalCode) {
this.postalCode = postalCode;
return this;
}
/**
* The customer's address region, county or department. For US customers a 2 letter
* [ISO3166-2:US](https://en.wikipedia.org/wiki/ISO_3166-2:US) state code is required
* (e.g. `CA` for California).
*/
public Customer withRegion(String region) {
this.region = region;
return this;
}
/**
* For Swedish customers only. The civic/company number (personnummer,
* samordningsnummer, or organisationsnummer) of the customer. Must be supplied if the
* customer's bank account is denominated in Swedish krona (SEK). This field cannot be
* changed once it has been set.
*/
public Customer withSwedishIdentityNumber(String swedishIdentityNumber) {
this.swedishIdentityNumber = swedishIdentityNumber;
return this;
}
}
public static class Links {
private String mandateImport;
/**
* Unique identifier, beginning with "IM".
*/
public Links withMandateImport(String mandateImport) {
this.mandateImport = mandateImport;
return this;
}
}
public static class Mandate {
private AuthorisationSource authorisationSource;
private Map<String, String> metadata;
private String reference;
/**
* This field is ACH specific, sometimes referred to as [SEC
* code](https://www.moderntreasury.com/learn/sec-codes).
*
* This is the way that the payer gives authorisation to the merchant. web:
* Authorisation is Internet Initiated or via Mobile Entry (maps to SEC code: WEB)
* telephone: Authorisation is provided orally over telephone (maps to SEC code: TEL)
* paper: Authorisation is provided in writing and signed, or similarly authenticated
* (maps to SEC code: PPD)
*
*/
public Mandate withAuthorisationSource(AuthorisationSource authorisationSource) {
this.authorisationSource = authorisationSource;
return this;
}
/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public Mandate withMetadata(Map<String, String> metadata) {
this.metadata = metadata;
return this;
}
/**
* Unique reference. Different schemes have different length and [character
* set](#appendix-character-sets) requirements. GoCardless will generate a unique
* reference satisfying the different scheme requirements if this field is left blank.
*/
public Mandate withReference(String reference) {
this.reference = reference;
return this;
}
public enum AuthorisationSource {
@SerializedName("web")
WEB, @SerializedName("telephone")
TELEPHONE, @SerializedName("paper")
PAPER, @SerializedName("unknown")
UNKNOWN;
@Override
public String toString() {
return name().toLowerCase();
}
}
}
}
/**
* Request class for {@link MandateImportEntryService#list }.
*
* For an existing mandate import, this endpoint lists all of the entries attached.
*
* After a mandate import has been submitted, you can use this endpoint to associate records in
* your system (using the `record_identifier` that you provided when creating the mandate
* import).
*
*/
public static final class MandateImportEntryListRequest<S>
extends ListRequest<S, MandateImportEntry> {
private String mandateImport;
private Status status;
/**
* Cursor pointing to the start of the desired set.
*/
public MandateImportEntryListRequest<S> withAfter(String after) {
setAfter(after);
return this;
}
/**
* Cursor pointing to the end of the desired set.
*/
public MandateImportEntryListRequest<S> withBefore(String before) {
setBefore(before);
return this;
}
/**
* Number of records to return.
*/
public MandateImportEntryListRequest<S> withLimit(Integer limit) {
setLimit(limit);
return this;
}
/**
* Unique identifier, beginning with "IM".
*/
public MandateImportEntryListRequest<S> withMandateImport(String mandateImport) {
this.mandateImport = mandateImport;
return this;
}
/**
* One of:
* <ul>
* <li>`sucessfully_processed`: the entry has been imported and the associated records
* created.</li>
* <li>`unsuccessfully_processed`: the entry could not be processed due to an error, see the
* 'processing_errors' value</li>
* </ul>
*/
public MandateImportEntryListRequest<S> withStatus(Status status) {
this.status = status;
return this;
}
private MandateImportEntryListRequest(HttpClient httpClient,
ListRequestExecutor<S, MandateImportEntry> executor) {
super(httpClient, executor);
}
public MandateImportEntryListRequest<S> withHeader(String headerName, String headerValue) {
this.addHeader(headerName, headerValue);
return this;