Skip to content

Commit

Permalink
Remove MockWebService dependent code
Browse files Browse the repository at this point in the history
  • Loading branch information
nriedman committed Apr 4, 2024
1 parent cf351d8 commit e13e849
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions ENGAGEHF/ENGAGEHFStandard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import SpeziAccount
import SpeziFirebaseAccountStorage
import SpeziFirestore
import SpeziHealthKit
import SpeziMockWebService
import SpeziOnboarding
import SpeziQuestionnaire
import SwiftUI
Expand All @@ -31,7 +30,6 @@ actor ENGAGEHFStandard: Standard, EnvironmentAccessible, HealthKitConstraint, On
Firestore.firestore().collection("users")
}

@Dependency var mockWebService: MockWebService?
@Dependency var accountStorage: FirestoreAccountStorage?

@AccountReference var account: Account
Expand Down Expand Up @@ -68,14 +66,6 @@ actor ENGAGEHFStandard: Standard, EnvironmentAccessible, HealthKitConstraint, On


func add(sample: HKSample) async {
if let mockWebService {
let encoder = JSONEncoder()
encoder.outputFormatting = [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes]
let jsonRepresentation = (try? String(data: encoder.encode(sample.resource), encoding: .utf8)) ?? ""
try? await mockWebService.upload(path: "healthkit/\(sample.uuid.uuidString)", body: jsonRepresentation)
return
}

do {
try await healthKitDocument(id: sample.id).setData(from: sample.resource)
} catch {
Expand All @@ -84,11 +74,6 @@ actor ENGAGEHFStandard: Standard, EnvironmentAccessible, HealthKitConstraint, On
}

func remove(sample: HKDeletedObject) async {
if let mockWebService {
try? await mockWebService.remove(path: "healthkit/\(sample.uuid.uuidString)")
return
}

do {
try await healthKitDocument(id: sample.uuid).delete()
} catch {
Expand All @@ -99,12 +84,6 @@ actor ENGAGEHFStandard: Standard, EnvironmentAccessible, HealthKitConstraint, On
func add(response: ModelsR4.QuestionnaireResponse) async {
let id = response.identifier?.value?.value?.string ?? UUID().uuidString

if let mockWebService {
let jsonRepresentation = (try? String(data: JSONEncoder().encode(response), encoding: .utf8)) ?? ""
try? await mockWebService.upload(path: "questionnaireResponse/\(id)", body: jsonRepresentation)
return
}

do {
try await userDocumentReference
.collection("QuestionnaireResponse") // Add all HealthKit sources in a /QuestionnaireResponse collection.
Expand Down

0 comments on commit e13e849

Please sign in to comment.