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

Anushka/update profile page #566

Merged
merged 15 commits into from
Feb 11, 2024
6 changes: 6 additions & 0 deletions HIAPI/Models/Profile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public struct Profile: Codable, APIReturnable {
//case foodWave
case discordTag
case avatarUrl
case coins
}

public let userId: String
Expand All @@ -39,6 +40,11 @@ public struct Profile: Codable, APIReturnable {
//public let foodWave: Int
public let discordTag: String
public let avatarUrl: String
public let coins: Int
}

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

public struct ProfileFavorites: Codable, APIReturnable {
Expand Down
14 changes: 6 additions & 8 deletions HIAPI/Models/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +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 PRO = Roles(rawValue: 1 << 7)
public static let allRoles = ["USER", "APPLICANT", "ATTENDEE", "MENTOR", "SPONSOR", "STAFF", "ADMIN", "PRO"]
public static let allRoles = ["USER", "APPLICANT", "ATTENDEE", "PRO", "SPONSOR", "STAFF", "ADMIN"]

public init(rawValue: Int) {
self.rawValue = rawValue
Expand All @@ -56,11 +56,10 @@ 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
case "PRO": self = .PRO
default:
#if DEBUG
throw DecodingError.unknownOption
Expand All @@ -75,11 +74,10 @@ 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") }
if contains(.PRO) { try container.encode("PRO") }
}
}

Expand All @@ -94,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
6 changes: 6 additions & 0 deletions HIAPI/Services/ProfileService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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
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)
}
}
23 changes: 21 additions & 2 deletions HackIllinois.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
D1C5B6582B732E44000E766D /* refresh.json in Resources */ = {isa = PBXBuildFile; fileRef = D1C5B6572B732E44000E766D /* refresh.json */; };
D1F1463A2B605C57004E7FC9 /* Hack_Mushroom_Loading.json in Resources */ = {isa = PBXBuildFile; fileRef = D1F146392B605C57004E7FC9 /* Hack_Mushroom_Loading.json */; };
D3A309BC2211175200CBA351 /* PassKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3A309BB2211175200CBA351 /* PassKit.framework */; };
D7451BD22B54BCFB00D501D0 /* URLImage in Frameworks */ = {isa = PBXBuildFile; productRef = D7451BD12B54BCFB00D501D0 /* URLImage */; };
DF3706382925DDAA000B4278 /* GoogleMapsBase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DF3706372925DDAA000B4278 /* GoogleMapsBase.framework */; };
DF37063B2925DDB8000B4278 /* GoogleMaps.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DF3706392925DDB7000B4278 /* GoogleMaps.framework */; };
DF37063C2925DDB8000B4278 /* GoogleMapsCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DF37063A2925DDB8000B4278 /* GoogleMapsCore.framework */; };
Expand Down Expand Up @@ -401,6 +402,7 @@
951E67F923C1C88200477703 /* Lottie in Frameworks */,
DF37063C2925DDB8000B4278 /* GoogleMapsCore.framework in Frameworks */,
951E67F623C1C83B00477703 /* Keychain in Frameworks */,
D7451BD22B54BCFB00D501D0 /* URLImage in Frameworks */,
D3A309BC2211175200CBA351 /* PassKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -859,6 +861,7 @@
packageProductDependencies = (
951E67F523C1C83B00477703 /* Keychain */,
951E67F823C1C88200477703 /* Lottie */,
D7451BD12B54BCFB00D501D0 /* URLImage */,
);
productName = HackIllinois;
productReference = 9518277F1EA35AF100049F79 /* HackIllinois.app */;
Expand Down Expand Up @@ -948,6 +951,7 @@
951E67F123C1C7FD00477703 /* XCRemoteSwiftPackageReference "api-manager" */,
951E67F423C1C83B00477703 /* XCRemoteSwiftPackageReference "keychain" */,
951E67F723C1C88200477703 /* XCRemoteSwiftPackageReference "lottie-ios" */,
D7451BD02B54BCFB00D501D0 /* XCRemoteSwiftPackageReference "url-image" */,
);
productRefGroup = 951827801EA35AF100049F79 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -1175,7 +1179,7 @@
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
Expand Down Expand Up @@ -1239,7 +1243,7 @@
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
Expand Down Expand Up @@ -1293,6 +1297,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = HackIllinois/HackIllinois.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
Expand Down Expand Up @@ -1324,6 +1329,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = HackIllinois/HackIllinois.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
Expand Down Expand Up @@ -1549,6 +1555,14 @@
version = 4.0.1;
};
};
D7451BD02B54BCFB00D501D0 /* XCRemoteSwiftPackageReference "url-image" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/dmytro-anokhin/url-image";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 3.1.1;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -1567,6 +1581,11 @@
package = 951E67F723C1C88200477703 /* XCRemoteSwiftPackageReference "lottie-ios" */;
productName = Lottie;
};
D7451BD12B54BCFB00D501D0 /* URLImage */ = {
isa = XCSwiftPackageProductDependency;
package = D7451BD02B54BCFB00D501D0 /* XCRemoteSwiftPackageReference "url-image" */;
productName = URLImage;
};
/* End XCSwiftPackageProductDependency section */

/* Begin XCVersionGroup section */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"images" : [
{
"filename" : "Ticket.png",
"filename" : "banner.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Ticket@2x.png",
"filename" : "banner (1).png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Ticket@3x.png",
"filename" : "banner (2).png",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Group 344.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 344 (1).png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 344 (2).png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"images" : [
{
"filename" : "Ticket.png",
"filename" : "Vector.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Ticket@2x.png",
"filename" : "Vector (1).png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Ticket@3x.png",
"filename" : "Vector (2).png",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions HackIllinois/Models/HIProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct HIProfile: Codable {
var timezone = ""
var discordTag = ""
var avatarUrl = ""
var coins = 0

init(provider: HIAPI.AuthService.OAuthProvider) {
self.provider = provider
Expand Down
Loading
Loading