Skip to content

Commit

Permalink
Merge pull request #37 from detailnet/feature/2615/screen-advertised-…
Browse files Browse the repository at this point in the history
…articles

Added listScreenableAdvertisedArticlesByPromotion for Articles client (DENNER-2615)
  • Loading branch information
curzio-della-santa committed Aug 10, 2020
2 parents 773c835 + ce62f7f commit 42fecb5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/ArticlesClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

/**
* Denner Articles Service client.
*
* @method static ArticlesClient factory(array $options = [])
* @method Response\ListResponse listAdvertisedArticles(array $params = [])
* @method Response\ResourceResponse|null fetchAdvertisedArticle(array $params = [])
Expand Down Expand Up @@ -43,8 +42,11 @@ public function listAdvertisedArticlesByWeek(int $year, int $week, array $params
return $this->listAdvertisedArticles($params);
}

public function listAdvertisedArticlesByPromotion(string $promotionId, array $params = []): Response\ListResponse
{
public function listAdvertisedArticlesByPromotion(
string $promotionId,
array $params = [],
bool $onlyScreenable = false
): Response\ListResponse {
$filters = [
'promotion.id' => [
'property' => 'promotion.id',
Expand All @@ -54,6 +56,15 @@ public function listAdvertisedArticlesByPromotion(string $promotionId, array $pa
],
];

if ($onlyScreenable) {
$filters[] = [ // Advertised articles with at least one screen
'property' => 'screens.0',
'operator' => 'exists',
'value' => true,
'type' => 'boolean',
];
}

// We may need to replace an already existing filter
$this->addOrReplaceFilters($filters, $params);

Expand Down

0 comments on commit 42fecb5

Please sign in to comment.