Skip to content

Commit 0c654d9

Browse files
committed
change to v1.9.23
1 parent 8081cf1 commit 0c654d9

4 files changed

Lines changed: 52 additions & 12 deletions

File tree

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ while (!cts.Token.IsCancellationRequested)
434434
{
435435
try
436436
{
437-
await amazonConnection.Notification.StartReceivingNotificationMessagesAsync(
437+
// Static method — no instance needed
438+
await NotificationService.StartReceivingNotificationMessagesAsync(
438439
param, messageReceiver, cancellationToken: cts.Token);
439440
}
440441
catch (OperationCanceledException) when (cts.Token.IsCancellationRequested)
@@ -481,6 +482,45 @@ public class CustomMessageReceiver : IMessageReceiver
481482
482483
```
483484
485+
### Notifications — End-to-End SQS Setup
486+
Complete workflow following the [Amazon SQS notification setup guide](https://developer-docs.amazon.com/sp-api/docs/set-up-notifications-with-amazon-sqs). Before running this code, grant SP-API permission to write to your SQS queue in the AWS Console.
487+
```CSharp
488+
489+
// Step 3: Create a destination (grantless operation — no seller authorization needed)
490+
var destination = amazonConnection.Notification.CreateDestination(
491+
new Notifications.CreateDestinationRequest()
492+
{
493+
Name = "CompanyName_SQS",
494+
ResourceSpecification = new Notifications.DestinationResourceSpecification
495+
{
496+
Sqs = new Notifications.SqsResource("arn:aws:sqs:us-east-2:9999999999999:NAME")
497+
}
498+
});
499+
500+
// Step 4: Create a subscription using the destinationId from Step 3
501+
// processingDirective is optional — only supported for ANY_OFFER_CHANGED and ORDER_CHANGE
502+
var subscription = amazonConnection.Notification.CreateSubscription(
503+
new ParameterCreateSubscription()
504+
{
505+
destinationId = destination.DestinationId,
506+
notificationType = NotificationType.ANY_OFFER_CHANGED,
507+
payloadVersion = "1.0",
508+
processingDirective = new Notifications.ProcessingDirective
509+
{
510+
EventFilter = new Notifications.EventFilter
511+
{
512+
EventFilterType = "ANY_OFFER_CHANGED",
513+
MarketplaceIds = new List<string> { "ATVPDKIKX0DER" },
514+
AggregationSettings = new Notifications.AggregationSettings
515+
{
516+
AggregationTimePeriod = Notifications.AggregationTimePeriod.FiveMinutes
517+
}
518+
}
519+
}
520+
});
521+
522+
```
523+
484524
### Feed Submit
485525
Here is a full sample for submitting a feed to change price, generate XML, and get the final processing report, same as in the [documentation](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).
486526

Source/FikaAmazonAPI.SampleCode/NotificationsSample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public async Task StartReceivingNotificationMessagesAsync(CancellationToken canc
199199
{
200200
try
201201
{
202-
await amazonConnection.Notification.StartReceivingNotificationMessagesAsync(
202+
await FikaAmazonAPI.Services.NotificationService.StartReceivingNotificationMessagesAsync(
203203
param, messageReceiver, cancellationToken: cancellationToken);
204204
}
205205
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)

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.9.22</Version>
11-
<AssemblyVersion>1.9.22</AssemblyVersion>
12-
<FileVersion>1.9.22</FileVersion>
10+
<Version>1.9.23</Version>
11+
<AssemblyVersion>1.9.23</AssemblyVersion>
12+
<FileVersion>1.9.23</FileVersion>
1313
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1414
<PackageProjectUrl>https://github.com/abuzuhri/Amazon-SP-API-CSharp</PackageProjectUrl>
1515
<PackageLicenseExpression>MIT</PackageLicenseExpression>

Source/FikaAmazonAPI/Services/NotificationService.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,18 @@ public async Task<bool> DeleteSubscriptionByIdAsync(NotificationType notificatio
115115
return true;
116116
}
117117

118-
public void StartReceivingNotificationMessages(ParameterMessageReceiver param, IMessageReceiver messageReceiver, bool isDeleteNotificationAfterRead = true) =>
118+
public static void StartReceivingNotificationMessages(ParameterMessageReceiver param, IMessageReceiver messageReceiver, bool isDeleteNotificationAfterRead = true) =>
119119
Task.Run(() => StartReceivingNotificationMessagesAsync(param, messageReceiver, isDeleteNotificationAfterRead)).ConfigureAwait(false).GetAwaiter().GetResult();
120120

121-
public void StartReceivingNotificationMessages(ParameterMessageReceiver param, IMessageReceiverWithResult messageReceiver, bool isDeleteNotificationAfterRead = false) =>
121+
public static void StartReceivingNotificationMessages(ParameterMessageReceiver param, IMessageReceiverWithResult messageReceiver, bool isDeleteNotificationAfterRead = false) =>
122122
Task.Run(() => StartReceivingNotificationMessagesAsync(param, messageReceiver, isDeleteNotificationAfterRead)).ConfigureAwait(false).GetAwaiter().GetResult();
123123

124-
public Task StartReceivingNotificationMessagesAsync(ParameterMessageReceiver param, IMessageReceiver messageReceiver, bool isDeleteNotificationAfterRead = true, CancellationToken cancellationToken = default)
124+
public static Task StartReceivingNotificationMessagesAsync(ParameterMessageReceiver param, IMessageReceiver messageReceiver, bool isDeleteNotificationAfterRead = true, CancellationToken cancellationToken = default)
125125
{
126126
return StartReceivingNotificationMessagesAsync(param, new MessageReceiverAdapter(messageReceiver), isDeleteNotificationAfterRead, cancellationToken);
127127
}
128128

129-
public async Task StartReceivingNotificationMessagesAsync(ParameterMessageReceiver param, IMessageReceiverWithResult messageReceiver, bool isDeleteNotificationAfterRead = false, CancellationToken cancellationToken = default)
129+
public static async Task StartReceivingNotificationMessagesAsync(ParameterMessageReceiver param, IMessageReceiverWithResult messageReceiver, bool isDeleteNotificationAfterRead = false, CancellationToken cancellationToken = default)
130130
{
131131
var awsAccessKeyId = param.awsAccessKeyId;
132132
var awsSecretAccessKey = param.awsSecretAccessKey;
@@ -165,7 +165,7 @@ public async Task StartReceivingNotificationMessagesAsync(ParameterMessageReceiv
165165
}
166166
}
167167

168-
private async Task ProcessAnyOfferChangedMessage(Message msg, IMessageReceiverWithResult messageReceiver, AmazonSQSClient amazonSQSClient, string SQS_URL, bool isDeleteNotificationAfterRead = true, CancellationToken cancellationToken = default)
168+
private static async Task ProcessAnyOfferChangedMessage(Message msg, IMessageReceiverWithResult messageReceiver, AmazonSQSClient amazonSQSClient, string SQS_URL, bool isDeleteNotificationAfterRead = true, CancellationToken cancellationToken = default)
169169
{
170170
var deleteMessage = isDeleteNotificationAfterRead;
171171
try
@@ -185,12 +185,12 @@ private async Task ProcessAnyOfferChangedMessage(Message msg, IMessageReceiverWi
185185
await DeleteMessageFromQueueAsync(amazonSQSClient, SQS_URL, msg.ReceiptHandle, cancellationToken);
186186
}
187187
}
188-
private async Task DeleteMessageFromQueueAsync(AmazonSQSClient sqsClient, string QueueUrl, string ReceiptHandle, CancellationToken cancellationToken = default)
188+
private static async Task DeleteMessageFromQueueAsync(AmazonSQSClient sqsClient, string QueueUrl, string ReceiptHandle, CancellationToken cancellationToken = default)
189189
{
190190
var deleteMessageRequest = new DeleteMessageRequest() { QueueUrl = QueueUrl, ReceiptHandle = ReceiptHandle };
191191
_ = await sqsClient.DeleteMessageAsync(deleteMessageRequest, cancellationToken);
192192
}
193-
private NotificationMessageResponce DeserializeNotification(Message message)
193+
private static NotificationMessageResponce DeserializeNotification(Message message)
194194
{
195195

196196
NotificationMessageResponce notification;

0 commit comments

Comments
 (0)