From 144a4c4c6257cc37e82a2da0f563d587a2837cf6 Mon Sep 17 00:00:00 2001 From: Sophia Liu Date: Sat, 10 Feb 2024 16:43:11 -0600 Subject: [PATCH 1/2] added mentor service and model files. todo: fix endpoint --- HIAPI/Models/Mentor.swift | 19 ++++++++++++++++++ HIAPI/Services/MentorService.swift | 27 ++++++++++++++++++++++++++ HackIllinois.xcodeproj/project.pbxproj | 8 ++++++++ 3 files changed, 54 insertions(+) create mode 100644 HIAPI/Models/Mentor.swift create mode 100644 HIAPI/Services/MentorService.swift diff --git a/HIAPI/Models/Mentor.swift b/HIAPI/Models/Mentor.swift new file mode 100644 index 00000000..325db47b --- /dev/null +++ b/HIAPI/Models/Mentor.swift @@ -0,0 +1,19 @@ +// +// 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 { + +} diff --git a/HIAPI/Services/MentorService.swift b/HIAPI/Services/MentorService.swift new file mode 100644 index 00000000..22356fd0 --- /dev/null +++ b/HIAPI/Services/MentorService.swift @@ -0,0 +1,27 @@ +// +// 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) -> APIRequest { + var headers = HTTPHeaders() + headers["Authorization"] = userToken + return APIRequest(service: self, endpoint: "attendance/", headers: headers, method: .POST) + } + +} diff --git a/HackIllinois.xcodeproj/project.pbxproj b/HackIllinois.xcodeproj/project.pbxproj index 51eabb0c..8b778e6e 100644 --- a/HackIllinois.xcodeproj/project.pbxproj +++ b/HackIllinois.xcodeproj/project.pbxproj @@ -135,6 +135,8 @@ D12B40FF2AC0B0BD001BCB05 /* HIScanAttendanceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12B40FE2AC0B0BD001BCB05 /* HIScanAttendanceViewController.swift */; }; D134D30F296B3F56006EA589 /* Montserrat-VariableFont_wght.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D134D30E296B3F56006EA589 /* Montserrat-VariableFont_wght.ttf */; }; D14D3AE3295FBDA200EB7995 /* HIBannerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D14D3AE2295FBDA100EB7995 /* HIBannerViewController.swift */; }; + D187BF5A2B78317600AD7356 /* Mentor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D187BF592B78317600AD7356 /* Mentor.swift */; }; + D187BF5C2B78318000AD7356 /* MentorService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D187BF5B2B78318000AD7356 /* MentorService.swift */; }; D1BE81172AC8FC680042C078 /* HIAPI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95E3142A21FAD5B30092C22E /* HIAPI.framework */; }; D1BE81182AC8FC690042C078 /* HIAPI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 95E3142A21FAD5B30092C22E /* HIAPI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; D1C5B6582B732E44000E766D /* refresh.json in Resources */ = {isa = PBXBuildFile; fileRef = D1C5B6572B732E44000E766D /* refresh.json */; }; @@ -342,6 +344,8 @@ D12B40FE2AC0B0BD001BCB05 /* HIScanAttendanceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HIScanAttendanceViewController.swift; sourceTree = ""; }; D134D30E296B3F56006EA589 /* Montserrat-VariableFont_wght.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Montserrat-VariableFont_wght.ttf"; sourceTree = ""; }; D14D3AE2295FBDA100EB7995 /* HIBannerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HIBannerViewController.swift; sourceTree = ""; }; + D187BF592B78317600AD7356 /* Mentor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Mentor.swift; sourceTree = ""; }; + D187BF5B2B78318000AD7356 /* MentorService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MentorService.swift; sourceTree = ""; }; D1C5B6572B732E44000E766D /* refresh.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = refresh.json; sourceTree = ""; }; D1F146392B605C57004E7FC9 /* Hack_Mushroom_Loading.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Hack_Mushroom_Loading.json; sourceTree = ""; }; D3A309BA221116A600CBA351 /* HackIllinois.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = HackIllinois.entitlements; sourceTree = ""; }; @@ -702,6 +706,7 @@ 95E3146121FAF1740092C22E /* BaseService.swift */, 95B12042220BEA9D00E024BB /* CheckInService.swift */, 95E3145F21FAF1740092C22E /* EventService.swift */, + D187BF5B2B78318000AD7356 /* MentorService.swift */, AC3B620F25E85D18002386A2 /* ProfileService.swift */, 95E3145C21FAF1740092C22E /* PassService.swift */, 95E3146321FAF1740092C22E /* RegistrationService.swift */, @@ -725,6 +730,7 @@ AC3B620D25E85CAD002386A2 /* Profile.swift */, 95E3146621FAF1740092C22E /* SimpleRequest.swift */, 95E3146721FAF1740092C22E /* User.swift */, + D187BF592B78317600AD7356 /* Mentor.swift */, 3C26401C23ADE8A5004E1DBE /* Project.swift */, 3C8F62D3238F9639001A5DAF /* Time.swift */, ACB53AE6261B874A007B1643 /* Interest.swift */, @@ -1142,10 +1148,12 @@ 95E3146A21FAF1740092C22E /* AnnouncementService.swift in Sources */, 95E3147221FAF1740092C22E /* RegistrationService.swift in Sources */, 95E3147421FAF1740092C22E /* SimpleRequest.swift in Sources */, + D187BF5C2B78318000AD7356 /* MentorService.swift in Sources */, 2FA73B502B58CAC3002658C0 /* Item.swift in Sources */, A5163FED221F283C003C543E /* StatsService.swift in Sources */, 95B12045220BEAD700E024BB /* TrackingService.swift in Sources */, 3C8F62D6238F9825001A5DAF /* TimeService.swift in Sources */, + D187BF5A2B78317600AD7356 /* Mentor.swift in Sources */, 95E3145921FAD71E0092C22E /* Error.swift in Sources */, 3C26401D23ADE8A5004E1DBE /* Project.swift in Sources */, ); From 4de555c334637c58d9dd4d692ca074c6f53eea84 Mon Sep 17 00:00:00 2001 From: Sophia Liu Date: Sat, 10 Feb 2024 23:02:17 -0600 Subject: [PATCH 2/2] Finished mentor service --- HIAPI/Models/Mentor.swift | 3 +-- HIAPI/Services/MentorService.swift | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/HIAPI/Models/Mentor.swift b/HIAPI/Models/Mentor.swift index 325db47b..45db93eb 100644 --- a/HIAPI/Models/Mentor.swift +++ b/HIAPI/Models/Mentor.swift @@ -13,7 +13,6 @@ import Foundation import APIManager - public struct MentorAttendanceContainer: Codable, APIReturnable { - + public let status: String } diff --git a/HIAPI/Services/MentorService.swift b/HIAPI/Services/MentorService.swift index 22356fd0..73ed8540 100644 --- a/HIAPI/Services/MentorService.swift +++ b/HIAPI/Services/MentorService.swift @@ -18,10 +18,12 @@ public final class MentorService: BaseService { return super.baseURL + "mentor/" } - public static func recordMentorAttendance(userToken: String) -> APIRequest { + public static func recordMentorAttendance(userToken: String, mentorId: String) -> APIRequest { var headers = HTTPHeaders() headers["Authorization"] = userToken - return APIRequest(service: self, endpoint: "attendance/", headers: headers, method: .POST) + var body = HTTPBody() + body["mentorId"] = userToken + return APIRequest(service: self, endpoint: "attendance/", body: body, headers: headers, method: .POST) } }