jlevers / selling-partner-api

A PHP client library for Amazon's Selling Partner API
BSD 3-Clause "New" or "Revised" License
398 stars 185 forks source link

createDestination() #572

Closed brm121966 closed 1 year ago

brm121966 commented 1 year ago

Hi, Please write in the documentation ( createDestination() ) an example of filling body values Thanks.

Akanksha-cedcoss commented 1 year ago

While creating destinations, you should use one resource type (sqs or eventBridge) per destination.

This is a sample body of createDestination Api call in case you are using Simple Queue Service (SQS) queue destination.

{
    "resourceSpecification": {
        "sqs": {
            "arn": "ARN associated with the SQS queue"
        }
    },
    "name": "your_custom_name_to_identify_destination"
}

sample arn :- arn:aws:sqs:"sqs-region":XXXXXXXXXXXX:"sqs_queue_name"

This is a sample body of createDestination Api call in case you are using EventBridgeResourceSpecification.

{
    "resourceSpecification": {
        "eventBridge": {
            "region": "AWS region",
            "accountId" : "AWS account identifier"
        }
    },
    "name": "your_custom_name_to_identify_destination"
}

Use this guide to decide which method to use depending on what notification type you are going to subscribe https://developer-docs.amazon.com/sp-api/docs/notifications-api-v1-use-case-guide

brm121966 commented 1 year ago

Thanks for the answer, but you are copying the documentation. Your answer does not apply to this PHP version of the sell-partner-api package. I spent quite a lot of time studying and filling in the parameters, and in the end I got the code.

 $body  = new \SellingPartnerApi\Model\NotificationsV1\CreateDestinationRequest( [
    "name" => "OfferChanged",
    "resource_specification" => new \SellingPartnerApi\Model\NotificationsV1\DestinationResourceSpecification([
        "sqs"  => new \SellingPartnerApi\Model\NotificationsV1\SqsResource([
             "arn" => arn:aws:iam::57xxxxxxxx35:user/bxxxxxxx@gmail.com
        ])
        ,"event_bridge" => new \SellingPartnerApi\Model\NotificationsV1\EventBridgeResourceSpecification([
             "region" => us-east-1
            ,"account_id" => '57xxxxxxxx35'                                     
        ])                  
    ])
])

Destination Created in a sandbox. getDestinations answered about the Destination created. But deleteDestination doesn't delete.

brm121966 commented 1 year ago

@Akanksha-cedcoss Can you tell me where to get "sqs_queue_name"? Thanks.

brm121966 commented 1 year ago

The destination created by MWS is currently running.

Change parameters:
"name" => "ReportsQueue", arn => arn:aws:sqs:us-east-1:57xxxxxxxx35:Reports

 $body  = new \SellingPartnerApi\Model\NotificationsV1\CreateDestinationRequest( [
    "name" => "ReportsQueue",
    "resource_specification" => new \SellingPartnerApi\Model\NotificationsV1\DestinationResourceSpecification([
        "sqs"  => new \SellingPartnerApi\Model\NotificationsV1\SqsResource([
             "arn" => arn:aws:sqs:us-east-1:57xxxxxxxx35:Reports
        ])
        ,"event_bridge" => new \SellingPartnerApi\Model\NotificationsV1\EventBridgeResourceSpecification([
             "region" => us-east-1
            ,"account_id" => '57xxxxxxxx35'                                     
        ])                  
    ])
])

Code an error in the response product.

[payload] => 
[errors] => Array
        (
            [0] => SellingPartnerApi\Model\NotificationsV1\Error Object
                 (
                       [container:protected] => Array
                               (
                                     [code] => InvalidInput
                                      [message] => Invalid input.
                                      [details] => A destination cannot be created with multiple resource types
                                )
                   )
       )

Does anyone know a solution?

brm121966 commented 1 year ago

I'm found a solution https://github.com/jlevers/selling-partner-api/issues/291