diff --git a/EbaySharp/Controllers/EbayController.cs b/EbaySharp/Controllers/EbayController.cs index ea9d52a..569d7b3 100644 --- a/EbaySharp/Controllers/EbayController.cs +++ b/EbaySharp/Controllers/EbayController.cs @@ -56,9 +56,9 @@ public async Task GetInventoryItem(string SKU) { return await new InventoryController(accessToken).GetInventoryItem(SKU); } - public async Task CreateInventoryItem(string SKU, InventoryItem inventoryItem) + public async Task CreateOrReplaceInventoryItem(string SKU, InventoryItem inventoryItem) { - await new InventoryController(accessToken).CreateInventoryItem(SKU, inventoryItem); + await new InventoryController(accessToken).CreateOrReplaceInventoryItem(SKU, inventoryItem); } public async Task GetOffers(string SKU) { @@ -68,6 +68,18 @@ public async Task GetOffer(string offerID) { return await new InventoryController(accessToken).GetOffer(offerID); } + public async TaskCreateOffer(Offer offer, string locale) + { + return await new InventoryController(accessToken).CreateOffer(offer, locale); + } + public async Task UpdateOffer(string offerId, Offer offer, string locale) + { + await new InventoryController(accessToken).UpdateOffer(offerId, offer, locale); + } + public async Task PublishOffer(string offerId, string locale) + { + return await new InventoryController(accessToken).PublishOffer(offerId, locale); + } public async Task DeleteInventoryItem(string SKU) { await new InventoryController(accessToken).DeleteInventoryItem(SKU); diff --git a/EbaySharp/Controllers/InventoryController.cs b/EbaySharp/Controllers/InventoryController.cs index 6736434..12e2c42 100644 --- a/EbaySharp/Controllers/InventoryController.cs +++ b/EbaySharp/Controllers/InventoryController.cs @@ -5,7 +5,6 @@ using EbaySharp.Entities.Sell.Inventory.Location; using EbaySharp.Entities.Sell.Inventory.Offer; using EbaySharp.Source; -using System.Text.Json; namespace EbaySharp.Controllers { @@ -36,11 +35,14 @@ public async Task DeleteInventoryItem(string SKU) string requestUrl = $"{Constants.SERVER_URL}{Constants.SELL.INVENTORY.ENDPOINT_URL}{string.Format(Constants.SELL.INVENTORY.METHODS.INVENTORY_ITEM, SKU)}"; await new RequestExecuter().ExecuteDeleteRequest(requestUrl, $"Bearer {accessToken}"); } - public async Task CreateInventoryItem(string SKU, InventoryItem inventoryItem) + public async Task CreateOrReplaceInventoryItem(string SKU, InventoryItem inventoryItem) { string requestUrl = $"{Constants.SERVER_URL}{Constants.SELL.INVENTORY.ENDPOINT_URL}{string.Format(Constants.SELL.INVENTORY.METHODS.INVENTORY_ITEM, SKU)}"; await new RequestExecuter().ExecutePutRequest(requestUrl, $"Bearer {accessToken}", inventoryItem.SerializeToJson(), inventoryItem.Locale); } + + #region OFFER + public async Task GetOffers(string SKU) { string requestUrl = $"{Constants.SERVER_URL}{Constants.SELL.INVENTORY.ENDPOINT_URL}{string.Format(Constants.SELL.INVENTORY.METHODS.OFFERS, SKU)}"; @@ -51,6 +53,27 @@ public async Task GetOffer(string offerID) string requestUrl = $"{Constants.SERVER_URL}{Constants.SELL.INVENTORY.ENDPOINT_URL}{string.Format(Constants.SELL.INVENTORY.METHODS.OFFER, offerID)}"; return await new RequestExecuter().ExecuteGetRequest(requestUrl, $"Bearer {accessToken}"); } + public async Task CreateOffer(Offer offer, string locale) + { + string requestUrl = $"{Constants.SERVER_URL}{Constants.SELL.INVENTORY.ENDPOINT_URL}{Constants.SELL.INVENTORY.METHODS.CREATE_OFFER}"; + return await new RequestExecuter().ExecutePostRequest(requestUrl, $"Bearer {accessToken}", offer.SerializeToJson(), locale); + } + public async Task UpdateOffer(string offerID, Offer offer, string locale) + { + string requestUrl = $"{Constants.SERVER_URL}{Constants.SELL.INVENTORY.ENDPOINT_URL}{string.Format(Constants.SELL.INVENTORY.METHODS.OFFER, offerID)}"; + await new RequestExecuter().ExecutePutRequest(requestUrl, $"Bearer {accessToken}", offer.SerializeToJson(), locale); + } + public async Task 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(requestUrl, $"Bearer {accessToken}", null, locale); + } + + #endregion + + + #region INVENTORY_LOCATION + public async Task GetInventoryLocations(int limit, int offset) { string requestUrl = $"{Constants.SERVER_URL}{Constants.SELL.INVENTORY.ENDPOINT_URL}{string.Format(Constants.SELL.INVENTORY.METHODS.LOCATIONS, limit, offset)}"; @@ -64,12 +87,14 @@ public async Task GetInventoryLocation(string merchantLocatio public async Task CreateInventoryLocation(InventoryLocation inventoryLocation) { string requestUrl = $"{Constants.SERVER_URL}{Constants.SELL.INVENTORY.ENDPOINT_URL}{string.Format(Constants.SELL.INVENTORY.METHODS.LOCATION, inventoryLocation.MerchantLocationKey)}"; - await new RequestExecuter().ExecutePostRequest(requestUrl, $"Bearer {accessToken}", inventoryLocation.SerializeToJson()); + await new RequestExecuter().ExecutePostRequest(requestUrl, $"Bearer {accessToken}", inventoryLocation.SerializeToJson(), null); } public async Task DeleteInventoryLocation(string merchantLocationKey) { string requestUrl = $"{Constants.SERVER_URL}{Constants.SELL.INVENTORY.ENDPOINT_URL}{string.Format(Constants.SELL.INVENTORY.METHODS.LOCATION, merchantLocationKey)}"; await new RequestExecuter().ExecuteDeleteRequest(requestUrl, $"Bearer {accessToken}"); } + + #endregion } } diff --git a/EbaySharp/Entities/Sell/Inventory/InventoryItem/InventoryItem.cs b/EbaySharp/Entities/Sell/Inventory/InventoryItem/InventoryItem.cs index 491ec0c..203f03c 100644 --- a/EbaySharp/Entities/Sell/Inventory/InventoryItem/InventoryItem.cs +++ b/EbaySharp/Entities/Sell/Inventory/InventoryItem/InventoryItem.cs @@ -3,7 +3,7 @@ public class InventoryItem { public Availability Availability { get; set; } - public ConditionEnum Condition { get; set; } + public ConditionEnum? Condition { get; set; } public string ConditionDescription { get; set; } public List ConditionDescriptors { get; set; } public string[] GroupIDs { get; set; } diff --git a/EbaySharp/Entities/Sell/Inventory/InventoryItem/Product.cs b/EbaySharp/Entities/Sell/Inventory/InventoryItem/Product.cs index 40fa0a5..b607352 100644 --- a/EbaySharp/Entities/Sell/Inventory/InventoryItem/Product.cs +++ b/EbaySharp/Entities/Sell/Inventory/InventoryItem/Product.cs @@ -1,6 +1,4 @@ -using System.Text.Json.Nodes; - -namespace EbaySharp.Entities.Sell.Inventory.InventoryItem +namespace EbaySharp.Entities.Sell.Inventory.InventoryItem { public class Product { @@ -15,6 +13,6 @@ public class Product public string Subtitle { get; set; } public string Title { get; set; } public string[] UPC { get; set; } - public string[] VIDeoIDs { get; set; } + public string[] VideoIds { get; set; } } } \ No newline at end of file diff --git a/EbaySharp/Entities/Sell/Inventory/Location/Address.cs b/EbaySharp/Entities/Sell/Inventory/Location/Address.cs index 847b484..17d3860 100644 --- a/EbaySharp/Entities/Sell/Inventory/Location/Address.cs +++ b/EbaySharp/Entities/Sell/Inventory/Location/Address.cs @@ -7,7 +7,7 @@ public class Address public string AddressLine1 { get; set; } public string AddressLine2 { get; set; } public string City { get; set; } - public CountryCodeEnum Country { get; set; } + public CountryCodeEnum? Country { get; set; } public string County { get; set; } public string PostalCode { get; set; } public string StateOrProvince { get; set; } diff --git a/EbaySharp/Entities/Sell/Inventory/Location/Location.cs b/EbaySharp/Entities/Sell/Inventory/Location/Location.cs index 3c897ca..be1bd5e 100644 --- a/EbaySharp/Entities/Sell/Inventory/Location/Location.cs +++ b/EbaySharp/Entities/Sell/Inventory/Location/Location.cs @@ -1,6 +1,4 @@ -using System.Net; - -namespace EbaySharp.Entities.Sell.Inventory.Location +namespace EbaySharp.Entities.Sell.Inventory.Location { public class Location { diff --git a/EbaySharp/Entities/Sell/Inventory/Offer/ListingPolicies.cs b/EbaySharp/Entities/Sell/Inventory/Offer/ListingPolicies.cs index be956c5..4dfc9aa 100644 --- a/EbaySharp/Entities/Sell/Inventory/Offer/ListingPolicies.cs +++ b/EbaySharp/Entities/Sell/Inventory/Offer/ListingPolicies.cs @@ -3,14 +3,14 @@ public class ListingPolicies { public BestOfferTerms BestOfferTerms { get; set; } - public bool EBayPlusIfEligible { get; set; } - public string FulfillmentPolicyID { get; set; } - public string PaymentPolicyID { get; set; } - public string[] ProductCompliancePolicyIDs { get; set; } + public bool? EBayPlusIfEligible { get; set; } + public string FulfillmentPolicyId { get; set; } + public string PaymentPolicyId { get; set; } + public string[] ProductCompliancePolicyIds { get; set; } public RegionalProductCompliancePolicies RegionalProductCompliancePolicies { get; set; } public RegionalTakeBackPolicies RegionalTakeBackPolicies { get; set; } - public string ReturnPolicyID { get; set; } + public string ReturnPolicyId { get; set; } public List ShippingCostOverrides { get; set; } - public string TakeBackPolicyID { get; set; } + public string TakeBackPolicyId { get; set; } } } \ No newline at end of file diff --git a/EbaySharp/Entities/Sell/Inventory/Offer/Offer.cs b/EbaySharp/Entities/Sell/Inventory/Offer/Offer.cs index 51a5102..2c63fe5 100644 --- a/EbaySharp/Entities/Sell/Inventory/Offer/Offer.cs +++ b/EbaySharp/Entities/Sell/Inventory/Offer/Offer.cs @@ -4,28 +4,27 @@ namespace EbaySharp.Entities.Sell.Inventory.Offer { public class Offer { - public int AvailableQuantity { get; set; } - public string CategoryID { get; set; } + public string CategoryId { get; set; } public Charity Charity { get; set; } public ExtendedProducerResponsibility ExtendedProducerResponsibility { get; set; } - public FormatTypeEnum Format { get; set; } - public bool HIDeBuyerDetails { get; set; } - public bool IncludeCatalogProductDetails { get; set; } + public FormatTypeEnum? Format { get; set; } + public bool? HideBuyerDetails { get; set; } + public bool? IncludeCatalogProductDetails { get; set; } public Listing Listing { get; set; } public string ListingDescription { get; set; } - public ListingDurationEnum ListingDuration { get; set; } + public ListingDurationEnum? ListingDuration { get; set; } public ListingPolicies ListingPolicies { get; set; } public string ListingStartDate { get; set; } - public int LotSize { get; set; } - public MarketplaceEnum MarketplaceID { get; set; } + public int? LotSize { get; set; } + public MarketplaceEnum? MarketplaceId { get; set; } public string MerchantLocationKey { get; set; } - public string OfferID { get; set; } + public string OfferId { get; set; } public PricingSummary PricingSummary { get; set; } - public int QuantityLimitPerBuyer { get; set; } + public int? QuantityLimitPerBuyer { get; set; } public Regulatory Regulatory { get; set; } - public string SecondaryCategoryID { get; set; } - public string SKU { get; set; } - public OfferStatusEnum Status { get; set; } + public string SecondaryCategoryId { get; set; } + public string Sku { get; set; } + public OfferStatusEnum? Status { get; set; } public string[] StoreCategoryNames { get; set; } public Tax Tax { get; set; } } diff --git a/EbaySharp/Entities/Sell/Inventory/Offer/OfferCreated.cs b/EbaySharp/Entities/Sell/Inventory/Offer/OfferCreated.cs new file mode 100644 index 0000000..c19ee74 --- /dev/null +++ b/EbaySharp/Entities/Sell/Inventory/Offer/OfferCreated.cs @@ -0,0 +1,7 @@ +namespace EbaySharp.Entities.Sell.Inventory.Offer +{ + public class OfferCreated + { + public string OfferId { get; set; } + } +} diff --git a/EbaySharp/Entities/Sell/Inventory/Offer/OfferPublished.cs b/EbaySharp/Entities/Sell/Inventory/Offer/OfferPublished.cs new file mode 100644 index 0000000..8b59285 --- /dev/null +++ b/EbaySharp/Entities/Sell/Inventory/Offer/OfferPublished.cs @@ -0,0 +1,7 @@ +namespace EbaySharp.Entities.Sell.Inventory.Offer +{ + public class OfferPublished + { + public string ListingId { get; set; } + } +} diff --git a/EbaySharp/Entities/Sell/Inventory/Offer/PricingSummary.cs b/EbaySharp/Entities/Sell/Inventory/Offer/PricingSummary.cs index a0974f2..3c070af 100644 --- a/EbaySharp/Entities/Sell/Inventory/Offer/PricingSummary.cs +++ b/EbaySharp/Entities/Sell/Inventory/Offer/PricingSummary.cs @@ -1,15 +1,13 @@ -using System.Diagnostics; - -namespace EbaySharp.Entities.Sell.Inventory.Offer +namespace EbaySharp.Entities.Sell.Inventory.Offer { public class PricingSummary { public Amount AuctionReservePrice { get; set; } public Amount AuctionStartPrice { get; set; } public Amount MinimumAdvertisedPrice { get; set; } - public SoldOnEnum OriginallySoldForRetailPriceOn { get; set; } + public SoldOnEnum? OriginallySoldForRetailPriceOn { get; set; } public Amount OriginalRetailPrice { get; set; } public Amount Price { get; set; } - public MinimumAdvertisedPriceHandlingEnum PricingVisibility { get; set; } + public MinimumAdvertisedPriceHandlingEnum? PricingVisibility { get; set; } } } \ No newline at end of file diff --git a/EbaySharp/Entities/Sell/Inventory/Offer/Tax.cs b/EbaySharp/Entities/Sell/Inventory/Offer/Tax.cs index 62921c2..18e9356 100644 --- a/EbaySharp/Entities/Sell/Inventory/Offer/Tax.cs +++ b/EbaySharp/Entities/Sell/Inventory/Offer/Tax.cs @@ -4,6 +4,6 @@ public class Tax { public bool ApplyTax { get; set; } public string ThirdPartyTaxCategory { get; set; } - public int VatPercentage { get; set; } + public float VatPercentage { get; set; } } } \ No newline at end of file diff --git a/EbaySharp/Source/Constants.cs b/EbaySharp/Source/Constants.cs index 443b379..ce1fa88 100644 --- a/EbaySharp/Source/Constants.cs +++ b/EbaySharp/Source/Constants.cs @@ -28,6 +28,7 @@ internal struct METHODS internal const string INVENTORY_ITEM = "/inventory_item/{0}"; internal const string OFFERS = "/offer?sku={0}"; internal const string OFFER = "/offer/{0}"; + internal const string CREATE_OFFER = "/offer"; internal const string LOCATIONS = "/location?limit={0}&offset={1}"; internal const string LOCATION = "/location/{0}"; } diff --git a/EbaySharp/Source/RequestExecuter.cs b/EbaySharp/Source/RequestExecuter.cs index 90855a1..481bd60 100644 --- a/EbaySharp/Source/RequestExecuter.cs +++ b/EbaySharp/Source/RequestExecuter.cs @@ -49,9 +49,9 @@ public async Task ExecuteDeleteRequest(string requestUrl, string authHeaderValue throw new Exception(responseContent); } } - private async Task executePostRequest(string requestUrl, string authHeaderValue, List>? keyValuePayload, string? JSONPayload) + private async Task executePostRequest(string requestUrl, string authHeaderValue, List>? keyValuePayload, string? JSONPayload, string? contentLanguage) { - HttpResponseMessage response = await executeRequest(HttpMethod.Post, requestUrl, authHeaderValue, null, keyValuePayload, JSONPayload); + HttpResponseMessage response = await executeRequest(HttpMethod.Post, requestUrl, authHeaderValue, contentLanguage, keyValuePayload, JSONPayload); string responseContent = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { @@ -59,7 +59,16 @@ private async Task executePostRequest(string requestUrl, string authHeader } throw new Exception(responseContent); } - public async Task ExecutePutRequest(string requestUrl, string authHeaderValue, string JSONPayload, string contentLanguage) + //private async Task executePostRequest(string requestUrl, string authHeaderValue, List>? keyValuePayload, string? JSONPayload, string? contentLanguage) + //{ + // HttpResponseMessage response = await executeRequest(HttpMethod.Post, requestUrl, authHeaderValue, contentLanguage, keyValuePayload, JSONPayload); + // string responseContent = await response.Content.ReadAsStringAsync(); + // if (response.IsSuccessStatusCode==false) + // { + // throw new Exception(responseContent); + // } + //} + public async Task ExecutePutRequest(string requestUrl, string authHeaderValue, string? JSONPayload, string? contentLanguage) { HttpResponseMessage response = await executeRequest(HttpMethod.Put, requestUrl, authHeaderValue, contentLanguage, null, JSONPayload); string responseContent = await response.Content.ReadAsStringAsync(); @@ -68,13 +77,17 @@ public async Task ExecutePutRequest(string requestUrl, string authHeaderValue, s throw new Exception(responseContent); } } - public async Task ExecutePostRequest(string requestUrl, string authHeaderValue, List> keyValuePayload) + public async Task ExecutePostRequest(string requestUrl, string authHeaderValue, List>? keyValuePayload) { - return await executePostRequest(requestUrl, authHeaderValue, keyValuePayload, null); + return await executePostRequest(requestUrl, authHeaderValue, keyValuePayload, null, null); } - public async Task ExecutePostRequest(string requestUrl, string authHeaderValue, string JSONPayload) + public async Task ExecutePostRequest(string requestUrl, string authHeaderValue, string? JSONPayload, string? contentLanguage) { - HttpResponseMessage response = await executeRequest(HttpMethod.Post, requestUrl, authHeaderValue, null, null, JSONPayload); + return await executePostRequest(requestUrl, authHeaderValue, null, JSONPayload, contentLanguage); + } + public async Task ExecutePostRequest(string requestUrl, string authHeaderValue, string JSONPayload, string? contentLanguage) + { + HttpResponseMessage response = await executeRequest(HttpMethod.Post, requestUrl, authHeaderValue, contentLanguage, null, JSONPayload); string responseContent = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode==false) { @@ -83,7 +96,7 @@ public async Task ExecutePostRequest(string requestUrl, string authHeaderValue, } public async Task ExecutePostRequest(string requestUrl, string authHeaderValue, string? JSONPayload) { - return await executePostRequest(requestUrl, authHeaderValue, null, JSONPayload); + return await executePostRequest(requestUrl, authHeaderValue, null, JSONPayload, null); } } } diff --git a/readme.md b/readme.md index 90cee43..9295f73 100644 --- a/readme.md +++ b/readme.md @@ -158,7 +158,7 @@ Dictionary aspects = new Dictionary { "Type", new[] { "Helmet/Action" } } }; -await ebayController.CreateInventoryItem("test-sku-api", new InventoryItem() +await ebayController.CreateOrReplaceInventoryItem("test-sku-api", new InventoryItem() { Availability = new Availability() { ShipToLocationAvailability = new ShipToLocationAvailability() { Quantity = 3 } }, Condition = ConditionEnum.NEW,