public void SendTrack(StomtTrack track, Action <LitJsonStomt.JsonData> callbackSuccess = null, Action <HttpWebResponse> callbackError = null) { var url = string.Format("{0}/tracks", restServerURL); GetPOSTResponse(url, track.ToString(), callbackSuccess, callbackError, () => { StomtOfflineQueue <StomtTrack> .add(track); }); }
public void SendSubscription(StomtSubscription subscription, Action <LitJsonStomt.JsonData> callbackSuccess = null, Action <HttpWebResponse> callbackError = null) { var url = string.Format("{0}/authentication/subscribe", restServerURL); GetPOSTResponse(url, subscription.ToString(), (response) => { StomtConfig.Subscribed = true; var track = this.initStomtTrack(); track.event_category = "auth"; track.event_action = "subscribed"; this.SendTrack(track); if (callbackSuccess != null) { callbackSuccess(response); } }, callbackError, () => { // save and send later StomtOfflineQueue <StomtSubscription> .add(subscription); }); }
public void SendStomt(StomtCreation stomtCreation, Action <LitJsonStomt.JsonData> callbackSuccess = null, Action <HttpWebResponse> callbackError = null) { // Upload file if pressent (and call function again) if (stomtCreation.screenshot != null) { SendImage(stomtCreation.screenshot, (response) => { var img_name = (string)response["images"]["stomt"]["name"]; stomtCreation.img_name = img_name; stomtCreation.screenshot = null; SendStomt(stomtCreation, callbackSuccess, callbackError); }, (response) => { // upload even when scrennshot upload failed stomtCreation.screenshot = null; SendStomt(stomtCreation, callbackSuccess, callbackError); }, () => { // save and send later StomtOfflineQueue <StomtCreation> .add(stomtCreation); }); return; } // Upload image if pressent (and call function again) if (stomtCreation.logs != null) { SendFile(stomtCreation.logs, (response) => { var file_uid = (string)response["files"]["stomt"]["file_uid"]; stomtCreation.file_uid = file_uid; stomtCreation.logs = null; SendStomt(stomtCreation, callbackSuccess, callbackError); }, (response) => { // upload even when logs upload failed stomtCreation.logs = null; SendStomt(stomtCreation, callbackSuccess, callbackError); }, () => { // save and send later StomtOfflineQueue <StomtCreation> .add(stomtCreation); }); return; } // Submit stomt var url = string.Format("{0}/stomts", restServerURL); // Send Stomt GetPOSTResponse(url, stomtCreation.ToString(), (response) => { string stomt_id = (string)response["id"]; var track = this.initStomtTrack(); track.event_category = "stomt"; track.event_action = "submit"; track.stomt_id = stomt_id; this.SendTrack(track); if (callbackSuccess != null) { callbackSuccess(response); } }, callbackError, () => { // save and send later StomtOfflineQueue <StomtCreation> .add(stomtCreation); }); }