Knetik.KnetikClient.CreateRequest C# (CSharp) Method

CreateRequest() protected method

protected CreateRequest ( string path, string body = "[]", string method = "post", int timestamp = -1, string serviceBundle = null ) : KnetikRequest
path string
body string
method string
timestamp int
serviceBundle string
return KnetikRequest
        protected KnetikRequest CreateRequest(string path, string body = "[]", string method = "post", int timestamp = -1, string serviceBundle = null)
        {
            if (timestamp == -1) {
                TimeSpan t = (DateTime.UtcNow - new DateTime (1970, 1, 1));
                timestamp = (int)t.TotalSeconds;
            }

            string url = BuildUrl (path, serviceBundle);

            string signature = BuildSignature (body, timestamp);
            string envelope = BuildEnvelope (body, timestamp, signature);

            Log ("URL: " + url);
            Log ("Envelope:\n" + envelope);

            System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding();
            byte[] data = encoding.GetBytes(envelope);

            KnetikRequest req = new KnetikRequest (method, url, data);

            req.SetHeader("Content-type", "application/json");
            req.SetHeader("User-Agent", "Knetik Unity SDK");

            return req;
        }