public async Task <GetAssetResponse> GetAsset(string accountName) { try { var account = await Client.GetAccount(accountName); if (account == null) { return(null); } var balance = await Client.GetCurrencyBalance(ConfigDataKey.DefaultTokenCode, accountName, ConfigDataKey.DefaultTokenSymbol); var respone = new GetAssetResponse { account_name = account.account_name, CoreLiquidBalance = balance.FirstOrDefault(), head_block_num = account.head_block_num, head_block_time = account.head_block_time, privileged = account.privileged, last_code_update = account.last_code_update, created = account.created, cpu_limit = account.cpu_limit, cpu_weight = account.cpu_weight, net_limit = account.net_limit, net_weight = account.net_weight, ram_quota = account.ram_quota, ram_usage = account.ram_usage, permissions = account.permissions, refund_request = account.refund_request, self_delegated_bandwidth = account.self_delegated_bandwidth, total_resources = account.total_resources, voter_info = account.voter_info }; if (string.IsNullOrWhiteSpace(respone.CoreLiquidBalance)) { respone.CoreLiquidBalance = $"0.0000 {ConfigDataKey.DefaultTokenSymbol}"; } return(respone); } catch (Exception e) { return(null); } }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetAssetResponse response = new GetAssetResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Arn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Arn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("AssetDetails", targetDepth)) { var unmarshaller = AssetDetailsUnmarshaller.Instance; response.AssetDetails = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("AssetType", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.AssetType = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("CreatedAt", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.CreatedAt = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("DataSetId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.DataSetId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Id", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Id = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Name", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Name = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("RevisionId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.RevisionId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("SourceId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.SourceId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("UpdatedAt", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.UpdatedAt = unmarshaller.Unmarshall(context); continue; } } return(response); }