@@ -10,29 +10,103 @@ namespace Dropbox.Api
1010 using System . Net . Http ;
1111
1212 /// <summary>
13- /// The client which contains endpoints which perform user-level actions .
13+ /// The class which contains all configurations for Dropbox client .
1414 /// </summary>
15- public sealed partial class DropboxClient : IDisposable
15+ public sealed class DropboxClientConfig
1616 {
1717 /// <summary>
18- /// Initializes a new instance of the <see cref="T:Dropbox.Api.DropboxClient"/> class.
18+ /// Initializes a new instance of the <see cref="DropboxClientConfig"/> class.
19+ /// </summary>
20+ public DropboxClientConfig ( )
21+ : this ( null )
22+ {
23+ }
24+
25+ /// <summary>
26+ /// Initializes a new instance of the <see cref="DropboxClientConfig"/> class.
27+ /// </summary>
28+ /// <param name="userAgent">The user agent to use when making requests.</param>
29+ public DropboxClientConfig ( string userAgent )
30+ : this ( userAgent , 4 )
31+ {
32+ }
33+
34+ /// <summary>
35+ /// Initializes a new instance of the <see cref="DropboxClientConfig"/> class.
1936 /// </summary>
20- /// <param name="oauth2AccessToken">The oauth2 access token for making client requests.</param>
21- /// <param name="maxRetriesOnError">The maximum retries on a 5xx error.</param>
2237 /// <param name="userAgent">The user agent to use when making requests.</param>
23- /// <param name="httpClient">The custom http client. If not provided, a default
24- /// http client will be created.</param>
38+ /// <param name="maxRetriesOnError">The max number retries on error.</param>
39+ public DropboxClientConfig ( string userAgent , int maxRetriesOnError )
40+ : this ( userAgent , maxRetriesOnError , null )
41+ {
42+ }
43+
44+ /// <summary>
45+ /// Initializes a new instance of the <see cref="DropboxClientConfig"/> class.
46+ /// </summary>
47+ /// <param name="userAgent">The user agent to use when making requests.</param>
48+ /// <param name="maxRetriesOnError">The max number retries on error.</param>
49+ /// <param name="httpClient">The custom http client.</param>
50+ internal DropboxClientConfig ( string userAgent , int maxRetriesOnError , HttpClient httpClient )
51+ {
52+ this . UserAgent = userAgent ;
53+ this . MaxRetriesOnError = maxRetriesOnError ;
54+ this . HttpClient = httpClient ;
55+ }
56+
57+ /// <summary>
58+ /// Gets or sets the max number retries on error. Default value is 4.
59+ /// </summary>
60+ public int MaxRetriesOnError { get ; set ; }
61+
62+ /// <summary>
63+ /// Gets or sets the user agent to use when making requests.
64+ /// </summary>
2565 /// <remarks>
26- /// The <paramref name="userAgent"/> helps Dropbox to identify requests coming from your application.
66+ /// This value helps Dropbox to identify requests coming from your application.
2767 /// We recommend that you use the format <c>"AppName/Version"</c>; if a value is supplied, the string
2868 /// <c>"/OfficialDropboxDotNetV2SDK/__version__"</c> is appended to the user agent.
2969 /// </remarks>
30- public DropboxClient (
31- string oauth2AccessToken ,
32- int maxRetriesOnError = 4 ,
33- string userAgent = null ,
34- HttpClient httpClient = null )
35- : this ( new DropboxRequestHandlerOptions ( oauth2AccessToken , maxRetriesOnError , userAgent , httpClient : httpClient ) )
70+ public string UserAgent { get ; set ; }
71+
72+ /// <summary>
73+ /// Gets or sets the custom http client. If not set, a default http client will be created.
74+ /// </summary>
75+ public HttpClient HttpClient { get ; set ; }
76+ }
77+
78+ /// <summary>
79+ /// The client which contains endpoints which perform user-level actions.
80+ /// </summary>
81+ public sealed partial class DropboxClient : IDisposable
82+ {
83+ /// <summary>
84+ /// Initializes a new instance of the <see cref="T:Dropbox.Api.DropboxClient"/> class.
85+ /// </summary>
86+ /// <param name="oauth2AccessToken">The oauth2 access token for making client requests.</param>
87+ public DropboxClient ( string oauth2AccessToken )
88+ : this ( oauth2AccessToken , new DropboxClientConfig ( ) )
89+ {
90+ }
91+
92+ /// <summary>
93+ /// Initializes a new instance of the <see cref="T:Dropbox.Api.DropboxClient"/> class.
94+ /// </summary>
95+ /// <param name="oauth2AccessToken">The oauth2 access token for making client requests.</param>
96+ /// <param name="userAgent">The user agent to use when making requests.</param>
97+ [ Obsolete ( "This constructor is deprecated, please use DropboxClientConfig instead." ) ]
98+ public DropboxClient ( string oauth2AccessToken , string userAgent )
99+ : this ( oauth2AccessToken , new DropboxClientConfig ( userAgent ) )
100+ {
101+ }
102+
103+ /// <summary>
104+ /// Initializes a new instance of the <see cref="T:Dropbox.Api.DropboxClient"/> class.
105+ /// </summary>
106+ /// <param name="oauth2AccessToken">The oauth2 access token for making client requests.</param>
107+ /// <param name="config">The <see cref="DropboxClientConfig"/>.</param>
108+ public DropboxClient ( string oauth2AccessToken , DropboxClientConfig config )
109+ : this ( new DropboxRequestHandlerOptions ( oauth2AccessToken , config . MaxRetriesOnError , config . UserAgent , httpClient : config . HttpClient ) )
36110 {
37111 if ( oauth2AccessToken == null )
38112 {
@@ -72,28 +146,36 @@ public sealed partial class DropboxTeamClient
72146 /// <summary>
73147 /// Initializes a new instance of the <see cref="T:Dropbox.Api.DropboxTeamClient"/> class.
74148 /// </summary>
75- /// <param name="oauth2AccessToken">The team oauth2 access token for making client requests.</param>
76- /// <param name="maxRetriesOnError">The maximum retries on a 5xx error.</param>
149+ /// <param name="oauth2AccessToken">The oauth2 access token for making client requests.</param>
150+ public DropboxTeamClient ( string oauth2AccessToken )
151+ : this ( oauth2AccessToken , new DropboxClientConfig ( ) )
152+ {
153+ }
154+
155+ /// <summary>
156+ /// Initializes a new instance of the <see cref="T:Dropbox.Api.DropboxTeamClient"/> class.
157+ /// </summary>
158+ /// <param name="oauth2AccessToken">The oauth2 access token for making client requests.</param>
77159 /// <param name="userAgent">The user agent to use when making requests.</param>
78- /// <param name="httpClient">The custom http client. If not provided, a default
79- /// http client will be created.</param>
80- /// <remarks>
81- /// The <paramref name="userAgent"/> helps Dropbox to identify requests coming from your application.
82- /// We recommend that you use the format <c>"AppName/Version"</c>; if a value is supplied, the string
83- /// <c>"/OfficialDropboxDotNetV2SDK/__version__"</c> is appended to the user agent.
84- /// </remarks >
85- public DropboxTeamClient (
86- string oauth2AccessToken ,
87- int maxRetriesOnError = 4 ,
88- string userAgent = null ,
89- HttpClient httpClient = null )
160+ [ Obsolete ( "This constructor is deprecated, please use DropboxClientConfig instead." ) ]
161+ public DropboxTeamClient ( string oauth2AccessToken , string userAgent )
162+ : this ( oauth2AccessToken , new DropboxClientConfig ( userAgent ) )
163+ {
164+ }
165+
166+ /// <summary >
167+ /// Initializes a new instance of the <see cref="T:Dropbox.Api. DropboxTeamClient"/> class.
168+ /// </summary>
169+ /// <param name="oauth2AccessToken">The oauth2 access token for making client requests.</param>
170+ /// <param name="config">The <see cref="DropboxClientConfig"/>.</param>
171+ public DropboxTeamClient ( string oauth2AccessToken , DropboxClientConfig config )
90172 {
91173 if ( oauth2AccessToken == null )
92174 {
93175 throw new ArgumentNullException ( "oauth2AccessToken" ) ;
94176 }
95177
96- this . options = new DropboxRequestHandlerOptions ( oauth2AccessToken , maxRetriesOnError , userAgent , httpClient : httpClient ) ;
178+ this . options = new DropboxRequestHandlerOptions ( oauth2AccessToken , config . MaxRetriesOnError , config . UserAgent , httpClient : config . HttpClient ) ;
97179 this . InitializeRoutes ( new DropboxRequestHandler ( this . options ) ) ;
98180 }
99181
@@ -171,7 +253,8 @@ public partial class AuthException
171253 /// <param name="message">The message that describes the error.</param>
172254 /// <param name="uri">The request URI</param>
173255 [ Obsolete ( "This constructor will be removed soon." ) ]
174- public AuthException ( string message , Uri uri = null ) : base ( null , message )
256+ public AuthException ( string message , Uri uri = null )
257+ : base ( null , message )
175258 {
176259 this . StatusCode = 401 ;
177260 this . RequestUri = uri ;
0 commit comments