@@ -190,31 +190,44 @@ class ShopInBitService {
190190 return ;
191191 }
192192
193- final ApiResponse <TicketFull > fullResp;
194- final ApiResponse <TicketStatus > statusResp;
195- final ApiResponse <List <TicketMessage >> messagesResp;
196- (fullResp, statusResp, messagesResp) = await (
197- client.getTicketFull (id, customerKey: customerKey),
198- client.getTicketStatus (id, customerKey: customerKey),
199- client.getMessages (id, customerKey: customerKey),
200- ).wait;
201-
202- if (existing == null ) {
203- await _insertHydrated (
204- ref: ref,
205- customerKey: customerKey,
206- full: fullResp.value,
207- status: statusResp.value,
208- messages: messagesResp.value,
193+ // get status first. If it fails there is no reason to make the remaining
194+ // two API calls
195+ final statusResp = await client.getTicketStatus (
196+ id,
197+ customerKey: customerKey,
198+ );
199+
200+ if (statusResp.exception? .statusCode == 403 ) {
201+ Logging .instance.w (
202+ "$runtimeType ._refreshBody status call permission denied. "
203+ "Ignoring ticket." ,
209204 );
210205 } else {
211- await _patchExisting (
212- existing: existing,
213- full: fullResp.value,
214- status: statusResp.value,
215- messages: messagesResp.value,
216- );
206+ final ApiResponse <TicketFull > fullResp;
207+ final ApiResponse <List <TicketMessage >> messagesResp;
208+ (fullResp, messagesResp) = await (
209+ client.getTicketFull (id, customerKey: customerKey),
210+ client.getMessages (id, customerKey: customerKey),
211+ ).wait;
212+
213+ if (existing == null ) {
214+ await _insertHydrated (
215+ ref: ref,
216+ customerKey: customerKey,
217+ full: fullResp.value,
218+ status: statusResp.value,
219+ messages: messagesResp.value,
220+ );
221+ } else {
222+ await _patchExisting (
223+ existing: existing,
224+ full: fullResp.value,
225+ status: statusResp.value,
226+ messages: messagesResp.value,
227+ );
228+ }
217229 }
230+
218231 completer.complete ();
219232 } catch (e, s) {
220233 completer.completeError (e, s);
0 commit comments