File tree Expand file tree Collapse file tree 3 files changed +25
-23
lines changed Expand file tree Collapse file tree 3 files changed +25
-23
lines changed Original file line number Diff line number Diff line change 25
25
26
26
using System;
27
27
using System.Collections.Generic;
28
- using System.Collections.ObjectModel;
29
28
using System.Linq;
30
29
using RestSharp;
31
30
using Aspose.Pdf.Cloud.Sdk.Client;
@@ -20821,6 +20820,7 @@ public PdfApi(string jwtToken)
20821
20820
Configuration = new Configuration("", "");
20822
20821
ApiClient = new ApiClient(Configuration);
20823
20822
ApiClient.AccessToken = jwtToken;
20823
+ ApiClient.Validate();
20824
20824
ExceptionFactory = Aspose.Pdf.Cloud.Sdk.Client.Configuration.DefaultExceptionFactory;
20825
20825
}
20826
20826
@@ -20843,12 +20843,10 @@ public PdfApi(string apiKey, string appSid)
20843
20843
public PdfApi(Configuration configuration)
20844
20844
{
20845
20845
if (configuration == null)
20846
- {
20847
20846
throw new ArgumentNullException("configuration");
20848
- }
20849
-
20850
20847
Configuration = configuration;
20851
20848
ApiClient = new ApiClient(Configuration);
20849
+ ApiClient.Validate();
20852
20850
ExceptionFactory = Aspose.Pdf.Cloud.Sdk.Client.Configuration.DefaultExceptionFactory;
20853
20851
}
20854
20852
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ namespace Aspose.Pdf.Cloud.Sdk.Client
42
42
/// <summary>
43
43
/// API client is mainly responsible for making the HTTP call to the API backend.
44
44
/// </summary>
45
- public partial class ApiClient
45
+ public class ApiClient
46
46
{
47
47
private const int MAX_AUTH_TRIES_COUNT = 5 ;
48
48
private int authTriesCount = 0 ;
@@ -164,12 +164,29 @@ private async System.Threading.Tasks.Task<bool> InterceptResponseAsync(IRestRequ
164
164
/// </summary>
165
165
public ApiClient ( Configuration config )
166
166
{
167
- Configuration = config ;
168
-
167
+ Configuration = config ;
169
168
RestClient = new RestClient ( config . BasePath ) ;
170
169
}
171
170
172
-
171
+ private static bool CheckSidKey ( string appSid , string apiKey )
172
+ {
173
+ if ( appSid == apiKey )
174
+ return true ;
175
+ string [ ] ssSid = appSid . Split ( '-' ) ;
176
+ string [ ] ssKey = apiKey . Split ( '-' ) ;
177
+ return ssSid . Length == 5 && ssKey . Length == 1 ;
178
+ }
179
+
180
+ internal void Validate ( )
181
+ {
182
+ if ( string . IsNullOrWhiteSpace ( Configuration . BasePath ) )
183
+ throw new ArgumentException ( "empty BasePath" ) ;
184
+ if ( ! string . IsNullOrWhiteSpace ( _accessToken ) )
185
+ return ;
186
+ if ( ! CheckSidKey ( Configuration . AppSid , Configuration . ApiKey ) )
187
+ throw new ArgumentException ( "AppSid/ApiKey are messed up or have wrong format" ) ;
188
+ }
189
+
173
190
/// <summary>
174
191
/// Gets or sets the Configuration.
175
192
/// </summary>
Original file line number Diff line number Diff line change 24
24
// --------------------------------------------------------------------------------------------------------------------
25
25
26
26
using System ;
27
- using System . Reflection ;
28
27
using System . Collections . Generic ;
29
28
using System . IO ;
30
29
using System . Linq ;
31
- using System . Text ;
30
+ using System . Reflection ;
32
31
33
32
namespace Aspose . Pdf . Cloud . Sdk . Client
34
33
{
@@ -57,12 +56,7 @@ public Configuration(string apiKey,
57
56
int timeout = 5 * 60 * 1000 ,
58
57
string userAgent = "aspose pdf cloud sdk"
59
58
)
60
- {
61
- if ( string . IsNullOrEmpty ( basePath ) )
62
- throw new ArgumentException ( "basePath cannot be empty" ) ;
63
- if ( ! _CheckSidKey ( appSid , apiKey ) )
64
- throw new ArgumentException ( "appSid and apiKey are messed up or have wrong format" ) ;
65
-
59
+ {
66
60
ApiKey = apiKey ;
67
61
AppSid = appSid ;
68
62
BasePath = basePath ;
@@ -74,13 +68,6 @@ public Configuration(string apiKey,
74
68
Timeout = timeout ;
75
69
}
76
70
77
- private static bool _CheckSidKey ( string appSid , string apiKey )
78
- {
79
- var ssSid = appSid . Split ( '-' ) ;
80
- var ssKey = apiKey . Split ( '-' ) ;
81
- return ssSid . Length == 5 && ssKey . Length == 1 ;
82
- }
83
-
84
71
/// <summary>
85
72
/// Default creation of exceptions for a given method name and response object
86
73
/// </summary>
You can’t perform that action at this time.
0 commit comments