示例#1
0
        public string Post(string path, string jsonPayload, string sessionId)
        {
            support.LogRequest("POST", path, jsonPayload);

            headerGen = new SessionIdAuthHeaderGenerator(sessionId);

            byte[] payloadBytes = null;
            if (jsonPayload != null)
            {
                payloadBytes = Converter.ToBytes(jsonPayload);
            }
            else
            {
                payloadBytes = new byte[0];
            }

            if (proxyConfiguration != null)
            {
                HttpMethods.proxyConfiguration = proxyConfiguration;
            }

            byte[] responseBytes = HttpMethods.PostHttp(headerGen, path, payloadBytes, additionalHeaders);

            String response = Converter.ToString(responseBytes);

            support.LogResponse(response);

            return(response);
        }
示例#2
0
        public string Post(string path, string jsonPayload)
        {
            support.LogRequest("POST", path, jsonPayload);

            byte[] payloadBytes = null;
            if (jsonPayload != null)
            {
                payloadBytes = Converter.ToBytes(jsonPayload);
            }
            else
            {
                payloadBytes = new byte[0];
            }

            if (proxyConfiguration != null)
            {
                HttpMethods.proxyConfiguration = proxyConfiguration;
            }

            byte[] responseBytes = HttpMethods.PostHttp(apiToken, path, payloadBytes);

            String response = Converter.ToString(responseBytes);

            support.LogResponse(response);

            return(response);
        }
示例#3
0
        public void NotifySigner(PackageId packageId, string signerEmail, string message)
        {
            string       path = template.UrlFor(UrlTemplate.NOTIFICATIONS_PATH).Replace("{packageId}", packageId.Id).Build();
            StringWriter sw   = new StringWriter();

            using (JsonWriter json = new JsonTextWriter(sw))
            {
                json.Formatting = Formatting.Indented;
                json.WriteStartObject();
                json.WritePropertyName("email");
                json.WriteValue(signerEmail);
                json.WritePropertyName("message");
                json.WriteValue(message);
                json.WriteEndObject();
            }

            try
            {
                HttpMethods.PostHttp(apiToken, path, Converter.ToBytes(sw.ToString()));
            }
            catch (Exception e)
            {
                throw new EslException("Could not send email notification to signer. Exception: " + e.Message);
            }
        }
示例#4
0
        public SessionToken CreateSenderSessionToken()
        {
            string path = template.UrlFor(UrlTemplate.SENDER_SESSION_PATH)
                          .Build();

            try {
                string response = Converter.ToString(HttpMethods.PostHttp(apiToken, path, new byte[0]));
                return(JsonConvert.DeserializeObject <SessionToken> (response));
            }
            catch (Exception e) {
                throw new EslException("Could not create a session token for sender." + " Exception: " + e.Message);
            }
        }
示例#5
0
        /// <summary>
        /// Creates a session token for a signer and returns the session token.
        /// </summary>
        /// <returns>The session token for signer.</returns>
        /// <param name="packageId">The package id.</param>
        /// <param name="signer">The signer to create a session token for.</param>
        public SessionToken CreateSignerSessionToken(PackageId packageId, string signerId)
        {
            string path = template.UrlFor(UrlTemplate.SESSION_PATH)
                          .Replace("{packageId}", packageId.Id)
                          .Replace("{signerId}", signerId)
                          .Build();

            try {
                string response = Converter.ToString(HttpMethods.PostHttp(apiToken, path, new byte[0]));
                return(JsonConvert.DeserializeObject <SessionToken> (response));
            } catch (Exception e) {
                throw new EslException("Could not create a session token for signer." + " Exception: " + e.Message);
            }
        }
示例#6
0
        /// <summary>
        /// Sends the package.
        /// </summary>
        /// <param name="packageId">The package id.</param>
        public void SendPackage(PackageId packageId)
        {
            string path = template.UrlFor(UrlTemplate.PACKAGE_ID_PATH)
                          .Replace("{packageId}", packageId.Id)
                          .Build();

            try {
                byte[] content = Converter.ToBytes("{\"status\":\"SENT\"}");

                HttpMethods.PostHttp(apiToken, path, content);
            } catch (Exception e) {
                throw new EslException("Could not send the package." + " Exception: " + e.Message);
            }
        }
示例#7
0
        /// <summary>
        /// Creates a package based on the settings of the pacakge parameter.
        /// </summary>
        /// <returns>The package id.</returns>
        /// <param name="package">The package to create.</param>
        internal PackageId CreatePackage(Silanis.ESL.API.Package package)
        {
            string path = template.UrlFor(UrlTemplate.PACKAGE_PATH)
                          .Build();

            try {
                string json    = JsonConvert.SerializeObject(package, settings);
                byte[] content = Converter.ToBytes(json);

                string response = Converter.ToString(HttpMethods.PostHttp(apiToken, path, content));

                return(JsonConvert.DeserializeObject <PackageId> (response));
            } catch (Exception e) {
                throw new EslException("Could not create a new package." + " Exception: " + e.Message);
            }
        }
示例#8
0
        public void Post(string path, string jsonPayload, string sessionId)
        {
            support.LogRequest("POST", path, jsonPayload);

            headerGen = new SessionIdAuthHeaderGenerator(sessionId);

            var payloadBytes = jsonPayload != null?Converter.ToBytes(jsonPayload) : new byte[0];

            if (proxyConfiguration != null)
            {
                HttpMethods.ProxyConfiguration = proxyConfiguration;
            }

            byte[] responseBytes = HttpMethods.PostHttp(headerGen, path, payloadBytes, SetupAuthorization(sessionId));

            var response = Converter.ToString(responseBytes);

            support.LogResponse(response);
        }
示例#9
0
        public string Post(string path, string jsonPayload)
        {
            support.LogRequest("POST", path, jsonPayload);

            var payloadBytes = jsonPayload != null?Converter.ToBytes(jsonPayload) : new byte[0];

            if (proxyConfiguration != null)
            {
                HttpMethods.ProxyConfiguration = proxyConfiguration;
            }

            var responseBytes = HttpMethods.PostHttp(apiKey, path, payloadBytes, SetupAuthorization(null));

            var response = Converter.ToString(responseBytes);

            support.LogResponse(response);

            return(response);
        }
示例#10
0
        public string Post(string path, string jsonPayload)
        {
            Support.LogMethodEntry(path, jsonPayload);
            byte[] payloadBytes = null;
            if (jsonPayload != null)
            {
                payloadBytes = Converter.ToBytes(jsonPayload);
            }
            else
            {
                payloadBytes = new byte[0];
            }
            byte[] responseBytes = HttpMethods.PostHttp(apiToken, path, payloadBytes);

            String result = Converter.ToString(responseBytes);

            Support.LogMethodExit(result);
            return(result);
        }