Skip to content

Commit

Permalink
Feed API added.
Browse files Browse the repository at this point in the history
  • Loading branch information
shafaqat-ali-cms365 committed Jul 8, 2024
1 parent 4a96fec commit 172e049
Show file tree
Hide file tree
Showing 10 changed files with 4,023 additions and 54 deletions.
112 changes: 70 additions & 42 deletions EbaySharp/Controllers/EbayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using EbaySharp.Entities.Common;
using EbaySharp.Entities.Developer.Analytics.RateLimit;
using EbaySharp.Entities.Developer.KeyManagement.SigningKey;
using EbaySharp.Entities.Sell.Feed;
using EbaySharp.Entities.Sell.Finances.Transaction;
using EbaySharp.Entities.Sell.Fulfillment.Order;
using EbaySharp.Entities.Sell.Fulfillment.Order.ShippingFulfillment;
Expand All @@ -16,8 +17,6 @@

namespace EbaySharp.Controllers
{


public class EbayController
{
private string accessToken;
Expand All @@ -26,6 +25,42 @@ public EbayController(string accessToken)
this.accessToken = accessToken;
}

#region BUY

#region BROWSE

public async Task<Item> GetItem(string itemId)
{
return await new BrowseController(accessToken).GetItem(itemId);
}

#endregion

#endregion

#region COMMERCE

#region TAXONOMY

public async Task<CategoryTreeId> GetDefaultCategoryTreeId(MarketplaceIdEnum MarketplaceId)
{
return await new TaxonomyController(accessToken).GetDefaultCategoryTreeId(MarketplaceId);
}
public async Task<CategorySuggestions> GetCategorySuggestions(string CategoryTreeId, string query)
{
return await new TaxonomyController(accessToken).GetCategorySuggestions(CategoryTreeId, query);
}
public async Task<CategoryTree> GetCategoryTree(string CategoryTreeId)
{
return await new TaxonomyController(accessToken).GetCategoryTree(CategoryTreeId);
}

#endregion

#endregion

#region DEVELOPER

#region ANALYTICS

#region RATE_LIMIT
Expand All @@ -46,11 +81,36 @@ public async Task<RateLimits> GetUserRateLimits()

#endregion

#region BROWSE
#region KEY_MANAGEMENT

public async Task<Item> GetItem(string itemId)
#region SIGNING_KEY

public async Task<SigningKeys> GetSigningKeys()
{
return await new BrowseController(accessToken).GetItem(itemId);
return await new KeyManagementController(accessToken).GetSigningKeys();
}
public async Task<SigningKey> GetSigningKey(string signingKeyId)
{
return await new KeyManagementController(accessToken).GetSigningKey(signingKeyId);
}
public async Task<SigningKey> CreateSigningKey(SigningKeyCipher signingKeyCipher = SigningKeyCipher.ED25519)
{
return await new KeyManagementController(accessToken).CreateSigningKey(signingKeyCipher);
}

#endregion

#endregion

#endregion

#region SELL

#region FEED

public async Task<ResultFile> GetResultFile(string taskId)
{
return await new FeedController(this.accessToken).GetResultFile(taskId);
}

#endregion
Expand Down Expand Up @@ -193,27 +253,6 @@ public async Task DeleteInventoryLocation(string merchantLocationKey)

#endregion

#region KEY_MANAGEMENT

#region SIGNING_KEY

public async Task<SigningKeys> GetSigningKeys()
{
return await new KeyManagementController(accessToken).GetSigningKeys();
}
public async Task<SigningKey> GetSigningKey(string signingKeyId)
{
return await new KeyManagementController(accessToken).GetSigningKey(signingKeyId);
}
public async Task<SigningKey> CreateSigningKey(SigningKeyCipher signingKeyCipher = SigningKeyCipher.ED25519)
{
return await new KeyManagementController(accessToken).CreateSigningKey(signingKeyCipher);
}

#endregion

#endregion

#region METADATA

public async Task<ReturnPolicies> GetReturnPolicies(string MarketplaceId)
Expand All @@ -222,7 +261,7 @@ public async Task<ReturnPolicies> GetReturnPolicies(string MarketplaceId)
}

#endregion

#region STORES

public async Task<StoreCategories> GetStoreCategories()
Expand All @@ -232,23 +271,10 @@ public async Task<StoreCategories> GetStoreCategories()

#endregion

#region TAXONOMY

public async Task<CategoryTreeId> GetDefaultCategoryTreeId(MarketplaceIdEnum MarketplaceId)
{
return await new TaxonomyController(accessToken).GetDefaultCategoryTreeId(MarketplaceId);
}
public async Task<CategorySuggestions> GetCategorySuggestions(string CategoryTreeId, string query)
{
return await new TaxonomyController(accessToken).GetCategorySuggestions(CategoryTreeId, query);
}
public async Task<CategoryTree> GetCategoryTree(string CategoryTreeId)
{
return await new TaxonomyController(accessToken).GetCategoryTree(CategoryTreeId);
}

#endregion

#region TRADITIONAL_SELLING

#region TRADING

public async Task<GetSellerListResponse> GetItems(int pageNumber, int entriesPerPage, string endTimeFrom, string endTimeTo)
Expand All @@ -257,5 +283,7 @@ public async Task<GetSellerListResponse> GetItems(int pageNumber, int entriesPer
}

#endregion

#endregion
}
}
24 changes: 24 additions & 0 deletions EbaySharp/Controllers/FeedController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using EbaySharp.Entities.Sell.Feed;
using EbaySharp.Source;

namespace EbaySharp.Controllers
{
class FeedController
{
private string accessToken;
public FeedController(string accessToken)
{
this.accessToken = accessToken;
}

#region TASK

public async Task<ResultFile> GetResultFile(string taskId)
{
string requestUrl = $"{Constants.API_SERVER_URL}{Constants.SELL.ENDPOINT_URL}{Constants.SELL.FEED.ENDPOINT_URL}{string.Format(Constants.SELL.FEED.METHODS.GET_DOWNLOAD_RESULT_FILE, taskId)}";
return await new RequestExecuter().ExecuteGetRequest<ResultFile>(requestUrl, $"Bearer {accessToken}");
}

#endregion
}
}
4 changes: 2 additions & 2 deletions EbaySharp/EbaySharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ApplicationIcon>EbaySharp_ico.ico</ApplicationIcon>
<PackageID>CMS365.EbaySharp</PackageID>
<Title>EbaySharp</Title>
<Version>6.6.5</Version>
<Version>6.6.6</Version>
<Authors>Shafaqat Ali</Authors>
<Company>CMS365 PTY LTD</Company>
<Description>EbaySharp is a .NET library that enables you to authenticate and make REST API calls to eBay. It's used for creating listings and managing orders using C# and .NET</Description>
Expand Down Expand Up @@ -46,13 +46,13 @@
</ItemGroup>

<ItemGroup>
<Folder Include="Entities\Sell\Account\" />
<Folder Include="Screenshots\" />
<Folder Include="Wiki\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
</ItemGroup>

</Project>
38 changes: 38 additions & 0 deletions EbaySharp/Entities/Sell/Feed/ResultFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using ICSharpCode.SharpZipLib.Zip;

namespace EbaySharp.Entities.Sell.Feed
{
public class ResultFile
{
public string FileName { get; set; }
public Stream FileContent { get; set; }
public async Task SaveUncompressed(string folderPath)
{
using (ZipInputStream s = new ZipInputStream(FileContent))
{
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{
using (FileStream streamWriter = File.Create($"{folderPath}\\{FileName.Replace(".zip","")}"))
{

int size = 2048;
byte[] data = new byte[2048];
while (true)
{
size = await s.ReadAsync(data, 0, data.Length);
if (size > 0)
{
await streamWriter.WriteAsync(data, 0, size);
}
else
{
break;
}
}
}
}
}
}
}
}
Loading

0 comments on commit 172e049

Please sign in to comment.