Ejemplo n.º 1
0
    def get_product_fees_estimate_for_sku(self,
                                          seller_sku,
                                          price: float,
                                          shipping_price=None,
                                          currency='USD',
                                          is_fba=False,
                                          points: dict = None,
                                          **kwargs) -> ApiResponse:
        """
        get_product_fees_estimate_for_sku(self, seller_sku, price: float, shipping_price=None, currency='USD', is_fba=False, points: dict = dict, **kwargs) -> ApiResponse

        Returns fees for sku

        Args:
            seller_sku:
            price:
            shipping_price:
            currency:
            is_fba:
            points:
            **kwargs:

        Returns:
            ApiResponse:

        """
        kwargs.update(
            self._create_body(price, shipping_price, currency, is_fba,
                              seller_sku, points))
        return self._request(fill_query_params(kwargs.pop('path'), seller_sku),
                             data=kwargs)
Ejemplo n.º 2
0
    def create_subscription(self,
                            notification_type: NotificationType or str,
                            destination_id: str = None,
                            **kwargs):
        """
        Creates a subscription for the specified notification type to be delivered to the specified destination.
        Before you can subscribe, you must first create the destination by calling the createDestination operation.

        **Usage Plan:**

        | Rate (requests per second) | Burst |
        | ---- | ---- |
        | 1 | 5 |

        For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.

        :param destination_id: str
        :param notification_type: str
        :param kwargs:
        :return:
        """
        data = {
            'destinationId': kwargs.pop('destinationId', destination_id),
            'payloadVersion': kwargs.pop('payload_version', '1.0')
        }
        return CreateSubscriptionResponse(**self._request(fill_query_params(
            kwargs.pop('path'), notification_type if isinstance(
                notification_type, str) else notification_type.value),
                                                          data={
                                                              **kwargs,
                                                              **data
                                                          }).json())
Ejemplo n.º 3
0
    def delete_notification_subscription(self,
                                         notification_type: NotificationType
                                         or str, subscription_id: str,
                                         **kwargs) -> ApiResponse:
        """
        delete_notification_subscription(self, notification_type: NotificationType or str, subscription_id: str, **kwargs) -> ApiResponse
        Deletes the subscription indicated by the subscription identifier and notification type that you specify.
        The subscription identifier can be for any subscription associated with your application. After you successfully call this operation, notifications will stop being sent for the associated subscription. The deleteSubscriptionById API is grantless. For more information, see "Grantless operations" in the Selling Partner API Developer Guide.

        **Usage Plan:**

        ======================================  ==============
        Rate (requests per second)               Burst
        ======================================  ==============
        1                                       5
        ======================================  ==============

        For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.

        Args:
            notification_type: NotificationType or str
            subscription_id: str
            **kwargs:

        Returns:
            ApiResponse:

        """
        return self._request(fill_query_params(
            kwargs.pop('path'), notification_type if isinstance(
                notification_type, str) else notification_type.value,
            subscription_id),
                             params={**kwargs})
Ejemplo n.º 4
0
    def delete_destination(self, destination_id: str, **kwargs) -> ApiResponse:
        """
        delete_destination(self, destination_id: str, **kwargs) -> ApiResponse
        Deletes the destination that you specify. The deleteDestination API is grantless. For more information, see "Grantless operations" in the Selling Partner API Developer Guide.

        **Usage Plan:**

        ======================================  ==============
        Rate (requests per second)               Burst
        ======================================  ==============
        1                                       5
        ======================================  ==============

        For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.

        Args:
            destination_id: str
            **kwargs:

        Returns:
            ApiResponse:

        """
        return self._request_grantless_operation(fill_query_params(
            kwargs.pop('path'), destination_id),
                                                 params={**kwargs})
Ejemplo n.º 5
0
    def get_subscription(self, notification_type: NotificationType or str, **kwargs) -> GetSubscriptionResponse:
        """
        get_subscription(self, notification_type: NotificationType or str, **kwargs) -> GetSubscriptionResponse
        Returns information about subscriptions of the specified notification type. You can use this API to get subscription information when you do not have a subscription identifier.

        **Usage Plan:**

        ======================================  ==============
        Rate (requests per second)               Burst
        ======================================  ==============
        1                                       5
        ======================================  ==============

        For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.


        Args:
            notification_type: NotificationType or str
            **kwargs:

        Returns:
            GetSubscriptionResponse:

        """
        return GetSubscriptionResponse(
            **self._request(fill_query_params(kwargs.pop('path'), notification_type if isinstance(notification_type, str) else notification_type.value),
                                                params={**kwargs}).json()
        )
Ejemplo n.º 6
0
    def get_destination(self, destination_id: str, **kwargs) -> GetDestinationResponse:
        """
        get_destination(self, destination_id: str, **kwargs) -> GetDestinationResponse
        Returns information about all destinations. The getDestinations API is grantless. For more information, see "Grantless operations" in the Selling Partner API Developer Guide.

        **Usage Plan:**

        ======================================  ==============
        Rate (requests per second)               Burst
        ======================================  ==============
        1                                       5
        ======================================  ==============

        For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.


        Args:
            destination_id: str
            **kwargs:

        Returns:
            GetDestinationResponse:


        """
        return GetDestinationResponse(
            **self._request_grantless_operation(fill_query_params(kwargs.pop('path'), destination_id),
                                                params={**kwargs}).json()
        )
Ejemplo n.º 7
0
    def delete_notification_subscription(self, notification_type,
                                         subscription_id, **kwargs):
        """
        Deletes the subscription indicated by the subscription identifier and notification type that you specify.
        The subscription identifier can be for any subscription associated with your application. After you successfully call this operation, notifications will stop being sent for the associated subscription. The deleteSubscriptionById API is grantless. For more information, see "Grantless operations" in the Selling Partner API Developer Guide.

        **Usage Plan:**

        | Rate (requests per second) | Burst |
        | ---- | ---- |
        | 1 | 5 |

        For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
        :param notification_type:
        :param subscription_id:
        :param kwargs:
        :return:
        """
        return DeleteSubscriptionByIdResponse(
            **self._request(fill_query_params(
                kwargs.pop('path'), notification_type if isinstance(
                    notification_type, str) else notification_type.value,
                subscription_id),
                            params={
                                **kwargs
                            }).json())
Ejemplo n.º 8
0
    def get_subscription(self, notification_type: NotificationType or str,
                         **kwargs) -> ApiResponse:
        """
        get_subscription(self, notification_type: NotificationType or str, **kwargs) -> ApiResponse
        Returns information about subscriptions of the specified notification type. You can use this API to get subscription information when you do not have a subscription identifier.

        **Usage Plan:**

        ======================================  ==============
        Rate (requests per second)               Burst
        ======================================  ==============
        1                                       5
        ======================================  ==============

        For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.

        Examples:
            literal blocks::

                Notifications().get_subscription(NotificationType.REPORT_PROCESSING_FINISHED)

        Args:
            notification_type: NotificationType or str
            **kwargs:

        Returns:
            ApiResponse:

        """
        return self._request(fill_query_params(
            kwargs.pop('path'), notification_type if isinstance(
                notification_type, str) else notification_type.value),
                             params={**kwargs})
Ejemplo n.º 9
0
 def upload_document(self, resource, file, content_type='application/pdf', **kwargs):
     md5 = create_md5(file)
     kwargs.update({
         'contentMD5': md5,
         'contentType': kwargs.pop('contentType', content_type),
         'marketplaceIds': self.marketplace_id
     })
     return self._request(fill_query_params(kwargs.pop('path'), resource), params=kwargs)
 def get_product_fees_estimate_for_asin(self,
                                        asin,
                                        price: float,
                                        currency='USD',
                                        shipping_price=None,
                                        is_fba=False,
                                        points: dict = dict,
                                        **kwargs):
     kwargs.update(
         self._create_body(price, shipping_price, currency, is_fba, asin,
                           points))
     return GetMyFeesEstimateResponse(**self._request(
         fill_query_params(kwargs.pop('path'), asin), data=kwargs).json())
Ejemplo n.º 11
0
    def create_subscription(self,
                            notification_type: NotificationType or str,
                            destination_id: str = None,
                            **kwargs) -> ApiResponse:
        """
        create_subscription(self, notification_type: NotificationType or str, destination_id: str = None, **kwargs) -> ApiResponse
        Creates a subscription for the specified notification type to be delivered to the specified destination.
        Before you can subscribe, you must first create the destination by calling the createDestination operation.

        **Usage Plan:**

        ======================================  ==============
        Rate (requests per second)               Burst
        ======================================  ==============
        1                                       5
        ======================================  ==============

        For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.

        Examples:
            literal blocks::

                Notifications().create_subscription(NotificationType.MFN_ORDER_STATUS_CHANGE, destination_id='dest_id')

        Args:
            notification_type: NotificationType or str
            destination_id: str
            **kwargs:


        Returns:
            ApiResponse:

        """
        data = {
            'destinationId': kwargs.pop('destinationId', destination_id),
            'payloadVersion': kwargs.pop('payload_version', '1.0')
        }
        return self._request(fill_query_params(
            kwargs.pop('path'), notification_type if isinstance(
                notification_type, str) else notification_type.value),
                             data={
                                 **kwargs,
                                 **data
                             })
Ejemplo n.º 12
0
    def get_product_fees_estimate_for_sku(self,
                                          seller_sku,
                                          price: float,
                                          shipping_price=None,
                                          currency='USD',
                                          is_fba=False,
                                          points: dict = None,
                                          marketplace_id: str = None,
                                          **kwargs) -> ApiResponse:
        """
        get_product_fees_estimate_for_sku(self, seller_sku, price: float, shipping_price=None, currency='USD', is_fba=False, points: dict = dict, **kwargs) -> ApiResponse

        Returns fees for sku

        Examples:
            literal blocks::

                ProductFees().get_product_fees_estimate_for_sku("UmaS1", 10, currency='USD', shipping_price=10, is_fba=False,
                                                          points={
                                                              "PointsNumber": 0,
                                                              "PointsMonetaryValue": {
                                                                  "CurrencyCode": "USD",
                                                                  "Amount": 0
                                                              }
                                                          })

        Args:
            seller_sku:
            price:
            shipping_price:
            currency:
            is_fba:
            points:
            marketplace_id: str | Defaults to self.marketplace_id
            **kwargs:

        Returns:
            ApiResponse:

        """
        kwargs.update(
            self._create_body(price, shipping_price, currency, is_fba,
                              seller_sku, points, marketplace_id))
        return self._request(fill_query_params(kwargs.pop('path'), seller_sku),
                             data=kwargs)
Ejemplo n.º 13
0
    def get_product_fees_estimate_for_sku(self, seller_sku, price: float, shipping_price=None, currency='USD',
                                          is_fba=False, points: dict = None, marketplace_id: str = None,
                                          optional_fulfillment_program: str = None, force_safe_sku: bool = True,
                                          **kwargs) -> ApiResponse:
        """
        get_product_fees_estimate_for_sku(self, seller_sku, price: float, shipping_price=None, currency='USD', is_fba=False, points: dict = dict, **kwargs) -> ApiResponse

        Returns fees for sku

        Examples:
            literal blocks::

                ProductFees().get_product_fees_estimate_for_sku("UmaS1", 10, currency='USD', shipping_price=10, is_fba=False,
                                                          points={
                                                              "PointsNumber": 0,
                                                              "PointsMonetaryValue": {
                                                                  "CurrencyCode": "USD",
                                                                  "Amount": 0
                                                              }
                                                          })

        Args:
            seller_sku:
            price:
            shipping_price:
            currency:
            is_fba:
            points:
            marketplace_id: str | Defaults to self.marketplace_id
            optional_fulfillment_program:
            force_safe_sku: bool | Force user SKU quote
            **kwargs:

        Returns:
            ApiResponse:

        """

        if force_safe_sku:
            #handle `forward slash` issue in SKU
            seller_sku = quote_plus(seller_sku)

        kwargs.update(self._create_body(price, shipping_price, currency, is_fba, seller_sku, points, marketplace_id, optional_fulfillment_program))
        return self._request(fill_query_params(kwargs.pop('path'), seller_sku), data=kwargs)
Ejemplo n.º 14
0
    def get_product_fees_estimate_for_asin(self,
                                           asin,
                                           price: float,
                                           currency='USD',
                                           shipping_price=None,
                                           is_fba=False,
                                           points: dict = None,
                                           **kwargs) -> ApiResponse:
        """
        get_product_fees_estimate_for_asin(self, asin, price: float, currency='USD', shipping_price=None, is_fba=False,  points: dict = dict, **kwargs) -> ApiResponse

        Returns fees for asin

        Examples:
            literal blocks::

                ProductFees().get_product_fees_estimate_for_asin("UmaS1", 10, currency='USD', shipping_price=10, is_fba=False,
                                                           points={
                                                               "PointsNumber": 0,
                                                               "PointsMonetaryValue": {
                                                                   "CurrencyCode": "USD",
                                                                   "Amount": 0
                                                               }
                                                           })

        Args:
            asin:
            price:
            currency:
            shipping_price:
            is_fba:
            points:
            **kwargs:

        Returns:
            ApiResponse:

        """
        kwargs.update(
            self._create_body(price, shipping_price, currency, is_fba, asin,
                              points))
        return self._request(fill_query_params(kwargs.pop('path'), asin),
                             data=kwargs)
Ejemplo n.º 15
0
    def delete_destination(self, destination_id, **kwargs):
        """
        Deletes the destination that you specify. The deleteDestination API is grantless. For more information, see "Grantless operations" in the Selling Partner API Developer Guide.

        **Usage Plan:**

        | Rate (requests per second) | Burst |
        | ---- | ---- |
        | 1 | 5 |

        For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
        :param destination_id:
        :param kwargs:
        :return:
        """
        return DeleteDestinationResponse(**self._request_grantless_operation(
            fill_query_params(kwargs.pop('path'), destination_id),
            params={
                **kwargs
            }).json())
Ejemplo n.º 16
0
    def get_subscription(self, notification_type, **kwargs):
        """
        Returns information about subscriptions of the specified notification type. You can use this API to get subscription information when you do not have a subscription identifier.

        **Usage Plan:**

        | Rate (requests per second) | Burst |
        | ---- | ---- |
        | 1 | 5 |

        For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
        :param notification_type:
        :param kwargs:
        :return:
        """
        return GetSubscriptionResponse(**self._request(fill_query_params(
            kwargs.pop('path'), notification_type if isinstance(
                notification_type, str) else notification_type.value),
                                                       params={
                                                           **kwargs
                                                       }).json())
 def get_product_fees_estimate_for_sku(self, seller_sku, price: float, shipping_price=None, currency='USD',
                                       is_fba=False, **kwargs):
     kwargs.update(self._create_body(price, shipping_price, currency, is_fba))
     return GetMyFeesEstimateResponse(
         **self._request(fill_query_params(kwargs.pop('path'), seller_sku), data=kwargs).json())
Ejemplo n.º 18
0
 def get_tracking(self, tracking_id: str, **kwargs) -> ApiResponse:
     return self._request(fill_query_params(kwargs.pop('path'),
                                            tracking_id),
                          params={**kwargs})