Skip to content

Commit 1b12dad

Browse files
committed
add restrictions
1 parent eee7ada commit 1b12dad

File tree

15 files changed

+435
-10
lines changed

15 files changed

+435
-10
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Install-Package CSharpAmazonSpAPI
3434
- [x] [FinancesV0](https://github.com/amzn/selling-partner-api-docs/blob/main/references/finances-api/financesV0.md)
3535
- [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)
3636
- [x] [ListingsItems](https://github.com/amzn/selling-partner-api-docs/blob/main/references/listings-items-api/listingsItems_2021-08-01.md)
37+
- [x] [Restrictions](https://developer-docs.amazon.com/sp-api/docs/listings-restrictions-api-v2021-08-01-reference)
38+
- [ ] [ProductTypes](https://developer-docs.amazon.com/sp-api/docs/product-type-definitions-api-v2020-09-01-reference)
3739
- [x] [Uploads](https://github.com/amzn/selling-partner-api-docs/blob/main/references/uploads-api/uploads_2020-11-01.md)
3840
- [x] [shipmentInvoicingV0](https://github.com/amzn/selling-partner-api-docs/blob/main/references/shipment-invoicing-api/shipmentInvoicingV0.md)
3941
- [x] [Shippings](https://github.com/amzn/selling-partner-api-docs/blob/main/references/shipping-api/shipping.md)
@@ -385,6 +387,17 @@ var amazonConnection = new AmazonConnection(new AmazonCredential()
385387

386388
---
387389

390+
## Get restrictions before try to add new lists
391+
392+
```CSharp
393+
var result = amazonConnection.Restrictions.GetListingsRestrictions(
394+
new Parameter.Restrictions.ParameterGetListingsRestrictions
395+
{
396+
asin = "AAAAAAAAAA",
397+
sellerId = "AXXXXXXXXXXXX"
398+
});
399+
```
400+
---
388401
## Create shipment operation from MerchantFulfillment
389402

390403
```CSharp

Source/FikaAmazonAPI.SampleCode/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ static async Task Main(string[] args)
3333
MarketPlace = MarketPlace.GetMarketPlaceByID(config.GetSection("FikaAmazonAPI:MarketPlaceID").Value),
3434
IsActiveLimitRate = true
3535
});
36+
37+
var result = amazonConnection.Restrictions.GetListingsRestrictions(new Parameter.Restrictions.ParameterGetListingsRestrictions
38+
{
39+
asin = "B07GY3J99B",
40+
sellerId = "A3J37AJU4O9RHK"
41+
});
42+
3643
var SKU = "693749790020";
3744
var sellerId = "A3J37AJU4O9RHK";
3845

Source/FikaAmazonAPI/AmazonConnection.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class AmazonConnection
2222
public FbaSmallandLightService FbaSmallandLight => this._FbaSmallandLight ?? throw _NoCredentials;
2323
public FeedService Feed => this._Feed ?? throw _NoCredentials;
2424
public ListingsItemService ListingsItem => this._ListingsItem ?? throw _NoCredentials;
25+
public RestrictionService Restrictions => this._Restrictions ?? throw _NoCredentials;
2526
public MerchantFulfillmentService MerchantFulfillment => this._MerchantFulfillment ?? throw _NoCredentials;
2627
public MessagingService Messaging => this._Messaging ?? throw _NoCredentials;
2728
public NotificationService Notification => this._Notification ?? throw _NoCredentials;
@@ -54,6 +55,7 @@ public class AmazonConnection
5455
private FbaSmallandLightService _FbaSmallandLight { get; set; }
5556
private FeedService _Feed { get; set; }
5657
private ListingsItemService _ListingsItem { get; set; }
58+
private RestrictionService _Restrictions { get; set; }
5759
private MerchantFulfillmentService _MerchantFulfillment { get; set; }
5860
private MessagingService _Messaging { get; set; }
5961
private NotificationService _Notification { get; set; }
@@ -107,6 +109,7 @@ private void Init(AmazonCredential Credentials)
107109
this._AplusContent = new AplusContentService(this.Credentials);
108110
this._Feed = new FeedService(this.Credentials);
109111
this._ListingsItem = new ListingsItemService(this.Credentials);
112+
this._Restrictions = new RestrictionService(this.Credentials);
110113
this._MerchantFulfillment = new MerchantFulfillmentService(this.Credentials);
111114
this._Messaging = new MessagingService(this.Credentials);
112115
this._Notification = new NotificationService(this.Credentials);
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.Restrictions
2+
{
3+
public enum ConditionType
4+
{
5+
/// <summary>
6+
/// New
7+
/// </summary>
8+
new_new,
9+
/// <summary>
10+
/// New - Open Box.
11+
/// </summary>
12+
new_open_box,
13+
/// <summary>
14+
/// New - OEM.
15+
/// </summary>
16+
new_oem,
17+
/// <summary>
18+
/// Refurbished
19+
/// </summary>
20+
refurbished_refurbished,
21+
/// <summary>
22+
/// Used - Like New.
23+
/// </summary>
24+
used_like_new,
25+
/// <summary>
26+
/// Used - Very Good.
27+
/// </summary>
28+
used_very_good,
29+
/// <summary>
30+
/// Used - Good.
31+
/// </summary>
32+
used_good,
33+
/// <summary>
34+
/// Used - Acceptable.
35+
/// </summary>
36+
used_acceptable,
37+
/// <summary>
38+
/// Collectible - Like New.
39+
/// </summary>
40+
collectible_like_new,
41+
/// <summary>
42+
/// Collectible - Very Good.
43+
/// </summary>
44+
collectible_very_good,
45+
/// <summary>
46+
/// Collectible - Good.
47+
/// </summary>
48+
collectible_good,
49+
/// <summary>
50+
/// Collectible - Acceptable.
51+
/// </summary>
52+
collectible_acceptable,
53+
/// <summary>
54+
/// Club
55+
/// </summary>
56+
club_club
57+
58+
}
59+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using Newtonsoft.Json;
2+
using System.Runtime.Serialization;
3+
using System.Text;
4+
5+
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.Restrictions
6+
{
7+
8+
/// <summary>
9+
/// A link to resources related to a listing restriction.
10+
/// </summary>
11+
[DataContract]
12+
public class Link
13+
{
14+
/// <summary>
15+
/// The URI of the related resource.
16+
/// </summary>
17+
/// <value>The URI of the related resource.</value>
18+
[DataMember(Name = "resource", EmitDefaultValue = false)]
19+
[JsonProperty(PropertyName = "resource")]
20+
public string Resource { get; set; }
21+
22+
/// <summary>
23+
/// The HTTP verb used to interact with the related resource.
24+
/// </summary>
25+
/// <value>The HTTP verb used to interact with the related resource.</value>
26+
[DataMember(Name = "verb", EmitDefaultValue = false)]
27+
[JsonProperty(PropertyName = "verb")]
28+
public string Verb { get; set; }
29+
30+
/// <summary>
31+
/// The title of the related resource.
32+
/// </summary>
33+
/// <value>The title of the related resource.</value>
34+
[DataMember(Name = "title", EmitDefaultValue = false)]
35+
[JsonProperty(PropertyName = "title")]
36+
public string Title { get; set; }
37+
38+
/// <summary>
39+
/// The media type of the related resource.
40+
/// </summary>
41+
/// <value>The media type of the related resource.</value>
42+
[DataMember(Name = "type", EmitDefaultValue = false)]
43+
[JsonProperty(PropertyName = "type")]
44+
public string Type { get; set; }
45+
46+
47+
/// <summary>
48+
/// Get the string presentation of the object
49+
/// </summary>
50+
/// <returns>String presentation of the object</returns>
51+
public override string ToString()
52+
{
53+
var sb = new StringBuilder();
54+
sb.Append("class Link {\n");
55+
sb.Append(" Resource: ").Append(Resource).Append("\n");
56+
sb.Append(" Verb: ").Append(Verb).Append("\n");
57+
sb.Append(" Title: ").Append(Title).Append("\n");
58+
sb.Append(" Type: ").Append(Type).Append("\n");
59+
sb.Append("}\n");
60+
return sb.ToString();
61+
}
62+
63+
/// <summary>
64+
/// Get the JSON string presentation of the object
65+
/// </summary>
66+
/// <returns>JSON string presentation of the object</returns>
67+
public string ToJson()
68+
{
69+
return JsonConvert.SerializeObject(this, Formatting.Indented);
70+
}
71+
72+
}
73+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using Newtonsoft.Json;
2+
using System.Collections.Generic;
3+
using System.Runtime.Serialization;
4+
using System.Text;
5+
6+
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.Restrictions
7+
{
8+
9+
/// <summary>
10+
/// A reason for the restriction, including path forward links that may allow Selling Partners to remove the restriction, if available.
11+
/// </summary>
12+
[DataContract]
13+
public class Reason
14+
{
15+
/// <summary>
16+
/// A message describing the reason for the restriction.
17+
/// </summary>
18+
/// <value>A message describing the reason for the restriction.</value>
19+
[DataMember(Name = "message", EmitDefaultValue = false)]
20+
[JsonProperty(PropertyName = "message")]
21+
public string Message { get; set; }
22+
23+
/// <summary>
24+
/// A code indicating why the listing is restricted.
25+
/// </summary>
26+
/// <value>A code indicating why the listing is restricted.</value>
27+
[DataMember(Name = "reasonCode", EmitDefaultValue = false)]
28+
[JsonProperty(PropertyName = "reasonCode")]
29+
public string ReasonCode { get; set; }
30+
31+
/// <summary>
32+
/// A list of path forward links that may allow Selling Partners to remove the restriction.
33+
/// </summary>
34+
/// <value>A list of path forward links that may allow Selling Partners to remove the restriction.</value>
35+
[DataMember(Name = "links", EmitDefaultValue = false)]
36+
[JsonProperty(PropertyName = "links")]
37+
public List<Link> Links { get; set; }
38+
39+
40+
/// <summary>
41+
/// Get the string presentation of the object
42+
/// </summary>
43+
/// <returns>String presentation of the object</returns>
44+
public override string ToString()
45+
{
46+
var sb = new StringBuilder();
47+
sb.Append("class Reason {\n");
48+
sb.Append(" Message: ").Append(Message).Append("\n");
49+
sb.Append(" ReasonCode: ").Append(ReasonCode).Append("\n");
50+
sb.Append(" Links: ").Append(Links).Append("\n");
51+
sb.Append("}\n");
52+
return sb.ToString();
53+
}
54+
55+
/// <summary>
56+
/// Get the JSON string presentation of the object
57+
/// </summary>
58+
/// <returns>JSON string presentation of the object</returns>
59+
public string ToJson()
60+
{
61+
return JsonConvert.SerializeObject(this, Formatting.Indented);
62+
}
63+
64+
}
65+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using Newtonsoft.Json;
2+
using System.Collections.Generic;
3+
using System.Runtime.Serialization;
4+
using System.Text;
5+
6+
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.Restrictions
7+
{
8+
9+
/// <summary>
10+
/// A listing restriction, optionally qualified by a condition, with a list of reasons for the restriction.
11+
/// </summary>
12+
[DataContract]
13+
public class Restriction
14+
{
15+
/// <summary>
16+
/// A marketplace identifier. Identifies the Amazon marketplace where the restriction is enforced.
17+
/// </summary>
18+
/// <value>A marketplace identifier. Identifies the Amazon marketplace where the restriction is enforced.</value>
19+
[DataMember(Name = "marketplaceId", EmitDefaultValue = false)]
20+
[JsonProperty(PropertyName = "marketplaceId")]
21+
public string MarketplaceId { get; set; }
22+
23+
/// <summary>
24+
/// The condition that applies to the restriction.
25+
/// </summary>
26+
/// <value>The condition that applies to the restriction.</value>
27+
[DataMember(Name = "conditionType", EmitDefaultValue = false)]
28+
[JsonProperty(PropertyName = "conditionType")]
29+
public string ConditionType { get; set; }
30+
31+
/// <summary>
32+
/// A list of reasons for the restriction.
33+
/// </summary>
34+
/// <value>A list of reasons for the restriction.</value>
35+
[DataMember(Name = "reasons", EmitDefaultValue = false)]
36+
[JsonProperty(PropertyName = "reasons")]
37+
public List<Reason> Reasons { get; set; }
38+
39+
40+
/// <summary>
41+
/// Get the string presentation of the object
42+
/// </summary>
43+
/// <returns>String presentation of the object</returns>
44+
public override string ToString()
45+
{
46+
var sb = new StringBuilder();
47+
sb.Append("class Restriction {\n");
48+
sb.Append(" MarketplaceId: ").Append(MarketplaceId).Append("\n");
49+
sb.Append(" ConditionType: ").Append(ConditionType).Append("\n");
50+
sb.Append(" Reasons: ").Append(Reasons).Append("\n");
51+
sb.Append("}\n");
52+
return sb.ToString();
53+
}
54+
55+
/// <summary>
56+
/// Get the JSON string presentation of the object
57+
/// </summary>
58+
/// <returns>JSON string presentation of the object</returns>
59+
public string ToJson()
60+
{
61+
return JsonConvert.SerializeObject(this, Formatting.Indented);
62+
}
63+
64+
}
65+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Newtonsoft.Json;
2+
using System.Collections.Generic;
3+
using System.Runtime.Serialization;
4+
using System.Text;
5+
6+
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.Restrictions
7+
{
8+
9+
/// <summary>
10+
/// A list of restrictions for the specified Amazon catalog item.
11+
/// </summary>
12+
[DataContract]
13+
public class RestrictionList
14+
{
15+
/// <summary>
16+
/// Gets or Sets Restrictions
17+
/// </summary>
18+
[DataMember(Name = "restrictions", EmitDefaultValue = false)]
19+
[JsonProperty(PropertyName = "restrictions")]
20+
public List<Restriction> Restrictions { get; set; }
21+
22+
23+
/// <summary>
24+
/// Get the string presentation of the object
25+
/// </summary>
26+
/// <returns>String presentation of the object</returns>
27+
public override string ToString()
28+
{
29+
var sb = new StringBuilder();
30+
sb.Append("class RestrictionList {\n");
31+
sb.Append(" Restrictions: ").Append(Restrictions).Append("\n");
32+
sb.Append("}\n");
33+
return sb.ToString();
34+
}
35+
36+
/// <summary>
37+
/// Get the JSON string presentation of the object
38+
/// </summary>
39+
/// <returns>JSON string presentation of the object</returns>
40+
public string ToJson()
41+
{
42+
return JsonConvert.SerializeObject(this, Formatting.Indented);
43+
}
44+
45+
}
46+
}

0 commit comments

Comments
 (0)