1
-
2
1
//------------------------------------------------------------------------------
3
2
// <auto-generated>
4
3
// This code was generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
@@ -14,6 +13,7 @@ namespace Codat.BankFeeds
14
13
using Codat . BankFeeds . Models . Errors ;
15
14
using Codat . BankFeeds . Models . Operations ;
16
15
using Codat . BankFeeds . Models . Shared ;
16
+ using Codat . BankFeeds . Utils . Retries ;
17
17
using Codat . BankFeeds . Utils ;
18
18
using Newtonsoft . Json ;
19
19
using System . Collections . Generic ;
@@ -41,7 +41,7 @@ public interface IAccountMapping
41
41
/// This endpoint is only needed if building an account management UI.
42
42
/// </remarks>
43
43
/// </summary>
44
- Task < CreateBankAccountMappingResponse > CreateAsync ( CreateBankAccountMappingRequest request ) ;
44
+ Task < CreateBankAccountMappingResponse > CreateAsync ( CreateBankAccountMappingRequest request , RetryConfig ? retryConfig = null ) ;
45
45
46
46
/// <summary>
47
47
/// List bank feed account mappings
@@ -54,7 +54,7 @@ public interface IAccountMapping
54
54
/// This endpoint is only needed if building an account management UI.
55
55
/// </remarks>
56
56
/// </summary>
57
- Task < GetBankAccountMappingResponse > GetAsync ( GetBankAccountMappingRequest request ) ;
57
+ Task < GetBankAccountMappingResponse > GetAsync ( GetBankAccountMappingRequest request , RetryConfig ? retryConfig = null ) ;
58
58
}
59
59
60
60
/// <summary>
@@ -64,31 +64,31 @@ public class AccountMapping: IAccountMapping
64
64
{
65
65
public SDKConfig SDKConfiguration { get ; private set ; }
66
66
private const string _language = "csharp" ;
67
- private const string _sdkVersion = "4.3 .0" ;
68
- private const string _sdkGenVersion = "2.319.7 " ;
67
+ private const string _sdkVersion = "4.4 .0" ;
68
+ private const string _sdkGenVersion = "2.339.1 " ;
69
69
private const string _openapiDocVersion = "3.0.0" ;
70
- private const string _userAgent = "speakeasy-sdk/csharp 4.3 .0 2.319.7 3.0.0 Codat.BankFeeds" ;
70
+ private const string _userAgent = "speakeasy-sdk/csharp 4.4 .0 2.339.1 3.0.0 Codat.BankFeeds" ;
71
71
private string _serverUrl = "" ;
72
- private ISpeakeasyHttpClient _defaultClient ;
72
+ private ISpeakeasyHttpClient _client ;
73
73
private Func < Security > ? _securitySource ;
74
74
75
- public AccountMapping ( ISpeakeasyHttpClient defaultClient , Func < Security > ? securitySource , string serverUrl , SDKConfig config )
75
+ public AccountMapping ( ISpeakeasyHttpClient client , Func < Security > ? securitySource , string serverUrl , SDKConfig config )
76
76
{
77
- _defaultClient = defaultClient ;
77
+ _client = client ;
78
78
_securitySource = securitySource ;
79
79
_serverUrl = serverUrl ;
80
80
SDKConfiguration = config ;
81
81
}
82
82
83
- public async Task < CreateBankAccountMappingResponse > CreateAsync ( CreateBankAccountMappingRequest request )
83
+ public async Task < CreateBankAccountMappingResponse > CreateAsync ( CreateBankAccountMappingRequest request , RetryConfig ? retryConfig = null )
84
84
{
85
85
string baseUrl = this . SDKConfiguration . GetTemplatedServerUrl ( ) ;
86
86
var urlString = URLBuilder . Build ( baseUrl , "/companies/{companyId}/connections/{connectionId}/bankFeedAccounts/mapping" , request ) ;
87
87
88
88
var httpRequest = new HttpRequestMessage ( HttpMethod . Post , urlString ) ;
89
89
httpRequest . Headers . Add ( "user-agent" , _userAgent ) ;
90
90
91
- var serializedBody = RequestBodySerializer . Serialize ( request , "Zero " , "json" , false , true ) ;
91
+ var serializedBody = RequestBodySerializer . Serialize ( request , "BankFeedAccountMapping " , "json" , false , true ) ;
92
92
if ( serializedBody != null )
93
93
{
94
94
httpRequest . Content = serializedBody ;
@@ -101,16 +101,51 @@ public async Task<CreateBankAccountMappingResponse> CreateAsync(CreateBankAccoun
101
101
102
102
var hookCtx = new HookContext ( "create-bank-account-mapping" , null , _securitySource ) ;
103
103
104
- httpRequest = await this . SDKConfiguration . hooks . BeforeRequestAsync ( new BeforeRequestContext ( hookCtx ) , httpRequest ) ;
104
+ httpRequest = await this . SDKConfiguration . Hooks . BeforeRequestAsync ( new BeforeRequestContext ( hookCtx ) , httpRequest ) ;
105
+ if ( retryConfig == null )
106
+ {
107
+ if ( this . SDKConfiguration . RetryConfig != null )
108
+ {
109
+ retryConfig = this . SDKConfiguration . RetryConfig ;
110
+ }
111
+ else
112
+ {
113
+ var backoff = new BackoffStrategy (
114
+ initialIntervalMs : 500L ,
115
+ maxIntervalMs : 60000L ,
116
+ maxElapsedTimeMs : 3600000L ,
117
+ exponent : 1.5
118
+ ) ;
119
+ retryConfig = new RetryConfig (
120
+ strategy : RetryConfig . RetryStrategy . BACKOFF ,
121
+ backoff : backoff ,
122
+ retryConnectionErrors : true ) ;
123
+ }
124
+ }
125
+
126
+ List < string > statusCodes = new List < string >
127
+ {
128
+ "408" ,
129
+ "429" ,
130
+ "5XX" ,
131
+ } ;
132
+
133
+ Func < Task < HttpResponseMessage > > retrySend = async ( ) =>
134
+ {
135
+ var _httpRequest = await _client . CloneAsync ( httpRequest ) ;
136
+ return await _client . SendAsync ( _httpRequest ) ;
137
+ } ;
138
+ var retries = new Codat . BankFeeds . Utils . Retries . Retries ( retrySend , retryConfig , statusCodes ) ;
139
+
105
140
HttpResponseMessage httpResponse ;
106
141
try
107
142
{
108
- httpResponse = await _defaultClient . SendAsync ( httpRequest ) ;
143
+ httpResponse = await retries . Run ( ) ;
109
144
int _statusCode = ( int ) httpResponse . StatusCode ;
110
145
111
146
if ( _statusCode == 400 || _statusCode == 401 || _statusCode == 402 || _statusCode == 403 || _statusCode == 404 || _statusCode == 429 || _statusCode >= 400 && _statusCode < 500 || _statusCode == 500 || _statusCode == 503 || _statusCode >= 500 && _statusCode < 600 )
112
147
{
113
- var _httpResponse = await this . SDKConfiguration . hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , httpResponse , null ) ;
148
+ var _httpResponse = await this . SDKConfiguration . Hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , httpResponse , null ) ;
114
149
if ( _httpResponse != null )
115
150
{
116
151
httpResponse = _httpResponse ;
@@ -119,7 +154,7 @@ public async Task<CreateBankAccountMappingResponse> CreateAsync(CreateBankAccoun
119
154
}
120
155
catch ( Exception error )
121
156
{
122
- var _httpResponse = await this . SDKConfiguration . hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , null , error ) ;
157
+ var _httpResponse = await this . SDKConfiguration . Hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , null , error ) ;
123
158
if ( _httpResponse != null )
124
159
{
125
160
httpResponse = _httpResponse ;
@@ -130,7 +165,7 @@ public async Task<CreateBankAccountMappingResponse> CreateAsync(CreateBankAccoun
130
165
}
131
166
}
132
167
133
- httpResponse = await this . SDKConfiguration . hooks . AfterSuccessAsync ( new AfterSuccessContext ( hookCtx ) , httpResponse ) ;
168
+ httpResponse = await this . SDKConfiguration . Hooks . AfterSuccessAsync ( new AfterSuccessContext ( hookCtx ) , httpResponse ) ;
134
169
135
170
var contentType = httpResponse . Content . Headers . ContentType ? . MediaType ;
136
171
int responseStatusCode = ( int ) httpResponse . StatusCode ;
@@ -175,7 +210,7 @@ public async Task<CreateBankAccountMappingResponse> CreateAsync(CreateBankAccoun
175
210
}
176
211
}
177
212
178
- public async Task < GetBankAccountMappingResponse > GetAsync ( GetBankAccountMappingRequest request )
213
+ public async Task < GetBankAccountMappingResponse > GetAsync ( GetBankAccountMappingRequest request , RetryConfig ? retryConfig = null )
179
214
{
180
215
string baseUrl = this . SDKConfiguration . GetTemplatedServerUrl ( ) ;
181
216
var urlString = URLBuilder . Build ( baseUrl , "/companies/{companyId}/connections/{connectionId}/bankFeedAccounts/mapping" , request ) ;
@@ -190,16 +225,51 @@ public async Task<GetBankAccountMappingResponse> GetAsync(GetBankAccountMappingR
190
225
191
226
var hookCtx = new HookContext ( "get-bank-account-mapping" , null , _securitySource ) ;
192
227
193
- httpRequest = await this . SDKConfiguration . hooks . BeforeRequestAsync ( new BeforeRequestContext ( hookCtx ) , httpRequest ) ;
228
+ httpRequest = await this . SDKConfiguration . Hooks . BeforeRequestAsync ( new BeforeRequestContext ( hookCtx ) , httpRequest ) ;
229
+ if ( retryConfig == null )
230
+ {
231
+ if ( this . SDKConfiguration . RetryConfig != null )
232
+ {
233
+ retryConfig = this . SDKConfiguration . RetryConfig ;
234
+ }
235
+ else
236
+ {
237
+ var backoff = new BackoffStrategy (
238
+ initialIntervalMs : 500L ,
239
+ maxIntervalMs : 60000L ,
240
+ maxElapsedTimeMs : 3600000L ,
241
+ exponent : 1.5
242
+ ) ;
243
+ retryConfig = new RetryConfig (
244
+ strategy : RetryConfig . RetryStrategy . BACKOFF ,
245
+ backoff : backoff ,
246
+ retryConnectionErrors : true ) ;
247
+ }
248
+ }
249
+
250
+ List < string > statusCodes = new List < string >
251
+ {
252
+ "408" ,
253
+ "429" ,
254
+ "5XX" ,
255
+ } ;
256
+
257
+ Func < Task < HttpResponseMessage > > retrySend = async ( ) =>
258
+ {
259
+ var _httpRequest = await _client . CloneAsync ( httpRequest ) ;
260
+ return await _client . SendAsync ( _httpRequest ) ;
261
+ } ;
262
+ var retries = new Codat . BankFeeds . Utils . Retries . Retries ( retrySend , retryConfig , statusCodes ) ;
263
+
194
264
HttpResponseMessage httpResponse ;
195
265
try
196
266
{
197
- httpResponse = await _defaultClient . SendAsync ( httpRequest ) ;
267
+ httpResponse = await retries . Run ( ) ;
198
268
int _statusCode = ( int ) httpResponse . StatusCode ;
199
269
200
270
if ( _statusCode == 401 || _statusCode == 402 || _statusCode == 403 || _statusCode == 404 || _statusCode == 429 || _statusCode >= 400 && _statusCode < 500 || _statusCode == 500 || _statusCode == 503 || _statusCode >= 500 && _statusCode < 600 )
201
271
{
202
- var _httpResponse = await this . SDKConfiguration . hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , httpResponse , null ) ;
272
+ var _httpResponse = await this . SDKConfiguration . Hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , httpResponse , null ) ;
203
273
if ( _httpResponse != null )
204
274
{
205
275
httpResponse = _httpResponse ;
@@ -208,7 +278,7 @@ public async Task<GetBankAccountMappingResponse> GetAsync(GetBankAccountMappingR
208
278
}
209
279
catch ( Exception error )
210
280
{
211
- var _httpResponse = await this . SDKConfiguration . hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , null , error ) ;
281
+ var _httpResponse = await this . SDKConfiguration . Hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , null , error ) ;
212
282
if ( _httpResponse != null )
213
283
{
214
284
httpResponse = _httpResponse ;
@@ -219,7 +289,7 @@ public async Task<GetBankAccountMappingResponse> GetAsync(GetBankAccountMappingR
219
289
}
220
290
}
221
291
222
- httpResponse = await this . SDKConfiguration . hooks . AfterSuccessAsync ( new AfterSuccessContext ( hookCtx ) , httpResponse ) ;
292
+ httpResponse = await this . SDKConfiguration . Hooks . AfterSuccessAsync ( new AfterSuccessContext ( hookCtx ) , httpResponse ) ;
223
293
224
294
var contentType = httpResponse . Content . Headers . ContentType ? . MediaType ;
225
295
int responseStatusCode = ( int ) httpResponse . StatusCode ;
0 commit comments