Created
March 22, 2023 16:08
set SQS destination. MWS is dead, but spapi likely uses a similar pattern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
business = Business.find(1) | |
client = business.mws | |
subscriptions = client.subscriptions.list_subscriptions(VDBMWS::SELLER_MARKETPLACE_US).parse.dig("SubscriptionList", "member") | |
subscriptions.pretty | |
subscriptions.each do |sub| | |
sqs_queue_url = sub.dig("Destination", "AttributeList", "member", "Value") | |
notif_type = sub.dig('NotificationType') | |
Rails.logger.info("client.subscriptions.delete_subscription(#{notif_type}, #{sqs_queue_url}, #{VDBMWS::SELLER_MARKETPLACE_US})") | |
puts client.subscriptions.delete_subscription(notif_type, sqs_queue_url, VDBMWS::SELLER_MARKETPLACE_US).parse | |
sleep(3) | |
end | |
destinations = client.subscriptions.list_registered_destinations(VDBMWS::SELLER_MARKETPLACE_US).parse.dig("DestinationList", "member") | |
destinations.each do |dest| | |
sqs_queue_url = dest.dig("AttributeList", "member", "Value") | |
puts client.subscriptions.deregister_destination(sqs_queue_url, VDBMWS::SELLER_MARKETPLACE_US).parse | |
end | |
# sqs_url = client.subscriptions.list_registered_destinations(VDBMWS::SELLER_MARKETPLACE_US).parse.dig("DestinationList", "member", "AttributeList", "member", "Value") | |
# if sqs_url == ENV.fetch("AWS_SQS_QUEUE_URL") | |
# end | |
# | |
# test = MWS.subscriptions.send_test_notification_to_destination(ENV.fetch("AWS_SQS_QUEUE_URL"), VDBMWS::SELLER_MARKETPLACE_US).parse | |
# registered = MWS.subscriptions.register_destination(ENV.fetch("AWS_SQS_QUEUE_URL"), VDBMWS::SELLER_MARKETPLACE_US).parse | |
# | |
# sub = MWS.subscriptions.list_subscriptions(VDBMWS::SELLER_MARKETPLACE_US).parse.dig("SubscriptionList", "member") | |
# # sub = { | |
# # "Destination" => { | |
# # "DeliveryChannel" => "SQS", | |
# # "AttributeList" => {"member" => {"Value" => "https://sqs.us-east-1.amazonaws.com/946359194286/vdb-any-offer-change", "Key" => "sqsQueueUrl"}} | |
# # }, | |
# # "NotificationType" => "AnyOfferChanged", | |
# # "IsEnabled" => "true" | |
# # } | |
# | |
# | |
# any_offer = MWS.subscriptions.create_subscription("AnyOfferChanged", ENV.fetch("AWS_SQS_QUEUE_URL"), VDBMWS::SELLER_MARKETPLACE_US) | |
# | |
# | |
# if destinations.empty? | |
# else | |
# end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment