/// <summary>
        /// Creates an agreement. Sends it out for signatures, and returns the agreementID in the response to the client
        /// </summary>
        /// <param name="info"></param>
        public virtual Task <AgreementCreationResponse> CreateAsync(AgreementCreationInfo info)
        {
            var request = new RestRequest(Method.POST);

            request.JsonSerializer = new Serialization.NewtonSoftSerializer();
            request.Resource       = "agreements";
            request.AddJsonBody(info);
            return(this.Sdk.ExecuteAsync <AgreementCreationResponse>(request));
        }
        /// <summary>
        ///     Creates an agreement. Sends it out for signatures, and returns the agreementID in the response to the client.
        /// </summary>
        /// <param name="accessToken">
        ///     An &lt;a href&#x3D;\&quot;#\&quot; onclick&#x3D;\&quot;this.href&#x3D;oauthDoc()\&quot;
        ///     oncontextmenu&#x3D;\&quot;this.href&#x3D;oauthDoc()\&quot; target&#x3D;\&quot;oauthDoc\&quot;&gt;OAuth Access Token
        ///     &lt;/a&gt; with scopes:&lt;ul&gt;&lt;li style&#x3D;&#39;list-style-type: square&#39;&gt;&lt;a href&#x3D;\&quot;#\
        ///     &quot; onclick&#x3D;\&quot;this.href&#x3D;oauthDoc(&#39;agreement_send&#39;)\&quot; oncontextmenu&#x3D;\&quot;
        ///     this.href&#x3D;oauthDoc(&#39;agreement_send&#39;)\&quot; target&#x3D;\&quot;oauthDoc\&quot;&gt;agreement_send&lt;/a
        ///     &gt; - If both authoringRequested and sendThroughWeb parameter are set to false&lt;/li&gt;&lt;li style&#x3D;&#39;
        ///     list-style-type: square&#39;&gt;&lt;a href&#x3D;\&quot;#\&quot; onclick&#x3D;\&quot;this.href&#x3D;oauthDoc(&#39;
        ///     agreement_write&#39;)\&quot; oncontextmenu&#x3D;\&quot;this.href&#x3D;oauthDoc(&#39;agreement_write&#39;)\&quot;
        ///     target&#x3D;\&quot;oauthDoc\&quot;&gt;agreement_write&lt;/a&gt; - If any of the authoringRequested or
        ///     sendThroughWeb parameter is set to true&lt;/li&gt;&lt;li style&#x3D;&#39;list-style-type: square&#39;&gt;&lt;a href
        ///     &#x3D;\&quot;#\&quot; onclick&#x3D;\&quot;this.href&#x3D;oauthDoc(&#39;user_login&#39;)\&quot; oncontextmenu&#x3D;\
        ///     &quot;this.href&#x3D;oauthDoc(&#39;user_login&#39;)\&quot; target&#x3D;\&quot;oauthDoc\&quot;&gt;user_login&lt;/a
        ///     &gt; - Required additionally if the autoLoginUser parameter is set to true&lt;/li&gt;&lt;/ul&gt;(Legacy clients can
        ///     use the access token obtained from /auth/tokens endpoint.)
        /// </param>
        /// <param name="agreementCreationInfo">
        ///     Information about the agreement that you want to send and authoring options that
        ///     you want to apply at the time of sending.
        /// </param>
        /// <param name="xUserId">The ID of the user on whose behalf agreement is being created.</param>
        /// <param name="xUserEmail">
        ///     The email address of the user on whose behalf agreement is being created. If both X-User-Id
        ///     and X-User-Email are provided then X-User-Id is given preference. If neither is specified then the user is inferred
        ///     from the access token.
        /// </param>
        /// <returns>AgreementCreationResponse</returns>
        public AgreementCreationResponse CreateAgreement(string accessToken, AgreementCreationInfo agreementCreationInfo, string xUserId, string xUserEmail)
        {
            // verify the required parameter 'accessToken' is set
            if (accessToken == null)
            {
                throw new ApiException(400, "Missing required parameter 'accessToken' when calling CreateAgreement");
            }

            // verify the required parameter 'agreementCreationInfo' is set
            if (agreementCreationInfo == null)
            {
                throw new ApiException(400, "Missing required parameter 'agreementCreationInfo' when calling CreateAgreement");
            }


            string path = "/agreements";

            path = path.Replace("{format}", "json");

            Dictionary <string, string>        queryParams  = new Dictionary <string, string>();
            Dictionary <string, string>        headerParams = new Dictionary <string, string>();
            Dictionary <string, string>        formParams   = new Dictionary <string, string>();
            Dictionary <string, FileParameter> fileParams   = new Dictionary <string, FileParameter>();
            string postBody = null;

            if (accessToken != null)
            {
                headerParams.Add("Access-Token", ApiClient.ParameterToString(accessToken));                      // header parameter
            }
            if (xUserId != null)
            {
                headerParams.Add("x-user-id", ApiClient.ParameterToString(xUserId));                  // header parameter
            }
            if (xUserEmail != null)
            {
                headerParams.Add("x-user-email", ApiClient.ParameterToString(xUserEmail)); // header parameter
            }
            postBody = ApiClient.Serialize(agreementCreationInfo);                         // http body (model) parameter

            // authentication setting, if any
            string[] authSettings = { };

            // make the HTTP request
            IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if ((int)response.StatusCode >= 400)
            {
                throw new ApiException((int)response.StatusCode, "Error calling CreateAgreement: " + response.Content, response.Content);
            }
            if ((int)response.StatusCode == 0)
            {
                throw new ApiException((int)response.StatusCode, "Error calling CreateAgreement: " + response.ErrorMessage, response.ErrorMessage);
            }

            return((AgreementCreationResponse)ApiClient.Deserialize(response.Content, typeof(AgreementCreationResponse), response.Headers));
        }