private static BuyOrder ReadMyBuyOrder(dynamic order) { string buyOrderId = order.buy_order_id ?? null; string marketHashName = order.market_hash_name ?? null; double? price = order.price ?? null; double? suggestedPrice = order.suggested_price ?? null; string state = order.state ?? null; DateTime?createdAt = null; if (order.created_at != null) { createdAt = DateTimeExtension.FromUnixTime((long)order.created_at); } DateTime?updatedAt = null; if (order.updated_at != null) { updatedAt = DateTimeExtension.FromUnixTime((long)order.updated_at); } int?placeInQueue = order.place_in_queue ?? null; BuyOrder myBuyOrder = new BuyOrder(buyOrderId, marketHashName, price, suggestedPrice, state, createdAt, updatedAt, placeInQueue); return(myBuyOrder); }
private static CreatedBitcoinDeposit ReadCreatedBitcoinDeposit(string result) { dynamic responseServerD = JsonConvert.DeserializeObject(result); dynamic orderD = responseServerD.data.order; CreatedBitcoinDeposit createdBitcoinDeposit = null; if (orderD != null) { string id = orderD.id ?? null; double? amountInUsd = orderD.amount_in_usd ?? null; string bitcoinAddress = orderD.bitcoin_address ?? null; double? bitcoinAmount = orderD.bitcoin_amount ?? null; string bitcoinUri = orderD.bitcoin_uri ?? null; double? currentPricePerBitcoinInUsd = orderD.current_price_per_bitcoin_in_usd ?? null; DateTime?createdAt = null; if (orderD.created_at != null) { createdAt = DateTimeExtension.FromUnixTime((long)orderD.created_at); } DateTime?expiresAt = null; if (orderD.expires_at != null) { expiresAt = DateTimeExtension.FromUnixTime((long)orderD.expires_at); } string note = orderD.note ?? null; string provider = orderD.provider ?? null; createdBitcoinDeposit = new CreatedBitcoinDeposit(id, amountInUsd, bitcoinAddress, bitcoinAmount, bitcoinUri, currentPricePerBitcoinInUsd, createdAt, expiresAt, note, provider); } return(createdBitcoinDeposit); }
internal static ItemOnSale ReadItemOnSale(dynamic item) { string itemId = item.item_id ?? null; string marketHashName = item.market_hash_name ?? null; string itemType = item.item_type ?? null; string image = item.image ?? null; double? price = item.price ?? null; double? suggestedPrice = item.suggested_price ?? null; double? floatValue = item.float_value ?? null; bool? isMine = item.is_mine ?? null; DateTime?updatedAt = null; if (item.updated_at != null) { updatedAt = DateTimeExtension.FromUnixTime((long)item.updated_at); } DateTime?withdrawableAt = null; if (item.withdrawable_at != null) { withdrawableAt = DateTimeExtension.FromUnixTime((long)item.withdrawable_at); } ItemOnSale itemOnSale = new ItemOnSale(itemId, marketHashName, itemType, image, price, suggestedPrice, floatValue, isMine, updatedAt, withdrawableAt); return(itemOnSale); }
private static SentItem ReadSentItem(dynamic item) { Market.AppId.AppName?appId = null; if (item.app_id != null) { appId = (Market.AppId.AppName)(int) item.app_id; } string itemId = item.item_id ?? null; string marketHashName = item.market_hash_name ?? null; string image = item.image ?? null; double? price = item.price ?? null; double? suggestedPrice = item.suggested_price ?? null; DateTime?withdrawableAt = null; if (item.withdrawable_at != null) { withdrawableAt = DateTimeExtension.FromUnixTime((long)item.withdrawable_at); } DateTime?deliveredAt = null; if (item.delivered_at != null) { deliveredAt = DateTimeExtension.FromUnixTime((long)item.delivered_at); } SentItem sentItem = new SentItem(appId, itemId, marketHashName, image, price, suggestedPrice, withdrawableAt, deliveredAt); return(sentItem); }
private static RecentTradeOffer ReadRecentTradeOffer(dynamic offer) { string steamTradeOfferId = offer.steam_trade_offer_id ?? null; TradeOfferStatusType?steamTradeOfferStatus = null; if (offer.steam_trade_offer_state != null) { steamTradeOfferStatus = (TradeOfferStatusType)(int)offer.steam_trade_offer_state; } string senderUid = offer.sender_uid ?? null; string recipientUid = offer.recipient_uid ?? null; int? numItemsSent = offer.num_items_sent ?? null; int? numItemsRetrieved = offer.num_items_retrieved ?? null; string tradeMessage = offer.trade_message ?? null; TradeTokenAndTradeIdFromString(tradeMessage, out string bitSkinsTradeToken, out string bitSkinsTradeId); DateTime?createdAt = null; if (offer.created_at != null) { createdAt = DateTimeExtension.FromUnixTime((long)offer.created_at); } DateTime?updatedAt = null; if (offer.updated_at != null) { updatedAt = DateTimeExtension.FromUnixTime((long)offer.updated_at); } RecentTradeOffer recentTradeOffer = new RecentTradeOffer(steamTradeOfferId, steamTradeOfferStatus, senderUid, recipientUid, numItemsSent, numItemsRetrieved, bitSkinsTradeToken, bitSkinsTradeId, tradeMessage, createdAt, updatedAt); return(recentTradeOffer); }
private static ItemHistoryRecord ReadItemHistoryRecord(dynamic item) { AppId.AppName?appId = null; if (item.app_id != null) { appId = (AppId.AppName)(int) item.app_id; } string itemId = item.item_id ?? null; string marketHashName = item.market_hash_name ?? null; double? price = item.price ?? null; DateTime?lastUpdateAt = null; if (item.last_update_at != null) { lastUpdateAt = DateTimeExtension.FromUnixTime((long)item.last_update_at); } DateTime?listedAt = null; if (item.listed_at != null) { listedAt = DateTimeExtension.FromUnixTime((long)item.listed_at); } DateTime?withdrawnAt = null; if (item.withdrawn_at != null) { withdrawnAt = DateTimeExtension.FromUnixTime((long)item.withdrawn_at); } bool?listedByMe = item.listed_by_me ?? null; bool?onHold = item.on_hold ?? null; bool?onSale = item.on_sale ?? null; ItemHistoryRecordType recordType = (item.bought_at != null) ? ItemHistoryRecordType.BoughtAt : ItemHistoryRecordType.SoldAt; DateTime?recordTime; if (recordType == ItemHistoryRecordType.BoughtAt) { recordTime = DateTimeExtension.FromUnixTime((long)item.bought_at); } else { if (item.sold_at != null) { recordTime = DateTimeExtension.FromUnixTime((long)item.sold_at); } else { recordTime = null; } } ItemHistoryRecord itemHistoryRecord = new ItemHistoryRecord(appId, itemId, marketHashName, price, recordType, lastUpdateAt, listedAt, withdrawnAt, listedByMe, onHold, onSale, recordTime); return(itemHistoryRecord); }
private static DateTime?ReadUpdatedAt(dynamic updatedAtD) { DateTime?updatedAt = null; if (updatedAtD != null) { updatedAt = DateTimeExtension.FromUnixTime((long)updatedAtD); } return(updatedAt); }
private static DelistedItem ReadDelistedItem(dynamic item) { string itemId = item.item_id; DateTime?withdrawableAt = null; if (item.withdrawable_at != null) { withdrawableAt = DateTimeExtension.FromUnixTime((long)item.withdrawable_at); } DelistedItem delistedItem = new DelistedItem(itemId, withdrawableAt); return(delistedItem); }
private static ItemRecentSale ReadItemRecentSale(dynamic item) { double? price = item.price ?? null; double? wearValue = item.wear_value ?? null; DateTime?soldAt = null; if (item.sold_at != null) { soldAt = DateTimeExtension.FromUnixTime((long)item.sold_at); } ItemRecentSale recentSaleItem = new ItemRecentSale(price, wearValue, soldAt); return(recentSaleItem); }
private static ItemRawPrice ReadItemRawPrice(dynamic item) { DateTime?time = null; if (item.time != null) { time = DateTimeExtension.FromUnixTime((long)item.time); } double?price = item.price ?? null; int? volume = item.volume ?? null; ItemRawPrice itemRawPrice = new ItemRawPrice(time, price, volume); return(itemRawPrice); }
private static MoneyEvent ReadMoneyEvent(dynamic moneyEventD) { MoneyEventType?type = null; if (moneyEventD.type != null) { type = StringToMoneyEventType((string)moneyEventD.type); if (type == MoneyEventType.Unknown) { return(null); } } DateTime?time = null; if (moneyEventD.time != null) { time = DateTimeExtension.FromUnixTime((long)moneyEventD.time); } double?amount = null; string description = ""; if (type == MoneyEventType.ItemBought || type == MoneyEventType.ItemSold) { amount = moneyEventD.price ?? null; if (moneyEventD.medium.app_id != null && moneyEventD.medium.market_hash_name != null) { description = $"{moneyEventD.medium.app_id}:{moneyEventD.medium.market_hash_name}"; } } else if (type == MoneyEventType.SaleFee || type == MoneyEventType.BuyCredit || type == MoneyEventType.StoreCredit) { amount = moneyEventD.amount ?? null; if (moneyEventD.medium != null) { description = $"{moneyEventD.medium}"; } } else { throw new InvalidOperationException(); } MoneyEvent moneyEvent = new MoneyEvent(type, amount, description, time); return(moneyEvent); }
private static BoughtItem ReadBoughtItem(dynamic item) { string itemId = item.item_id ?? null; string marketHashName = item.market_hash_name ?? null; double? price = item.price ?? null; DateTime?withdrawableAt = null; if (item.withdrawable_at != null) { withdrawableAt = DateTimeExtension.FromUnixTime((long)item.withdrawable_at); } BoughtItem boughtItem = new BoughtItem(itemId, marketHashName, price, withdrawableAt); return(boughtItem); }
private static RelistedItem ReadRelistedItem(dynamic item) { string itemId = item.item_id ?? null; bool? instantSale = item.instant_sale ?? null; double? price = item.price ?? null; DateTime?withdrawableAt = null; if (item.withdrawable_at != null) { withdrawableAt = DateTimeExtension.FromUnixTime((long)item.withdrawable_at); } RelistedItem relistedItem = new RelistedItem(itemId, instantSale, price, withdrawableAt); return(relistedItem); }
private static BitSkinsInventoryItem ReadBitskinsInventoryItem(dynamic item) { ReadInventoryItem(item, out string marketHashName, out double?suggestedPrice, out string itemType, out string image); int? numberOfItems = item.number_of_items ?? null; double?recentAveragePrice = (item.recent_sales_info == null) ? null : item.recent_sales_info.average_price; List <string> itemIds = new List <string>(); foreach (dynamic itemId in item.item_ids) { itemIds.Add((string)itemId); } List <double> prices = new List <double>(); foreach (dynamic price in item.prices) { prices.Add((double)price); } List <DateTime> createdAt = new List <DateTime>(); foreach (dynamic date in item.created_at) { createdAt.Add(DateTimeExtension.FromUnixTime((long)date)); } List <DateTime> updatedAt = new List <DateTime>(); foreach (dynamic date in item.updated_at) { updatedAt.Add(DateTimeExtension.FromUnixTime((long)date)); } List <DateTime> withdrawableAt = new List <DateTime>(); foreach (dynamic date in item.withdrawable_at) { withdrawableAt.Add(DateTimeExtension.FromUnixTime((long)date)); } BitSkinsInventoryItem bitSkinsInventoryItem = new BitSkinsInventoryItem(marketHashName, suggestedPrice, itemType, image, numberOfItems, itemIds, prices, createdAt, updatedAt, withdrawableAt, recentAveragePrice); return(bitSkinsInventoryItem); }
private static PendingWithdrawalFromBitskinsInventoryItem ReadPendingWithdrawalFromBitskinsInventoryItem(dynamic item) { ReadInventoryItem(item, out string marketHashName, out double?suggestedPrice, out string itemType, out string image); string itemId = item.item_id ?? null; DateTime?withdrawableAt = null; if (item.withdrawable_at != null) { withdrawableAt = DateTimeExtension.FromUnixTime((long)item.withdrawable_at); } double?lastPrice = item.last_price ?? null; PendingWithdrawalFromBitskinsInventoryItem pendingWithdrawalFromBitskinsInventoryItem = new PendingWithdrawalFromBitskinsInventoryItem( marketHashName, suggestedPrice, itemType, image, itemId, withdrawableAt, lastPrice); return(pendingWithdrawalFromBitskinsInventoryItem); }
static BlockHeader UnforgeBlockHeader(ForgedReader reader) { return(new BlockHeader { Level = reader.ReadInt32(), Proto = reader.ReadInt32(1), Predecessor = reader.ReadBase58(Lengths.B.Decoded, Prefix.B), Timestamp = DateTimeExtension.FromUnixTime(reader.ReadInt64()), ValidationPass = reader.ReadInt32(1), OperationsHash = reader.ReadBase58(Lengths.LLo.Decoded, Prefix.LLo), Fitness = reader.ReadEnumerable(r => r.ReadHexString()).ToList(), Context = reader.ReadBase58(Lengths.Co.Decoded, Prefix.Co), Priority = reader.ReadInt32(2), ProofOfWorkNonce = Hex.Convert(reader.ReadBytes(8)), SeedNonceHash = UnforgeSeedNonce(reader), Signature = reader.ReadBase58(Lengths.sig.Decoded, Prefix.sig), }); }
private static ItemPrice ReadItemPrice(dynamic item) { string marketHashName = item.market_hash_name ?? null; double? price = item.price ?? null; string pricingMode = item.pricing_mode ?? null; DateTime?createdAt = null; if (item.created_at != null) { createdAt = DateTimeExtension.FromUnixTime((long)item.created_at); } string iconUrl = item.icon_url ?? null; double?instantSalePrice = item.instant_sale_price ?? null; ItemPrice databaseItem = new ItemPrice(marketHashName, price, pricingMode, createdAt, iconUrl, instantSalePrice); return(databaseItem); }
private static WithdrawnItem ReadWithdrawnItem(dynamic item) { Market.AppId.AppName?appId = null; if (item.app_id != null) { appId = (Market.AppId.AppName)(int) item.app_id; } string itemId = item.item_id ?? null; DateTime?withdrawableAt = null; if (item.withdrawable_at != null) { withdrawableAt = DateTimeExtension.FromUnixTime((long)item.withdrawable_at); } WithdrawnItem withdrawnItem = new WithdrawnItem(appId, itemId, withdrawableAt); return(withdrawnItem); }
private static ModifiedItem ReadModifiedItem(dynamic item) { string itemId = item.item_id ?? null; string marketHashName = item.market_hash_name ?? null; string image = item.image ?? null; double? price = item.price ?? null; double? oldPrice = item.old_price ?? null; double? discount = item.discount ?? null; DateTime?withdrawableAt = null; if (item.withdrawable_at != null) { withdrawableAt = DateTimeExtension.FromUnixTime((long)item.withdrawable_at); } ModifiedItem modifiedItem = new ModifiedItem(itemId, marketHashName, image, price, oldPrice, discount, withdrawableAt); return(modifiedItem); }
private static MarketBuyOrder ReadMarketBuyOrder(dynamic order) { string buyOrderId = order.buy_order_id ?? null; string marketHashName = order.market_hash_name ?? null; double? price = order.price ?? null; double? suggestedPrice = order.suggested_price ?? null; bool? isMine = order.is_mine ?? null; DateTime?createdAt = null; if (order.created_at != null) { createdAt = DateTimeExtension.FromUnixTime((long)order.created_at); } int?placeInQueue = order.place_in_queue ?? null; MarketBuyOrder marketBuyOrder = new MarketBuyOrder(buyOrderId, marketHashName, price, suggestedPrice, isMine, createdAt, placeInQueue); return(marketBuyOrder); }
private static TradeDetails ReadTradeDetails(string result) { dynamic responseServerD = JsonConvert.DeserializeObject(result); dynamic createdAtD = responseServerD.data.created_at; dynamic itemsSentD = responseServerD.data.items_sent; dynamic itemsRetrievedD = responseServerD.data.items_retrieved; DateTime?createdAt = null; if (createdAtD != null) { createdAt = DateTimeExtension.FromUnixTime((long)createdAtD); } List <SentItem> sentItems = ReadSentItems(itemsSentD); List <RetrievedItem> retrievedItems = ReadRetrievedItems(itemsRetrievedD); TradeDetails tradeDetails = new TradeDetails(sentItems, retrievedItems, createdAt); return(tradeDetails); }
private static MarketItem ReadMarketItem(dynamic item) { string marketHashName = item.market_hash_name ?? null; int? totalItems = item.total_items ?? null; double? lowestPrice = item.lowest_price ?? null; double? highestPrice = item.highest_price ?? null; double? cumulativePrice = item.cumulative_price ?? null; double? recentAveragePrice = (item.recent_sales_info == null) ? null : item.recent_sales_info.average_price; DateTime?updatedAt = null; if (item.updated_at != null) { updatedAt = DateTimeExtension.FromUnixTime((long)item.updated_at); } MarketItem marketItem = new MarketItem(marketHashName, totalItems, lowestPrice, highestPrice, cumulativePrice, recentAveragePrice, updatedAt); return(marketItem); }
private static SellHistoryRecord ReadSellHistoryRecord(dynamic item) { AppId.AppName?appId = null; if (item.app_id != null) { appId = (AppId.AppName)(int) item.app_id; } string itemId = item.item_id; string marketHashName = item.market_hash_name; double? salePrice = item.sale_price ?? null; DateTime?time = null; if (item.time != null) { time = DateTimeExtension.FromUnixTime((long)item.time); } SellHistoryRecord sellHistoryRecord = new SellHistoryRecord(appId, itemId, marketHashName, salePrice, time); return(sellHistoryRecord); }
private static BuyHistoryRecord ReadBuyHistoryRecord(dynamic item) { AppId.AppName?appId = null; if (item.app_id != null) { appId = (AppId.AppName)(int) item.app_id; } string itemId = item.item_id ?? null; string marketHashName = item.market_hash_name ?? null; double? buyPrice = item.buy_price ?? null; bool? withdrawn = item.withdrawn ?? null; DateTime?time = null; if (item.time != null) { time = DateTimeExtension.FromUnixTime((long)item.time); } BuyHistoryRecord historyBuyRecord = new BuyHistoryRecord(appId, itemId, marketHashName, buyPrice, withdrawn, time); return(historyBuyRecord); }
private static BitcoinDepositRate ReadBitcoinDepositRate(string result) { dynamic responseServerD = JsonConvert.DeserializeObject(result); dynamic dataD = responseServerD.data; BitcoinDepositRate bitcoinDepositRate = null; if (dataD != null) { double? pricePerBitcoinInUsd = dataD.price_per_bitcoin_in_usd ?? null; DateTime?expiresAt = null; if (dataD.expires_at != null) { expiresAt = DateTimeExtension.FromUnixTime((long)dataD.expires_at); } int?expiresIn = dataD.expires_in ?? null; bitcoinDepositRate = new BitcoinDepositRate(pricePerBitcoinInUsd, expiresAt, expiresIn); } return(bitcoinDepositRate); }
public void FromUnixTimeTest() { DateTime dt = DateTimeExtension.FromUnixTime((long)1420070400000); }