-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_accounts.go
740 lines (624 loc) · 25.1 KB
/
api_accounts.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
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
/*
Paxos API
<p>Welcome to Paxos APIs. At Paxos, our mission is to enable the movement of any asset, any time, in a trustworthy way. These APIs serve that mission by making it easier than ever for you to directly integrate our product capabilities into your application, leveraging the speed, stability, and security of the Paxos platform.</p> <p>The documentation that follows gives you access to our Crypto Brokerage, Trading, and Exchange products. It includes APIs for market data, orders, and the held rate quote flow.</p> <p>To test in our sandbox environment, <a href=\"https://account.sandbox.paxos.com\" target=\"_blank\">sign up</a> for an account. For more information about Paxos and our APIs, visit <a href=\"https://www.paxos.com/\" target=\"_blank\">Paxos.com</a>.</p>
API version: 2.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package paxos
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"strings"
"time"
)
// AccountsAPIService AccountsAPI service
type AccountsAPIService service
type ApiCreateAccountRequest struct {
ctx context.Context
ApiService *AccountsAPIService
createAccountRequest *CreateAccountRequest
}
func (r ApiCreateAccountRequest) CreateAccountRequest(createAccountRequest CreateAccountRequest) ApiCreateAccountRequest {
r.createAccountRequest = &createAccountRequest
return r
}
func (r ApiCreateAccountRequest) Execute() (*Account, *http.Response, error) {
return r.ApiService.CreateAccountExecute(r)
}
/*
CreateAccount Create Account
Create an account for a given identity, via the `identity_id` field.
This identity is the primary owner of the account for all tax-related purposes.
To track user balances using Paxos [Profiles](#tag/Profiles), use `create_profile=true` when creating the account.
Once an account has been created, it is not possible to associate it with a [Profile](#tag/Profiles).
### Account Members
In addition to the primary owner, other identities may be associated with the account, by using `members`.
The identity on the account is treated as a BENEFICIAL_OWNER.
To add a financial advisor to an account, add a member with the FINANCIAL_ADVISOR role.
#### Example
This example request creates a joint account for John and Jane Doe. John has identity_id=82c338f4-3cb7-4d9b-be2a-4b077c82ee3a,
and Jane has identity_id=0f5d8475-33f3-4ebd-88a0-66dedc2581c1. John is the primary owner of the account for tax-purposes, but Jane
is a full beneficial owner.
Additionally, this account has an associated financial advisor with identity_id=0d26f878-298e-4d47-81be-cdf4e982a3d3.
<!--indentation does not work in swagger code blocks-->
<pre>
<code>
{
"account": {
"identity_id": "82c338f4-3cb7-4d9b-be2a-4b077c82ee3a",
"members": [{
"identity_id": "0f5d8475-33f3-4ebd-88a0-66dedc2581c1",
"roles": ["BENEFICIAL_OWNER"]
}, {
"identity_id": "0d26f878-298e-4d47-81be-cdf4e982a3d3",
"roles": ["FINANCIAL_ADVISOR"]
}]
}
}
</code>
</pre>
### Fields
Any fields not listed are forbidden in this request.
Field | Notes
---|---
identity_id | Required
description | Optional
metadata | Optional
ref_id | Optional
members | Optional
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return ApiCreateAccountRequest
*/
func (a *AccountsAPIService) CreateAccount(ctx context.Context) ApiCreateAccountRequest {
return ApiCreateAccountRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
// @return Account
func (a *AccountsAPIService) CreateAccountExecute(r ApiCreateAccountRequest) (*Account, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *Account
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AccountsAPIService.CreateAccount")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/identity/accounts"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.createAccountRequest == nil {
return localVarReturnValue, nil, reportError("createAccountRequest is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.createAccountRequest
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiGetAccountRequest struct {
ctx context.Context
ApiService *AccountsAPIService
id string
}
func (r ApiGetAccountRequest) Execute() (*Account, *http.Response, error) {
return r.ApiService.GetAccountExecute(r)
}
/*
GetAccount Method for GetAccount
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id uuid id of account
@return ApiGetAccountRequest
*/
func (a *AccountsAPIService) GetAccount(ctx context.Context, id string) ApiGetAccountRequest {
return ApiGetAccountRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
// @return Account
func (a *AccountsAPIService) GetAccountExecute(r ApiGetAccountRequest) (*Account, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *Account
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AccountsAPIService.GetAccount")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/identity/accounts/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiListAccountsRequest struct {
ctx context.Context
ApiService *AccountsAPIService
pageCursor *string
order *string
orderBy *string
limit *int32
createdAtLt *time.Time
createdAtLte *time.Time
createdAtEq *time.Time
createdAtGte *time.Time
createdAtGt *time.Time
identityId *string
updatedAtLt *time.Time
updatedAtLte *time.Time
updatedAtEq *time.Time
updatedAtGte *time.Time
updatedAtGt *time.Time
}
func (r ApiListAccountsRequest) PageCursor(pageCursor string) ApiListAccountsRequest {
r.pageCursor = &pageCursor
return r
}
// Return items in ascending (ASC) or descending (DESC) order. Defaults to DESC.
func (r ApiListAccountsRequest) Order(order string) ApiListAccountsRequest {
r.order = &order
return r
}
// The specific method by which the returned results will be ordered.
func (r ApiListAccountsRequest) OrderBy(orderBy string) ApiListAccountsRequest {
r.orderBy = &orderBy
return r
}
// Number of results to return.
func (r ApiListAccountsRequest) Limit(limit int32) ApiListAccountsRequest {
r.limit = &limit
return r
}
// Include timestamps strictly less than lt. RFC3339 format, like `2006-01-02T15:04:05Z`.
func (r ApiListAccountsRequest) CreatedAtLt(createdAtLt time.Time) ApiListAccountsRequest {
r.createdAtLt = &createdAtLt
return r
}
// Include timestamps less than or equal to lte. RFC3339 format, like `2006-01-02T15:04:05Z`.
func (r ApiListAccountsRequest) CreatedAtLte(createdAtLte time.Time) ApiListAccountsRequest {
r.createdAtLte = &createdAtLte
return r
}
// Include timestamps exactly equal to eq. RFC3339 format, like `2006-01-02T15:04:05Z`.
func (r ApiListAccountsRequest) CreatedAtEq(createdAtEq time.Time) ApiListAccountsRequest {
r.createdAtEq = &createdAtEq
return r
}
// Include timestamps greater than or equal to lte. RFC3339 format, like `2006-01-02T15:04:05Z`.
func (r ApiListAccountsRequest) CreatedAtGte(createdAtGte time.Time) ApiListAccountsRequest {
r.createdAtGte = &createdAtGte
return r
}
// Include timestamps strictly greater than gt. RFC3339 format, like `2006-01-02T15:04:05Z`.
func (r ApiListAccountsRequest) CreatedAtGt(createdAtGt time.Time) ApiListAccountsRequest {
r.createdAtGt = &createdAtGt
return r
}
// Optionally filter by primary identity identity.
func (r ApiListAccountsRequest) IdentityId(identityId string) ApiListAccountsRequest {
r.identityId = &identityId
return r
}
// Include timestamps strictly less than lt. RFC3339 format, like `2006-01-02T15:04:05Z`.
func (r ApiListAccountsRequest) UpdatedAtLt(updatedAtLt time.Time) ApiListAccountsRequest {
r.updatedAtLt = &updatedAtLt
return r
}
// Include timestamps less than or equal to lte. RFC3339 format, like `2006-01-02T15:04:05Z`.
func (r ApiListAccountsRequest) UpdatedAtLte(updatedAtLte time.Time) ApiListAccountsRequest {
r.updatedAtLte = &updatedAtLte
return r
}
// Include timestamps exactly equal to eq. RFC3339 format, like `2006-01-02T15:04:05Z`.
func (r ApiListAccountsRequest) UpdatedAtEq(updatedAtEq time.Time) ApiListAccountsRequest {
r.updatedAtEq = &updatedAtEq
return r
}
// Include timestamps greater than or equal to lte. RFC3339 format, like `2006-01-02T15:04:05Z`.
func (r ApiListAccountsRequest) UpdatedAtGte(updatedAtGte time.Time) ApiListAccountsRequest {
r.updatedAtGte = &updatedAtGte
return r
}
// Include timestamps strictly greater than gt. RFC3339 format, like `2006-01-02T15:04:05Z`.
func (r ApiListAccountsRequest) UpdatedAtGt(updatedAtGt time.Time) ApiListAccountsRequest {
r.updatedAtGt = &updatedAtGt
return r
}
func (r ApiListAccountsRequest) Execute() (*ListAccountsResponse, *http.Response, error) {
return r.ApiService.ListAccountsExecute(r)
}
/*
ListAccounts List Accounts
List accounts with pagination. Every response will contain a `next_page` field,
as long as the end of the list has not been reached. Pass this value into the `page_cursor` field of the next request
to retrieve the next page of results.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return ApiListAccountsRequest
*/
func (a *AccountsAPIService) ListAccounts(ctx context.Context) ApiListAccountsRequest {
return ApiListAccountsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
// @return ListAccountsResponse
func (a *AccountsAPIService) ListAccountsExecute(r ApiListAccountsRequest) (*ListAccountsResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *ListAccountsResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AccountsAPIService.ListAccounts")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/identity/accounts"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.pageCursor != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "page_cursor", r.pageCursor, "")
}
if r.order != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "order", r.order, "")
}
if r.orderBy != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "order_by", r.orderBy, "")
}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "")
}
if r.createdAtLt != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "created_at.lt", r.createdAtLt, "")
}
if r.createdAtLte != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "created_at.lte", r.createdAtLte, "")
}
if r.createdAtEq != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "created_at.eq", r.createdAtEq, "")
}
if r.createdAtGte != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "created_at.gte", r.createdAtGte, "")
}
if r.createdAtGt != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "created_at.gt", r.createdAtGt, "")
}
if r.identityId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "identity_id", r.identityId, "")
}
if r.updatedAtLt != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "updated_at.lt", r.updatedAtLt, "")
}
if r.updatedAtLte != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "updated_at.lte", r.updatedAtLte, "")
}
if r.updatedAtEq != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "updated_at.eq", r.updatedAtEq, "")
}
if r.updatedAtGte != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "updated_at.gte", r.updatedAtGte, "")
}
if r.updatedAtGt != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "updated_at.gt", r.updatedAtGt, "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiUpdateAccountRequest struct {
ctx context.Context
ApiService *AccountsAPIService
updateAccountRequest *UpdateAccountRequest
}
func (r ApiUpdateAccountRequest) UpdateAccountRequest(updateAccountRequest UpdateAccountRequest) ApiUpdateAccountRequest {
r.updateAccountRequest = &updateAccountRequest
return r
}
func (r ApiUpdateAccountRequest) Execute() (*Account, *http.Response, error) {
return r.ApiService.UpdateAccountExecute(r)
}
/*
UpdateAccount Update Account
This enables you to update an existing account with new information. Please refer to the following
table for fields that can be updated via this endpoint.
Field | Notes
---|---
account.id | Required
account.description | Optional
account.ref_id | Optional
account.metadata | Optional. This will overwrite any existing metadata added to the account.
account.members | Optional. The only roles that can be added/removed are `FINANCIAL_ADVISOR` or `AUTHORIZED_USER.` You must always specify the full members object as we do not currently support differential member updates.
set_user_disabled | Optional. Setting this to `true` will disable the account, limiting its ability to be used within the Paxos platform.
#### Example Requests
#### Disabling an account
<!--indentation does not work in swagger code blocks-->
<pre>
<code>
{
"set_user_disabled": true,
"account": {
"id": "82c338f4-3cb7-4d9b-be2a-4b077c82ee3a",
"description": "Account Description",
"ref_id": "82c338f4-3cb7",
}
}
</code>
</pre>
### Adding an account member
To retain the existing account members and add a new account member, the `members` field must contain the existing account members and the
new member. The below example adds an `AUTHORIZED_USER` to the account.
In order to add account members while leaving existing account members unaffected, clients
should use the [Add Account Members](#operation/AddAccountMembers) API.
<!--indentation does not work in swagger code blocks-->
<pre>
<code>
{
"account": {
"id": "82c338f4-3cb7-4d9b-be2a-4b077c82ee3a",
"members": [{
"identity_id": "0f5d8475-33f3-4ebd-88a0-66dedc2581c1",
"roles": ["BENEFICIAL_OWNER"]
}, {
"identity_id": "0d26f878-298e-4d47-81be-cdf4e982a3d3",
"roles": ["FINANCIAL_ADVISOR"]
}, {
"identity_id": "012k23eb-298e-4d47-81be-cdf4e982a3d3",
"roles": ["AUTHORIZED_USER"]
}]
}
}
</code>
</pre>
### Removing an account member
To remove an existing account member and retain other needed members, the `members` field must contain
the existing account members without the account member you'd like to remove. The below example removes an `AUTHORIZED_USER` from the account.
Note, this API requires the `members` array to have at least one element. In order to delete all members
from an account, clients should use the [Delete Account Member](#operation/DeleteAccountMember) API.
<!--indentation does not work in swagger code blocks-->
<pre>
<code>
{
"account": {
"id": "82c338f4-3cb7-4d9b-be2a-4b077c82ee3a",
"members": [{
"identity_id": "0f5d8475-33f3-4ebd-88a0-66dedc2581c1",
"roles": ["BENEFICIAL_OWNER"]
}]
}
}
</code>
</pre>
### Updating an account members' roles
To update an account members' roles, the `members` field must contain all the existing members with their roles along
with the additional role that you'd like to add or remove. The below example adds the `FINANCIAL_ADVISOR` role to an member that is already a `BENEFICIAL_OWNER`.
<!--indentation does not work in swagger code blocks-->
<pre>
<code>
{
"account": {
"id": "82c338f4-3cb7-4d9b-be2a-4b077c82ee3a",
"members": [{
"identity_id": "0f5d8475-33f3-4ebd-88a0-66dedc2581c1",
"roles": ["BENEFICIAL_OWNER", "FINANCIAL_ADVISOR"]
}]
}
}
</code>
</pre>
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return ApiUpdateAccountRequest
*/
func (a *AccountsAPIService) UpdateAccount(ctx context.Context) ApiUpdateAccountRequest {
return ApiUpdateAccountRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
// @return Account
func (a *AccountsAPIService) UpdateAccountExecute(r ApiUpdateAccountRequest) (*Account, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *Account
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AccountsAPIService.UpdateAccount")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/identity/accounts"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.updateAccountRequest == nil {
return localVarReturnValue, nil, reportError("updateAccountRequest is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.updateAccountRequest
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}