Skip to content

Commit

Permalink
Offer methods added.
Browse files Browse the repository at this point in the history
  • Loading branch information
shafaqat-ali-cms365 committed Jan 29, 2024
1 parent 28ccb71 commit bdb5412
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 16 deletions.
4 changes: 4 additions & 0 deletions EbaySharp/Controllers/EbayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public async Task<OfferPublished> PublishOffer(string offerId, string locale)
{
return await new InventoryController(accessToken).PublishOffer(offerId, locale);
}
public async Task<OfferWithdrawn> WithdrawOffer(string offerId)
{
return await new InventoryController(accessToken).WithdrawOffer(offerId);
}
public async Task DeleteInventoryItem(string SKU)
{
await new InventoryController(accessToken).DeleteInventoryItem(SKU);
Expand Down
5 changes: 5 additions & 0 deletions EbaySharp/Controllers/InventoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public async Task<OfferPublished> PublishOffer(string offerID, string locale)
string requestUrl = $"{Constants.SERVER_URL}{Constants.SELL.INVENTORY.ENDPOINT_URL}{string.Format(Constants.SELL.INVENTORY.METHODS.OFFER, offerID)}/publish";
return await new RequestExecuter().ExecutePostRequest<OfferPublished>(requestUrl, $"Bearer {accessToken}", null, locale);
}
public async Task<OfferWithdrawn> WithdrawOffer(string offerID)
{
string requestUrl = $"{Constants.SERVER_URL}{Constants.SELL.INVENTORY.ENDPOINT_URL}{string.Format(Constants.SELL.INVENTORY.METHODS.OFFER, offerID)}/withdraw";
return await new RequestExecuter().ExecutePostRequest<OfferWithdrawn>(requestUrl, $"Bearer {accessToken}", null, null);
}

#endregion

Expand Down
2 changes: 1 addition & 1 deletion 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.0.1</Version>
<Version>6.1.0</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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class BulkMigrateListingError
{
public string Category { get; set; }
public string Domain { get; set; }
public string ErrorID { get; set; }
public int ErrorId { get; set; }
public string[] InputRefIDs { get; set; }
public string LongMessage { get; set; }
public string Message { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System.Text.Json.Serialization;

namespace EbaySharp.Entities.Sell.Inventory.Listing
namespace EbaySharp.Entities.Sell.Inventory.Listing
{
public class BulkMigrateListingRequestItem
{
[JsonPropertyName("listingID")]
public string ListingID { get; set; }
public string ListingId { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
namespace EbaySharp.Entities.Sell.Inventory.Listing
using EbaySharp.Entities.Common;

namespace EbaySharp.Entities.Sell.Inventory.Listing
{
public class BulkMigrateListingResponseItem
{
public List<BulkMigrateListingError> Errors { get; set; }
public string InventoryItemGroupKey { get; set; }
public List<BulkMigrateListingInventoryItem> InventoryItems { get; set; }
public string ListingID { get; set; }
public string MarketplaceID { get; set; }
public string StatusCode { get; set; }
public string ListingId { get; set; }
public MarketplaceEnum MarketplaceId { get; set; }
public int StatusCode { get; set; }
public List<BulkMigrateListingWarning> Warnings { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ public class BulkMigrateListingWarning
{
public string Category { get; set; }
public string Domain { get; set; }
public string ErrorID { get; set; }
public string[] InputRefIDs { get; set; }
public int ErrorId { get; set; }
public string[] InputRefIds { get; set; }
public string LongMessage { get; set; }
public string Message { get; set; }
public string[] OutputRefIDs { get; set; }
public string[] OutputRefIds { get; set; }
public List<KeyValuePair<string, string>> Parameters { get; set; }
public string Subdomain { get; set; }
}
Expand Down
2 changes: 1 addition & 1 deletion EbaySharp/Entities/Sell/Inventory/Offer/Offer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Offer
public int? QuantityLimitPerBuyer { get; set; }
public Regulatory Regulatory { get; set; }
public string SecondaryCategoryId { get; set; }
public string Sku { get; set; }
public string SKU { get; set; }
public OfferStatusEnum? Status { get; set; }
public string[] StoreCategoryNames { get; set; }
public Tax Tax { get; set; }
Expand Down
7 changes: 7 additions & 0 deletions EbaySharp/Entities/Sell/Inventory/Offer/OfferWithdrawn.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace EbaySharp.Entities.Sell.Inventory.Offer
{
public class OfferWithdrawn
{
public string ListingId { get; set; }
}
}
2 changes: 1 addition & 1 deletion EbaySharp/Source/RequestExecuter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private async Task<HttpResponseMessage> executeRequest(HttpMethod httpMethod, st
var content = new StringContent(JSONPayload, null, "application/json");
if (string.IsNullOrEmpty(contentLanguageHeaderValue) == false)
{
content.Headers.Add("Content-Language", contentLanguageHeaderValue);
content.Headers.Add("Content-Language", contentLanguageHeaderValue.Replace("_", "-"));
}
request.Content = content;
}
Expand Down
60 changes: 60 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ EbaySharp currently supports the following Ebay REST APIs:
- [Offer](#offer)
- [Get offers](#get-offers)
- [Get offer](#get-offer)
- [Create offer](#create-offer)
- [Update offer](#update-offer)
- [Publish offer](#publish-offer)
- [Withdraw offer](#withdraw-offer)
- [Metadata](#metadata)
- [Marketplace](#Marketplace)
- [Get return policies](#get-return-policies)
Expand Down Expand Up @@ -252,7 +256,63 @@ EbaySharp.Controllers.EbayController ebayController = new EbaySharp.Controllers.
Offer offer = await ebayController.GetOffer(offerID);

```
##### Create offer
You can find more detail [here](https://developer.ebay.com/api-docs/sell/inventory/resources/offer/methods/createOffer)

```C#

EbaySharp.Controllers.EbayController ebayController = new EbaySharp.Controllers.EbayController(clientCredentials.AccessToken);
Offer offer = new Offer()
{
Sku = SKU,
MarketplaceId = MarketplaceEnum.EBAY_AU,
Format = FormatTypeEnum.FIXED_PRICE,
PricingSummary = new PricingSummary()
{
Price = new Amount()
{
Currency = "AUD",
Value = "75"
}
},
MerchantLocationKey = inventoryLocation.MerchantLocationKey,
CategoryId = "162480",
ListingPolicies = new ListingPolicies()
{
FulfillmentPolicyId = "ReplaceYourFulfillmentPolicyId",
PaymentPolicyId = "ReplaceYourPaymentPolicyId",
ReturnPolicyId = "ReplaceYourReturnPolicyId"
}
};
OfferCreated offerCreated = await ebayController.CreateOffer(offer, "en-AU");

```
##### Update offer
You can find more detail [here](https://developer.ebay.com/api-docs/sell/inventory/resources/offer/methods/updateOffer)

```C#

EbaySharp.Controllers.EbayController ebayController = new EbaySharp.Controllers.EbayController(clientCredentials.AccessToken);
Offer offer = await ebayController.GetOffer(offerId);
offer.PricingSummary.Price.Value = "100";
await ebayController.UpdateOffer(offerId, offer, "en-AU");
```
##### Publish offer
You can find more detail [here](https://developer.ebay.com/api-docs/sell/inventory/resources/offer/methods/publishOffer)

```C#

EbaySharp.Controllers.EbayController ebayController = new EbaySharp.Controllers.EbayController(clientCredentials.AccessToken);
OfferPublished offerPublished = await ebayController.PublishOffer(offerId, "en-AU");
```
##### Withdraw offer
You can find more detail [here](https://developer.ebay.com/api-docs/sell/inventory/resources/offer/methods/withdrawOffer)

```C#

EbaySharp.Controllers.EbayController ebayController = new EbaySharp.Controllers.EbayController(clientCredentials.AccessToken);
OfferWithdrawn offerWithdrawn = await ebayController.WithdrawOffer(offerId);
```

### Metadata
You can see a list of Metadata methods [here](https://developer.ebay.com/api-docs/sell/metadata/resources/methods)
Expand Down

0 comments on commit bdb5412

Please sign in to comment.