Skip to content

Commit

Permalink
Merge branch 'dev' into devp/point-shop-feature
Browse files Browse the repository at this point in the history
  • Loading branch information
s0phialiu authored Feb 11, 2024
2 parents 622fa3d + 74eac67 commit 24fa8eb
Show file tree
Hide file tree
Showing 111 changed files with 1,010 additions and 338 deletions.
4 changes: 3 additions & 1 deletion HIAPI/Models/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public struct Event: Codable {
case startTime
case points
case isAsync
case mapImageUrl
}

public let id: String
Expand All @@ -85,10 +86,11 @@ public struct Event: Codable {
public let info: String
public let locations: [Location]
public let name: String
public let sponsor: String
public let sponsor: String?
public let startTime: Date
public let points: Int
public let isAsync: Bool
public let mapImageUrl: String?
}

public struct Location: Codable {
Expand Down
18 changes: 18 additions & 0 deletions HIAPI/Models/Mentor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// MentorService.swift
// HackIllinois
//
// Created by HackIllinois Team on 2/10/24.
// Copyright © 2024 HackIllinois. All rights reserved.
// This file is part of the Hackillinois iOS App.
// The Hackillinois iOS App is open source software, released under the University of
// Illinois/NCSA Open Source License. You should have received a copy of
// this license in a file with the distribution.
//

import Foundation
import APIManager

public struct MentorAttendanceContainer: Codable, APIReturnable {
public let status: String
}
4 changes: 4 additions & 0 deletions HIAPI/Models/Profile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public struct Profile: Codable, APIReturnable {
public let coins: Int
}

public struct Ranking: Codable, APIReturnable {
public let ranking: Int
}

public struct ProfileFavorites: Codable, APIReturnable {
public let userId: String
public let profiles: Set<String>
Expand Down
11 changes: 8 additions & 3 deletions HIAPI/Models/Staff.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
//
// Staff.swift
// HIAPI
// HackIllinois
//
// Created by Dev Patel on 2/7/24.
// Copyright © 2024 HackIllinois. All rights reserved.
// Created by HackIllinois Team on 2/7/24.
// Copyright © 2017 HackIllinois. All rights reserved.
// This file is part of the Hackillinois iOS App.
// The Hackillinois iOS App is open source software, released under the University of
// Illinois/NCSA Open Source License. You should have received a copy of
// this license in a file with the distribution.
//

import Foundation
import APIManager

Expand Down
16 changes: 11 additions & 5 deletions HIAPI/Models/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ public struct RolesContainer: Codable, APIReturnable {
public struct Roles: OptionSet, Codable {
public let rawValue: Int

// Mentor deprecated 2024
public static let null = Roles([])
public static let USER = Roles(rawValue: 1 << 0)
public static let APPLICANT = Roles(rawValue: 1 << 1)
public static let ATTENDEE = Roles(rawValue: 1 << 2)
public static let MENTOR = Roles(rawValue: 1 << 3)
public static let PRO = Roles(rawValue: 1 << 3)
public static let SPONSOR = Roles(rawValue: 1 << 4)
public static let STAFF = Roles(rawValue: 1 << 5)
public static let ADMIN = Roles(rawValue: 1 << 6)
public static let allRoles = ["USER", "APPLICANT", "ATTENDEE", "MENTOR", "SPONSOR", "STAFF", "ADMIN"]
public static let allRoles = ["USER", "APPLICANT", "ATTENDEE", "PRO", "SPONSOR", "STAFF", "ADMIN"]

public init(rawValue: Int) {
self.rawValue = rawValue
Expand All @@ -55,7 +56,7 @@ public struct Roles: OptionSet, Codable {
case "USER": self = .USER
case "APPLICANT": self = .APPLICANT
case "ATTENDEE": self = .ATTENDEE
case "MENTOR": self = .MENTOR
case "PRO": self = .PRO
case "SPONSOR": self = .SPONSOR
case "STAFF": self = .STAFF
case "ADMIN": self = .ADMIN
Expand All @@ -73,7 +74,7 @@ public struct Roles: OptionSet, Codable {
if contains(.USER) { try container.encode("USER") }
if contains(.APPLICANT) { try container.encode("APPLICANT") }
if contains(.ATTENDEE) { try container.encode("ATTENDEE") }
if contains(.MENTOR) { try container.encode("MENTOR") }
if contains(.PRO) { try container.encode("PRO") }
if contains(.SPONSOR) { try container.encode("SPONSOR") }
if contains(.STAFF) { try container.encode("STAFF") }
if contains(.ADMIN) { try container.encode("ADMIN") }
Expand All @@ -91,7 +92,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 Expand Up @@ -181,3 +182,8 @@ public struct DietaryRestrictions: OptionSet, Codable, APIReturnable {
public struct Token: Codable, APIReturnable {
public let token: String
}

public struct FollowStatus: Codable, APIReturnable {
public let userId: String
public let following: [String]
}
29 changes: 29 additions & 0 deletions HIAPI/Services/MentorService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// MentorService.swift
// HackIllinois
//
// Created by HackIllinois Team on 2/10/24.
// Copyright © 2024 HackIllinois. All rights reserved.
// This file is part of the Hackillinois iOS App.
// The Hackillinois iOS App is open source software, released under the University of
// Illinois/NCSA Open Source License. You should have received a copy of
// this license in a file with the distribution.
//

import Foundation
import APIManager

public final class MentorService: BaseService {
public override static var baseURL: String {
return super.baseURL + "mentor/"
}

public static func recordMentorAttendance(userToken: String, mentorId: String) -> APIRequest<MentorAttendanceContainer> {
var headers = HTTPHeaders()
headers["Authorization"] = userToken
var body = HTTPBody()
body["mentorId"] = userToken
return APIRequest<MentorAttendanceContainer>(service: self, endpoint: "attendance/", body: body, headers: headers, method: .POST)
}

}
6 changes: 6 additions & 0 deletions HIAPI/Services/ProfileService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public final class ProfileService: BaseService {
public static func updateUserProfile(profileData: [String: Any]) -> APIRequest<Profile> {
return APIRequest<Profile>(service: self, endpoint: "", body: profileData, headers: headers, method: .PUT)
}

public static func getUserRanking(userToken: String) -> APIRequest<Ranking> {
var authorizationHeaders = HTTPHeaders()
authorizationHeaders["Authorization"] = userToken
return APIRequest<Ranking>(service: self, endpoint: "ranking/", headers: authorizationHeaders, method: .GET)
}

public static func getAllFavorites() -> APIRequest<ProfileFavorites> {
return APIRequest<ProfileFavorites>(service: self, endpoint: "favorite/", method: .GET)
Expand Down
23 changes: 16 additions & 7 deletions HIAPI/Services/StaffService.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
//
// StaffService.swift
// HIAPI
// HackIllinois
//
// Created by Dev Patel on 2/7/24.
// Copyright © 2024 HackIllinois. All rights reserved.
// Created by HackIllinois Team on 2/7/24.
// Copyright © 2017 HackIllinois. All rights reserved.
// This file is part of the Hackillinois iOS App.
// The Hackillinois iOS App is open source software, released under the University of
// Illinois/NCSA Open Source License. You should have received a copy of
// this license in a file with the distribution.
//

import Foundation
Expand All @@ -20,15 +24,20 @@ public final class StaffService: BaseService {
return APIRequest<StaffContainer>(service: self, endpoint: "shift/", headers: headers, method: .GET)
}

public static func recordStaffAttendance(userToken: String) -> APIRequest<StaffAttendanceContainer> {
public static func recordStaffAttendance(userToken: String, eventId: String) -> APIRequest<StaffAttendanceContainer> {
var body = HTTPBody()
body["eventId"] = eventId
var headers = HTTPHeaders()
headers["Authorization"] = userToken
return APIRequest<StaffAttendanceContainer>(service: self, endpoint: "attendance/", headers: headers, method: .POST)
return APIRequest<StaffAttendanceContainer>(service: self, endpoint: "attendance/", body: body, headers: headers, method: .POST)
}

public static func recordUserAttendance(userToken: String) -> APIRequest<UserAttendanceContainer> {
public static func recordUserAttendance(userToken: String, userId: String, eventId: String) -> APIRequest<UserAttendanceContainer> {
var body = HTTPBody()
body["userId"] = userId
body["eventId"] = eventId
var headers = HTTPHeaders()
headers["Authorization"] = userToken
return APIRequest<UserAttendanceContainer>(service: self, endpoint: "scan-attendee/", headers: headers, method: .PUT)
return APIRequest<UserAttendanceContainer>(service: self, endpoint: "scan-attendee/", body: body, headers: headers, method: .PUT)
}
}
22 changes: 20 additions & 2 deletions HIAPI/Services/UserService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,25 @@ 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)
}

public static func favoriteEvent(userToken: String, eventID: String) -> APIRequest<FollowStatus> {
var authorizationHeaders = HTTPHeaders()
authorizationHeaders["Authorization"] = userToken
var body = HTTPBody()
body["eventId"] = eventID
return APIRequest<FollowStatus>(service: self, endpoint: "follow/", body: body, headers: authorizationHeaders, method: .PUT)
}

public static func unfavoriteEvent(userToken: String, eventID: String) -> APIRequest<FollowStatus> {
var authorizationHeaders = HTTPHeaders()
authorizationHeaders["Authorization"] = userToken
var body = HTTPBody()
body["eventId"] = eventID
return APIRequest<FollowStatus>(service: self, endpoint: "unfollow/", body: body, headers: authorizationHeaders, method: .PUT)
}
}
Loading

0 comments on commit 24fa8eb

Please sign in to comment.