1- using System ;
2- using System . Collections . Generic ;
3- using System . Text ;
4- using System . Configuration ;
5- using SendSafely . Exceptions ;
6- using System . Net ;
7- using SendSafely . Objects ;
8-
9- namespace SendSafely . Utilities
10- {
11- internal class StartupUtility
12- {
13- private Connection connection ;
14-
15- public StartupUtility ( String host , String privateKey , String apiKey )
16- {
17- this . connection = new Connection ( host , privateKey , apiKey ) ;
18- }
19-
20- public StartupUtility ( Connection connection )
21- {
22- this . connection = connection ;
23- }
24-
25- public StartupUtility ( String host , String privateKey , String apiKey , WebProxy proxy )
26- {
27- if ( privateKey == null || privateKey . Length == 0 )
28- {
29- throw new InvalidCredentialsException ( "The private key can't be null or empty" ) ;
30- }
31- else if ( apiKey == null || apiKey . Length == 0 )
32- {
33- throw new InvalidCredentialsException ( "The API key can't be null or empty" ) ;
34- }
35-
36- this . connection = new Connection ( host , privateKey , apiKey , proxy ) ;
37- }
38-
39- public Objects . Version VerifyVersion ( )
40- {
41- Endpoint p = ConnectionStrings . Endpoints [ "version" ] . Clone ( ) ;
42- String version = "0.3" ;
43- p . Path = p . Path . Replace ( "{version}" , version ) ;
44-
45- VersionResponse response = connection . Send < VersionResponse > ( p ) ;
46- return response . Version ;
47- }
48-
49- public String VerifyCredentials ( )
50- {
51- Endpoint p = ConnectionStrings . Endpoints [ "verifyCredentials" ] . Clone ( ) ;
52-
53- StandardResponse response = connection . Send < StandardResponse > ( p ) ;
54-
55- if ( response . Response != APIResponse . SUCCESS )
56- {
57- throw new InvalidCredentialsException ( "Failed to verify the credentials." ) ;
58- }
59-
60- return response . Message ;
1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Text ;
4+ using System . Configuration ;
5+ using SendSafely . Exceptions ;
6+ using System . Net ;
7+ using SendSafely . Objects ;
8+
9+ namespace SendSafely . Utilities
10+ {
11+ internal class StartupUtility
12+ {
13+ private Connection connection ;
14+
15+ public StartupUtility ( String host , String privateKey , String apiKey )
16+ {
17+ this . connection = new Connection ( host , privateKey , apiKey ) ;
18+ }
19+
20+ public StartupUtility ( Connection connection )
21+ {
22+ this . connection = connection ;
23+ }
24+
25+ public StartupUtility ( String host , String privateKey , String apiKey , WebProxy proxy )
26+ {
27+ if ( privateKey == null || privateKey . Length == 0 )
28+ {
29+ throw new InvalidCredentialsException ( "The private key can't be null or empty" ) ;
30+ }
31+ else if ( apiKey == null || apiKey . Length == 0 )
32+ {
33+ throw new InvalidCredentialsException ( "The API key can't be null or empty" ) ;
34+ }
35+
36+ this . connection = new Connection ( host , privateKey , apiKey , proxy ) ;
37+ }
38+
39+ public Objects . Version VerifyVersion ( )
40+ {
41+ Endpoint p = ConnectionStrings . Endpoints [ "version" ] . Clone ( ) ;
42+ String version = "0.3" ;
43+ p . Path = p . Path . Replace ( "{version}" , version ) ;
44+
45+ VersionResponse response = connection . Send < VersionResponse > ( p ) ;
46+ return response . Version ;
47+ }
48+
49+ public String VerifyCredentials ( )
50+ {
51+ Endpoint p = ConnectionStrings . Endpoints [ "verifyCredentials" ] . Clone ( ) ;
52+
53+ StandardResponse response = connection . Send < StandardResponse > ( p ) ;
54+
55+ if ( response . Response != APIResponse . SUCCESS )
56+ {
57+ throw new InvalidCredentialsException ( "Failed to verify the credentials." ) ;
58+ }
59+
60+ return response . Message ;
6161 }
6262
6363 public User GetUserInformation ( )
@@ -72,24 +72,24 @@ public User GetUserInformation()
7272 }
7373
7474 return Convert ( response ) ;
75- }
76-
77- public Connection GetConnectionObject ( )
78- {
79- return this . connection ;
80- }
81-
82- private User Convert ( UserInformationResponse response )
83- {
75+ }
76+
77+ public Connection GetConnectionObject ( )
78+ {
79+ return this . connection ;
80+ }
81+
82+ private User Convert ( UserInformationResponse response )
83+ {
8484 User user = new User ( ) ;
8585 user . AllowPublicKey = response . AllowPublicKey ;
8686 user . ClientKey = response . ClientKey ;
8787 user . Email = response . Email ;
8888 user . FirstName = response . FirstName ;
8989 user . Id = response . Id ;
9090 user . LastName = response . LastName ;
91- user . PackageLife = response . PackageLife ;
92- return user ;
93- }
94- }
95- }
91+ user . PackageLife = response . PackageLife ;
92+ return user ;
93+ }
94+ }
95+ }
0 commit comments