Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staff HIAPI Endpoints #570

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions HIAPI/Models/Staff.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// Staff.swift
// HIAPI
//
// Created by Dev Patel on 2/7/24.
// Copyright © 2024 HackIllinois. All rights reserved.
//
import Foundation
import APIManager

public struct StaffContainer: Decodable, APIReturnable {
public let shifts: [Staff]
// public init(from decoder: Decoder) throws {
// let container = try decoder.singleValueContainer()
// self.items = try container.decode([Staff].self)
// }
}

public struct Staff: Codable {
internal enum CodingKeys: String, CodingKey {
case isPro
case eventId
case isStaff
case name
case description
case startTime
case endTime
case eventType
case exp
case locations
case isAsync
case mapImageUrl
case points
case isPrivate
case displayOnStaffCheckIn
}
public let isPro: String
public let eventId: String
public let isStaff: Bool
public let name: Int
public let description: String
public let startTime: Date
public let endTime: Date
public let eventType: String
public let exp: Int
public let locations: [Location]
public let isAsync: Bool
public let mapImageUrl: String
public let points: Int
public let isPrivate: Bool
public let displayOnStaffCheckIn: Bool


}

public struct UserAttendanceContainer: Codable, APIReturnable {
internal enum CodingKeys: String, CodingKey {
case sucess
}
public let sucess: Bool
}

public struct StaffAttendanceContainer: Codable, APIReturnable {

}

34 changes: 34 additions & 0 deletions HIAPI/Services/StaffService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// StaffService.swift
// HIAPI
//
// Created by Dev Patel on 2/7/24.
// Copyright © 2024 HackIllinois. All rights reserved.
//

import Foundation
import APIManager

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

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

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

public static func recordUserAttendance(userToken: String) -> APIRequest<UserAttendanceContainer> {
var headers = HTTPHeaders()
headers["Authorization"] = userToken
return APIRequest<UserAttendanceContainer>(service: self, endpoint: "scan-attendee/", headers: headers, method: .PUT)
}
}
Loading