/// <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 <a href=\"#\" onclick=\"this.href=oauthDoc()\" /// oncontextmenu=\"this.href=oauthDoc()\" target=\"oauthDoc\">OAuth Access Token /// </a> with scopes:<ul><li style='list-style-type: square'><a href=\"#\ /// " onclick=\"this.href=oauthDoc('agreement_send')\" oncontextmenu=\" /// this.href=oauthDoc('agreement_send')\" target=\"oauthDoc\">agreement_send</a /// > - If both authoringRequested and sendThroughWeb parameter are set to false</li><li style=' /// list-style-type: square'><a href=\"#\" onclick=\"this.href=oauthDoc(' /// agreement_write')\" oncontextmenu=\"this.href=oauthDoc('agreement_write')\" /// target=\"oauthDoc\">agreement_write</a> - If any of the authoringRequested or /// sendThroughWeb parameter is set to true</li><li style='list-style-type: square'><a href /// =\"#\" onclick=\"this.href=oauthDoc('user_login')\" oncontextmenu=\ /// "this.href=oauthDoc('user_login')\" target=\"oauthDoc\">user_login</a /// > - Required additionally if the autoLoginUser parameter is set to true</li></ul>(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)); }