/// <summary>
        /// Set the token URL.
        /// </summary>
        /// <param name="tokenURL"> the token Url </param>
        /// <returns> the OAuthFlowBuilder </returns>
        /// <exception cref="System.InvalidOperationException"> if any argument is null/empty string </exception>
        public virtual OAuthFlowBuilder SetTokenURL(string tokenURL)
        {
            Util.ThrowIfNull(tokenURL);

            this.tokenURL = tokenURL;
            return(this);
        }
        /// <summary>
        /// Set the redirect URL
        /// </summary>
        /// <param name="redirectURL"> the redirect Url </param>
        /// <returns> the OAuthFlowBuilder </returns>
        /// <exception cref="System.InvalidOperationException"> if any argument is null/empty string </exception>
        public virtual OAuthFlowBuilder SetRedirectURL(string redirectURL)
        {
            Util.ThrowIfNull(redirectURL);

            this.redirectURL = redirectURL;
            return(this);
        }
        /// <summary>
        /// Set the authorization URL.
        /// </summary>
        /// <param name="authorizationURL"> the authorization URL </param>
        /// <returns> the OAuthFlowBuilder </returns>
        /// <exception cref="System.InvalidOperationException"> if any argument is null/empty string </exception>
        public virtual OAuthFlowBuilder SetAuthorizationURL(string authorizationURL)
        {
            Util.ThrowIfNull(authorizationURL);

            this.authorizationURL = authorizationURL;
            return(this);
        }
        /// <summary>
        /// Set the client ID
        /// </summary>
        /// <param name="clientId"> the Value To set </param>
        /// <returns> the OAuthFlowBuilder </returns>
        /// <exception cref="System.InvalidOperationException"> if any argument is null/empty string </exception>
        public virtual OAuthFlowBuilder SetClientId(string clientId)
        {
            Util.ThrowIfNull(clientId);

            this.clientId = clientId;
            return(this);
        }
        /// <summary>
        /// Set the client secret.
        /// </summary>
        /// <param name="clientSecret"> the client secret </param>
        /// <returns> the OAuthFlowBuilder </returns>
        /// <exception cref="System.InvalidOperationException"> if any argument is null/empty string </exception>
        public virtual OAuthFlowBuilder SetClientSecret(string clientSecret)
        {
            Util.ThrowIfNull(clientSecret);

            this.clientSecret = clientSecret;
            return(this);
        }
        /// <summary>
        /// Set the HttpClient.
        /// </summary>
        /// <param name="httpClient"> the HttpClient </param>
        /// <returns> the OAuthFlowBuilder </returns>
        public virtual OAuthFlowBuilder SetHttpClient(HttpClient httpClient)
        {
            Util.ThrowIfNull(httpClient);

            this.httpClient = httpClient;
            return(this);
        }
        /// <summary>
        /// <para>Set the JsonSerializer.</para>
        /// </summary>
        /// <param name="jsonSerializer"> the JsonSerializer </param>
        /// <returns> the oAuthFlowBuilder </returns>
        /// <exception cref="System.InvalidOperationException"> if any argument is null/empty string </exception>
        public virtual OAuthFlowBuilder SetJsonSerializer(JsonSerializer jsonSerializer)
        {
            Util.ThrowIfNull(jsonSerializer);

            this.jsonSerializer = jsonSerializer;
            return(this);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Compose a User-Agent string that represents this version of the SDK (along with platform info)
        /// </summary>
        /// <param name="userAgent"></param>
        /// <returns> a User-Agent string </returns>
        private string GenerateUserAgent(string userAgent)
        {
            // Set User Agent
            string   thisVersion = "";
            string   title       = "";
            Assembly assembly    = Assembly.GetCallingAssembly();

            if (assembly != null)
            {
                thisVersion = assembly.GetName().Version.ToString();
                title       = assembly.GetName().Name;
            }
            if (userAgent == null)
            {
                assembly = Assembly.GetEntryAssembly();
                if (assembly != null)
                {
                    string[] strings = assembly.GetName().ToString().Split(',');
                    if (strings.Length > 0)
                    {
                        userAgent = strings[0];
                    }
                }
            }
            return(title + "/" + thisVersion + "/" + userAgent + "/" + Utils.GetOSFriendlyName());
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="smartsheet"> the Smartsheet </param>
        /// <param name="masterResourceType"> the master resource Type </param>
        public AbstractAssociatedResources(SmartsheetImpl smartsheet, string masterResourceType) : base(smartsheet)
        {
            Utils.ThrowIfNull(masterResourceType);
            Utils.ThrowIfEmpty(masterResourceType);

            this.masterResourceType = masterResourceType;
        }
Ejemplo n.º 10
0
        /// <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;
        }
Ejemplo n.º 11
0
        /// <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;
        }
Ejemplo n.º 12
0
        /// <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;
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Create a discussion.
 ///
 /// It mirrors To the following Smartsheet REST API method: POST /sheet/{Id}/Discussions POST /row/{Id}/Discussions
 ///
 /// Returns: the created discussion
 ///
 /// Exceptions:
 ///   IllegalArgumentException : if any argument is null
 ///   InvalidRequestException : if there is any problem with the REST API request
 ///   AuthorizationException : if there is any problem with the REST API authorization(access token)
 ///   ResourceNotFoundException : if the resource can not be found
 ///   ServiceUnavailableException : if the REST API service is not available (possibly due To rate limiting)
 ///   SmartsheetRestException : if there is any other REST API related error occurred during the operation
 ///   SmartsheetException : if there is any other error occurred during the operation
 /// </summary>
 /// <param name="objectId"> the ID of the object </param>
 /// <param name="discussion"> the discussion object limited To the following attributes: Title, Comment </param>
 /// <returns> the created discussion </returns>
 /// <exception cref="SmartsheetException"> the Smartsheet exception </exception>
 public virtual Discussion CreateDiscussion(long objectId, Discussion discussion)
 {
     Utils.ThrowIfNull(objectId, discussion);
     return(this.CreateResource <Discussion>(MasterResourceType + "/" + objectId + "/discussions",
                                             typeof(Discussion), discussion));
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Update a column.
        ///
        /// It mirrors To the following Smartsheet REST API method: PUT /column/{Id}
        ///
        /// Exceptions:
        ///   IllegalArgumentException : if any argument is null
        ///   InvalidRequestException : if there is any problem with the REST API request
        ///   AuthorizationException : if there is any problem with the REST API authorization(access token)
        ///   ResourceNotFoundException : if the resource can not be found
        ///   ServiceUnavailableException : if the REST API service is not available (possibly due To rate limiting)
        ///   SmartsheetRestException : if there is any other REST API related error occurred during the operation
        ///   SmartsheetException : if there is any other error occurred during the operation
        /// </summary>
        /// <param name="column"> the column To update limited To the following attributes: Index (column's new Index in the sheet),
        /// Title, SheetId, Type, Options (optional), Symbol (optional), SystemColumnType (optional),
        /// AutoNumberFormat (optional) </param>
        /// <returns> the updated sheet (note that if there is no such resource, this method will throw
        /// ResourceNotFoundException rather than returning null). </returns>
        /// <exception cref="SmartsheetException"> the Smartsheet exception </exception>
        public virtual Column UpdateColumn(Column column)
        {
            Utils.ThrowIfNull(column);

            return(this.UpdateResource("column/" + column.ID, typeof(Column), column));
        }