Made progress on implementing some shops.
Performed some folder restructuring as well.
This commit is contained in:
		| @@ -0,0 +1,29 @@ | ||||
| using System.Collections; | ||||
| using System.Collections.Generic; | ||||
| using Newtonsoft.Json.Linq; | ||||
| using Props.Shop.Framework; | ||||
|  | ||||
| namespace Props.Shop.Ebay.Api.ItemSummary | ||||
| { | ||||
|     public class SearchResultParser | ||||
|     { | ||||
|         private dynamic data; | ||||
|         public int BeginIndex => data.offset; | ||||
|         public int EndIndex => BeginIndex + data.limit; | ||||
|         public IEnumerable<ProductListing> ProductListings { get; private set; } | ||||
|  | ||||
|         public SearchResultParser(string result) | ||||
|         { | ||||
|             data = JObject.Parse(result); | ||||
|  | ||||
|             List<ProductListing> parsed = new List<ProductListing>(); | ||||
|             foreach (dynamic itemSummary in data.itemSummaries) | ||||
|             { | ||||
|                 ProductListing listing = new ProductListing(); | ||||
|                 // TODO: Finish parsing the data. | ||||
|                 parsed.Add(listing); | ||||
|             } | ||||
|             ProductListings = parsed; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,57 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Text; | ||||
|  | ||||
| namespace Props.Shop.Ebay.Api.ItemSummary | ||||
| { | ||||
|     public class SearchUriBuilder | ||||
|     { | ||||
|         UriBuilder uriBuilder = new UriBuilder("/search"); | ||||
|         private HashSet<string> queries = new HashSet<string>(); | ||||
|         private bool autoCorrect = false; | ||||
|         private int? maxResults = 100; | ||||
|         private int? offset = 0; | ||||
|         public bool AutoCorrect | ||||
|         { | ||||
|             set | ||||
|             { | ||||
|                 autoCorrect = value; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public int? MaxResults | ||||
|         { | ||||
|             set | ||||
|             { | ||||
|                 maxResults = value; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public int? Offset | ||||
|         { | ||||
|             set | ||||
|             { | ||||
|                 offset = value; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public void AddSearchQuery(string query) | ||||
|         { | ||||
|             queries.Add(query); | ||||
|         } | ||||
|  | ||||
|         public Uri Build() | ||||
|         { | ||||
|             StringBuilder queryBuilder = new StringBuilder("q="); | ||||
|             queryBuilder.Append('('); | ||||
|             queryBuilder.AppendJoin(", ", queries); | ||||
|             queryBuilder.Append(')'); | ||||
|             uriBuilder.Query += queryBuilder.ToString(); | ||||
|  | ||||
|             if (autoCorrect) uriBuilder.Query += "&auto_correct=KEYWORD"; | ||||
|             if (maxResults.HasValue) uriBuilder.Query += "&limit=" + maxResults.Value; | ||||
|             if (offset.HasValue) uriBuilder.Query += "&offset=" + offset.Value; | ||||
|             return uriBuilder.Uri; | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user