private async Task <TResult> GetApiDataProperty <TResult>(ApiCommands commandType, string propertyName, string [] ignoreProperties = null, params KeyValuePair <string, string>[] queryParameters) { var jobj = await GetApiData(commandType, null, queryParameters); if (jobj[propertyName] == null) { return(default(TResult)); } var jtoken = jobj[propertyName]; if (ignoreProperties != null) { foreach (var property in ignoreProperties) { var prop = jtoken.Children <JProperty>().FirstOrDefault(x => x.Name == property); if (prop != null) { prop.Remove(); } } } return(DeserializeJson <TResult>(jtoken)); }
private static async Task <int> ApiModifyCommands(ApiModify modifyOpts) { AccountCommands acctCommands = new AccountCommands(); var account = acctCommands.GetActiveAccount(); ApiCommands apiCommands = new ApiCommands(account); if (modifyOpts.DeleteFiles.Count() > 0) { if (await apiCommands.Delete(modifyOpts.DeleteFiles)) { return(0); } return(1); } else if (!string.IsNullOrWhiteSpace(modifyOpts.UploadFile)) { if (await apiCommands.Upload(modifyOpts.UploadFile)) { return(0); } return(1); } return(1); }
/// <summary> /// convert binary array from socket into command /// </summary> /// <param name="buf">got array</param> public void SetFromBytes(byte[] buf) { if (buf.Length < 6) { return; } cmd = (ApiCommands)BitConverter.ToInt16(buf, 0); sz = BitConverter.ToUInt32(buf, 2); }
private Uri GetApiUri(ApiCommands commandType, params KeyValuePair <string, string>[] queryParameters) { var builder = new UriBuilder(string.Format("{0}{1}", urlBase, GetEnumDescription(commandType))); var query = HttpUtility.ParseQueryString(builder.Query); query["token"] = token; foreach (var param in queryParameters) { query[param.Key] = param.Value; } builder.Query = query.ToString(); return(builder.Uri); }
private uint send_size(ApiCommands cmd) { switch (cmd) { case ApiCommands.apiGetInfo: return(raConstants.szKeyType); case ApiCommands.apiGetBlocks: return(10); case ApiCommands.apiGetBalance: return(16); case ApiCommands.apiGetBlockSize: return(raConstants.szHashType); case ApiCommands.apiGetTransactions: return(64 + sizeof(UInt64) + sizeof(UInt16)); case ApiCommands.apiGetTransaction: return(64 + 64); case ApiCommands.apiCommitTransaction: return(64 + 32 + 32 + sizeof(UInt32) + sizeof(UInt64) + 16 + 0x20); case ApiCommands.apiGetTransactionsByKey: return(64 + sizeof(UInt64) + sizeof(UInt16)); case ApiCommands.apiGetBinaryData: return(66); case ApiCommands.apiGetBinaryPart: return(64 + sizeof(ushort) + (sizeof(uint) * 2)); case ApiCommands.apiGetPrevHash: return(raConstants.szHashType); default: return(0); } }
private static async Task <int> ApiGetCommands(ApiGet apiOption) { AccountCommands acctCommands = new AccountCommands(); var account = acctCommands.GetActiveAccount(); ApiCommands apiCommands = new ApiCommands(account); if (apiOption.ListAllFiles) { await apiCommands.ListAllFiles(apiOption.ReturnJson); return(0); } else if (!string.IsNullOrWhiteSpace(apiOption.ListFilesFromDirectory)) { await apiCommands.ListAllFiles(apiOption.ReturnJson, apiOption.ListFilesFromDirectory); return(0); } else if (apiOption.GetPersonalMetadata) { await apiCommands.GetSiteData(apiOption.ReturnJson); return(0); } else if (!string.IsNullOrWhiteSpace(apiOption.GetSiteMetadata)) { await apiCommands.GetSiteData(apiOption.ReturnJson, apiOption.GetSiteMetadata); return(0); } else if (apiOption.GetApiKey) { await apiCommands.GetSiteKey(apiOption.ReturnJson); return(0); } return(1); }
public ApiRepository(string accessToken, int resultsPerPage) { _commands = new ApiCommands(accessToken, resultsPerPage); }
/// <summary> /// constructor with code of command (sets lenght of data by cmd) /// </summary> /// <param name="ncmd">command's code</param> public ApiCmd(ApiCommands ncmd) { cmd = ncmd; sz = send_size(ncmd); }
/// <summary> /// constructor "empty" команды /// </summary> public ApiCmd() { cmd = ApiCommands.apiInvalid; sz = 0; }
public FoccoErpApiCommands(Settings settings) { _apiCommands = new ApiCommands(settings); }
private async Task <TResult> GetApiData <TResult>(ApiCommands commandType, string[] ignoreProperties = null, params KeyValuePair <string, string>[] queryParameters) { return(await GetApiData <TResult>(GetApiUri(commandType, queryParameters), ignoreProperties)); }
private async Task <JObject> GetApiData(ApiCommands commandType, string[] ignoreProperties = null, params KeyValuePair <string, string>[] queryParameters) { return(await GetApiData <JObject>(commandType, ignoreProperties, queryParameters)); }