예제 #1
0
 /**
  * @param int|string $sectionId Section id or uniqueName
  * @param string $method
  * @param array $parameters
  * @return array|bool|float|int|string
  * @throws InvalidMethodException
  * @throws InvalidMethodParametersException
  * @throws ItemDoesNotExistsException
  * @throws UnsatisfactoryResponseCodeException
  */
 public function getArticlesBySectionId($sectionId, $method, $parameters = [])
 {
     $methodValidator = new ArticleListMethodValidator($method);
     if (!$methodValidator->isValid()) {
         throw new InvalidMethodException(sprintf('Method "%s" is not allowed', $method));
     }
     $parametersConverter = new ArticlesListParametersConverter();
     $parameters = $parametersConverter->convert($parameters);
     $parametersValidator = new ArticlesListParametersValidator($method, $parameters);
     if (!$parametersValidator->isValid()) {
         throw new InvalidMethodParametersException(sprintf('Invalid parameter name or value used for "%s" method', $method));
     }
     $url = sprintf('/publication/{publicationId}/sections/%s/%s?%s', $sectionId, $method, http_build_query($parameters));
     $url = rtrim($url, '?&');
     $response = $this->apiGet($url);
     return $response->json();
 }
 /**
  * @dataProvider parametersProvider
  */
 public function testValidator($method, $parameters, $expected)
 {
     $validator = new ArticlesListParametersValidator($method, $parameters);
     $this->assertEquals($expected, $validator->isValid());
 }