Skip to content

Commit 5878c5a

Browse files
authored
feat: new filter for summit tickets -> has_promo_code (#424)
Signed-off-by: romanetar <roman_ag@hotmail.com>
1 parent 119d9cb commit 5878c5a

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitTicketApiController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ function () {
151151
'badge_prints_count' => ['==', '>=', '<=', '>', '<'],
152152
'has_owner_company' => ['=='],
153153
'exclude_is_printable_free_unassigned' => ['=='],
154+
'has_promo_code' => ['=='],
154155
];
155156
},
156157
function () {
@@ -189,6 +190,7 @@ function () {
189190
'badge_prints_count' => 'sometimes|integer',
190191
'has_owner_company' => ['sometimes', new Boolean()],
191192
'exclude_is_printable_free_unassigned' => ['sometimes', new Boolean()],
193+
'has_promo_code' => ['sometimes', new Boolean()],
192194
];
193195
},
194196
function () {
@@ -330,6 +332,7 @@ function () {
330332
'badge_prints_count' => ['==', '>=', '<=', '>', '<'],
331333
'has_owner_company' => ['=='],
332334
'exclude_is_printable_free_unassigned' => ['=='],
335+
'has_promo_code' => ['=='],
333336
];
334337
},
335338
function () {
@@ -368,6 +371,7 @@ function () {
368371
'badge_prints_count' => 'sometimes|integer',
369372
'has_owner_company' => ['sometimes', new Boolean()],
370373
'exclude_is_printable_free_unassigned' => ['sometimes', new Boolean()],
374+
'has_promo_code' => ['sometimes', new Boolean()],
371375
];
372376
},
373377
function () {

app/Repositories/Summit/DoctrineSummitAttendeeTicketRepository.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private function requiredAliases(?Filter $filter, ?Order $order): array
141141
$need['m'] = true;
142142
} // usa m.id y a.email
143143

144-
if ($has('promo_code') || $has('promo_code_id') || $has('promo_code_description')) {
144+
if ($has('promo_code') || $has('promo_code_id') || $has('promo_code_description') || $has('has_promo_code')) {
145145
$need['pc'] = true;
146146
}
147147
if ($has('promo_code_tag') || $has('promo_code_tag_id')) {
@@ -437,6 +437,17 @@ protected function getFilterMappings()
437437
),
438438
]
439439
),
440+
'has_promo_code' => new DoctrineSwitchFilterMapping([
441+
'1' => new DoctrineCaseFilterMapping(
442+
'true',
443+
"pc is not null"
444+
),
445+
'0' => new DoctrineCaseFilterMapping(
446+
'false',
447+
"pc is null"
448+
),
449+
]
450+
),
440451
];
441452
}
442453

tests/OAuth2SummitTicketsApiTest.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,4 +950,38 @@ public function testGetAllTicketsByPromoCodeTag()
950950
$this->assertTrue(!is_null($tickets));
951951
return $tickets;
952952
}
953-
}
953+
954+
public function testGetAllTicketsWithoutPromoCode()
955+
{
956+
$params = [
957+
'id' => self::$summit->getId(),
958+
'page' => 1,
959+
'per_page' => 10,
960+
'filter' => [
961+
'has_promo_code==0',
962+
],
963+
'order' => '+id'
964+
];
965+
966+
$headers = [
967+
"HTTP_Authorization" => " Bearer " . $this->access_token,
968+
"CONTENT_TYPE" => "application/json"
969+
];
970+
971+
$response = $this->action(
972+
"GET",
973+
"OAuth2SummitTicketApiController@getAllBySummit",
974+
$params,
975+
[],
976+
[],
977+
[],
978+
$headers
979+
);
980+
981+
$content = $response->getContent();
982+
$this->assertResponseStatus(200);
983+
$tickets = json_decode($content);
984+
$this->assertTrue(!is_null($tickets));
985+
return $tickets;
986+
}
987+
}

0 commit comments

Comments
 (0)