+ private buildResponsePayload(uuid: string): ResponsePayload {
+ const responsesStatus = this.responses
+ .get(uuid)
+ ?.responses.every((response) => response.status === ResponseStatus.SUCCESS)
+ ? ResponseStatus.SUCCESS
+ : ResponseStatus.FAILURE;
+ return {
+ status: responsesStatus,
+ hashIdsSucceeded: this.responses
+ .get(uuid)
+ ?.responses.map(({ status, hashId }) => {
+ if (status === ResponseStatus.SUCCESS) {
+ return hashId;
+ }
+ })
+ .filter((hashId) => hashId !== undefined),
+ ...(responsesStatus === ResponseStatus.FAILURE && {
+ hashIdsFailed: this.responses
+ .get(uuid)
+ ?.responses.map(({ status, hashId }) => {
+ if (status === ResponseStatus.FAILURE) {
+ return hashId;
+ }
+ })
+ .filter((hashId) => hashId !== undefined),
+ }),
+ ...(responsesStatus === ResponseStatus.FAILURE && {
+ responsesFailed: this.responses
+ .get(uuid)
+ ?.responses.map((response) => {
+ if (response.status === ResponseStatus.FAILURE) {
+ return response;
+ }
+ })
+ .filter((response) => response !== undefined),
+ }),
+ };