Code Duplication    Length = 15-19 lines in 3 locations

src/Yandex/Market/Partner/PartnerClient.php 3 locations

@@ 506-524 (lines=19) @@
503
     *
504
     * @link https://tech.yandex.ru/market/partner/doc/dg/reference/post-models-docpage/
505
     */
506
    public function getModels(array $modelIds, $regionId, $currency = null)
507
    {
508
        $resource = sprintf('models.%s', self::DECODE_TYPE_DEFAULT);
509
        $queryParams = $this->filterParams([
510
            'regionId' => $regionId,
511
            'currency' => $currency,
512
        ]);
513
514
        $response = $this->sendRequest('POST', $this->getServiceUrl($resource), [
515
            'query' => $queryParams,
516
            'json' => [
517
                'models' => $modelIds
518
            ],
519
        ]);
520
        $decodedResponseBody = $this->getDecodedBody($response->getBody());
521
        $marketModelsResponse = new GetMarketModelsResponse($decodedResponseBody);
522
523
        return $marketModelsResponse->getModels();
524
    }
525
526
    /**
527
     * Get model offers
@@ 537-551 (lines=15) @@
534
     *
535
     * @link https://tech.yandex.ru/market/partner/doc/dg/reference/get-models-id-offers-docpage/
536
     */
537
    public function getModelOffers($modelId, $regionId, $currency = null, $orderByPrice = null)
538
    {
539
        $resource = sprintf('models/%s/offers.%s', $modelId, self::DECODE_TYPE_DEFAULT);
540
        $queryParams = $this->filterParams([
541
            'regionId' => $regionId,
542
            'currency' => $currency,
543
            'orderByPrice' => $orderByPrice,
544
        ]);
545
546
        $response = $this->sendRequest('GET', $this->getServiceUrl($resource), ['query' => $queryParams]);
547
        $decodedResponseBody = $this->getDecodedBody($response->getBody());
548
        $marketModelsResponse = new GetMarketModelsResponse($decodedResponseBody);
549
550
        return $marketModelsResponse->getModels()->current();
551
    }
552
553
    /**
554
     * Get multiple models offers
@@ 563-581 (lines=19) @@
560
     *
561
     * @link https://tech.yandex.ru/market/partner/doc/dg/reference/post-models-offers-docpage/
562
     */
563
    public function getModelsOffers(array $modelIds, $regionId, $currency = null)
564
    {
565
        $resource = sprintf('models/offers.%s', self::DECODE_TYPE_DEFAULT);
566
        $queryParams = $this->filterParams([
567
            'regionId' => $regionId,
568
            'currency' => $currency,
569
        ]);
570
571
        $response = $this->sendRequest('POST', $this->getServiceUrl($resource), [
572
            'query' => $queryParams,
573
            'json' => [
574
                'models' => $modelIds
575
            ],
576
        ]);
577
        $decodedResponseBody = $this->getDecodedBody($response->getBody());
578
        $marketModelsResponse = new GetMarketModelsResponse($decodedResponseBody);
579
580
        return $marketModelsResponse->getModels();
581
    }
582
}
583