Skip to content

Commit

Permalink
add productr types
Browse files Browse the repository at this point in the history
  • Loading branch information
abuzuhri committed Mar 12, 2022
1 parent b799a72 commit 49f5029
Show file tree
Hide file tree
Showing 16 changed files with 727 additions and 14 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Install-Package CSharpAmazonSpAPI
- [x] [Feeds](https://github.com/amzn/selling-partner-api-docs/blob/main/references/feeds-api/feeds_2021-06-30.md) for [feedType](https://github.com/amzn/selling-partner-api-docs/blob/main/references/feeds-api/feedtype-values.md) for step to call feed read [doc](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/feeds-api-use-case-guide/feeds-api-use-case-guide_2021-06-30.md)
- [x] [ListingsItems](https://github.com/amzn/selling-partner-api-docs/blob/main/references/listings-items-api/listingsItems_2021-08-01.md)
- [x] [Restrictions](https://developer-docs.amazon.com/sp-api/docs/listings-restrictions-api-v2021-08-01-reference)
- [ ] [ProductTypes](https://developer-docs.amazon.com/sp-api/docs/product-type-definitions-api-v2020-09-01-reference)
- [x] [ProductTypes](https://developer-docs.amazon.com/sp-api/docs/product-type-definitions-api-v2020-09-01-reference)
- [x] [Uploads](https://github.com/amzn/selling-partner-api-docs/blob/main/references/uploads-api/uploads_2020-11-01.md)
- [x] [shipmentInvoicingV0](https://github.com/amzn/selling-partner-api-docs/blob/main/references/shipment-invoicing-api/shipmentInvoicingV0.md)
- [x] [Shippings](https://github.com/amzn/selling-partner-api-docs/blob/main/references/shipping-api/shipping.md)
Expand Down Expand Up @@ -452,6 +452,27 @@ var shipmentRequest = new CreateShipmentRequest(
var shipmentResponse = amazonConnection.MerchantFulfillment.CreateShipment(shipmentRequest);
```

## ProductTypes SearchDefinitions

```CSharp
var list = amazonConnection.ProductType.SearchDefinitionsProductTypes(
new Parameter.ProductTypes.SearchDefinitionsProductTypesParameter()
{
keywords = new List<string> { String.Empty },
});
```

## ProductTypes GetDefinitions

```CSharp
var def = amazonConnection.ProductType.GetDefinitionsProductType(
new Parameter.ProductTypes.GetDefinitionsProductTypeParameter()
{
productType = "PRODUCT",
requirements = RequirementsEnum.LISTING,
locale = AmazonSpApiSDK.Models.ProductTypes.LocaleEnum.en_US
});
```
---
## Q & A

Expand Down
37 changes: 37 additions & 0 deletions Source/FikaAmazonAPI.SampleCode/ProductTypeSample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using static FikaAmazonAPI.AmazonSpApiSDK.Models.ListingsItems.ListingsItemPutRequest;

namespace FikaAmazonAPI.SampleCode
{
internal class ProductTypeSample
{

AmazonConnection amazonConnection;
public ProductTypeSample(AmazonConnection amazonConnection)
{
this.amazonConnection = amazonConnection;
}


private void SearchDefinitionsProductTypes()
{
var list = amazonConnection.ProductType.SearchDefinitionsProductTypes(
new Parameter.ProductTypes.SearchDefinitionsProductTypesParameter()
{
keywords = new List<string> { String.Empty },
});

}
private void GetDefinitionsProductType()
{
var def = amazonConnection.ProductType.GetDefinitionsProductType(
new Parameter.ProductTypes.GetDefinitionsProductTypeParameter()
{
productType = "PRODUCT",
requirements = RequirementsEnum.LISTING,
locale = AmazonSpApiSDK.Models.ProductTypes.LocaleEnum.en_US
});
}


}
}
15 changes: 14 additions & 1 deletion Source/FikaAmazonAPI.SampleCode/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using FikaAmazonAPI.ReportGeneration;
using FikaAmazonAPI.Utils;
using Microsoft.Extensions.Configuration;
using static FikaAmazonAPI.AmazonSpApiSDK.Models.ListingsItems.ListingsItemPutRequest;
using static FikaAmazonAPI.Utils.Constants;

namespace FikaAmazonAPI.SampleCode
Expand Down Expand Up @@ -34,6 +35,18 @@ static async Task Main(string[] args)
IsActiveLimitRate = true
});

var aha = amazonConnection.ProductType.SearchDefinitionsProductTypes(new Parameter.ProductTypes.SearchDefinitionsProductTypesParameter()
{
keywords = new List<string> { String.Empty },
});

var def = amazonConnection.ProductType.GetDefinitionsProductType(new Parameter.ProductTypes.GetDefinitionsProductTypeParameter()
{
productType = "PRODUCT",
requirements = RequirementsEnum.LISTING,
locale = AmazonSpApiSDK.Models.ProductTypes.LocaleEnum.en_US
});

var result = amazonConnection.Restrictions.GetListingsRestrictions(new Parameter.Restrictions.ParameterGetListingsRestrictions
{
asin = "B07GY3J99B",
Expand All @@ -50,7 +63,7 @@ static async Task Main(string[] args)
sku = SKU,
listingsItemPutRequest = new ListingsItemPutRequest()
{
productType = "LUGGAGE",
productType = "PRODUCT",
requirements = Requirements.LISTING,

//Example from https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2020-09-01-use-case-guide
Expand Down
3 changes: 3 additions & 0 deletions Source/FikaAmazonAPI/AmazonConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class AmazonConnection
public MessagingService Messaging => this._Messaging ?? throw _NoCredentials;
public NotificationService Notification => this._Notification ?? throw _NoCredentials;
public ProductFeeService ProductFee => this._ProductFee ?? throw _NoCredentials;
public ProductTypeService ProductType => this._ProductType ?? throw _NoCredentials;
public SalesService Sales => this._Sales ?? throw _NoCredentials;
public SellerService Seller => this._Seller ?? throw _NoCredentials;
public ServicesService Services => this._Services ?? throw _NoCredentials;
Expand Down Expand Up @@ -60,6 +61,7 @@ public class AmazonConnection
private MessagingService _Messaging { get; set; }
private NotificationService _Notification { get; set; }
private ProductFeeService _ProductFee { get; set; }
private ProductTypeService _ProductType { get; set; }
private SalesService _Sales { get; set; }
private SellerService _Seller { get; set; }
private ServicesService _Services { get; set; }
Expand Down Expand Up @@ -114,6 +116,7 @@ private void Init(AmazonCredential Credentials)
this._Messaging = new MessagingService(this.Credentials);
this._Notification = new NotificationService(this.Credentials);
this._ProductFee = new ProductFeeService(this.Credentials);
this._ProductType = new ProductTypeService(this.Credentials);
this._Sales = new SalesService(this.Credentials);
this._Seller = new SellerService(this.Credentials);
this._Services = new ServicesService(this.Credentials);
Expand Down
158 changes: 158 additions & 0 deletions Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ProductTypes/LocaleEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
using System.Runtime.Serialization;

namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ProductTypes
{
public enum LocaleEnum
{
/// <summary>
/// Arabic
/// </summary>
[EnumMember(Value = "ar")]
ar,
/// <summary>
/// Arabic (U.A.E.)
/// </summary>
[EnumMember(Value = "ar_AE")] ar_AE,
/// <summary>
/// German
/// </summary>
[EnumMember(Value = "de")] de,
/// <summary>
/// German (Germany)
/// </summary>
[EnumMember(Value = "de_DE")] de_DE,
/// <summary>
/// English
/// </summary>
[EnumMember(Value = "en")] en,
/// <summary>
/// English (U.A.E.)
/// </summary>
[EnumMember(Value = "en_AE")] en_AE,
/// <summary>
/// English (Australia)
/// </summary>
[EnumMember(Value = "en_AU")] en_AU,
/// <summary>
/// English (Canada)
/// </summary>
[EnumMember(Value = "en_CA")] en_CA,
/// <summary>
/// English (United Kingdom)
/// </summary>
[EnumMember(Value = "en_GB")] en_GB,
/// <summary>
/// English (India)
/// </summary>
[EnumMember(Value = "en_IN")] en_IN,
/// <summary>
/// English (Singapore)
/// </summary>
[EnumMember(Value = "en_SG")] en_SG,
/// <summary>
/// English (United States)
/// </summary>
[EnumMember(Value = "en_US")] en_US,
/// <summary>
/// Spanish
/// </summary>
[EnumMember(Value = "es")] es,
/// <summary>
/// Spanish (Spain)
/// </summary>
[EnumMember(Value = "es_ES")] es_ES,
/// <summary>
/// Spanish (Mexico)
/// </summary>
[EnumMember(Value = "es_MX")] es_MX,
/// <summary>
/// Spanish (United States)
/// </summary>
[EnumMember(Value = "es_US")] es_US,
/// <summary>
/// French
/// </summary>
[EnumMember(Value = "fr")] fr,
/// <summary>
/// French (Canada)
/// </summary>
[EnumMember(Value = "fr_CA")] fr_CA,
/// <summary>
/// French (France)
/// </summary>
[EnumMember(Value = "fr_FR")] fr_FR,
/// <summary>
/// Italian
/// </summary>
[EnumMember(Value = "it")] it,
/// <summary>
/// Italian (Italy)
/// </summary>
[EnumMember(Value = "it_IT")] it_IT,
/// <summary>
/// Japanese
/// </summary>
[EnumMember(Value = "ja")] ja,
/// <summary>
/// Japanese (Japan)
/// </summary>
[EnumMember(Value = "ja_JP")] ja_JP,
/// <summary>
/// Dutch
/// </summary>
[EnumMember(Value = "nl")] nl,
/// <summary>
/// Dutch (Netherlands)
/// </summary>
[EnumMember(Value = "nl_NL")] nl_NL,
/// <summary>
/// Polish
/// </summary>
[EnumMember(Value = "pl")] pl,
/// <summary>
/// Polish (Poland)
/// </summary>
[EnumMember(Value = "pl_PL")] pl_PL,
/// <summary>
/// Portuguese
/// </summary>
[EnumMember(Value = "pt")] pt,
/// <summary>
/// Portuguese (Brazil)
/// </summary>
[EnumMember(Value = "pt_BR")] pt_BR,
/// <summary>
/// Portuguese (Portugal)
/// </summary>
[EnumMember(Value = "pt_PT")] pt_PT,
/// <summary>
/// Swedish
/// </summary>
[EnumMember(Value = "sv")] sv,
/// <summary>
/// Swedish (Sweden)
/// </summary>
[EnumMember(Value = "sv_SE")] sv_SE,
/// <summary>
/// Turkish
/// </summary>
[EnumMember(Value = "tr")] tr,
/// <summary>
/// Turkish (Turkey)
/// </summary>
[EnumMember(Value = "tr_TR")] tr_TR,
/// <summary>
/// Chinese
/// </summary>
[EnumMember(Value = "zh")] zh,
/// <summary>
/// Chinese (Simplified)
/// </summary>
[EnumMember(Value = "zh_CN")] zh_CN,
/// <summary>
/// Chinese (Traditional)
/// </summary>
[EnumMember(Value = "zh_TW")] zh_TW,

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ProductTypes
{

/// <summary>
/// An Amazon product type with a definition available.
/// </summary>
[DataContract]
public class ProductType
{
/// <summary>
/// The name of the Amazon product type.
/// </summary>
/// <value>The name of the Amazon product type.</value>
[DataMember(Name = "name", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }

/// <summary>
/// The Amazon marketplace identifiers for which the product type definition is available.
/// </summary>
/// <value>The Amazon marketplace identifiers for which the product type definition is available.</value>
[DataMember(Name = "marketplaceIds", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "marketplaceIds")]
public List<string> MarketplaceIds { get; set; }


/// <summary>
/// Get the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class ProductType {\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append(" MarketplaceIds: ").Append(MarketplaceIds).Append("\n");
sb.Append("}\n");
return sb.ToString();
}

/// <summary>
/// Get the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}

}
}
Loading

0 comments on commit 49f5029

Please sign in to comment.