Ejemplo n.º 1
0
        public bool Build(string templateId, string username, string password, out IResponse returnResponse)
        {
            returnResponse = new Response();
            try
            {
                string accountId = _api.GetAccountId(username, password);

                string uri = $"{_config.ApiUrl}/v2/accounts/{accountId}/templates/{templateId}";

                JObject        returnedContent;
                HttpStatusCode status = _api.SendDocuSignRequest(HttpMethod.Get, uri, username, password, out returnedContent);
                if (status != HttpStatusCode.OK)
                {
                    string message = "Get Document Fields failed. Check TemplateID passed in querystring and retry.";
                    _logger.Error($"Build() {message}");
                    throw new SigSvcTemplateIdFailure(message);
                }

                AddTemplateTabsToResponse(returnedContent, returnResponse);
                return(true);
            }
            catch (Exception exc)
            {
                _logger.Error(exc, "Build()");
                returnResponse.InsertExceptionIntoMeta(exc);
                return(false);
            }
        }
Ejemplo n.º 2
0
        private void SendEnvelope(string emailAddress, SignatureRequest request, string username, string password, JArray returnDataArray)
        {
            string accountId = _api.GetAccountId(username, password);
            string uri       = $"{_config.ApiUrl}/v2/accounts/{accountId}/envelopes";

            if (request.Documents != null) // with attached documents
            {
                CreateEnvelopeFromTemplate(emailAddress, request, username, password, returnDataArray, uri, request.Documents);
            }
            else
            {
                CreateEnvelopeFromTemplate(emailAddress, request, username, password, returnDataArray, uri);
            }
        }
Ejemplo n.º 3
0
        public IActionResult GetAccount([FromServices] IRestApiWrapper api)
        {
            try
            {
                string username, password;
                ExtractHeaderValues(Request.Headers, out username, out password);

                string accountId = api.GetAccountId(username, password);

                Response response = new Response("accountId", accountId);
                response.Meta.Add("status", "200");
                return(ResultFormatter.Format(200, response));
            }
            catch (Exception exc)
            {
                _logger.Error(exc, "GET account");
                return(ResultFormatter.Format(500, exc));
            }
        }
Ejemplo n.º 4
0
        public bool Build(string envelopeId, string username, string password, out IResponse response)
        {
            Response returnResponse = new Response();

            string accountId = _api.GetAccountId(username, password);
            string uri       = $"{_config.ApiUrl}/v2/accounts/{accountId}/envelopes/{envelopeId}";

            JObject        result;
            HttpStatusCode status = _api.SendDocuSignRequest(HttpMethod.Get, uri, username, password, out result);

            if (status != HttpStatusCode.OK)
            {
                string message = "Get Envelope status failed. Check envelopeId and Account header information and retry.";
                _logger.Error($"Build() {message}");
                throw new SigSvcDocuSignAPICallFailure(message);
            }
            else
            {
                returnResponse.Data = new EnvelopeStatus(result["status"].Value <string>());
            }
            response = returnResponse;
            return(true);
        }