-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
840109f
commit 077bb8a
Showing
7 changed files
with
201 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
using CSGencodes.Core.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Web; | ||
|
||
namespace CSGencodes.Core.Services | ||
{ | ||
public class MarketplaceService | ||
{ | ||
/// <summary> | ||
/// Generates a Steam Community Market URL which searchs for all skins with the selected stickers. | ||
/// </summary> | ||
/// <returns></returns> | ||
public string GetSteamMarketUrl(List<AppliedSticker> appliedStickers) | ||
{ | ||
if (appliedStickers.Count == 0) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
StringBuilder sb = new(); | ||
sb.Append("https://steamcommunity.com/market/search?q="); | ||
|
||
string query = HttpUtility.UrlEncode($"\"{string.Join(",", appliedStickers.Select(x => x.name))}\""); | ||
|
||
sb.Append(query); | ||
sb.Append("&descriptions=1&category_730_ItemSet%5B%5D=any&category_730_Weapon%5B%5D=any&category_730_Quality%5B%5D=#p1_price_asc"); | ||
|
||
string url = sb.ToString(); | ||
|
||
return url; | ||
} | ||
public string GetSkinbidUrl(List<AppliedSticker> appliedStickers) | ||
{ | ||
if (appliedStickers.Count == 0) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
StringBuilder sb = new(); | ||
sb.Append("https://skinbid.com/listings?Stickers=false,"); | ||
|
||
string query = $"{string.Join(",", appliedStickers.Select(x => x.gen_id))}"; | ||
|
||
sb.Append(query); | ||
|
||
string url = sb.ToString(); | ||
|
||
return url; | ||
} | ||
public string? GetBuff163Url(List<AppliedSticker> appliedStickers) | ||
{ | ||
// Example: https://buff.163.com/market/csgo#tab=selling&page_num=1&extra_tag_ids=16226,16226,16226,16226 | ||
List<int> searchIds = []; | ||
if (appliedStickers.Count != 0) | ||
{ | ||
foreach (var sticker in appliedStickers) | ||
{ | ||
if (sticker.BuffStickerId is not null) | ||
{ | ||
searchIds.Add((int)sticker.BuffStickerId); | ||
} | ||
} | ||
} | ||
|
||
if (searchIds.Count == 0) | ||
{ | ||
return null; | ||
} | ||
|
||
return $"https://buff.163.com/market/csgo#tab=selling&page_num=1&extra_tag_ids={String.Join(",", searchIds)}"; | ||
} | ||
public string GetSkinportUrl(List<AppliedSticker> appliedStickers) | ||
{ | ||
if (appliedStickers.Count == 0) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
StringBuilder sb = new(); | ||
sb.Append("https://skinport.com/market?sticker="); | ||
|
||
string query = $"{string.Join("%2C", appliedStickers.Select(x => x.name.Replace(" ", "+")))}"; | ||
|
||
sb.Append(query); | ||
|
||
sb.Append("&r=erdbeerchen02"); | ||
|
||
|
||
string url = sb.ToString(); | ||
|
||
return url; | ||
} | ||
|
||
|
||
public string GetCsfloatDatabaseUrl(Weapon? selectedWeapon, List<AppliedSticker> appliedStickers) | ||
{ | ||
// Example: https://csfloat.com/db?defIndex=7&paintIndex=282&min=0.1&max=0.7&stickers=%5B%7B%22i%22:%225015%22%7D,%7B%22i%22:%225015%22%7D,%7B%22i%22:%225015%22%7D,%7B%22i%22:%225015%22%7D%5D | ||
StringBuilder sb = new(); | ||
sb.Append("https://csfloat.com/db?"); | ||
|
||
List<string> parameters = new(); | ||
|
||
if (selectedWeapon is not null) | ||
{ | ||
parameters.Add($"defIndex={selectedWeapon.weapon_id}"); | ||
parameters.Add($"paintIndex={selectedWeapon.gen_id}"); | ||
} | ||
|
||
if (appliedStickers.Count != 0) | ||
{ | ||
// Example: [{"i":"5015"},{"i":"5015"},{"i":"5015"},{"i":"5015"}] | ||
var stickers = appliedStickers.Take(4); | ||
List<string> sticker_values = new(); | ||
foreach (var sticker in stickers) | ||
{ | ||
sticker_values.Add($"{{\"i\":\"{sticker.gen_id}\"}}"); | ||
} | ||
|
||
|
||
parameters.Add($"stickers=[{string.Join(",", sticker_values)}]"); | ||
} | ||
|
||
|
||
if (parameters.Count == 0) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
sb.Append(string.Join("&", parameters)); | ||
|
||
return sb.ToString(); | ||
} | ||
|
||
public string GetCsfloatUrl(List<AppliedSticker> appliedStickers) | ||
{ | ||
StringBuilder sb = new(); | ||
sb.Append("https://csfloat.com/search?"); | ||
|
||
List<string> parameters = new(); | ||
|
||
if (appliedStickers.Count != 0) | ||
{ | ||
// Example: [{"i":"5015"},{"i":"5015"},{"i":"5015"},{"i":"5015"}] | ||
var stickers = appliedStickers.Take(4); | ||
List<string> sticker_values = new(); | ||
foreach (var sticker in stickers) | ||
{ | ||
sticker_values.Add($"{{\"i\":\"{sticker.gen_id}\"}}"); | ||
} | ||
|
||
|
||
parameters.Add($"stickers=[{string.Join(",", sticker_values)}]"); | ||
} | ||
|
||
|
||
if (parameters.Count == 0) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
sb.Append(string.Join("&", parameters)); | ||
|
||
return sb.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters