Skip to content

Commit 981c7f9

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

4 files changed

Lines changed: 36 additions & 7 deletions

File tree

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: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,15 @@ public function checkUser(Summit $summit, string $userId, string $region = Regio
9191
}
9292
catch (RequestException $ex) {
9393
Log::warning($ex->getMessage());
94-
return null;
94+
return [];
95+
}
96+
catch(EmptyResponse $ex){
97+
Log::warning($ex->getMessage());
98+
return [];
9599
}
96100
catch (Exception $ex) {
97101
Log::error($ex->getMessage());
98-
return null;
102+
return [];
99103
}
100104
}
101105

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

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

117-
118121
// http://docs.guzzlephp.org/en/stable/request-options.html
119122
$response = $this->client->request('POST',
120123
$this->endpoint,
@@ -138,11 +141,15 @@ public function checkEmail(Summit $summit,string $email, string $region = Region
138141
}
139142
catch (RequestException $ex) {
140143
Log::warning($ex->getMessage());
141-
return null;
144+
return [];
145+
}
146+
catch(EmptyResponse $ex){
147+
Log::warning($ex->getMessage());
148+
return [];
142149
}
143150
catch (Exception $ex) {
144151
Log::error($ex->getMessage());
145-
return null;
152+
return [];
146153
}
147154
}
148155

@@ -180,11 +187,15 @@ public function userList(Summit $summit, string $region = Regions::US)
180187
}
181188
catch (RequestException $ex) {
182189
Log::warning($ex->getMessage());
183-
return null;
190+
return [];
191+
}
192+
catch(EmptyResponse $ex){
193+
Log::warning($ex->getMessage());
194+
return [];
184195
}
185196
catch (Exception $ex) {
186197
Log::error($ex->getMessage());
187-
return null;
198+
return [];
188199
}
189200
}
190201
}

app/Services/Model/Imp/RegistrationIngestionService.php

Lines changed: 1 addition & 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']));

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)