public static async Task <JsonSku> GetSkuInfo(string skuQueried) { try { Properties.Settings.Default.Reload(); string serverIP = Properties.Settings.Default.ServerIp; int serverPort = Properties.Settings.Default.ServerPort; string urlServer = "http://" + serverIP + ":" + serverPort; var client = new RestClient(urlServer); client.Authenticator = new HttpBasicAuthenticator(privateApiLogin, privateApiMdp); var request = new RestRequest("sku", Method.GET); client.Timeout = timeout; client.ReadWriteTimeout = timeout; request.Timeout = timeout; request.ReadWriteTimeout = timeout; request.AddParameter("refNumber", skuQueried); var response = await client.ExecuteTaskAsync(request); if (response.IsSuccessful) { var skuInfo = JsonSku.DeserializedJsonAlone(response.Content); if (skuInfo != null) { return(skuInfo); } return(null); } else { return(null); } } catch (Exception error) { ExceptionMessageBox exp = new ExceptionMessageBox(error, "Error in Get sku"); exp.ShowDialog(); return(null); } }
public static string SerializedJsonAlone(JsonSku jsl) { JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); return(jsSerializer.Serialize(jsl)); }