1
-
2
1
//------------------------------------------------------------------------------
3
2
// <auto-generated>
4
- // This code was generated by Speakeasy (https://speakeasyapi.dev ). DO NOT EDIT.
3
+ // This code was generated by Speakeasy (https://speakeasy.com ). DO NOT EDIT.
5
4
//
6
5
// Changes to this file may cause incorrect behavior and will be lost when
7
6
// the code is regenerated.
11
10
namespace Codat . Sync . Expenses
12
11
{
13
12
using Codat . Sync . Expenses . Hooks ;
13
+ using Codat . Sync . Expenses . Models . Components ;
14
14
using Codat . Sync . Expenses . Models . Errors ;
15
- using Codat . Sync . Expenses . Models . Operations ;
16
- using Codat . Sync . Expenses . Models . Shared ;
15
+ using Codat . Sync . Expenses . Models . Requests ;
16
+ using Codat . Sync . Expenses . Utils . Retries ;
17
17
using Codat . Sync . Expenses . Utils ;
18
18
using Newtonsoft . Json ;
19
19
using System . Collections . Generic ;
@@ -23,7 +23,7 @@ namespace Codat.Sync.Expenses
23
23
using System ;
24
24
25
25
/// <summary>
26
- /// Create accounts and view account schemas .
26
+ /// Create accounts and view create account options .
27
27
/// </summary>
28
28
public interface IAccounts
29
29
{
@@ -44,7 +44,7 @@ public interface IAccounts
44
44
///
45
45
/// </remarks>
46
46
/// </summary>
47
- Task < Models . Operations . CreateAccountResponse > CreateAsync ( CreateAccountRequest request ) ;
47
+ Task < Models . Requests . CreateAccountResponse > CreateAsync ( CreateAccountRequest request , RetryConfig ? retryConfig = null ) ;
48
48
49
49
/// <summary>
50
50
/// Get create account model
@@ -62,33 +62,33 @@ public interface IAccounts
62
62
///
63
63
/// </remarks>
64
64
/// </summary>
65
- Task < GetCreateChartOfAccountsModelResponse > GetCreateModelAsync ( GetCreateChartOfAccountsModelRequest request ) ;
65
+ Task < GetCreateChartOfAccountsModelResponse > GetCreateModelAsync ( GetCreateChartOfAccountsModelRequest request , RetryConfig ? retryConfig = null ) ;
66
66
}
67
67
68
68
/// <summary>
69
- /// Create accounts and view account schemas .
69
+ /// Create accounts and view create account options .
70
70
/// </summary>
71
71
public class Accounts : IAccounts
72
72
{
73
73
public SDKConfig SDKConfiguration { get ; private set ; }
74
74
private const string _language = "csharp" ;
75
- private const string _sdkVersion = "5.4 .0" ;
76
- private const string _sdkGenVersion = "2.319.7 " ;
75
+ private const string _sdkVersion = "6.0 .0" ;
76
+ private const string _sdkGenVersion = "2.415.6 " ;
77
77
private const string _openapiDocVersion = "prealpha" ;
78
- private const string _userAgent = "speakeasy-sdk/csharp 5.4 .0 2.319.7 prealpha Codat.Sync.Expenses" ;
78
+ private const string _userAgent = "speakeasy-sdk/csharp 6.0 .0 2.415.6 prealpha Codat.Sync.Expenses" ;
79
79
private string _serverUrl = "" ;
80
- private ISpeakeasyHttpClient _defaultClient ;
81
- private Func < Security > ? _securitySource ;
80
+ private ISpeakeasyHttpClient _client ;
81
+ private Func < Codat . Sync . Expenses . Models . Components . Security > ? _securitySource ;
82
82
83
- public Accounts ( ISpeakeasyHttpClient defaultClient , Func < Security > ? securitySource , string serverUrl , SDKConfig config )
83
+ public Accounts ( ISpeakeasyHttpClient client , Func < Codat . Sync . Expenses . Models . Components . Security > ? securitySource , string serverUrl , SDKConfig config )
84
84
{
85
- _defaultClient = defaultClient ;
85
+ _client = client ;
86
86
_securitySource = securitySource ;
87
87
_serverUrl = serverUrl ;
88
88
SDKConfiguration = config ;
89
89
}
90
90
91
- public async Task < Models . Operations . CreateAccountResponse > CreateAsync ( CreateAccountRequest request )
91
+ public async Task < Models . Requests . CreateAccountResponse > CreateAsync ( CreateAccountRequest request , RetryConfig ? retryConfig = null )
92
92
{
93
93
string baseUrl = this . SDKConfiguration . GetTemplatedServerUrl ( ) ;
94
94
var urlString = URLBuilder . Build ( baseUrl , "/companies/{companyId}/connections/{connectionId}/push/accounts" , request ) ;
@@ -109,16 +109,52 @@ public Accounts(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySour
109
109
110
110
var hookCtx = new HookContext ( "create-account" , null , _securitySource ) ;
111
111
112
- httpRequest = await this . SDKConfiguration . hooks . BeforeRequestAsync ( new BeforeRequestContext ( hookCtx ) , httpRequest ) ;
112
+ httpRequest = await this . SDKConfiguration . Hooks . BeforeRequestAsync ( new BeforeRequestContext ( hookCtx ) , httpRequest ) ;
113
+ if ( retryConfig == null )
114
+ {
115
+ if ( this . SDKConfiguration . RetryConfig != null )
116
+ {
117
+ retryConfig = this . SDKConfiguration . RetryConfig ;
118
+ }
119
+ else
120
+ {
121
+ var backoff = new BackoffStrategy (
122
+ initialIntervalMs : 500L ,
123
+ maxIntervalMs : 60000L ,
124
+ maxElapsedTimeMs : 3600000L ,
125
+ exponent : 1.5
126
+ ) ;
127
+ retryConfig = new RetryConfig (
128
+ strategy : RetryConfig . RetryStrategy . BACKOFF ,
129
+ backoff : backoff ,
130
+ retryConnectionErrors : true
131
+ ) ;
132
+ }
133
+ }
134
+
135
+ List < string > statusCodes = new List < string >
136
+ {
137
+ "408" ,
138
+ "429" ,
139
+ "5XX" ,
140
+ } ;
141
+
142
+ Func < Task < HttpResponseMessage > > retrySend = async ( ) =>
143
+ {
144
+ var _httpRequest = await _client . CloneAsync ( httpRequest ) ;
145
+ return await _client . SendAsync ( _httpRequest ) ;
146
+ } ;
147
+ var retries = new Codat . Sync . Expenses . Utils . Retries . Retries ( retrySend , retryConfig , statusCodes ) ;
148
+
113
149
HttpResponseMessage httpResponse ;
114
150
try
115
151
{
116
- httpResponse = await _defaultClient . SendAsync ( httpRequest ) ;
152
+ httpResponse = await retries . Run ( ) ;
117
153
int _statusCode = ( int ) httpResponse . StatusCode ;
118
154
119
155
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 )
120
156
{
121
- var _httpResponse = await this . SDKConfiguration . hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , httpResponse , null ) ;
157
+ var _httpResponse = await this . SDKConfiguration . Hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , httpResponse , null ) ;
122
158
if ( _httpResponse != null )
123
159
{
124
160
httpResponse = _httpResponse ;
@@ -127,7 +163,7 @@ public Accounts(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySour
127
163
}
128
164
catch ( Exception error )
129
165
{
130
- var _httpResponse = await this . SDKConfiguration . hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , null , error ) ;
166
+ var _httpResponse = await this . SDKConfiguration . Hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , null , error ) ;
131
167
if ( _httpResponse != null )
132
168
{
133
169
httpResponse = _httpResponse ;
@@ -138,16 +174,16 @@ public Accounts(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySour
138
174
}
139
175
}
140
176
141
- httpResponse = await this . SDKConfiguration . hooks . AfterSuccessAsync ( new AfterSuccessContext ( hookCtx ) , httpResponse ) ;
177
+ httpResponse = await this . SDKConfiguration . Hooks . AfterSuccessAsync ( new AfterSuccessContext ( hookCtx ) , httpResponse ) ;
142
178
143
179
var contentType = httpResponse . Content . Headers . ContentType ? . MediaType ;
144
180
int responseStatusCode = ( int ) httpResponse . StatusCode ;
145
181
if ( responseStatusCode == 200 )
146
182
{
147
183
if ( Utilities . IsContentTypeMatch ( "application/json" , contentType ) )
148
184
{
149
- var obj = ResponseBodyDeserializer . Deserialize < Models . Shared . CreateAccountResponse > ( await httpResponse . Content . ReadAsStringAsync ( ) , NullValueHandling . Ignore ) ;
150
- var response = new Models . Operations . CreateAccountResponse ( )
185
+ var obj = ResponseBodyDeserializer . Deserialize < Models . Components . CreateAccountResponse > ( await httpResponse . Content . ReadAsStringAsync ( ) , NullValueHandling . Ignore ) ;
186
+ var response = new Models . Requests . CreateAccountResponse ( )
151
187
{
152
188
StatusCode = responseStatusCode ,
153
189
ContentType = contentType ,
@@ -183,7 +219,7 @@ public Accounts(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySour
183
219
}
184
220
}
185
221
186
- public async Task < GetCreateChartOfAccountsModelResponse > GetCreateModelAsync ( GetCreateChartOfAccountsModelRequest request )
222
+ public async Task < GetCreateChartOfAccountsModelResponse > GetCreateModelAsync ( GetCreateChartOfAccountsModelRequest request , RetryConfig ? retryConfig = null )
187
223
{
188
224
string baseUrl = this . SDKConfiguration . GetTemplatedServerUrl ( ) ;
189
225
var urlString = URLBuilder . Build ( baseUrl , "/companies/{companyId}/connections/{connectionId}/options/chartOfAccounts" , request ) ;
@@ -198,16 +234,52 @@ public async Task<GetCreateChartOfAccountsModelResponse> GetCreateModelAsync(Get
198
234
199
235
var hookCtx = new HookContext ( "get-create-chartOfAccounts-model" , null , _securitySource ) ;
200
236
201
- httpRequest = await this . SDKConfiguration . hooks . BeforeRequestAsync ( new BeforeRequestContext ( hookCtx ) , httpRequest ) ;
237
+ httpRequest = await this . SDKConfiguration . Hooks . BeforeRequestAsync ( new BeforeRequestContext ( hookCtx ) , httpRequest ) ;
238
+ if ( retryConfig == null )
239
+ {
240
+ if ( this . SDKConfiguration . RetryConfig != null )
241
+ {
242
+ retryConfig = this . SDKConfiguration . RetryConfig ;
243
+ }
244
+ else
245
+ {
246
+ var backoff = new BackoffStrategy (
247
+ initialIntervalMs : 500L ,
248
+ maxIntervalMs : 60000L ,
249
+ maxElapsedTimeMs : 3600000L ,
250
+ exponent : 1.5
251
+ ) ;
252
+ retryConfig = new RetryConfig (
253
+ strategy : RetryConfig . RetryStrategy . BACKOFF ,
254
+ backoff : backoff ,
255
+ retryConnectionErrors : true
256
+ ) ;
257
+ }
258
+ }
259
+
260
+ List < string > statusCodes = new List < string >
261
+ {
262
+ "408" ,
263
+ "429" ,
264
+ "5XX" ,
265
+ } ;
266
+
267
+ Func < Task < HttpResponseMessage > > retrySend = async ( ) =>
268
+ {
269
+ var _httpRequest = await _client . CloneAsync ( httpRequest ) ;
270
+ return await _client . SendAsync ( _httpRequest ) ;
271
+ } ;
272
+ var retries = new Codat . Sync . Expenses . Utils . Retries . Retries ( retrySend , retryConfig , statusCodes ) ;
273
+
202
274
HttpResponseMessage httpResponse ;
203
275
try
204
276
{
205
- httpResponse = await _defaultClient . SendAsync ( httpRequest ) ;
277
+ httpResponse = await retries . Run ( ) ;
206
278
int _statusCode = ( int ) httpResponse . StatusCode ;
207
279
208
280
if ( _statusCode == 401 || _statusCode == 402 || _statusCode == 403 || _statusCode == 404 || _statusCode == 429 || _statusCode >= 400 && _statusCode < 500 || _statusCode == 500 || _statusCode == 503 || _statusCode >= 500 && _statusCode < 600 )
209
281
{
210
- var _httpResponse = await this . SDKConfiguration . hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , httpResponse , null ) ;
282
+ var _httpResponse = await this . SDKConfiguration . Hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , httpResponse , null ) ;
211
283
if ( _httpResponse != null )
212
284
{
213
285
httpResponse = _httpResponse ;
@@ -216,7 +288,7 @@ public async Task<GetCreateChartOfAccountsModelResponse> GetCreateModelAsync(Get
216
288
}
217
289
catch ( Exception error )
218
290
{
219
- var _httpResponse = await this . SDKConfiguration . hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , null , error ) ;
291
+ var _httpResponse = await this . SDKConfiguration . Hooks . AfterErrorAsync ( new AfterErrorContext ( hookCtx ) , null , error ) ;
220
292
if ( _httpResponse != null )
221
293
{
222
294
httpResponse = _httpResponse ;
@@ -227,7 +299,7 @@ public async Task<GetCreateChartOfAccountsModelResponse> GetCreateModelAsync(Get
227
299
}
228
300
}
229
301
230
- httpResponse = await this . SDKConfiguration . hooks . AfterSuccessAsync ( new AfterSuccessContext ( hookCtx ) , httpResponse ) ;
302
+ httpResponse = await this . SDKConfiguration . Hooks . AfterSuccessAsync ( new AfterSuccessContext ( hookCtx ) , httpResponse ) ;
231
303
232
304
var contentType = httpResponse . Content . Headers . ContentType ? . MediaType ;
233
305
int responseStatusCode = ( int ) httpResponse . StatusCode ;
0 commit comments