public virtual ActionResult SubmitInvoice(InvoiceModel model) { var Submit = RESTHelper.Post <ResultModel <ResponseModel> >(ConfigurationManager.AppSettings["HostAPIURL"] + ConfigurationManager.AppSettings["AddInvoice"], model); var response = "Success Insert Invoice"; if (Submit.StatusCode != (int)HttpStatusCode.OK) { response = Submit.StatusMessage; } TempData["StatusMessage"] = response; return(RedirectToAction(MVC.Home.Index())); }
IEnumerator UploadFile(string filePath, string name) { UploadHandler uploadHandler = new UploadHandlerFile(filePath); //Debug.Log(FirebaseConfig.storageEndpoint + GetAuthParam()); RequestHelper req = new RequestHelper { Uri = FirebaseConfig.storageEndpoint, Params = new Dictionary <string, string> { { "uploadType", "media" }, { "name", string.IsNullOrEmpty(path)?name:$"{path}/{name}" } }, ContentType = "application/octet-stream", UploadHandler = uploadHandler }; // Authenticate request if any user signed in if (FirebaseAuthentication.currentUser != null) { req.Headers.Add("Authorization", "Bearer " + FirebaseAuthentication.currentUser.accessToken); } RESTHelper.Post(req, res => { UploadResponse uploadResponse = JsonUtility.FromJson <UploadResponse>(res); uploadResponse.downloadUrl = $"{FirebaseConfig.storageEndpoint}/{uploadResponse.name.Replace("/","%2F")}?alt=media&token={uploadResponse.downloadTokens}"; callbackHandler.successCallback?.Invoke(uploadResponse); }, err => { callbackHandler.exceptionCallback?.Invoke(err); }); float lastProgress = 0f; //Progress Callback if (uploadProgressCallback != null) { while (uploadHandler.progress != 1) { uploadProgressCallback.Invoke(uploadHandler.progress); yield return(new WaitUntil(() => uploadHandler.progress >= 0.95f? uploadHandler.progress == 1f : //If reached 95% or avobe, we will wait for 100% uploadHandler.progress >= lastProgress + 0.05f)); //Else, we will wait for reaching next 5% } uploadProgressCallback.Invoke(1f); uploadHandler.Dispose(); } }
private void SynchronizeData(DistractionEventPlainData plainData) { firebaseHelper.AddEventThing(new DistractionEventData() { EventType = DistractionEventType.StartSession, Time = plainData.Time, UserId = plainData.UserId, }); bool sent = RESTHelper.Post(_configuration.ServerUrl + "PositiveThingsData", plainData, _configuration.ServerUser, _configuration.ServerPassword); if (sent) { plainData.Synchronized = true; PositiveThingsDatabase.SaveDistractionEventPlainData(plainData); } }
/// <summary> /// 1.3 Search for new lights /// URL: http://<bridgeipaddress>/api/<username>/lights /// Method: POST /// Version: 1.0 /// Permission: Whitelist /// </summary> /// <param name="url"></param> /// <returns></returns> public static async Task <bool> SearchForNewLights(string url, string body = "") { url = url + "/lights"; Debug.WriteLine("<Philips Hue - APIs - Lights> SearchForNewLights - Url to be used: " + url); Debug.WriteLine("<Philips Hue - APIs - Lights> SearchForNewLights - Body to be used: " + body); bool success = false; if (body == null) { body = ""; } string response = await RESTHelper.Post(url, body); Debug.WriteLine("<Philips Hue - APIs - Lights> SearchForNewLights - Response recieved: : " + response); success = ErrorHelper.CheckForError(response, success); Debug.WriteLine("<Philips Hue - APIs - Lights> SearchForNewLights - Sucess: " + success.ToString()); return(success); }
/// <summary> /// Documentation /// https://www.developers.meethue.com/documentation/configuration-api /// </summary> /// <summary> /// 7.1 Create user /// URL: http://<bridgeipaddress>/api /// Method: POST /// Version: 1.0 /// Permission: All /// </summary> /// <param name="url"></param> /// <param name="deviceName"></param> /// <returns></returns> public static async Task <string> CreateUser(string url, string deviceName) { ///{ "devicetype": "Leaf_Home_Control#iphone peter"} var body = $"{{\"devicetype\": \"Leaf_Home_Control#{deviceName}\"}}"; string response = await RESTHelper.Post(url, body); if (response.Contains("success")) { string user = response; } else if (response.Contains("101")) { response = "link button not pressed"; } else { response = "failure"; } return(response); }