10
10
#nullable enable
11
11
namespace Codat . Sync . Payroll
12
12
{
13
+ using Codat . Sync . Payroll . Hooks ;
14
+ using Codat . Sync . Payroll . Models . Errors ;
13
15
using Codat . Sync . Payroll . Models . Shared ;
14
16
using Codat . Sync . Payroll . Utils ;
15
17
using Newtonsoft . Json ;
@@ -18,8 +20,6 @@ namespace Codat.Sync.Payroll
18
20
using System . Threading . Tasks ;
19
21
using System ;
20
22
21
-
22
-
23
23
/// <summary>
24
24
/// Sync for Payroll: The API for Sync for Payroll. <br/>
25
25
///
@@ -31,81 +31,97 @@ namespace Codat.Sync.Payroll
31
31
/// <br/>
32
32
/// ---<br/>
33
33
/// <br/>
34
+ /// <!-- Start Codat Tags Table --><br/>
34
35
/// ## Endpoints<br/>
35
36
/// <br/>
36
- /// | Endpoints | Description |<br/>
37
- /// |:---------------------|:-----------------------------------------------------------------------------------------------------------|<br/>
38
- /// | Companies | Create and manage your SMB users' companies. |<br/>
39
- /// | Connections | Create new and manage existing data connections for a company. |<br/>
40
- /// | Accounts | Get, create, and update Accounts. |<br/>
41
- /// | Journal entries | Get, create, and update Journal entries. |<br/>
42
- /// | Journals | Get, create, and update Journals. |<br/>
43
- /// | Tracking categories | Get, create, and update Tracking Categories for additional categorization of payroll components. |<br/>
44
- /// | Company info | View company profile from the source platform. |<br/>
45
- /// | Manage data | Control how data is retrieved from an integration. |
37
+ /// | Endpoints | Description |<br/>
38
+ /// | :- |:- |<br/>
39
+ /// | Companies | Create and manage your SMB users' companies. |<br/>
40
+ /// | Connections | Create new and manage existing data connections for a company. |<br/>
41
+ /// | Accounts | Get, create, and update Accounts. |<br/>
42
+ /// | Journal entries | Get, create, and update Journal entries. |<br/>
43
+ /// | Journals | Get, create, and update Journals. |<br/>
44
+ /// | Tracking categories | Get, create, and update Tracking Categories for additional categorization of payroll components. |<br/>
45
+ /// | Company info | View company profile from the source platform. |<br/>
46
+ /// | Manage data | Control how data is retrieved from an integration. |<br/>
47
+ /// <!-- End Codat Tags Table -->
46
48
/// </remarks>
47
49
/// </summary>
48
50
public interface ICodatSyncPayroll
49
51
{
50
52
51
53
/// <summary>
52
- /// Create and manage your Codat companies.
54
+ /// Create and manage your SMB users' companies.
53
55
/// </summary>
54
56
public ICompanies Companies { get ; }
55
57
56
58
/// <summary>
57
- /// Manage your companies' data connections.
59
+ /// Create new and manage existing data connections for a company .
58
60
/// </summary>
59
61
public IConnections Connections { get ; }
60
62
61
63
/// <summary>
62
- /// Accounts
64
+ /// Get, create, and update Accounts.
63
65
/// </summary>
64
66
public IAccounts Accounts { get ; }
65
67
66
68
/// <summary>
67
- /// Journal entries
69
+ /// Get, create, and update Journal entries.
68
70
/// </summary>
69
71
public IJournalEntries JournalEntries { get ; }
70
72
71
73
/// <summary>
72
- /// Journals
74
+ /// Get, create, and update Journals.
73
75
/// </summary>
74
76
public IJournals Journals { get ; }
75
77
76
78
/// <summary>
77
- /// Asynchronously retrieve data from an integration to refresh data in Codat .
79
+ /// Control how data is retrieved from an integration.
78
80
/// </summary>
79
81
public IManageData ManageData { get ; }
80
82
81
83
/// <summary>
82
- /// View company information fetched from the source platform.
84
+ /// View company profile from the source platform.
83
85
/// </summary>
84
86
public ICompanyInfo CompanyInfo { get ; }
85
87
86
88
/// <summary>
87
- /// Tracking categories
89
+ /// Get, create, and update Tracking Categories for additional categorization of payroll components.
88
90
/// </summary>
89
91
public ITrackingCategories TrackingCategories { get ; }
90
92
}
91
-
93
+
92
94
public class SDKConfig
93
95
{
94
- public static string [ ] ServerList = new string [ ]
95
- {
96
+ /// <summary>
97
+ /// List of server URLs available to the SDK.
98
+ /// </summary>
99
+ public static readonly string [ ] ServerList = {
96
100
"https://api.codat.io" ,
97
101
} ;
98
- /// Contains the list of servers available to the SDK
99
- public string serverUrl = "" ;
100
- public int serverIndex = 0 ;
101
102
102
- public string GetTemplatedServerDetails ( )
103
+ public string ServerUrl = "" ;
104
+ public int ServerIndex = 0 ;
105
+ public SDKHooks hooks = new SDKHooks ( ) ;
106
+
107
+ public string GetTemplatedServerUrl ( )
108
+ {
109
+ if ( ! String . IsNullOrEmpty ( this . ServerUrl ) )
110
+ {
111
+ return Utilities . TemplateUrl ( Utilities . RemoveSuffix ( this . ServerUrl , "/" ) , new Dictionary < string , string > ( ) ) ;
112
+ }
113
+ return Utilities . TemplateUrl ( SDKConfig . ServerList [ this . ServerIndex ] , new Dictionary < string , string > ( ) ) ;
114
+ }
115
+
116
+ public ISpeakeasyHttpClient InitHooks ( ISpeakeasyHttpClient client )
103
117
{
104
- if ( ! String . IsNullOrEmpty ( this . serverUrl ) )
118
+ string preHooksUrl = GetTemplatedServerUrl ( ) ;
119
+ var ( postHooksUrl , postHooksClient ) = this . hooks . SDKInit ( preHooksUrl , client ) ;
120
+ if ( preHooksUrl != postHooksUrl )
105
121
{
106
- return Utilities . TemplateUrl ( Utilities . RemoveSuffix ( this . serverUrl , "/" ) , new Dictionary < string , string > ( ) ) ;
122
+ this . ServerUrl = postHooksUrl ;
107
123
}
108
- return Utilities . TemplateUrl ( SDKConfig . ServerList [ this . serverIndex ] , new Dictionary < string , string > ( ) ) ;
124
+ return postHooksClient ;
109
125
}
110
126
}
111
127
@@ -120,29 +136,31 @@ public string GetTemplatedServerDetails()
120
136
/// <br/>
121
137
/// ---<br/>
122
138
/// <br/>
139
+ /// <!-- Start Codat Tags Table --><br/>
123
140
/// ## Endpoints<br/>
124
141
/// <br/>
125
- /// | Endpoints | Description |<br/>
126
- /// |:---------------------|:-----------------------------------------------------------------------------------------------------------|<br/>
127
- /// | Companies | Create and manage your SMB users' companies. |<br/>
128
- /// | Connections | Create new and manage existing data connections for a company. |<br/>
129
- /// | Accounts | Get, create, and update Accounts. |<br/>
130
- /// | Journal entries | Get, create, and update Journal entries. |<br/>
131
- /// | Journals | Get, create, and update Journals. |<br/>
132
- /// | Tracking categories | Get, create, and update Tracking Categories for additional categorization of payroll components. |<br/>
133
- /// | Company info | View company profile from the source platform. |<br/>
134
- /// | Manage data | Control how data is retrieved from an integration. |
142
+ /// | Endpoints | Description |<br/>
143
+ /// | :- |:- |<br/>
144
+ /// | Companies | Create and manage your SMB users' companies. |<br/>
145
+ /// | Connections | Create new and manage existing data connections for a company. |<br/>
146
+ /// | Accounts | Get, create, and update Accounts. |<br/>
147
+ /// | Journal entries | Get, create, and update Journal entries. |<br/>
148
+ /// | Journals | Get, create, and update Journals. |<br/>
149
+ /// | Tracking categories | Get, create, and update Tracking Categories for additional categorization of payroll components. |<br/>
150
+ /// | Company info | View company profile from the source platform. |<br/>
151
+ /// | Manage data | Control how data is retrieved from an integration. |<br/>
152
+ /// <!-- End Codat Tags Table -->
135
153
/// </remarks>
136
154
/// </summary>
137
155
public class CodatSyncPayroll : ICodatSyncPayroll
138
156
{
139
157
public SDKConfig SDKConfiguration { get ; private set ; }
140
158
141
159
private const string _language = "csharp" ;
142
- private const string _sdkVersion = "3.0 .0" ;
143
- private const string _sdkGenVersion = "2.257.2 " ;
160
+ private const string _sdkVersion = "3.1 .0" ;
161
+ private const string _sdkGenVersion = "2.319.7 " ;
144
162
private const string _openapiDocVersion = "3.0.0" ;
145
- private const string _userAgent = "speakeasy-sdk/csharp 3.0 .0 2.257.2 3.0.0 Codat.Sync.Payroll" ;
163
+ private const string _userAgent = "speakeasy-sdk/csharp 3.1 .0 2.319.7 3.0.0 Codat.Sync.Payroll" ;
146
164
private string _serverUrl = "" ;
147
165
private int _serverIndex = 0 ;
148
166
private ISpeakeasyHttpClient _defaultClient ;
@@ -160,6 +178,10 @@ public CodatSyncPayroll(Security? security = null, Func<Security>? securitySourc
160
178
{
161
179
if ( serverIndex != null )
162
180
{
181
+ if ( serverIndex . Value < 0 || serverIndex . Value >= SDKConfig . ServerList . Length )
182
+ {
183
+ throw new Exception ( $ "Invalid server index { serverIndex . Value } ") ;
184
+ }
163
185
_serverIndex = serverIndex . Value ;
164
186
}
165
187
@@ -182,21 +204,42 @@ public CodatSyncPayroll(Security? security = null, Func<Security>? securitySourc
182
204
{
183
205
_securitySource = ( ) => security ;
184
206
}
207
+ else
208
+ {
209
+ throw new Exception ( "security and securitySource cannot both be null" ) ;
210
+ }
185
211
186
212
SDKConfiguration = new SDKConfig ( )
187
213
{
188
- serverIndex = _serverIndex ,
189
- serverUrl = _serverUrl
214
+ ServerIndex = _serverIndex ,
215
+ ServerUrl = _serverUrl
190
216
} ;
191
217
218
+ _defaultClient = SDKConfiguration . InitHooks ( _defaultClient ) ;
219
+
220
+
192
221
Companies = new Companies ( _defaultClient , _securitySource , _serverUrl , SDKConfiguration ) ;
222
+
223
+
193
224
Connections = new Connections ( _defaultClient , _securitySource , _serverUrl , SDKConfiguration ) ;
225
+
226
+
194
227
Accounts = new Accounts ( _defaultClient , _securitySource , _serverUrl , SDKConfiguration ) ;
228
+
229
+
195
230
JournalEntries = new JournalEntries ( _defaultClient , _securitySource , _serverUrl , SDKConfiguration ) ;
231
+
232
+
196
233
Journals = new Journals ( _defaultClient , _securitySource , _serverUrl , SDKConfiguration ) ;
234
+
235
+
197
236
ManageData = new ManageData ( _defaultClient , _securitySource , _serverUrl , SDKConfiguration ) ;
237
+
238
+
198
239
CompanyInfo = new CompanyInfo ( _defaultClient , _securitySource , _serverUrl , SDKConfiguration ) ;
240
+
241
+
199
242
TrackingCategories = new TrackingCategories ( _defaultClient , _securitySource , _serverUrl , SDKConfiguration ) ;
200
243
}
201
244
}
202
- }
245
+ }
0 commit comments