-
Notifications
You must be signed in to change notification settings - Fork 2
/
legalentity_test.go
341 lines (334 loc) · 16.7 KB
/
legalentity_test.go
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package moderntreasury_test
import (
"context"
"errors"
"os"
"testing"
"time"
"github.com/Modern-Treasury/modern-treasury-go/v2"
"github.com/Modern-Treasury/modern-treasury-go/v2/internal/testutil"
"github.com/Modern-Treasury/modern-treasury-go/v2/option"
)
func TestLegalEntityNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := moderntreasury.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
option.WithOrganizationID("my-organization-ID"),
)
_, err := client.LegalEntities.New(context.TODO(), moderntreasury.LegalEntityNewParams{
LegalEntityType: moderntreasury.F(moderntreasury.LegalEntityNewParamsLegalEntityTypeBusiness),
Addresses: moderntreasury.F([]moderntreasury.LegalEntityNewParamsAddress{{
Country: moderntreasury.F("country"),
Line1: moderntreasury.F("line1"),
Locality: moderntreasury.F("locality"),
PostalCode: moderntreasury.F("postal_code"),
Region: moderntreasury.F("region"),
AddressTypes: moderntreasury.F([]moderntreasury.LegalEntityNewParamsAddressesAddressType{moderntreasury.LegalEntityNewParamsAddressesAddressTypeBusiness}),
Line2: moderntreasury.F("line2"),
}}),
BankSettings: moderntreasury.F(moderntreasury.BankSettingsParam{
ID: moderntreasury.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
BackupWithholdingPercentage: moderntreasury.F(int64(0)),
CreatedAt: moderntreasury.F(time.Now()),
DiscardedAt: moderntreasury.F(time.Now()),
EnableBackupWithholding: moderntreasury.F(true),
LiveMode: moderntreasury.F(true),
Object: moderntreasury.F("object"),
PrivacyOptOut: moderntreasury.F(true),
RegulationO: moderntreasury.F(true),
UpdatedAt: moderntreasury.F(time.Now()),
}),
BusinessName: moderntreasury.F("business_name"),
CitizenshipCountry: moderntreasury.F("citizenship_country"),
DateFormed: moderntreasury.F(time.Now()),
DateOfBirth: moderntreasury.F(time.Now()),
DoingBusinessAsNames: moderntreasury.F([]string{"string"}),
Email: moderntreasury.F("email"),
FirstName: moderntreasury.F("first_name"),
Identifications: moderntreasury.F([]moderntreasury.LegalEntityNewParamsIdentification{{
IDNumber: moderntreasury.F("id_number"),
IDType: moderntreasury.F(moderntreasury.LegalEntityNewParamsIdentificationsIDTypeArCuil),
IssuingCountry: moderntreasury.F("issuing_country"),
}}),
LastName: moderntreasury.F("last_name"),
LegalEntityAssociations: moderntreasury.F([]moderntreasury.LegalEntityNewParamsLegalEntityAssociation{{
RelationshipTypes: moderntreasury.F([]moderntreasury.LegalEntityNewParamsLegalEntityAssociationsRelationshipType{moderntreasury.LegalEntityNewParamsLegalEntityAssociationsRelationshipTypeBeneficialOwner}),
ChildLegalEntity: moderntreasury.F(moderntreasury.LegalEntityNewParamsLegalEntityAssociationsChildLegalEntity{
Addresses: moderntreasury.F([]moderntreasury.LegalEntityNewParamsLegalEntityAssociationsChildLegalEntityAddress{{
Country: moderntreasury.F("country"),
Line1: moderntreasury.F("line1"),
Locality: moderntreasury.F("locality"),
PostalCode: moderntreasury.F("postal_code"),
Region: moderntreasury.F("region"),
AddressTypes: moderntreasury.F([]moderntreasury.LegalEntityNewParamsLegalEntityAssociationsChildLegalEntityAddressesAddressType{moderntreasury.LegalEntityNewParamsLegalEntityAssociationsChildLegalEntityAddressesAddressTypeBusiness}),
Line2: moderntreasury.F("line2"),
}}),
BankSettings: moderntreasury.F(moderntreasury.BankSettingsParam{
ID: moderntreasury.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
BackupWithholdingPercentage: moderntreasury.F(int64(0)),
CreatedAt: moderntreasury.F(time.Now()),
DiscardedAt: moderntreasury.F(time.Now()),
EnableBackupWithholding: moderntreasury.F(true),
LiveMode: moderntreasury.F(true),
Object: moderntreasury.F("object"),
PrivacyOptOut: moderntreasury.F(true),
RegulationO: moderntreasury.F(true),
UpdatedAt: moderntreasury.F(time.Now()),
}),
BusinessName: moderntreasury.F("business_name"),
CitizenshipCountry: moderntreasury.F("citizenship_country"),
DateFormed: moderntreasury.F(time.Now()),
DateOfBirth: moderntreasury.F(time.Now()),
DoingBusinessAsNames: moderntreasury.F([]string{"string"}),
Email: moderntreasury.F("email"),
FirstName: moderntreasury.F("first_name"),
Identifications: moderntreasury.F([]moderntreasury.LegalEntityNewParamsLegalEntityAssociationsChildLegalEntityIdentification{{
IDNumber: moderntreasury.F("id_number"),
IDType: moderntreasury.F(moderntreasury.LegalEntityNewParamsLegalEntityAssociationsChildLegalEntityIdentificationsIDTypeArCuil),
IssuingCountry: moderntreasury.F("issuing_country"),
}}),
LastName: moderntreasury.F("last_name"),
LegalEntityType: moderntreasury.F(moderntreasury.LegalEntityNewParamsLegalEntityAssociationsChildLegalEntityLegalEntityTypeBusiness),
LegalStructure: moderntreasury.F(moderntreasury.LegalEntityNewParamsLegalEntityAssociationsChildLegalEntityLegalStructureCorporation),
Metadata: moderntreasury.F(map[string]string{
"key": "value",
"foo": "bar",
"modern": "treasury",
}),
MiddleName: moderntreasury.F("middle_name"),
PhoneNumbers: moderntreasury.F([]moderntreasury.LegalEntityNewParamsLegalEntityAssociationsChildLegalEntityPhoneNumber{{
PhoneNumber: moderntreasury.F("phone_number"),
}}),
PoliticallyExposedPerson: moderntreasury.F(true),
PreferredName: moderntreasury.F("preferred_name"),
Prefix: moderntreasury.F("prefix"),
RiskRating: moderntreasury.F(moderntreasury.LegalEntityNewParamsLegalEntityAssociationsChildLegalEntityRiskRatingLow),
Suffix: moderntreasury.F("suffix"),
WealthAndEmploymentDetails: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsParam{
ID: moderntreasury.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
AnnualIncome: moderntreasury.F(int64(0)),
CreatedAt: moderntreasury.F(time.Now()),
DiscardedAt: moderntreasury.F(time.Now()),
EmployerCountry: moderntreasury.F("employer_country"),
EmployerName: moderntreasury.F("employer_name"),
EmployerState: moderntreasury.F("employer_state"),
EmploymentStatus: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsEmploymentStatusEmployed),
IncomeCountry: moderntreasury.F("income_country"),
IncomeSource: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsIncomeSourceFamilySupport),
IncomeState: moderntreasury.F("income_state"),
Industry: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsIndustryAccounting),
LiveMode: moderntreasury.F(true),
Object: moderntreasury.F("object"),
Occupation: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsOccupationConsulting),
SourceOfFunds: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsSourceOfFundsAlimony),
UpdatedAt: moderntreasury.F(time.Now()),
WealthSource: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsWealthSourceBusinessSale),
}),
Website: moderntreasury.F("website"),
}),
ChildLegalEntityID: moderntreasury.F("child_legal_entity_id"),
OwnershipPercentage: moderntreasury.F(int64(0)),
Title: moderntreasury.F("title"),
}}),
LegalStructure: moderntreasury.F(moderntreasury.LegalEntityNewParamsLegalStructureCorporation),
Metadata: moderntreasury.F(map[string]string{
"key": "value",
"foo": "bar",
"modern": "treasury",
}),
MiddleName: moderntreasury.F("middle_name"),
PhoneNumbers: moderntreasury.F([]moderntreasury.LegalEntityNewParamsPhoneNumber{{
PhoneNumber: moderntreasury.F("phone_number"),
}}),
PoliticallyExposedPerson: moderntreasury.F(true),
PreferredName: moderntreasury.F("preferred_name"),
Prefix: moderntreasury.F("prefix"),
RiskRating: moderntreasury.F(moderntreasury.LegalEntityNewParamsRiskRatingLow),
Suffix: moderntreasury.F("suffix"),
WealthAndEmploymentDetails: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsParam{
ID: moderntreasury.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
AnnualIncome: moderntreasury.F(int64(0)),
CreatedAt: moderntreasury.F(time.Now()),
DiscardedAt: moderntreasury.F(time.Now()),
EmployerCountry: moderntreasury.F("employer_country"),
EmployerName: moderntreasury.F("employer_name"),
EmployerState: moderntreasury.F("employer_state"),
EmploymentStatus: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsEmploymentStatusEmployed),
IncomeCountry: moderntreasury.F("income_country"),
IncomeSource: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsIncomeSourceFamilySupport),
IncomeState: moderntreasury.F("income_state"),
Industry: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsIndustryAccounting),
LiveMode: moderntreasury.F(true),
Object: moderntreasury.F("object"),
Occupation: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsOccupationConsulting),
SourceOfFunds: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsSourceOfFundsAlimony),
UpdatedAt: moderntreasury.F(time.Now()),
WealthSource: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsWealthSourceBusinessSale),
}),
Website: moderntreasury.F("website"),
})
if err != nil {
var apierr *moderntreasury.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
func TestLegalEntityGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := moderntreasury.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
option.WithOrganizationID("my-organization-ID"),
)
_, err := client.LegalEntities.Get(context.TODO(), "id")
if err != nil {
var apierr *moderntreasury.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
func TestLegalEntityUpdateWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := moderntreasury.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
option.WithOrganizationID("my-organization-ID"),
)
_, err := client.LegalEntities.Update(
context.TODO(),
"id",
moderntreasury.LegalEntityUpdateParams{
Addresses: moderntreasury.F([]moderntreasury.LegalEntityUpdateParamsAddress{{
Country: moderntreasury.F("country"),
Line1: moderntreasury.F("line1"),
Locality: moderntreasury.F("locality"),
PostalCode: moderntreasury.F("postal_code"),
Region: moderntreasury.F("region"),
AddressTypes: moderntreasury.F([]moderntreasury.LegalEntityUpdateParamsAddressesAddressType{moderntreasury.LegalEntityUpdateParamsAddressesAddressTypeBusiness}),
Line2: moderntreasury.F("line2"),
}}),
BankSettings: moderntreasury.F(moderntreasury.BankSettingsParam{
ID: moderntreasury.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
BackupWithholdingPercentage: moderntreasury.F(int64(0)),
CreatedAt: moderntreasury.F(time.Now()),
DiscardedAt: moderntreasury.F(time.Now()),
EnableBackupWithholding: moderntreasury.F(true),
LiveMode: moderntreasury.F(true),
Object: moderntreasury.F("object"),
PrivacyOptOut: moderntreasury.F(true),
RegulationO: moderntreasury.F(true),
UpdatedAt: moderntreasury.F(time.Now()),
}),
BusinessName: moderntreasury.F("business_name"),
CitizenshipCountry: moderntreasury.F("citizenship_country"),
DateFormed: moderntreasury.F(time.Now()),
DateOfBirth: moderntreasury.F(time.Now()),
DoingBusinessAsNames: moderntreasury.F([]string{"string"}),
Email: moderntreasury.F("email"),
FirstName: moderntreasury.F("first_name"),
Identifications: moderntreasury.F([]moderntreasury.LegalEntityUpdateParamsIdentification{{
IDNumber: moderntreasury.F("id_number"),
IDType: moderntreasury.F(moderntreasury.LegalEntityUpdateParamsIdentificationsIDTypeArCuil),
IssuingCountry: moderntreasury.F("issuing_country"),
}}),
LastName: moderntreasury.F("last_name"),
LegalStructure: moderntreasury.F(moderntreasury.LegalEntityUpdateParamsLegalStructureCorporation),
Metadata: moderntreasury.F(map[string]string{
"key": "value",
"foo": "bar",
"modern": "treasury",
}),
MiddleName: moderntreasury.F("middle_name"),
PhoneNumbers: moderntreasury.F([]moderntreasury.LegalEntityUpdateParamsPhoneNumber{{
PhoneNumber: moderntreasury.F("phone_number"),
}}),
PoliticallyExposedPerson: moderntreasury.F(true),
PreferredName: moderntreasury.F("preferred_name"),
Prefix: moderntreasury.F("prefix"),
RiskRating: moderntreasury.F(moderntreasury.LegalEntityUpdateParamsRiskRatingLow),
Suffix: moderntreasury.F("suffix"),
WealthAndEmploymentDetails: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsParam{
ID: moderntreasury.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
AnnualIncome: moderntreasury.F(int64(0)),
CreatedAt: moderntreasury.F(time.Now()),
DiscardedAt: moderntreasury.F(time.Now()),
EmployerCountry: moderntreasury.F("employer_country"),
EmployerName: moderntreasury.F("employer_name"),
EmployerState: moderntreasury.F("employer_state"),
EmploymentStatus: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsEmploymentStatusEmployed),
IncomeCountry: moderntreasury.F("income_country"),
IncomeSource: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsIncomeSourceFamilySupport),
IncomeState: moderntreasury.F("income_state"),
Industry: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsIndustryAccounting),
LiveMode: moderntreasury.F(true),
Object: moderntreasury.F("object"),
Occupation: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsOccupationConsulting),
SourceOfFunds: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsSourceOfFundsAlimony),
UpdatedAt: moderntreasury.F(time.Now()),
WealthSource: moderntreasury.F(moderntreasury.WealthAndEmploymentDetailsWealthSourceBusinessSale),
}),
Website: moderntreasury.F("website"),
},
)
if err != nil {
var apierr *moderntreasury.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
func TestLegalEntityListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := moderntreasury.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
option.WithOrganizationID("my-organization-ID"),
)
_, err := client.LegalEntities.List(context.TODO(), moderntreasury.LegalEntityListParams{
AfterCursor: moderntreasury.F("after_cursor"),
LegalEntityType: moderntreasury.F(moderntreasury.LegalEntityListParamsLegalEntityTypeBusiness),
Metadata: moderntreasury.F(map[string]string{
"foo": "string",
}),
PerPage: moderntreasury.F(int64(0)),
ShowDeleted: moderntreasury.F("show_deleted"),
})
if err != nil {
var apierr *moderntreasury.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}