Skip to content

Commit

Permalink
QR code using qrInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
anushkasankaran committed Jan 21, 2024
1 parent bbc4011 commit a3b49e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion HIAPI/Models/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fileprivate extension Optional where Wrapped == String {
}

public struct QRData: Codable, APIReturnable {
public let id: String
public let userId: String
public let qrInfo: String
}

Expand Down
6 changes: 4 additions & 2 deletions HIAPI/Services/UserService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public final class UserService: BaseService {
return APIRequest<User>(service: self, endpoint: "", headers: headers, method: .GET)
}

public static func getQR() -> APIRequest<QRData> {
return APIRequest<QRData>(service: self, endpoint: "qr/", method: .GET)
public static func getQR(userToken: String) -> APIRequest<QRData> {
var authorizationHeaders = HTTPHeaders()
authorizationHeaders["Authorization"] = userToken
return APIRequest<QRData>(service: self, endpoint: "qr/", headers: authorizationHeaders, method: .GET)
}
}
4 changes: 3 additions & 1 deletion HackIllinois/ViewControllers/HIProfileCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@ struct HIProfileCardView: View {

func getQRInfo() {
guard let user = HIApplicationStateController.shared.user else { return }
HIAPI.UserService.getQR()
HIAPI.UserService.getQR(userToken: user.token)
.onCompletion { result in
do {
let (qr, _) = try result.get()
DispatchQueue.main.async {
self.qrInfo = qr.qrInfo
print("qrInfo is not empty:")
print(qrInfo)
}
} catch {
print("An error has occurred \(error)")
Expand Down

0 comments on commit a3b49e6

Please sign in to comment.