Exemplo n.º 1
0
        private void SendFile(string fileContent, Action <LitJsonStomt.JsonData> callbackSuccess, Action <HttpWebResponse> callbackError, Action callbackOffline)
        {
            // Convert to Base64
            var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(fileContent);
            var file           = System.Convert.ToBase64String(plainTextBytes);

            // Build Body
            var jsonFileUpload = new StringBuilder();
            var writerImage    = new LitJsonStomt.JsonWriter(jsonFileUpload);

            writerImage.WriteObjectStart();
            writerImage.WritePropertyName("files");
            writerImage.WriteObjectStart();
            writerImage.WritePropertyName("stomt");
            writerImage.WriteArrayStart();
            writerImage.WriteObjectStart();
            writerImage.WritePropertyName("data");
            writerImage.Write(file);
            writerImage.WritePropertyName("filename");
            writerImage.Write("UnityLogs");
            writerImage.WriteObjectEnd();
            writerImage.WriteArrayEnd();
            writerImage.WriteObjectEnd();
            writerImage.WriteObjectEnd();

            // Send Request
            var url = string.Format("{0}/files", restServerURL);

            GetPOSTResponse(url, jsonFileUpload.ToString(), callbackSuccess, callbackError, callbackOffline);
        }
        public override string ToString()
        {
            var jsonSubscription = new StringBuilder();
            var writer           = new LitJsonStomt.JsonWriter(jsonSubscription);

            writer.WriteObjectStart();

            if (!string.IsNullOrEmpty(this.email))
            {
                writer.WritePropertyName("email");
                writer.Write(this.email);
            }

            if (!string.IsNullOrEmpty(this.phone))
            {
                writer.WritePropertyName("phone");
                writer.Write(this.phone);
            }

            writer.WritePropertyName("message");
            writer.Write(this.message);

            writer.WriteObjectEnd();

            return(jsonSubscription.ToString());
        }
Exemplo n.º 3
0
        private void SendImage(string image, Action <LitJsonStomt.JsonData> callbackSuccess, Action <HttpWebResponse> callbackError, Action callbackOffline)
        {
            // Build Body
            var jsonImage   = new StringBuilder();
            var writerImage = new LitJsonStomt.JsonWriter(jsonImage);

            writerImage.WriteObjectStart();
            writerImage.WritePropertyName("images");
            writerImage.WriteObjectStart();
            writerImage.WritePropertyName("stomt");
            writerImage.WriteArrayStart();
            writerImage.WriteObjectStart();
            writerImage.WritePropertyName("data");
            writerImage.Write(image);
            writerImage.WriteObjectEnd();
            writerImage.WriteArrayEnd();
            writerImage.WriteObjectEnd();
            writerImage.WriteObjectEnd();

            // Send Request
            var url = string.Format("{0}/images", restServerURL);

            GetPOSTResponse(url, jsonImage.ToString(), callbackSuccess, callbackError, callbackOffline);
        }
        public override string ToString()
        {
            var jsonTrack   = new StringBuilder();
            var writerTrack = new LitJsonStomt.JsonWriter(jsonTrack);

            writerTrack.WriteObjectStart();

            writerTrack.WritePropertyName("device_platform");
            writerTrack.Write(this.device_platform);

            writerTrack.WritePropertyName("device_id");
            writerTrack.Write(this.device_id);

            writerTrack.WritePropertyName("sdk_type");
            writerTrack.Write(this.sdk_type);

            writerTrack.WritePropertyName("sdk_version");
            writerTrack.Write(this.sdk_version);

            writerTrack.WritePropertyName("sdk_integration");
            writerTrack.Write(this.sdk_integration);

            writerTrack.WritePropertyName("target_id");
            writerTrack.Write(this.target_id);

            writerTrack.WritePropertyName("stomt_id");
            writerTrack.Write(this.stomt_id);

            writerTrack.WritePropertyName("event_category");
            writerTrack.Write(this.event_category);

            writerTrack.WritePropertyName("event_action");
            writerTrack.Write(this.event_action);

            if (!String.IsNullOrEmpty(this.event_label))
            {
                writerTrack.WritePropertyName("event_label");
                writerTrack.Write(this.event_label);
            }

            writerTrack.WriteObjectEnd();

            return(jsonTrack.ToString());
        }
Exemplo n.º 5
0
        public void SendLoginRequest(string userName, string password, Action <LitJsonStomt.JsonData> callbackSuccess, Action <HttpWebResponse> callbackError)
        {
            var jsonSubscription   = new StringBuilder();
            var writerSubscription = new LitJsonStomt.JsonWriter(jsonSubscription);

            writerSubscription.WriteObjectStart();

            writerSubscription.WritePropertyName("login_method");
            writerSubscription.Write("normal");

            writerSubscription.WritePropertyName("emailusername");
            writerSubscription.Write(userName);

            writerSubscription.WritePropertyName("password");
            writerSubscription.Write(password);

            writerSubscription.WriteObjectEnd();

            var url = string.Format("{0}/authentication/session", restServerURL);

            GetPOSTResponse(url, jsonSubscription.ToString(), (response) =>
            {
                StomtConfig.Subscribed = true;
                StomtConfig.LoggedIn   = true;

                var track            = this.initStomtTrack();
                track.event_category = "auth";
                track.event_action   = "login";
                track.event_label    = "normal";
                this.SendTrack(track);

                if (callbackSuccess != null)
                {
                    callbackSuccess(response);
                }
            }, callbackError);
        }
        public override string ToString()
        {
            var jsonStomt   = new StringBuilder();
            var writerStomt = new LitJsonStomt.JsonWriter(jsonStomt);

            writerStomt.WriteObjectStart();
            //writerStomt.WritePropertyName("anonym");
            //writerStomt.Write(this.anonym);
            writerStomt.WritePropertyName("positive");
            writerStomt.Write(this.positive);
            writerStomt.WritePropertyName("text");
            writerStomt.Write(this.text);
            writerStomt.WritePropertyName("lang");
            writerStomt.Write(this.lang);

            if (!string.IsNullOrEmpty(this.target_id))
            {
                writerStomt.WritePropertyName("target_id");
                writerStomt.Write(this.target_id);
            }

            // Add labels
            writerStomt.WritePropertyName("extradata");
            writerStomt.WriteObjectStart();

            writerStomt.WritePropertyName("labels");
            writerStomt.WriteArrayStart();

            if (labels.Length > 0)
            {
                foreach (string label in labels)
                {
                    if (label != "AddLabelHere" && label != "add-label-here")
                    {
                        writerStomt.Write(label);
                    }
                }
            }

            // Add default labels
            if (!DisableDefaultLabels)
            {
                writerStomt.Write(Application.platform.ToString());
                writerStomt.Write(Screen.currentResolution.ToString());
            }

            writerStomt.WriteArrayEnd();

            // Add CustomKeyValuePairs
            if (CustomKeyValuePairs.Count > 0)
            {
                foreach (List <string> PairList in CustomKeyValuePairs)
                {
                    if (PairList.Count > 1)
                    {
                        writerStomt.WritePropertyName(PairList[0]);
                        writerStomt.Write(PairList[1]);
                    }
                }
            }

            writerStomt.WriteObjectEnd();


            if (!string.IsNullOrEmpty(this.img_name))
            {
                writerStomt.WritePropertyName("img_name");
                writerStomt.Write(this.img_name);
            }

            if (!string.IsNullOrEmpty(this.file_uid))
            {
                writerStomt.WritePropertyName("files");
                writerStomt.WriteObjectStart();
                writerStomt.WritePropertyName("stomt");
                writerStomt.WriteObjectStart();
                writerStomt.WritePropertyName("file_uid");
                writerStomt.Write(this.file_uid);
                writerStomt.WriteObjectEnd();
                writerStomt.WriteObjectEnd();
            }

            writerStomt.WriteObjectEnd();
            return(jsonStomt.ToString());
        }