@@ -12,13 +12,13 @@ namespace Codat.Platform
1212 using Codat . Platform . Hooks ;
1313 using Codat . Platform . Models . Components ;
1414 using Codat . Platform . Models . Errors ;
15- using Codat . Platform . Utils . Retries ;
1615 using Codat . Platform . Utils ;
16+ using Codat . Platform . Utils . Retries ;
1717 using Newtonsoft . Json ;
18+ using System ;
1819 using System . Collections . Generic ;
1920 using System . Net . Http ;
2021 using System . Threading . Tasks ;
21- using System ;
2222
2323 /// <summary>
2424 /// Platform API: Platform API
@@ -66,6 +66,12 @@ public interface ICodatPlatform
6666 /// Configure UI and retrieve access tokens for authentication used by **Connections SDK**.
6767 /// </summary>
6868 public IConnectionManagement ConnectionManagement { get ; }
69+ public ICors Cors { get ; }
70+
71+ /// <summary>
72+ /// Manage company profile configuration, sync settings, and API keys.
73+ /// </summary>
74+ public ISettings Settings { get ; }
6975
7076 /// <summary>
7177 /// Initiate data refreshes, view pull status and history.
@@ -83,9 +89,9 @@ public interface ICodatPlatform
8389 public IIntegrations Integrations { get ; }
8490
8591 /// <summary>
86- /// Manage company profile configuration, sync settings, and API keys .
92+ /// View validation outcomes for completed read data operations .
8793 /// </summary>
88- public ISettings Settings { get ; }
94+ public IReadData ReadData { get ; }
8995
9096 /// <summary>
9197 /// Initiate and monitor Create, Update, and Delete operations.
@@ -103,40 +109,6 @@ public interface ICodatPlatform
103109 public ICustomDataType CustomDataType { get ; }
104110 }
105111
106- public class SDKConfig
107- {
108- /// <summary>
109- /// List of server URLs available to the SDK.
110- /// </summary>
111- public static readonly string [ ] ServerList = {
112- "https://api.codat.io" ,
113- } ;
114-
115- public string ServerUrl = "" ;
116- public int ServerIndex = 0 ;
117- public SDKHooks Hooks = new SDKHooks ( ) ;
118- public RetryConfig ? RetryConfig = null ;
119-
120- public string GetTemplatedServerUrl ( )
121- {
122- if ( ! String . IsNullOrEmpty ( this . ServerUrl ) )
123- {
124- return Utilities . TemplateUrl ( Utilities . RemoveSuffix ( this . ServerUrl , "/" ) , new Dictionary < string , string > ( ) ) ;
125- }
126- return Utilities . TemplateUrl ( SDKConfig . ServerList [ this . ServerIndex ] , new Dictionary < string , string > ( ) ) ;
127- }
128-
129- public ISpeakeasyHttpClient InitHooks ( ISpeakeasyHttpClient client )
130- {
131- string preHooksUrl = GetTemplatedServerUrl ( ) ;
132- var ( postHooksUrl , postHooksClient ) = this . Hooks . SDKInit ( preHooksUrl , client ) ;
133- if ( preHooksUrl != postHooksUrl )
134- {
135- this . ServerUrl = postHooksUrl ;
136- }
137- return postHooksClient ;
138- }
139- }
140112
141113 /// <summary>
142114 /// Platform API: Platform API
@@ -172,25 +144,52 @@ public class CodatPlatform: ICodatPlatform
172144 public SDKConfig SDKConfiguration { get ; private set ; }
173145
174146 private const string _language = "csharp" ;
175- private const string _sdkVersion = "6.0 .0" ;
176- private const string _sdkGenVersion = "2.462.1 " ;
147+ private const string _sdkVersion = "6.1 .0" ;
148+ private const string _sdkGenVersion = "2.723.11 " ;
177149 private const string _openapiDocVersion = "3.0.0" ;
178- private const string _userAgent = "speakeasy-sdk/csharp 6.0.0 2.462.1 3.0.0 Codat.Platform" ;
179- private string _serverUrl = "" ;
180- private int _serverIndex = 0 ;
181- private ISpeakeasyHttpClient _client ;
182- private Func < Codat . Platform . Models . Components . Security > ? _securitySource ;
183150 public ICompanies Companies { get ; private set ; }
184151 public IConnections Connections { get ; private set ; }
185152 public IConnectionManagement ConnectionManagement { get ; private set ; }
153+ public ICors Cors { get ; private set ; }
154+ public ISettings Settings { get ; private set ; }
186155 public IRefreshData RefreshData { get ; private set ; }
187156 public IWebhooks Webhooks { get ; private set ; }
188157 public IIntegrations Integrations { get ; private set ; }
189- public ISettings Settings { get ; private set ; }
158+ public IReadData ReadData { get ; private set ; }
190159 public IPushData PushData { get ; private set ; }
191160 public ISupplementalData SupplementalData { get ; private set ; }
192161 public ICustomDataType CustomDataType { get ; private set ; }
193162
163+ public CodatPlatform ( SDKConfig config )
164+ {
165+ SDKConfiguration = config ;
166+ InitHooks ( ) ;
167+
168+ Companies = new Companies ( SDKConfiguration ) ;
169+
170+ Connections = new Connections ( SDKConfiguration ) ;
171+
172+ ConnectionManagement = new ConnectionManagement ( SDKConfiguration ) ;
173+
174+ Cors = new Cors ( SDKConfiguration ) ;
175+
176+ Settings = new Settings ( SDKConfiguration ) ;
177+
178+ RefreshData = new RefreshData ( SDKConfiguration ) ;
179+
180+ Webhooks = new Webhooks ( SDKConfiguration ) ;
181+
182+ Integrations = new Integrations ( SDKConfiguration ) ;
183+
184+ ReadData = new ReadData ( SDKConfiguration ) ;
185+
186+ PushData = new PushData ( SDKConfiguration ) ;
187+
188+ SupplementalData = new SupplementalData ( SDKConfiguration ) ;
189+
190+ CustomDataType = new CustomDataType ( SDKConfiguration ) ;
191+ }
192+
194193 public CodatPlatform ( string ? authHeader = null , Func < string > ? authHeaderSource = null , int ? serverIndex = null , string ? serverUrl = null , Dictionary < string , string > ? urlParams = null , ISpeakeasyHttpClient ? client = null , RetryConfig ? retryConfig = null )
195194 {
196195 if ( serverIndex != null )
@@ -199,7 +198,6 @@ public CodatPlatform(string? authHeader = null, Func<string>? authHeaderSource =
199198 {
200199 throw new Exception ( $ "Invalid server index { serverIndex . Value } ") ;
201200 }
202- _serverIndex = serverIndex . Value ;
203201 }
204202
205203 if ( serverUrl != null )
@@ -208,10 +206,8 @@ public CodatPlatform(string? authHeader = null, Func<string>? authHeaderSource =
208206 {
209207 serverUrl = Utilities . TemplateUrl ( serverUrl , urlParams ) ;
210208 }
211- _serverUrl = serverUrl ;
212209 }
213-
214- _client = client ?? new SpeakeasyHttpClient ( ) ;
210+ Func < Codat . Platform . Models . Components . Security > ? _securitySource = null ;
215211
216212 if ( authHeaderSource != null )
217213 {
@@ -226,44 +222,114 @@ public CodatPlatform(string? authHeader = null, Func<string>? authHeaderSource =
226222 throw new Exception ( "authHeader and authHeaderSource cannot both be null" ) ;
227223 }
228224
229- SDKConfiguration = new SDKConfig ( )
225+ SDKConfiguration = new SDKConfig ( client )
230226 {
231- ServerIndex = _serverIndex ,
232- ServerUrl = _serverUrl ,
227+ ServerIndex = serverIndex == null ? 0 : serverIndex . Value ,
228+ ServerUrl = serverUrl == null ? "" : serverUrl ,
229+ SecuritySource = _securitySource ,
233230 RetryConfig = retryConfig
234231 } ;
235232
236- _client = SDKConfiguration . InitHooks ( _client ) ;
233+ InitHooks ( ) ;
237234
235+ Companies = new Companies ( SDKConfiguration ) ;
238236
239- Companies = new Companies ( _client , _securitySource , _serverUrl , SDKConfiguration ) ;
237+ Connections = new Connections ( SDKConfiguration ) ;
240238
239+ ConnectionManagement = new ConnectionManagement ( SDKConfiguration ) ;
241240
242- Connections = new Connections ( _client , _securitySource , _serverUrl , SDKConfiguration ) ;
241+ Cors = new Cors ( SDKConfiguration ) ;
243242
243+ Settings = new Settings ( SDKConfiguration ) ;
244244
245- ConnectionManagement = new ConnectionManagement ( _client , _securitySource , _serverUrl , SDKConfiguration ) ;
245+ RefreshData = new RefreshData ( SDKConfiguration ) ;
246246
247+ Webhooks = new Webhooks ( SDKConfiguration ) ;
247248
248- RefreshData = new RefreshData ( _client , _securitySource , _serverUrl , SDKConfiguration ) ;
249+ Integrations = new Integrations ( SDKConfiguration ) ;
249250
251+ ReadData = new ReadData ( SDKConfiguration ) ;
250252
251- Webhooks = new Webhooks ( _client , _securitySource , _serverUrl , SDKConfiguration ) ;
253+ PushData = new PushData ( SDKConfiguration ) ;
252254
255+ SupplementalData = new SupplementalData ( SDKConfiguration ) ;
253256
254- Integrations = new Integrations ( _client , _securitySource , _serverUrl , SDKConfiguration ) ;
257+ CustomDataType = new CustomDataType ( SDKConfiguration ) ;
258+ }
255259
260+ private void InitHooks ( )
261+ {
262+ string preHooksUrl = SDKConfiguration . GetTemplatedServerUrl ( ) ;
263+ var ( postHooksUrl , postHooksClient ) = SDKConfiguration . Hooks . SDKInit ( preHooksUrl , SDKConfiguration . Client ) ;
264+ var config = SDKConfiguration ;
265+ if ( preHooksUrl != postHooksUrl )
266+ {
267+ config . ServerUrl = postHooksUrl ;
268+ }
269+ config . Client = postHooksClient ;
270+ SDKConfiguration = config ;
271+ }
256272
257- Settings = new Settings ( _client , _securitySource , _serverUrl , SDKConfiguration ) ;
273+ public class SDKBuilder
274+ {
275+ private SDKConfig _sdkConfig = new SDKConfig ( client : new SpeakeasyHttpClient ( ) ) ;
258276
277+ public SDKBuilder ( ) { }
259278
260- PushData = new PushData ( _client , _securitySource , _serverUrl , SDKConfiguration ) ;
279+ public SDKBuilder WithServerIndex ( int serverIndex )
280+ {
281+ if ( serverIndex < 0 || serverIndex >= SDKConfig . ServerList . Length )
282+ {
283+ throw new Exception ( $ "Invalid server index { serverIndex } ") ;
284+ }
285+ _sdkConfig . ServerIndex = serverIndex ;
286+ return this ;
287+ }
261288
289+ public SDKBuilder WithServerUrl ( string serverUrl , Dictionary < string , string > ? serverVariables = null )
290+ {
291+ if ( serverVariables != null )
292+ {
293+ serverUrl = Utilities . TemplateUrl ( serverUrl , serverVariables ) ;
294+ }
295+ _sdkConfig . ServerUrl = serverUrl ;
296+ return this ;
297+ }
298+
299+ public SDKBuilder WithAuthHeaderSource ( Func < string > authHeaderSource )
300+ {
301+ _sdkConfig . SecuritySource = ( ) => new Codat . Platform . Models . Components . Security ( ) { AuthHeader = authHeaderSource ( ) } ;
302+ return this ;
303+ }
304+
305+ public SDKBuilder WithAuthHeader ( string authHeader )
306+ {
307+ _sdkConfig . SecuritySource = ( ) => new Codat . Platform . Models . Components . Security ( ) { AuthHeader = authHeader } ;
308+ return this ;
309+ }
262310
263- SupplementalData = new SupplementalData ( _client , _securitySource , _serverUrl , SDKConfiguration ) ;
311+ public SDKBuilder WithClient ( ISpeakeasyHttpClient client )
312+ {
313+ _sdkConfig . Client = client ;
314+ return this ;
315+ }
264316
317+ public SDKBuilder WithRetryConfig ( RetryConfig retryConfig )
318+ {
319+ _sdkConfig . RetryConfig = retryConfig ;
320+ return this ;
321+ }
322+
323+ public CodatPlatform Build ( )
324+ {
325+ if ( _sdkConfig . SecuritySource == null ) {
326+ throw new Exception ( "securitySource cannot be null. One of `AuthHeader` or `authHeaderSource` needs to be defined." ) ;
327+ }
328+ return new CodatPlatform ( _sdkConfig ) ;
329+ }
265330
266- CustomDataType = new CustomDataType ( _client , _securitySource , _serverUrl , SDKConfiguration ) ;
267331 }
332+
333+ public static SDKBuilder Builder ( ) => new SDKBuilder ( ) ;
268334 }
269335}
0 commit comments