Skip to content

Commit 7a646c0

Browse files
authored
Merge pull request #210 from abuzuhri/main
[pull] main from abuzuhri:main
2 parents 076d10b + 746b842 commit 7a646c0

10 files changed

Lines changed: 129 additions & 25 deletions

File tree

.github/workflows/nuget.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,7 @@ jobs:
3838
3939
- name: PushNuget
4040
run: dotnet nuget push "**/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }} --skip-duplicate
41-
42-
43-
- name: Add github package source
44-
run: nuget sources Add -Name "github" -Source https://nuget.pkg.github.com/${{github.repository_owner}}/index.json -UserName ${{github.repository_owner}} -Password ${{ secrets.TOKEN_GITHUB_AMAZON_SP_API }}
45-
46-
47-
- name: Push to GitHub Packages
48-
run: dotnet nuget push "**/*.nupkg" --skip-duplicate --source https://nuget.pkg.github.com/${{github.repository_owner}}/index.json --api-key ${GITHUB_TOKEN}
49-
env:
50-
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB_AMAZON_SP_API }}
51-
41+
5242
- name: Get tag
5343
id: tag
5444
uses: dawidd6/action-get-tag@v1

Amazon-SP-API-CSharp.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{177F077C-82C9-4DBB-BA03-CF8E14D4AB4E}"
99
ProjectSection(SolutionItems) = preProject
1010
.gitignore = .gitignore
11-
azure-pipelines.yml = azure-pipelines.yml
11+
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
1212
LICENSE = LICENSE
13+
.github\workflows\nuget.yml = .github\workflows\nuget.yml
1314
PII_QA.md = PII_QA.md
1415
README.md = README.md
1516
EndProjectSection

Source/FikaAmazonAPI.SampleCode/FeedsSample.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ public async Task SubmitFeedPRICING_JSONAsync(string SKU, decimal PRICE, decimal
200200
msg.MaximumSellerAllowedPrice = new StandardPrice()
201201
{
202202
currency = amazonConnection.GetCurrentMarketplace.CurrencyCode.ToString(),
203-
Value = decimal.Round(maxPrice.Value, 2)
203+
Value = decimal.Round(maxPrice.Value, 2),
204+
start_at = "2024-01-01",
205+
end_at = "2025-01-01"
204206
};
205207
}
206208

@@ -209,7 +211,9 @@ public async Task SubmitFeedPRICING_JSONAsync(string SKU, decimal PRICE, decimal
209211
msg.MinimumSellerAllowedPrice = new StandardPrice()
210212
{
211213
currency = amazonConnection.GetCurrentMarketplace.CurrencyCode.ToString(),
212-
Value = decimal.Round(minPrice.Value, 2)
214+
Value = decimal.Round(minPrice.Value, 2),
215+
start_at = "2024-01-01",
216+
end_at = "2025-01-01"
213217
};
214218
}
215219

@@ -226,6 +230,29 @@ public async Task SubmitFeedPRICING_JSONAsync(string SKU, decimal PRICE, decimal
226230

227231
}
228232

233+
public async Task SubmitInventoryJSON_Async(string SKU, int quantity, DateTime? restockDate = null)
234+
{
235+
ConstructJSONFeedService createDocument = new ConstructJSONFeedService(amazonConnection.GetCurrentSellerID);
236+
237+
var list = new List<InventoryMessage>();
238+
var msg = new InventoryMessage()
239+
{
240+
SKU = SKU,
241+
Quantity = quantity,
242+
RestockDate = restockDate
243+
};
244+
245+
list.Add(msg);
246+
createDocument.AddInventoryMessage(list);
247+
248+
var jsonString = createDocument.GetJSON();
249+
250+
string feedID = await amazonConnection.Feed.SubmitFeedAsync(jsonString, FeedType.JSON_LISTINGS_FEED, null, null, ContentType.JSON);
251+
252+
await GetJsonFeedDetails(feedID);
253+
254+
}
255+
229256
public async Task SubmitFeedPricingWithSalePrice(string sku, decimal price, decimal salePrice, DateTime startDate, DateTime endDate)
230257
{
231258
var currencyCode = amazonConnection.GetCurrentMarketplace.CurrencyCode.ToString();

Source/FikaAmazonAPI.SampleCode/Program.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ static async Task Main(string[] args)
2525
IsDebugMode = true
2626
}, loggerFactory: factory);
2727

28+
29+
30+
//var list = amazonConnection.Seller.GetMarketplaceParticipations();
31+
32+
2833
FeedsSample feedsSample = new FeedsSample(amazonConnection);
29-
_ = feedsSample.SubmitFeedPRICING_JSONAsync("B087YHP3HQ.151", 131.77M, 67.70M, 131.77M);
34+
feedsSample.SubmitFeedPRICING_JSONAsync("B09H73T814.259", 112.0M, 53.51M, 112.20M).GetAwaiter().GetResult();
3035

3136

3237
Console.ReadLine();

Source/FikaAmazonAPI/ConstructFeed/ConstructJSONFeedService.cs

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,54 @@ public void AddPriceMessage(IList<PriceMessage> messages)
3030
currency = itm.StandardPrice.currency,
3131
our_price = new List<PriceData>()
3232
{
33-
new PriceData(){ schedule = new List<SchedulePriceData>(){ new SchedulePriceData() { value_with_tax= itm.StandardPrice.Value } } }
33+
new PriceData()
34+
{
35+
schedule = new List<SchedulePriceData>()
36+
{
37+
new SchedulePriceData()
38+
{
39+
value_with_tax= itm.StandardPrice.Value
40+
}
41+
}
42+
}
3443
},
3544
};
3645

3746
if (itm.MinimumSellerAllowedPrice != null)
3847
{
39-
patcheValueData.minimum_seller_allowed_price = new List<PriceData>()
48+
patcheValueData.minimum_seller_allowed_price = new List<PriceData>
4049
{
41-
new PriceData(){ schedule = new List<SchedulePriceData>(){ new SchedulePriceData() { value_with_tax= itm.MinimumSellerAllowedPrice.Value } } }
50+
new PriceData
51+
{
52+
schedule = new List<SchedulePriceData>
53+
{
54+
new SchedulePriceData
55+
{
56+
value_with_tax = itm.MinimumSellerAllowedPrice.Value,
57+
start_at = itm.MinimumSellerAllowedPrice.start_at,
58+
end_at = itm.MinimumSellerAllowedPrice.end_at
59+
}
60+
}
61+
}
4262
};
4363
}
4464

4565
if (itm.MaximumSellerAllowedPrice != null)
4666
{
47-
patcheValueData.maximum_seller_allowed_price = new List<PriceData>()
67+
patcheValueData.maximum_seller_allowed_price = new List<PriceData>
4868
{
49-
new PriceData(){ schedule = new List<SchedulePriceData>(){ new SchedulePriceData() { value_with_tax= itm.MaximumSellerAllowedPrice.Value } } }
69+
new PriceData
70+
{
71+
schedule = new List<SchedulePriceData>
72+
{
73+
new SchedulePriceData
74+
{
75+
value_with_tax = itm.MaximumSellerAllowedPrice.Value,
76+
start_at = itm.MaximumSellerAllowedPrice.start_at,
77+
end_at = itm.MaximumSellerAllowedPrice.end_at
78+
}
79+
}
80+
}
5081
};
5182
}
5283

@@ -70,6 +101,51 @@ public void AddPriceMessage(IList<PriceMessage> messages)
70101
}
71102
}
72103

104+
public void AddInventoryMessage(IList<InventoryMessage> messages)
105+
{
106+
int index = jsonMessagesData.messages.Count;
107+
foreach (var itm in messages)
108+
{
109+
var patcheValueData = new PatcheValueData()
110+
{
111+
fulfillment_channel_code = "DEFAULT"
112+
};
113+
114+
if (itm.QuantitySpecified)
115+
{
116+
patcheValueData.quantity = itm.Quantity;
117+
}
118+
119+
if (itm.FulfillmentLatencySpecified)
120+
{
121+
patcheValueData.lead_time_to_ship_max_days = System.Convert.ToInt32(itm.FulfillmentLatency);
122+
}
123+
124+
if (itm.RestockDateSpecified)
125+
{
126+
patcheValueData.restock_date = itm.RestockDate;
127+
}
128+
129+
var msg = new MessagesData()
130+
{
131+
messageId = ++index,
132+
sku = itm.SKU,
133+
operationType = "PATCH",
134+
productType = "PRODUCT",
135+
patches = new List<PatcheData>{
136+
new PatcheData()
137+
{
138+
op = "replace",
139+
path = "/attributes/fulfillment_availability",
140+
value =new List<PatcheValueData>{ patcheValueData }
141+
}
142+
}
143+
};
144+
145+
jsonMessagesData.messages.Add(msg);
146+
}
147+
}
148+
73149
public string GetJSON()
74150
{
75151
string jsonString = JsonConvert.SerializeObject(jsonMessagesData, Formatting.Indented, new JsonSerializerSettings

Source/FikaAmazonAPI/ConstructFeed/JsonMessages/PatcheValueData.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23

34
namespace FikaAmazonAPI.ConstructFeed.JsonMessages
45
{
@@ -14,5 +15,6 @@ public class PatcheValueData
1415
public IList<PriceData> our_price { get; set; }
1516
public IList<PriceData> minimum_seller_allowed_price { get; set; }
1617
public IList<PriceData> maximum_seller_allowed_price { get; set; }
18+
public DateTime? restock_date { get; set; }
1719
}
1820
}

Source/FikaAmazonAPI/ConstructFeed/JsonMessages/PriceData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ public class PriceData
99
public class SchedulePriceData
1010
{
1111
public decimal value_with_tax { get; set; }
12+
public string start_at { get; set; }
13+
public string end_at { get; set; }
1214
}
1315
}

Source/FikaAmazonAPI/ConstructFeed/Messages/StandardPrice.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ public class StandardPrice
88
public decimal Value { get; set; }
99
[XmlAttribute]
1010
public string currency { get; set; }
11+
public string start_at { get; set; }
12+
public string end_at { get; set; }
1113
}
1214
}

Source/FikaAmazonAPI/FikaAmazonAPI.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<Product>CSharp Amazon Sp API</Product>
88
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
99
<LangVersion>8.0</LangVersion>
10-
<Version>1.8.2</Version>
11-
<AssemblyVersion>1.8.2</AssemblyVersion>
12-
<FileVersion>1.8.2</FileVersion>
10+
<Version>1.8.9</Version>
11+
<AssemblyVersion>1.8.7</AssemblyVersion>
12+
<FileVersion>1.8.7</FileVersion>
1313
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1414
<PackageProjectUrl>https://github.com/abuzuhri/Amazon-SP-API-CSharp</PackageProjectUrl>
1515
<PackageLicenseExpression>MIT</PackageLicenseExpression>

Source/FikaAmazonAPI/Services/RequestService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ protected async Task<T> ExecuteRequestTry<T>(RateLimitType rateLimitType = RateL
123123
CancellationToken cancellationToken = default) where T : new()
124124
{
125125
RestHeader();
126-
await RefreshToken();
127126
AddAccessToken();
128127
AddShippingBusinessId();
129128

0 commit comments

Comments
 (0)