Skip to content

Commit

Permalink
Samsung External Registration Feed
Browse files Browse the repository at this point in the history
* fixing attendee not found by email

Change-Id: I0c65057de74eaedd6299c90655fef7e795cfa04e
  • Loading branch information
smarcet committed Jun 9, 2023
1 parent 5f7c8ea commit 981c7f9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
3 changes: 3 additions & 0 deletions app/Services/Apis/Samsung/DecryptedSingleResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function __construct(string $key, string $content, string $forum){
if(!is_array($list))
throw new InvalidResponse(sprintf("invalid data field on response %s", $content));
$this->payload = count($list) == 1 ? $list[0] : $list;

if(count($this->payload) == 0)
throw new EmptyResponse("response not found");
}


Expand Down
25 changes: 18 additions & 7 deletions app/Services/Apis/Samsung/SamsungRegistrationAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,15 @@ public function checkUser(Summit $summit, string $userId, string $region = Regio
}
catch (RequestException $ex) {
Log::warning($ex->getMessage());
return null;
return [];
}
catch(EmptyResponse $ex){
Log::warning($ex->getMessage());
return [];
}
catch (Exception $ex) {
Log::error($ex->getMessage());
return null;
return [];
}
}

Expand All @@ -114,7 +118,6 @@ public function checkEmail(Summit $summit,string $email, string $region = Region

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


// http://docs.guzzlephp.org/en/stable/request-options.html
$response = $this->client->request('POST',
$this->endpoint,
Expand All @@ -138,11 +141,15 @@ public function checkEmail(Summit $summit,string $email, string $region = Region
}
catch (RequestException $ex) {
Log::warning($ex->getMessage());
return null;
return [];
}
catch(EmptyResponse $ex){
Log::warning($ex->getMessage());
return [];
}
catch (Exception $ex) {
Log::error($ex->getMessage());
return null;
return [];
}
}

Expand Down Expand Up @@ -180,11 +187,15 @@ public function userList(Summit $summit, string $region = Regions::US)
}
catch (RequestException $ex) {
Log::warning($ex->getMessage());
return null;
return [];
}
catch(EmptyResponse $ex){
Log::warning($ex->getMessage());
return [];
}
catch (Exception $ex) {
Log::error($ex->getMessage());
return null;
return [];
}
}
}
1 change: 1 addition & 0 deletions app/Services/Model/Imp/RegistrationIngestionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public function ingestExternalAttendee($summit_id, $index, $external_attendee, I
$cancelled = $external_attendee['cancelled'] ?? false;

$ticket_type = $summit->getTicketTypeByExternalId($ticket_class['id']);

if (is_null($ticket_type)) {
// create ticket type if it does not exists
Log::debug(sprintf("RegistrationIngestionService::ingestSummit: ticket class %s does not exists", $ticket_class['id']));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,19 @@ public function find(): ?SummitAttendeeTicket
Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find ticket_criteria %s", $this->ticket_criteria));

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

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

if(is_null($attendee)) {

Log::debug
Expand Down Expand Up @@ -123,15 +129,22 @@ public function find(): ?SummitAttendeeTicket

return $attendee->getFirstTicket();
}

if(filter_var($this->ticket_criteria, FILTER_VALIDATE_EMAIL)){

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

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

if(is_null($attendee)) {

Log::debug
Expand Down Expand Up @@ -170,6 +183,7 @@ public function find(): ?SummitAttendeeTicket
}
return $attendee->getFirstTicket();
}
Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find ticket_criteria %s is not a valid QRCode or email", $this->ticket_criteria));
return null;
}
}

0 comments on commit 981c7f9

Please sign in to comment.