-
Notifications
You must be signed in to change notification settings - Fork 1
/
api_categories.go
1759 lines (1603 loc) · 68.1 KB
/
api_categories.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
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
/*
* finAPI Access (with deprecation)
*
* <strong>RESTful API for Account Information Services (AIS) and Payment Initiation Services (PIS)</strong> The following pages give you some general information on how to use our APIs.<br/> The actual API services documentation then follows further below. You can use the menu to jump between API sections. <br/> <br/> This page has a built-in HTTP(S) client, so you can test the services directly from within this page, by filling in the request parameters and/or body in the respective services, and then hitting the TRY button. Note that you need to be authorized to make a successful API call. To authorize, refer to the 'Authorization' section of the API, or just use the OAUTH button that can be found near the TRY button. <br/> <h2 id=\"general-information\">General information</h2> <h3 id=\"general-error-responses\"><strong>Error Responses</strong></h3> When an API call returns with an error, then in general it has the structure shown in the following example: <pre> { \"errors\": [ { \"message\": \"Interface 'FINTS_SERVER' is not supported for this operation.\", \"code\": \"BAD_REQUEST\", \"type\": \"TECHNICAL\" } ], \"date\": \"2020-11-19 16:54:06.854\", \"requestId\": \"selfgen-312042e7-df55-47e4-bffd-956a68ef37b5\", \"endpoint\": \"POST /api/v1/bankConnections/import\", \"authContext\": \"1/21\", \"bank\": \"DEMO0002 - finAPI Test Redirect Bank\" } </pre> If an API call requires an additional authentication by the user, HTTP code 510 is returned and the error response contains the additional \"multiStepAuthentication\" object, see the following example: <pre> { \"errors\": [ { \"message\": \"Es ist eine zusätzliche Authentifizierung erforderlich. Bitte geben Sie folgenden Code an: 123456\", \"code\": \"ADDITIONAL_AUTHENTICATION_REQUIRED\", \"type\": \"BUSINESS\", \"multiStepAuthentication\": { \"hash\": \"678b13f4be9ed7d981a840af8131223a\", \"status\": \"CHALLENGE_RESPONSE_REQUIRED\", \"challengeMessage\": \"Es ist eine zusätzliche Authentifizierung erforderlich. Bitte geben Sie folgenden Code an: 123456\", \"answerFieldLabel\": \"TAN\", \"redirectUrl\": null, \"redirectContext\": null, \"redirectContextField\": null, \"twoStepProcedures\": null, \"photoTanMimeType\": null, \"photoTanData\": null, \"opticalData\": null } } ], \"date\": \"2019-11-29 09:51:55.931\", \"requestId\": \"selfgen-45059c99-1b14-4df7-9bd3-9d5f126df294\", \"endpoint\": \"POST /api/v1/bankConnections/import\", \"authContext\": \"1/18\", \"bank\": \"DEMO0001 - finAPI Test Bank\" } </pre> An exception to this error format are API authentication errors, where the following structure is returned: <pre> { \"error\": \"invalid_token\", \"error_description\": \"Invalid access token: cccbce46-xxxx-xxxx-xxxx-xxxxxxxxxx\" } </pre> <h3 id=\"general-paging\"><strong>Paging</strong></h3> API services that may potentially return a lot of data implement paging. They return a limited number of entries within a \"page\". Further entries must be fetched with subsequent calls. <br/><br/> Any API service that implements paging provides the following input parameters:<br/> • \"page\": the number of the page to be retrieved (starting with 1).<br/> • \"perPage\": the number of entries within a page. The default and maximum value is stated in the documentation of the respective services. A paged response contains an additional \"paging\" object with the following structure: <pre> { ... , \"paging\": { \"page\": 1, \"perPage\": 20, \"pageCount\": 234, \"totalCount\": 4662 } } </pre> <h3 id=\"general-internationalization\"><strong>Internationalization</strong></h3> The finAPI services support internationalization which means you can define the language you prefer for API service responses. <br/><br/> The following languages are available: German, English, Czech, Slovak. <br/><br/> The preferred language can be defined by providing the official HTTP <strong>Accept-Language</strong> header. <br/><br/> finAPI reacts on the official iso language codes "de", "en", "cs" and "sk" for the named languages. Additional subtags supported by the Accept-Language header may be provided, e.g. "en-US", but are ignored. <br/> If no Accept-Language header is given, German is used as the default language. <br/><br/> Exceptions:<br/> • Bank login hints and login fields are only available in the language of the bank and not being translated.<br/> • Direct messages from the bank systems typically returned as BUSINESS errors will not be translated.<br/> • BUSINESS errors created by finAPI directly are available in German and English.<br/> • TECHNICAL errors messages meant for developers are mostly in English, but also may be translated. <h3 id=\"general-request-ids\"><strong>Request IDs</strong></h3> With any API call, you can pass a request ID via a header with name \"X-Request-Id\". The request ID can be an arbitrary string with up to 255 characters. Passing a longer string will result in an error. <br/><br/> If you don't pass a request ID for a call, finAPI will generate a random ID internally. <br/><br/> The request ID is always returned back in the response of a service, as a header with name \"X-Request-Id\". <br/><br/> We highly recommend to always pass a (preferably unique) request ID, and include it into your client application logs whenever you make a request or receive a response (especially in the case of an error response). finAPI is also logging request IDs on its end. Having a request ID can help the finAPI support team to work more efficiently and solve tickets faster. <h3 id=\"general-overriding-http-methods\"><strong>Overriding HTTP methods</strong></h3> Some HTTP clients do not support the HTTP methods PATCH or DELETE. If you are using such a client in your application, you can use a POST request instead with a special HTTP header indicating the originally intended HTTP method. <br/><br/> The header's name is <strong>X-HTTP-Method-Override</strong>. Set its value to either <strong>PATCH</strong> or <strong>DELETE</strong>. POST Requests having this header set will be treated either as PATCH or DELETE by the finAPI servers. <br/><br/> Example: <br/><br/> <strong>X-HTTP-Method-Override: PATCH</strong><br/> POST /api/v1/label/51<br/> {\"name\": \"changed label\"}<br/><br/> will be interpreted by finAPI as:<br/><br/> PATCH /api/v1/label/51<br/> {\"name\": \"changed label\"}<br/> <h3 id=\"general-user-metadata\"><strong>User metadata</strong></h3> With the migration to PSD2 APIs, a new term called \"User metadata\" (also known as \"PSU metadata\") has been introduced to the API. This user metadata aims to inform the banking API if there was a real end-user behind an HTTP request or if the request was triggered by a system (e.g. by an automatic batch update). In the latter case, the bank may apply some restrictions such as limiting the number of HTTP requests for a single consent. Also, some operations may be forbidden entirely by the banking API. For example, some banks do not allow issuing a new consent without the end-user being involved. Therefore, it is certainly necessary and obligatory for the customer to provide the PSU metadata for such operations. <br/><br/> As finAPI does not have direct interaction with the end-user, it is the client application's responsibility to provide all the necessary information about the end-user. This must be done by sending additional headers with every request triggered on behalf of the end-user. <br/><br/> At the moment, the following headers are supported by the API:<br/> • \"PSU-IP-Address\" - the IP address of the user's device.<br/> • \"PSU-Device-OS\" - the user's device and/or operating system identification.<br/> • \"PSU-User-Agent\" - the user's web browser or other client device identification. <h3 id=\"general-faq\"><strong>FAQ</strong></h3> <strong>Is there a finAPI SDK?</strong> <br/> Currently we do not offer a native SDK, but there is the option to generate an SDK for almost any target language via OpenAPI. Use the 'Download SDK' button on this page for SDK generation. <br/> <br/> <strong>How can I enable finAPI's automatic batch update?</strong> <br/> Currently there is no way to set up the batch update via the API. Please contact [email protected] for this. <br/> <br/> <strong>Why do I need to keep authorizing when calling services on this page?</strong> <br/> This page is a \"one-page-app\". Reloading the page resets the OAuth authorization context. There is generally no need to reload the page, so just don't do it and your authorization will persist.
*
* API version: 1.151.1
* Contact: [email protected]
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package finapi
import (
"bytes"
_context "context"
_ioutil "io/ioutil"
_nethttp "net/http"
_neturl "net/url"
"strings"
"reflect"
)
// Linger please
var (
_ _context.Context
)
// CategoriesApiService CategoriesApi service
type CategoriesApiService service
type ApiCreateCategoryRequest struct {
ctx _context.Context
ApiService *CategoriesApiService
categoryParams *CategoryParams
xRequestId *string
}
func (r ApiCreateCategoryRequest) CategoryParams(categoryParams CategoryParams) ApiCreateCategoryRequest {
r.categoryParams = &categoryParams
return r
}
func (r ApiCreateCategoryRequest) XRequestId(xRequestId string) ApiCreateCategoryRequest {
r.xRequestId = &xRequestId
return r
}
func (r ApiCreateCategoryRequest) Execute() (Category, *_nethttp.Response, error) {
return r.ApiService.CreateCategoryExecute(r)
}
/*
* CreateCategory Create a new category
* Create a new custom transaction category for the authorized user, that can then be assigned to transactions via PATCH /transactions, and that will also be regarded in finAPI's automatic transaction categorization process. Must pass the user's access_token.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiCreateCategoryRequest
*/
func (a *CategoriesApiService) CreateCategory(ctx _context.Context) ApiCreateCategoryRequest {
return ApiCreateCategoryRequest{
ApiService: a,
ctx: ctx,
}
}
/*
* Execute executes the request
* @return Category
*/
func (a *CategoriesApiService) CreateCategoryExecute(r ApiCreateCategoryRequest) (Category, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodPost
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue Category
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CategoriesApiService.CreateCategory")
if err != nil {
return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/categories"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
if r.categoryParams == nil {
return localVarReturnValue, nil, reportError("categoryParams 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
}
if r.xRequestId != nil {
localVarHeaderParams["X-Request-Id"] = parameterToString(*r.xRequestId, "")
}
// body params
localVarPostBody = r.categoryParams
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 401 {
var v BadCredentialsError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 404 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 422 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 500 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
}
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 ApiDeleteAllCategoriesRequest struct {
ctx _context.Context
ApiService *CategoriesApiService
xHTTPMethodOverride *string
xRequestId *string
}
func (r ApiDeleteAllCategoriesRequest) XHTTPMethodOverride(xHTTPMethodOverride string) ApiDeleteAllCategoriesRequest {
r.xHTTPMethodOverride = &xHTTPMethodOverride
return r
}
func (r ApiDeleteAllCategoriesRequest) XRequestId(xRequestId string) ApiDeleteAllCategoriesRequest {
r.xRequestId = &xRequestId
return r
}
func (r ApiDeleteAllCategoriesRequest) Execute() (IdentifierList, *_nethttp.Response, error) {
return r.ApiService.DeleteAllCategoriesExecute(r)
}
/*
* DeleteAllCategories Delete all categories
* Delete all custom categories of the user that is authorized by the access_token. Must pass the user's access_token. Note that this deletes both parent categories as well as any related sub-categories.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiDeleteAllCategoriesRequest
*/
func (a *CategoriesApiService) DeleteAllCategories(ctx _context.Context) ApiDeleteAllCategoriesRequest {
return ApiDeleteAllCategoriesRequest{
ApiService: a,
ctx: ctx,
}
}
/*
* Execute executes the request
* @return IdentifierList
*/
func (a *CategoriesApiService) DeleteAllCategoriesExecute(r ApiDeleteAllCategoriesRequest) (IdentifierList, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodDelete
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue IdentifierList
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CategoriesApiService.DeleteAllCategories")
if err != nil {
return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/categories"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.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
}
if r.xHTTPMethodOverride != nil {
localVarHeaderParams["X-HTTP-Method-Override"] = parameterToString(*r.xHTTPMethodOverride, "")
}
if r.xRequestId != nil {
localVarHeaderParams["X-Request-Id"] = parameterToString(*r.xRequestId, "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 401 {
var v BadCredentialsError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 500 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
}
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 ApiDeleteCategoryRequest struct {
ctx _context.Context
ApiService *CategoriesApiService
id int64
xHTTPMethodOverride *string
xRequestId *string
}
func (r ApiDeleteCategoryRequest) XHTTPMethodOverride(xHTTPMethodOverride string) ApiDeleteCategoryRequest {
r.xHTTPMethodOverride = &xHTTPMethodOverride
return r
}
func (r ApiDeleteCategoryRequest) XRequestId(xRequestId string) ApiDeleteCategoryRequest {
r.xRequestId = &xRequestId
return r
}
func (r ApiDeleteCategoryRequest) Execute() (*_nethttp.Response, error) {
return r.ApiService.DeleteCategoryExecute(r)
}
/*
* DeleteCategory Delete a category
* Delete a single category of the user that is authorized by the access_token. Must pass the user's access_token. Note that you can only delete user-custom categories (category's where the 'isCustom' flag is true). Also note that when deleting a parent category, all its sub-categories will be deleted as well.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param id Category identifier
* @return ApiDeleteCategoryRequest
*/
func (a *CategoriesApiService) DeleteCategory(ctx _context.Context, id int64) ApiDeleteCategoryRequest {
return ApiDeleteCategoryRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
/*
* Execute executes the request
*/
func (a *CategoriesApiService) DeleteCategoryExecute(r ApiDeleteCategoryRequest) (*_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodDelete
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CategoriesApiService.DeleteCategory")
if err != nil {
return nil, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/categories/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", _neturl.PathEscape(parameterToString(r.id, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.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
}
if r.xHTTPMethodOverride != nil {
localVarHeaderParams["X-HTTP-Method-Override"] = parameterToString(*r.xHTTPMethodOverride, "")
}
if r.xRequestId != nil {
localVarHeaderParams["X-Request-Id"] = parameterToString(*r.xRequestId, "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarHTTPResponse, newErr
}
newErr.model = v
return localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 401 {
var v BadCredentialsError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarHTTPResponse, newErr
}
newErr.model = v
return localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarHTTPResponse, newErr
}
newErr.model = v
return localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 404 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarHTTPResponse, newErr
}
newErr.model = v
return localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 422 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarHTTPResponse, newErr
}
newErr.model = v
return localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 500 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarHTTPResponse, newErr
}
newErr.model = v
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type ApiEditCategoryRequest struct {
ctx _context.Context
ApiService *CategoriesApiService
id int64
editCategoryParams *EditCategoryParams
xHTTPMethodOverride *string
xRequestId *string
}
func (r ApiEditCategoryRequest) EditCategoryParams(editCategoryParams EditCategoryParams) ApiEditCategoryRequest {
r.editCategoryParams = &editCategoryParams
return r
}
func (r ApiEditCategoryRequest) XHTTPMethodOverride(xHTTPMethodOverride string) ApiEditCategoryRequest {
r.xHTTPMethodOverride = &xHTTPMethodOverride
return r
}
func (r ApiEditCategoryRequest) XRequestId(xRequestId string) ApiEditCategoryRequest {
r.xRequestId = &xRequestId
return r
}
func (r ApiEditCategoryRequest) Execute() (Category, *_nethttp.Response, error) {
return r.ApiService.EditCategoryExecute(r)
}
/*
* EditCategory Edit a category
* Change the name of a custom transaction category belonging to the authorized user. Must pass the user's access_token.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param id Identifier of the category to edit
* @return ApiEditCategoryRequest
*/
func (a *CategoriesApiService) EditCategory(ctx _context.Context, id int64) ApiEditCategoryRequest {
return ApiEditCategoryRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
/*
* Execute executes the request
* @return Category
*/
func (a *CategoriesApiService) EditCategoryExecute(r ApiEditCategoryRequest) (Category, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodPatch
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue Category
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CategoriesApiService.EditCategory")
if err != nil {
return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/categories/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", _neturl.PathEscape(parameterToString(r.id, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
if r.editCategoryParams == nil {
return localVarReturnValue, nil, reportError("editCategoryParams 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
}
if r.xHTTPMethodOverride != nil {
localVarHeaderParams["X-HTTP-Method-Override"] = parameterToString(*r.xHTTPMethodOverride, "")
}
if r.xRequestId != nil {
localVarHeaderParams["X-Request-Id"] = parameterToString(*r.xRequestId, "")
}
// body params
localVarPostBody = r.editCategoryParams
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 401 {
var v BadCredentialsError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 404 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 422 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 500 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
}
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 ApiGetAndSearchAllCategoriesRequest struct {
ctx _context.Context
ApiService *CategoriesApiService
ids *[]int64
search *string
isCustom *bool
page *int32
perPage *int32
order *[]string
xRequestId *string
}
func (r ApiGetAndSearchAllCategoriesRequest) Ids(ids []int64) ApiGetAndSearchAllCategoriesRequest {
r.ids = &ids
return r
}
func (r ApiGetAndSearchAllCategoriesRequest) Search(search string) ApiGetAndSearchAllCategoriesRequest {
r.search = &search
return r
}
func (r ApiGetAndSearchAllCategoriesRequest) IsCustom(isCustom bool) ApiGetAndSearchAllCategoriesRequest {
r.isCustom = &isCustom
return r
}
func (r ApiGetAndSearchAllCategoriesRequest) Page(page int32) ApiGetAndSearchAllCategoriesRequest {
r.page = &page
return r
}
func (r ApiGetAndSearchAllCategoriesRequest) PerPage(perPage int32) ApiGetAndSearchAllCategoriesRequest {
r.perPage = &perPage
return r
}
func (r ApiGetAndSearchAllCategoriesRequest) Order(order []string) ApiGetAndSearchAllCategoriesRequest {
r.order = &order
return r
}
func (r ApiGetAndSearchAllCategoriesRequest) XRequestId(xRequestId string) ApiGetAndSearchAllCategoriesRequest {
r.xRequestId = &xRequestId
return r
}
func (r ApiGetAndSearchAllCategoriesRequest) Execute() (PageableCategoryList, *_nethttp.Response, error) {
return r.ApiService.GetAndSearchAllCategoriesExecute(r)
}
/*
* GetAndSearchAllCategories Get and search all categories
* Get a list of all global finAPI categories as well as all custom categories of the authorized user. Must pass the user's access_token. You can set optional search criteria to get only those categories that you are interested in. If you do not specify any search criteria, then this service functions as a 'get all' service.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiGetAndSearchAllCategoriesRequest
*/
func (a *CategoriesApiService) GetAndSearchAllCategories(ctx _context.Context) ApiGetAndSearchAllCategoriesRequest {
return ApiGetAndSearchAllCategoriesRequest{
ApiService: a,
ctx: ctx,
}
}
/*
* Execute executes the request
* @return PageableCategoryList
*/
func (a *CategoriesApiService) GetAndSearchAllCategoriesExecute(r ApiGetAndSearchAllCategoriesRequest) (PageableCategoryList, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodGet
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue PageableCategoryList
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CategoriesApiService.GetAndSearchAllCategories")
if err != nil {
return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/categories"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
if r.ids != nil {
t := *r.ids
if reflect.TypeOf(t).Kind() == reflect.Slice {
s := reflect.ValueOf(t)
for i := 0; i < s.Len(); i++ {
localVarQueryParams.Add("ids", parameterToString(s.Index(i), "multi"))
}
} else {
localVarQueryParams.Add("ids", parameterToString(t, "multi"))
}
}
if r.search != nil {
localVarQueryParams.Add("search", parameterToString(*r.search, ""))
}
if r.isCustom != nil {
localVarQueryParams.Add("isCustom", parameterToString(*r.isCustom, ""))
}
if r.page != nil {
localVarQueryParams.Add("page", parameterToString(*r.page, ""))
}
if r.perPage != nil {
localVarQueryParams.Add("perPage", parameterToString(*r.perPage, ""))
}
if r.order != nil {
t := *r.order
if reflect.TypeOf(t).Kind() == reflect.Slice {
s := reflect.ValueOf(t)
for i := 0; i < s.Len(); i++ {
localVarQueryParams.Add("order", parameterToString(s.Index(i), "multi"))
}
} else {
localVarQueryParams.Add("order", parameterToString(t, "multi"))
}
}
// 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
}
if r.xRequestId != nil {
localVarHeaderParams["X-Request-Id"] = parameterToString(*r.xRequestId, "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 401 {
var v BadCredentialsError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 500 {
var v ErrorMessage
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
}
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 ApiGetCashFlowsRequest struct {
ctx _context.Context
ApiService *CategoriesApiService
search *string
counterpart *string
purpose *string
accountIds *[]int64
minBankBookingDate *string
maxBankBookingDate *string
minFinapiBookingDate *string
maxFinapiBookingDate *string
minAmount *float64
maxAmount *float64
direction *string
labelIds *[]int64
categoryIds *[]int64
isNew *bool
minImportDate *string
maxImportDate *string
includeSubCashFlows *bool
order *[]string
xRequestId *string
}
func (r ApiGetCashFlowsRequest) Search(search string) ApiGetCashFlowsRequest {
r.search = &search
return r
}
func (r ApiGetCashFlowsRequest) Counterpart(counterpart string) ApiGetCashFlowsRequest {
r.counterpart = &counterpart
return r
}
func (r ApiGetCashFlowsRequest) Purpose(purpose string) ApiGetCashFlowsRequest {
r.purpose = &purpose
return r
}
func (r ApiGetCashFlowsRequest) AccountIds(accountIds []int64) ApiGetCashFlowsRequest {
r.accountIds = &accountIds
return r
}
func (r ApiGetCashFlowsRequest) MinBankBookingDate(minBankBookingDate string) ApiGetCashFlowsRequest {
r.minBankBookingDate = &minBankBookingDate
return r
}
func (r ApiGetCashFlowsRequest) MaxBankBookingDate(maxBankBookingDate string) ApiGetCashFlowsRequest {
r.maxBankBookingDate = &maxBankBookingDate
return r
}
func (r ApiGetCashFlowsRequest) MinFinapiBookingDate(minFinapiBookingDate string) ApiGetCashFlowsRequest {
r.minFinapiBookingDate = &minFinapiBookingDate
return r
}
func (r ApiGetCashFlowsRequest) MaxFinapiBookingDate(maxFinapiBookingDate string) ApiGetCashFlowsRequest {
r.maxFinapiBookingDate = &maxFinapiBookingDate
return r
}
func (r ApiGetCashFlowsRequest) MinAmount(minAmount float64) ApiGetCashFlowsRequest {
r.minAmount = &minAmount
return r