<?php

namespace Tops\AmazonSellingPartnerAPI\Api;

class NotificationApi extends BaseApi
{
    /**
     * Operation Get Subscription
     *
     * @param string $notification_type  The type of notification to which you want to subscribe. (required)
     *
     * @return json  Returns information about subscriptions of the specified notification type.
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * About more Ref:- https://github.com/amzn/selling-partner-api-docs/blob/main/references/notifications-api/notifications.md#getsubscription
     */
    public function getSubscription($notification_type)
    {
        if (null === $notification_type) {
            throw new \InvalidArgumentException('Missing the required parameter $notification_type when calling getOrderItemsBuyerInfo');
        }

        $resource_path = '/notifications/v1/subscriptions/{notificationType}';
        $http_body = '';
        $query_params = [];
        $method = 'GET';
      
        // path params
        if (null !== $notification_type) {
            $resource_path = str_replace(
                '{' . 'notificationType' . '}',
                rawurlencode($notification_type),
                $resource_path
            );
        }
        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);
        
        $url = $this->config->getHost() . $resource_path;

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }
    /**
     * Operation Create Subscription
     *
     * @param array $body The request schema for the createSubscription operation. (required)
     * @param string $notification_type The type of notification to which you want to subscribe. (required)
     *
     * @return json
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * About more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/notifications-api/notifications.md#createsubscription
     */
    public function createSubscription($body, $notification_type)
    {
        if (null === $body) {
            throw new \InvalidArgumentException('Missing the required parameter $body when calling getOrderItemsBuyerInfo');
        }
        if (null === $notification_type) {
            throw new \InvalidArgumentException('Missing the required parameter $notification_type when calling getOrderItemsBuyerInfo');
        }

        $resource_path = '/notifications/v1/subscriptions/{notificationType}';
        $http_body = $body;
        $query_params = [];
        $method = 'POST';
      
        // path params
        if (null !== $notification_type) {
            $resource_path = str_replace(
                '{' . 'notificationType' . '}',
                $notification_type,
                $resource_path
            );
        }

        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);
        
        $url = $this->config->getHost() . $resource_path;

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }
    /**
     * Operation Get Subscription By Id
     *
     * @param string $subscription_id The identifier for the subscription that you want to get. (required)
     * @param enum $notification_type The type of notification to which you want to subscribe. (required)
     *
     * @return json Returns information about a subscription for the specified notification type.
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * About more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/notifications-api/notifications.md#getsubscriptionbyid
     */
    public function getSubscriptionById($subscription_id, $notification_type)
    {
        if (null === $subscription_id) {
            throw new \InvalidArgumentException('Missing the required parameter $subscription_id when calling getOrderItemsBuyerInfo');
        }
        if (null === $notification_type) {
            throw new \InvalidArgumentException('Missing the required parameter $notification_type when calling getOrderItemsBuyerInfo');
        }

        $resource_path = '/notifications/v1/subscriptions/{notificationType}/{subscriptionId}';
        $http_body = '';
        $query_params = [];
        $method = 'GET';
      
        // path params
        if (null !== $notification_type) {
            $resource_path = str_replace(
                '{' . 'notificationType' . '}',
                $notification_type,
                $resource_path
            );
        }
        if (null !== $subscription_id) {
            $resource_path = str_replace(
                '{' . 'subscriptionId' . '}',
                $subscription_id,
                $resource_path
            );
        }
        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);
        
        $url = $this->config->getHost() . $resource_path;

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }
    /**
     * Operation Delete Subscription By Id
     *
     * @param string $subscription_id The identifier for the subscription that you want to delete. (required)
     * @param enum $notification_type The type of notification to which you want to subscribe. (required)
     *
     * @return json Returns the Small and Light enrollment status for the item indicated by the specified seller SKU in the specified marketplace.
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * About more Ref:- https://github.com/amzn/selling-partner-api-docs/blob/main/references/notifications-api/notifications.md#deletesubscriptionbyid
     */
    public function deleteSubscriptionById($subscription_id, $notification_type)
    {
        if (null === $subscription_id) {
            throw new \InvalidArgumentException('Missing the required parameter $subscription_id when calling getOrderItemsBuyerInfo');
        }
        if (null === $notification_type) {
            throw new \InvalidArgumentException('Missing the required parameter $notification_type when calling getOrderItemsBuyerInfo');
        }

        $resource_path = '/notifications/v1/subscriptions/{notificationType}/{subscriptionId}';
        $http_body = '';
        $query_params = [];
        $method = 'DELETE';

        // path params
        if (null !== $notification_type) {
            $resource_path = str_replace(
                '{' . 'notificationType' . '}',
                rawurlencode($notification_type),
                $resource_path
            );
        }
        if (null !== $subscription_id) {
            $resource_path = str_replace(
                '{' . 'subscriptionId' . '}',
                rawurlencode($subscription_id),
                $resource_path
            );
        }
        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);
        
        $url = $this->config->getHost() . $resource_path;

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }

    /**
    * Operation Get Destinations
    *
    * @return json Returns information about all destinations.
    *
    * @author Chetan Meena <chetan@topsinfosolutions.com>
    *
    * About more Ref:- https://github.com/amzn/selling-partner-api-docs/blob/main/references/notifications-api/notifications.md#getdestinations
    */
    public function getDestinations()
    {
        $resource_path = '/notifications/v1/destinations';
        $http_body = '';
        $query_params = [];
        $method = 'GET';
      
        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);
        
        $url = $this->config->getHost() . $resource_path;

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }
    /**
    * Operation Create Destinations
    *
    * @param array $body The request schema for the createDestination operation. (required)
    * @return json
    *
    * @author Chetan Meena <chetan@topsinfosolutions.com>
    *
    * About more Ref:- https://github.com/amzn/selling-partner-api-docs/blob/main/references/notifications-api/notifications.md#createdestination
    */
    public function createDestination($body)
    {
        if (null === $body) {
            throw new \InvalidArgumentException('Missing the required parameter $body when calling getOrderItemsBuyerInfo');
        }

        $resource_path = '/notifications/v1/destinations';
        $http_body = $body;
        $query_params = [];
        $method = 'POST';
        
        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);
        
        $url = $this->config->getHost() . $resource_path;

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }
   
    /**
     * Operation Get Destination
     *
     * @param $destination_id The identifier generated when you created the destination. (required)
     * @return json Returns information about the destination that you specify..
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * About more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/notifications-api/notifications.md#getdestination
     */
    public function getDestination($destination_id)
    {
        if (null === $destination_id) {
            throw new \InvalidArgumentException('Missing the required parameter $destination_id when calling getOrderItemsBuyerInfo');
        }
        $resource_path = '/notifications/v1/destinations/{destinationId}';
        $http_body = '';
        $query_params = [];
        $method = 'GET';

        // path params
        if (null !== $destination_id) {
            $resource_path = str_replace(
                '{' . 'destinationId' . '}',
                $destination_id,
                $resource_path
            );
        }
      
        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);
        
        $url = $this->config->getHost() . $resource_path;

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }
    /**
     * Operation Delete Destination
     *
     * @param $destination_id The identifier for the destination that you want to delete. (required)
     * @return json
     *
     * @author Chetan Meena <chetan@topsinfosolutions.com>
     *
     * About more Ref: https://github.com/amzn/selling-partner-api-docs/blob/main/references/notifications-api/notifications.md#deletedestination
     */
    public function deleteDestination($destination_id)
    {
        if (null === $destination_id) {
            throw new \InvalidArgumentException('Missing the required parameter $destination_id when calling getOrderItemsBuyerInfo');
        }

        $resource_path = '/notifications/v1/destinations/{destinationId}';
        $http_body = '';
        $query_params = [];
        $method = 'DELETE';
      
        // path params
        if (null !== $destination_id) {
            $resource_path = str_replace(
                '{' . 'destinationId' . '}',
                $destination_id,
                $resource_path
            );
        }
        $curl_headers = $this->generateRequest($resource_path, $query_params, $http_body, $this->config, $method);
        
        $url = $this->config->getHost() . $resource_path;

        return $this->sendRequest($url, $query_params, $http_body, $curl_headers, $method);
    }
}
