<?php

namespace Tops\AmazonSellingPartnerAPI\Api;

// Version : 2021-06-30
class ReportsApi20210630 extends BaseApi
{
    /**
    * Operation Get Reports
    *
    * @param string|array $params['reportTypes'] A list of report types used to filter reports. When reportTypes is provided, the other filter parameters (processingStatuses, marketplaceIds, createdSince, createdUntil) and pageSize may also be provided. Either reportTypes or nextToken is required. <Min count : 1 and Max count 10>
    * @param string|array $params['processingStatuses'] A list of processing statuses used to filter reports.  <Min count 1>
    * @param string|array $params['marketplaceIds'] A list of marketplace identifiers used to filter reports. The reports returned will match at least one of the marketplaces that you specify <Min count 1 and Max count 100>
    * @param string|array $params['pageSize'] The maximum number of reports to return in a single call. <Min 1 and Max 100>
    * @param string (date-time) $params['createdSince'] The earliest report creation date and time for reports to include in the response, in ISO 8601 date time format. The default is 90 days ago. Reports are retained for a maximum of 90 days.
    * @param string (date-time) $params['createdUntil'] The latest report creation date and time for reports to include in the response, in ISO 8601 date time format. The default is now.
    * @param string $params['nextToken'] A string token returned in the response to your previous request. nextToken is returned when the number of results exceeds the specified pageSize value. To get the next page of results, call the getReports operation and include this token as the only parameter. Specifying nextToken with any other parameters will cause the request to fail.
    *
    *
    * @return json Returns pricing information for a seller's offer listings based on seller SKU or ASIN.
    *
    * @author Manikant Patidar <manikant@topsinfosolutions.com>
    *
    * About more Ref :- https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference
    */
    public function getReports($params)
    {
        $resource_path = '/reports/2021-06-30/reports';

        $http_body = '';
        $query_params = [];
        $method = 'GET';

        // get Querry Params
        if (array_key_exists('reportTypes', $params) && $params['reportTypes'] !== null) {
            $query_params['reportTypes'] = $params['reportTypes'];
        }

        if (array_key_exists('processingStatuses', $params) && $params['processingStatuses'] !== null) {
            $query_params['processingStatuses'] =  $params['processingStatuses'];
        }
        if (array_key_exists('marketplaceIds', $params) && $params['marketplaceIds'] !== null) {
            $query_params['marketplaceIds'] = $params['marketplaceIds'];
        }

        if (array_key_exists('pageSize', $params) && $params['pageSize'] !== null) {
            $query_params['pageSize'] =  $params['pageSize'];
        }
        if (array_key_exists('createdSince', $params) && $params['createdSince'] !== null) {
            $query_params['createdSince'] = $params['createdSince'];
        }

        if (array_key_exists('createdUntil', $params) && $params['createdUntil'] !== null) {
            $query_params['createdUntil'] =  $params['createdUntil'];
        }
        if (array_key_exists('nextToken', $params) && $params['nextToken'] !== null) {
            $query_params['nextToken'] =  $params['nextToken'];
        }

        $url = $this->config->getHost() . $resource_path;

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

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

    /**
     * Operation Create Report
     *
     * @param array $body required
     *
     * @return json
     *
     * @author Manikant Patidar <manikant@topsinfosolutions.com>
     *
     * About more Ref :- https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference#createreport
     */
    public function createReport($body)
    {
        $resource_path = '/reports/2021-06-30/reports';
        $http_body = $body;
        $query_params = [];
        $method = 'POST';

        $url = $this->config->getHost() . $resource_path;

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

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

    /**
     * Operation Get Report
     *
     * @param string $report_id The identifier for the report. This identifier is unique only in combination with a seller ID
     *
     * @return json
     *
     * @author Manikant Patidar <manikant@topsinfosolutions.com>
     *
     * About more Ref :- https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference#getreport
     */
    public function getReport($report_id)
    {
        if (null === $report_id) {
            throw new \InvalidArgumentException('Missing the required parameter $report_id when calling getReport');
        }

        $resource_path = '/reports/2021-06-30/reports/{reportId}';

        $http_body = '';
        $query_params = [];
        $method = 'GET';
        
        // path params
        if (null !== $report_id) {
            $resource_path = str_replace(
                '{' . 'reportId' . '}',
                $report_id,
                $resource_path
            );
        }

        $url = $this->config->getHost() . $resource_path;

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

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

    /**
     * Operation cancel Report
     *
     * @param string $report_id The identifier for the report. This identifier is unique only in combination with a seller ID.
     *
     * @return json
     *
     * @author Manikant Patidar <manikant@topsinfosolutions.com>
     *
     * About more Ref :- https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference#cancelreport
     */
    public function cancelReport($report_id)
    {
        if (null === $report_id) {
            throw new \InvalidArgumentException('Missing the required parameter $report_id when calling cancelReport');
        }

        $resource_path = '/reports/2021-06-30/reports/{reportId}';
        $http_body = '';
        $query_params = [];
        $method = 'DELETE';
        
        // path params
        if (null !== $report_id) {
            $resource_path = str_replace(
                '{' . 'reportId' . '}',
                $report_id,
                $resource_path
            );
        }

        $url = $this->config->getHost() . $resource_path;

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

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

    /**
     * Operation Get Report Schedules
     *
     * @param string|array  $params['reportTypes'] A list of report types used to filter report schedules. <Min count : 1 Max count : 10>
     *
     * @return json
     *
     * @author Manikant Patidar <manikant@topsinfosolutions.com>
     *
     * About more Ref :- https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference#getreportschedules
     */
    public function getReportSchedules($params)
    {
        if (!array_key_exists('reportTypes', $params) ||  null === $params['reportTypes']) {
            throw new \InvalidArgumentException('Missing the required parameter reportTypes when calling getReportSchedules');
        }

        $resource_path = '/reports/2021-06-30/schedules';

        $http_body = '';
        $query_params = [];
        $method = 'GET';
        
        // get Query params
        if ($params['reportTypes'] !== null) {
            $query_params['reportTypes'] = is_array($params['reportTypes']) ? implode(',', $params['reportTypes']) :  $params['reportTypes'];
        }

        $url = $this->config->getHost() . $resource_path;

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

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

    /**
     * Operation Create Report Schedule
     *
     * @param array $body (required)
     *
     * @return json
     *
     * @author Manikant Patidar <manikant@topsinfosolutions.com>
     *
     * About moe Ref :- https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference#createreportschedule
     */
    public function createReportSchedule($body)
    {
        if (null === $body) {
            throw new \InvalidArgumentException('Missing the required parameter $body when calling createReportSchedule');
        }

        $resource_path = '/reports/2021-06-30/schedules';
        $http_body = $body;
        $query_params = [];
        $method = 'POST';
        

        $url = $this->config->getHost() . $resource_path;

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

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

    /**
     * Operation Get Report Schedule
     *
     * @param string $report_schedule_id The identifier for the report schedule. This identifier is unique only in combination with a seller ID.
     *
     * @return json
     *
     * @author Manikant Patidar <manikant@topsinfosolutions.com>
     *
     * About more Ref :- https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference#getreportschedule
     */
    public function getReportSchedule($report_schedule_id)
    {
        if (null === $report_schedule_id) {
            throw new \InvalidArgumentException('Missing the required parameter $report_schedule_id when calling getReportSchedule');
        }

        $resource_path = '/reports/2021-06-30/schedules/{reportScheduleId}';
        $http_body = '';
        $query_params = [];
        $method = 'GET';
        
        // path params
        if (null !== $report_schedule_id) {
            $resource_path = str_replace(
                '{' . 'reportScheduleId' . '}',
                $report_schedule_id,
                $resource_path
            );
        }

        $url = $this->config->getHost() . $resource_path;

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

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

    /**
     * Operation Cancel Report Schedule
     *
     * @param string $report_schedule_id The identifier for the report schedule. This identifier is unique only in combination with a seller ID.
     *
     * @return json
     *
     * @author Manikant Patidar <manikant@topsinfosolutions.com>
     *
     * About more Ref :- https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference#cancelreportschedule
     */
    public function cancelReportSchedule($report_schedule_id)
    {
        if (null === $report_schedule_id) {
            throw new \InvalidArgumentException('Missing the required parameter $report_schedule_id when calling cancelReportSchedule');
        }

        $resource_path = '/reports/2021-06-30/schedules/{reportScheduleId}';
        $http_body = '';
        $query_params = [];
        $method = 'DELETE';
        
        // path params
        if (null !== $report_schedule_id) {
            $resource_path = str_replace(
                '{' . 'reportScheduleId' . '}',
                $report_schedule_id,
                $resource_path
            );
        }

        $url = $this->config->getHost() . $resource_path;

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

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

    /**
     * Operation Get Pricing
     *
     * @param string  $report_document_id The identifier for the report document.
     *
     * @return json
     *
     * @author Manikant Patidar <manikant@topsinfosolutions.com>
     *
     * About more Ref :- https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference#getreportdocument
     */
    public function getReportDocument($report_document_id)
    {
        if (null === $report_document_id) {
            throw new \InvalidArgumentException('Missing the required parameter $report_document_id when calling getReportDocument');
        }

        $resource_path = '/reports/2021-06-30/documents/{reportDocumentId}';
        $http_body = '';
        $query_params = [];
        $method = 'GET';
        
        // path params
        if (null !== $report_document_id) {
            $resource_path = str_replace(
                '{' . 'reportDocumentId' . '}',
                $report_document_id,
                $resource_path
            );
        }

        $url = $this->config->getHost() . $resource_path;

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

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