public static RecordInfo UpdateShipmentRecord(Object RestAPIObject, string RestAPIType, string PrivateKey, string Token, string SecureURL, long Id) { RestAPIActions restAPIClientWM = GetRestAPIClient(PrivateKey, Token, SecureURL); restAPIClientWM.Type = RestAPIType; restAPIClientWM.ID = Id; RecordInfo addInfo = restAPIClientWM.UpdateShipMentRecord(RestAPIObject); return(addInfo); }
private static List <T> GetRestAPIJSON <T>(string strRestAPIClientID, string restAPIClientType, string PrivateKey, string Token, string SecureURL, string RecordsGetLimit, long RecordsOffset, string StartDate = "", int LastInvoiceNum = 0) { RestAPIActions restAPIClientWM = GetRestAPIClient(PrivateKey, Token, SecureURL); string restAPIClientStream = string.Empty; List <T> reclist = new List <T>(); restAPIClientWM.Type = restAPIClientType; int parsedValue; if (strRestAPIClientID.Length != 0 && int.TryParse(strRestAPIClientID, out parsedValue)) { restAPIClientWM.ID = Convert.ToInt32(strRestAPIClientID); } int parsedRecordsGetLimitValue; if (RecordsGetLimit.Length != 0 && int.TryParse(RecordsGetLimit, out parsedRecordsGetLimitValue)) { restAPIClientWM.RecordsGetLimit = Convert.ToInt32(RecordsGetLimit); } restAPIClientWM.RecordsOffset = RecordsOffset; // commected by Sam as date based search is not working //if (StartDate != string.Empty) // restAPIClientWM.datestart = StartDate; if (LastInvoiceNum != 0) { restAPIClientWM.invoicenumberstart = LastInvoiceNum; } RecordInfo recInf = restAPIClientWM.GetRecords <T>(); if (recInf.Status == ActionStatus.Succeeded) { try { reclist = (List <T>)recInf.ResultSet; restAPIClientStream = Newtonsoft.Json.JsonConvert.SerializeObject(reclist); } catch (Exception ex) { } } return(reclist); }
public static string AddRecord(Object RestAPIObject, string RestAPIType, string PrivateKey, string Token, string SecureURL) { RestAPIActions restAPIClientWM = GetRestAPIClient(PrivateKey, Token, SecureURL); restAPIClientWM.Type = RestAPIType; RecordInfo addInfo = restAPIClientWM.AddRecord(RestAPIObject); string sIDPrefix = RestAPIType.Substring(0, RestAPIType.Length - 1); if (addInfo.Status == ActionStatus.Succeeded) { return(sIDPrefix + " added. " + sIDPrefix + "ID: " + addInfo.ResultSet); } else { return(sIDPrefix + " add failed. Error Code: " + addInfo.CodeNumber + ", Description: " + addInfo.Description); } }
private static string GetRestAPIJSON(string strRestAPIClientID, string restAPIClientType, string PrivateKey, string Token, string SecureURL, string RecordsGetLimit) { RestAPIActions restAPIClientWM = GetRestAPIClient(PrivateKey, Token, SecureURL); string restAPIClientStream = string.Empty; restAPIClientWM.Type = restAPIClientType; int parsedValue; if (strRestAPIClientID.Length != 0 && int.TryParse(strRestAPIClientID, out parsedValue)) { restAPIClientWM.ID = Convert.ToInt32(strRestAPIClientID); } int parsedRecordsGetLimitValue; if (RecordsGetLimit.Length != 0 && int.TryParse(RecordsGetLimit, out parsedRecordsGetLimitValue)) { restAPIClientWM.RecordsGetLimit = Convert.ToInt32(RecordsGetLimit); } RecordInfo recInf = restAPIClientWM.GetRecords(); if (recInf.Status == ActionStatus.Succeeded) { try { List <Object> reclist = (List <Object>)recInf.ResultSet; restAPIClientStream = Newtonsoft.Json.JsonConvert.SerializeObject(reclist); } catch (Exception ex) { } } return(restAPIClientStream); }
public static RestAPIActions GetRestAPIClient(string strPrivateKey, string strToken, string strSecureURL) { RestAPIActions restAPIClientWM = new RestAPIActions(); string sHost = string.Empty; string sVersion = string.Empty; string sContentType = string.Empty; //Provide the parameters for the HTTP Client sHost = "http://apirest.3dcart.com/3dCartWebAPI/v"; sVersion = "1"; sContentType = "application/json"; restAPIClientWM.HttpHost = sHost; restAPIClientWM.ServiceVersion = sVersion; restAPIClientWM.PrivateKey = strPrivateKey; restAPIClientWM.Token = strToken; restAPIClientWM.SecureURL = strSecureURL; restAPIClientWM.ContentType = sContentType; return(restAPIClientWM); }
public static string DeleteRecord(string RestAPIType, string RestAPIDeleteID, string PrivateKey, string Token, string SecureURL) { RestAPIActions restAPIClientWM = GetRestAPIClient(PrivateKey, Token, SecureURL); restAPIClientWM.Type = RestAPIType; restAPIClientWM.ID = Convert.ToInt32(RestAPIDeleteID); RecordInfo deleteInfo = restAPIClientWM.DeleteRecord(); string sIDPrefix = RestAPIType.Substring(0, RestAPIType.Length - 1); if (deleteInfo.Status == ActionStatus.Succeeded) { return(sIDPrefix + " deleted. " + sIDPrefix + "ID: " + deleteInfo.ResultSet); } else { return(sIDPrefix + " delete failed. Error Code: " + deleteInfo.CodeNumber + ", Description: " + deleteInfo.Description); } }