/// <summary> /// <para>Build the SmartsheetClient instance.</para> /// </summary> /// <returns> the SmartsheetClient instance </returns> public virtual SmartsheetClient Build() { if (httpClient == null) { httpClient = new DefaultHttpClient(); } if (jsonSerializer == null) { jsonSerializer = new JsonNetSerializer(); } if (baseURI == null) { baseURI = DEFAULT_BASE_URI; } SmartsheetImpl smartsheet = new SmartsheetImpl(baseURI, accessToken, httpClient, jsonSerializer); if (assumedUser != null) { smartsheet.AssumedUser = assumedUser; } return(smartsheet); }
/// <summary> /// Create an instance with given server URI, HttpClient (optional) and JsonSerializer (optional) /// /// Exceptions: - IllegalArgumentException : if serverURI/Version/AccessToken is null/empty /// </summary> /// <param name="baseURI"> the server uri </param> /// <param name="accessToken"> the access token </param> /// <param name="httpClient"> the http client (optional) </param> /// <param name="jsonSerializer"> the Json serializer (optional) </param> public SmartsheetImpl(string baseURI, string accessToken, HttpClient httpClient, JsonSerializer jsonSerializer) { Utils.ThrowIfNull(baseURI); Utils.ThrowIfEmpty(baseURI); this.baseURI = new Uri(baseURI); this.httpClient = httpClient == null ? new DefaultHttpClient(new RestClient(), SmartsheetShouldRetry) : httpClient; this.jsonSerializer = jsonSerializer == null ? new JsonNetSerializer() : jsonSerializer; this.accessToken = accessToken; }
/// <summary> /// Creates an instance with given server URI, HttpClient (optional), and JsonSerializer (optional) /// /// Exceptions: - IllegalArgumentException : if serverURI/Version/AccessToken is null/empty /// </summary> /// <param name="baseURI"> the server uri </param> /// <param name="accessToken"> the access token </param> /// <param name="httpClient"> the HTTP client (optional) </param> /// <param name="jsonSerializer"> the JSON serializer (optional) </param> public SmartsheetImpl(string baseURI, string accessToken, HttpClient httpClient, JsonSerializer jsonSerializer) { Utils.ThrowIfNull(baseURI); Utils.ThrowIfEmpty(baseURI); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; this.baseURI = new Uri(baseURI); this.accessToken = accessToken; this.jsonSerializer = jsonSerializer == null ? new JsonNetSerializer() : jsonSerializer; this.httpClient = httpClient == null ? new DefaultHttpClient(new RestClient(), this.jsonSerializer) : httpClient; this.UserAgent = null; }
/// <summary> /// Creates an instance with given server URI, HttpClient (optional), and JsonSerializer (optional) /// /// Exceptions: - IllegalArgumentException : if serverURI/Version/AccessToken is null/empty /// </summary> /// <param name="baseURI"> the server uri </param> /// <param name="accessToken"> the access token </param> /// <param name="httpClient"> the HTTP client (optional) </param> /// <param name="jsonSerializer"> the JSON serializer (optional) </param> /// <param name="dateTimeFixOptOut"> opt out of deserializer string ==> DateTime conversion fix </param> public SmartsheetImpl(string baseURI, string accessToken, HttpClient httpClient, JsonSerializer jsonSerializer, bool dateTimeFixOptOut) { Utils.ThrowIfNull(baseURI); Utils.ThrowIfEmpty(baseURI); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; this.baseURI = new Uri(baseURI); this.accessToken = accessToken; if (jsonSerializer == null) { JsonNetSerializer jsonNetSerializer = new JsonNetSerializer(); if (dateTimeFixOptOut) { jsonNetSerializer.DateParseHandling = Newtonsoft.Json.DateParseHandling.DateTime; } jsonSerializer = jsonNetSerializer; } this.jsonSerializer = jsonSerializer; this.httpClient = httpClient == null ? new DefaultHttpClient(new RestClient(), this.jsonSerializer) : httpClient; this.UserAgent = null; }
/// <summary> /// <para>Set the HttpClient.</para> /// </summary> /// <param name="httpClient"> the http client </param> /// <returns> the SmartsheetClient builder </returns> public virtual SmartsheetBuilder SetHttpClient(HttpClient httpClient) { this.httpClient = httpClient; return this; }
/// <summary> /// <para>Build the SmartsheetClient instance.</para> /// </summary> /// <returns> the SmartsheetClient instance </returns> public virtual SmartsheetClient Build() { if (httpClient == null) { httpClient = new DefaultHttpClient(); } if (jsonSerializer == null) { jsonSerializer = new JsonNetSerializer(); } if (baseURI == null) { baseURI = DEFAULT_BASE_URI; } SmartsheetImpl smartsheet = new SmartsheetImpl(baseURI, accessToken, httpClient, jsonSerializer); if (assumedUser != null) { smartsheet.AssumedUser = assumedUser; } return smartsheet; }
/// <summary> /// Constructor. /// /// Exceptions: - /// </summary> /// <param name="clientId"> the client Id </param> /// <param name="clientSecret"> the client secret </param> /// <param name="redirectURL"> the redirect Url </param> /// <param name="authorizationURL"> the authorization Url </param> /// <param name="tokenURL"> the token Url </param> /// <param name="httpClient"> the http client </param> /// <param name="jsonSerializer"> the Json serializer </param> /// <exception cref="System.InvalidOperationException"> If any argument is null, or empty string. </exception> public OAuthFlowImpl(string clientId, string clientSecret, string redirectURL, string authorizationURL, string tokenURL, HttpClient httpClient, JsonSerializer jsonSerializer) { Util.ThrowIfNull(clientId, clientSecret, redirectURL, authorizationURL, tokenURL, httpClient, jsonSerializer); Util.ThrowIfEmpty(clientId, clientSecret, redirectURL, authorizationURL, tokenURL); this.clientId = clientId; this.clientSecret = clientSecret; this.redirectURL = redirectURL; this.authorizationURL = authorizationURL; this.tokenURL = tokenURL; this.httpClient = httpClient; this.jsonSerializer = jsonSerializer; }
/// <summary> /// <para>Set the HttpClient.</para> /// </summary> /// <param name="httpClient"> the http client </param> /// <returns> the SmartsheetClient builder </returns> public SmartsheetBuilder SetHttpClient(HttpClient httpClient) { this.httpClient = httpClient; return(this); }
/// <summary> /// Create an instance with given server URI, HttpClient (optional) and JsonSerializer (optional) /// /// Exceptions: - IllegalArgumentException : if serverURI/Version/AccessToken is null/empty /// </summary> /// <param name="baseURI"> the server uri </param> /// <param name="accessToken"> the access token </param> /// <param name="httpClient"> the http client (optional) </param> /// <param name="jsonSerializer"> the Json serializer (optional) </param> public SmartsheetImpl(string baseURI, string accessToken, HttpClient httpClient, JsonSerializer jsonSerializer) { Utils.ThrowIfNull(baseURI); Utils.ThrowIfEmpty(baseURI); this.baseURI = new Uri(baseURI); this.httpClient = httpClient == null ? new DefaultHttpClient() : httpClient; this.jsonSerializer = jsonSerializer == null ? new JsonNetSerializer() : jsonSerializer; this.accessToken = accessToken; }
/// <summary> /// Creates an instance with given server URI, HttpClient (optional), and JsonSerializer (optional) /// /// Exceptions: - IllegalArgumentException : if serverURI/Version/AccessToken is null/empty /// </summary> /// <param name="baseURI"> the server uri </param> /// <param name="accessToken"> the access token </param> /// <param name="httpClient"> the HTTP client (optional) </param> /// <param name="jsonSerializer"> the JSON serializer (optional) </param> public SmartsheetImpl(string baseURI, string accessToken, HttpClient httpClient, JsonSerializer jsonSerializer) : this(baseURI, accessToken, httpClient, jsonSerializer, false) { }