Skip to content

Commit 1172f07

Browse files
committed
Samsung External Registration Feed
* fixing attendee not found by email Change-Id: I0c65057de74eaedd6299c90655fef7e795cfa04e
1 parent 5f7c8ea commit 1172f07

File tree

5 files changed

+53
-6
lines changed

5 files changed

+53
-6
lines changed

app/Services/Apis/Samsung/DecryptedListResponse.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public function __construct(string $key, string $content, string $forum){
5252
$list = json_decode($dec->getData(), true);
5353
if(!is_array($list))
5454
throw new InvalidResponse(sprintf("invalid data field on response %s", $content));
55+
56+
if(count($list) == 0)
57+
throw new EmptyResponse("response not found");
58+
5559
$this->payload = $list;
5660
}
5761

app/Services/Apis/Samsung/DecryptedSingleResponse.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public function __construct(string $key, string $content, string $forum){
4545
if(!is_array($list))
4646
throw new InvalidResponse(sprintf("invalid data field on response %s", $content));
4747
$this->payload = count($list) == 1 ? $list[0] : $list;
48+
49+
if(count($this->payload) == 0)
50+
throw new EmptyResponse("response not found");
4851
}
4952

5053

app/Services/Apis/Samsung/SamsungRegistrationAPI.php

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
**/
14-
use GuzzleHttp\Client;
1514
use Exception;
1615
use GuzzleHttp\ClientInterface;
1716
use GuzzleHttp\Exception\RequestException;
@@ -91,11 +90,19 @@ public function checkUser(Summit $summit, string $userId, string $region = Regio
9190
}
9291
catch (RequestException $ex) {
9392
Log::warning($ex->getMessage());
94-
return null;
93+
return [];
94+
}
95+
catch(EmptyResponse $ex){
96+
Log::warning($ex->getMessage());
97+
return [];
98+
}
99+
catch (InvalidResponse $ex){
100+
Log::warning($ex->getMessage());
101+
return [];
95102
}
96103
catch (Exception $ex) {
97104
Log::error($ex->getMessage());
98-
return null;
105+
return [];
99106
}
100107
}
101108

@@ -114,7 +121,6 @@ public function checkEmail(Summit $summit,string $email, string $region = Region
114121

115122
Log::debug(sprintf("SamsungRegistrationAPI::checkEmail POST %s payload %s", $this->endpoint, $request));
116123

117-
118124
// http://docs.guzzlephp.org/en/stable/request-options.html
119125
$response = $this->client->request('POST',
120126
$this->endpoint,
@@ -138,11 +144,19 @@ public function checkEmail(Summit $summit,string $email, string $region = Region
138144
}
139145
catch (RequestException $ex) {
140146
Log::warning($ex->getMessage());
141-
return null;
147+
return [];
148+
}
149+
catch(EmptyResponse $ex){
150+
Log::warning($ex->getMessage());
151+
return [];
152+
}
153+
catch (InvalidResponse $ex){
154+
Log::warning($ex->getMessage());
155+
return [];
142156
}
143157
catch (Exception $ex) {
144158
Log::error($ex->getMessage());
145-
return null;
159+
return [];
146160
}
147161
}
148162

@@ -182,6 +196,14 @@ public function userList(Summit $summit, string $region = Regions::US)
182196
Log::warning($ex->getMessage());
183197
return null;
184198
}
199+
catch(EmptyResponse $ex){
200+
Log::warning($ex->getMessage());
201+
return null;
202+
}
203+
catch(InvalidResponse $ex){
204+
Log::warning($ex->getMessage());
205+
return null;
206+
}
185207
catch (Exception $ex) {
186208
Log::error($ex->getMessage());
187209
return null;

app/Services/Model/Imp/RegistrationIngestionService.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public function ingestExternalAttendee($summit_id, $index, $external_attendee, I
171171
$cancelled = $external_attendee['cancelled'] ?? false;
172172

173173
$ticket_type = $summit->getTicketTypeByExternalId($ticket_class['id']);
174+
174175
if (is_null($ticket_type)) {
175176
// create ticket type if it does not exists
176177
Log::debug(sprintf("RegistrationIngestionService::ingestSummit: ticket class %s does not exists", $ticket_class['id']));
@@ -640,6 +641,9 @@ public function ingestSummit(Summit $summit): void
640641
Log::debug(sprintf("RegistrationIngestionService::ingestSummit getting external attendees page %s", $page));
641642
$response = $feed->getAttendees($page, $summit->getExternalRegistrationFeedLastIngestDate());
642643

644+
if(is_null($response))
645+
throw new ValidationException("Response is empty");
646+
643647
if ($response->hasData()) {
644648
$shouldMarkProcess = true;
645649
} else {

app/Services/Model/Strategies/TicketFinder/Strategies/TicketFinderByExternalFeedStrategy.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,19 @@ public function find(): ?SummitAttendeeTicket
7676
Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find ticket_criteria %s", $this->ticket_criteria));
7777

7878
if($this->feed->isValidQRCode($this->ticket_criteria)){
79+
Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find ticket_criteria %s is a valid QRCode", $this->ticket_criteria));
7980
$externalAttendeeId = $this->feed->getExternalUserIdFromQRCode($this->ticket_criteria);
8081
// check first if we have it locally
8182
$attendee = $this->attendee_repository->getBySummitAndExternalId
8283
(
8384
$this->summit, $externalAttendeeId
8485
);
8586

87+
if(!is_null($attendee) && !$attendee->hasTickets()){
88+
Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find attendee %s has no tickets, re fetch it from external feed", $externalAttendeeId));
89+
$attendee = null;
90+
}
91+
8692
if(is_null($attendee)) {
8793

8894
Log::debug
@@ -123,15 +129,22 @@ public function find(): ?SummitAttendeeTicket
123129

124130
return $attendee->getFirstTicket();
125131
}
132+
126133
if(filter_var($this->ticket_criteria, FILTER_VALIDATE_EMAIL)){
127134

135+
Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find ticket_criteria %s is a valid email", $this->ticket_criteria));
128136
$externalAttendeeEmail = $this->ticket_criteria;
129137
// check first if we have it locally
130138
$attendee = $this->attendee_repository->getBySummitAndEmail
131139
(
132140
$this->summit, $externalAttendeeEmail
133141
);
134142

143+
if(!is_null($attendee) && !$attendee->hasTickets()){
144+
Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find attendee %s has no tickets, re fetch it from external feed", $externalAttendeeEmail));
145+
$attendee = null;
146+
}
147+
135148
if(is_null($attendee)) {
136149

137150
Log::debug
@@ -170,6 +183,7 @@ public function find(): ?SummitAttendeeTicket
170183
}
171184
return $attendee->getFirstTicket();
172185
}
186+
Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find ticket_criteria %s is not a valid QRCode or email", $this->ticket_criteria));
173187
return null;
174188
}
175189
}

0 commit comments

Comments
 (0)