Skip to content

Commit

Permalink
Merge pull request #458 from HackIllinois/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ashayp22 authored Mar 2, 2022
2 parents 4975773 + 72f0e51 commit 88b3783
Show file tree
Hide file tree
Showing 425 changed files with 2,477 additions and 6,269 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# codeowners' reviews are required before merging

* @redsn0w422 @sujaypat @PatrickKan @jeffkim2001
* @PatrickKan @jeffkim2001 @ashayp22

23 changes: 23 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Description

Fixes #135

<!--
A few bullet points describing the overall goals of the pull request's commits.
-->

## Todos

<!--
- [ ] Tests
- [ ] More Tests
- [ ] Documentation
-->

## Screenshots

<!--
Mac OS Screenshots: ctrl + shift + cmd + 3 (entire screen) or 4 (selection of screen), then paste in editor
Mac OS GIFs: Try using Kap
Linux/Windows: Ctrl + Alt + PrintScreen (of a window) or Ctrl + Shift + PrintScreen (selection of screen), then paste in editor
-->
7 changes: 7 additions & 0 deletions HIAPI/Models/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public struct Event: Codable {
case sponsor
case startTime
case points
case isAsync
}

public let id: String
Expand All @@ -46,6 +47,7 @@ public struct Event: Codable {
public let sponsor: String
public let startTime: Date
public let points: Int
public let isAsync: Bool
}

public struct Location: Codable {
Expand All @@ -70,3 +72,8 @@ public struct EventCheckInStatus: Codable, APIReturnable {
public let totalPoints: Int
public let status: String
}

public struct EventTracker: Codable {
public let eventId: String
public let users: [String]
}
42 changes: 36 additions & 6 deletions HIAPI/Models/Profile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,56 @@ public struct Profile: Codable, APIReturnable {
case lastName
case points
case timezone
case info = "description"
case discord
case avatarUrl
case teamStatus
case interests
}

public let id: String
public let firstName: String
public let lastName: String
public let points: Int
public let timezone: String
public let info: String
public let discord: String
public let avatarUrl: String
public let teamStatus: String
public let interests: [String]
}

public struct ProfileFavorites: Codable, APIReturnable {
public let id: String
public let profiles: Set<String>
}

public struct LeaderboardProfileContainer: Decodable, APIReturnable {
public let profiles: [LeaderboardProfile]

public init(from data: Data) throws {
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .secondsSince1970
self = try decoder.decode(LeaderboardProfileContainer.self, from: data)
}
}

public struct LeaderboardProfile: Codable, APIReturnable {
internal enum CodingKeys: String, CodingKey {
case id
case discord
case points
}

public let id: String
public let discord: String
public let points: Int
}

public struct TiersContainer: Decodable, APIReturnable {
public let tiers: [Tier]
public init(from data: Data) throws {
let decoder = JSONDecoder()
let tiers = try decoder.decode([Tier].self, from: data)
self.tiers = tiers
}
}

public struct Tier: Codable, APIReturnable {
public let name: String
public let threshold: Int
}
6 changes: 1 addition & 5 deletions HIAPI/Models/Time.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ public struct EventTimes: Codable {
public let saturdayEnd: Date
public let sundayStart: Date
public let sundayEnd: Date
public let mondayStart: Date
public let mondayEnd: Date

public init(eventStart: Date, eventEnd: Date, hackStart: Date, hackEnd: Date, fridayStart: Date, fridayEnd: Date,
saturdayStart: Date, saturdayEnd: Date, sundayStart: Date, sundayEnd: Date, mondayStart: Date, mondayEnd: Date) {
saturdayStart: Date, saturdayEnd: Date, sundayStart: Date, sundayEnd: Date) {
self.eventStart = eventStart
self.eventEnd = eventEnd
self.hackStart = hackStart
Expand All @@ -55,7 +53,5 @@ public struct EventTimes: Codable {
self.saturdayEnd = saturdayEnd
self.sundayStart = sundayStart
self.sundayEnd = sundayEnd
self.mondayStart = mondayStart
self.mondayEnd = mondayEnd
}
}
4 changes: 2 additions & 2 deletions HIAPI/Services/EventService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public class EventService: BaseService {
public static func favoriteBy(id: String) -> APIRequest<EventFavorites> {
var body = HTTPBody()
body["eventId"] = id
return APIRequest<EventFavorites>(service: self, endpoint: "favorite/add/", body: body, method: .POST)
return APIRequest<EventFavorites>(service: self, endpoint: "favorite/", body: body, method: .POST)
}

public static func unfavoriteBy(id: String) -> APIRequest<EventFavorites> {
var body = HTTPBody()
body["eventId"] = id
return APIRequest<EventFavorites>(service: self, endpoint: "favorite/remove/", body: body, method: .POST)
return APIRequest<EventFavorites>(service: self, endpoint: "favorite/", body: body, method: .DELETE)
}

}
6 changes: 6 additions & 0 deletions HIAPI/Services/ProfileService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,10 @@ public final class ProfileService: BaseService {
return APIRequest<ProfileFavorites>(service: self, endpoint: "favorite/remove/", body: body, method: .POST)
}

public static func getLeaderboard(num: Int) -> APIRequest<LeaderboardProfileContainer> {
return APIRequest<LeaderboardProfileContainer>(service: self, endpoint: "leaderboard/?limit=\(num)", headers: headers, method: .GET)
}
public static func getTiers() -> APIRequest<TiersContainer> {
return APIRequest<TiersContainer>(service: self, endpoint: "tier/threshold/", headers: headers, method: .GET)
}
}
Loading

0 comments on commit 88b3783

Please sign in to comment.