Changed prefix from WOK to WOP because Kit shouldn't be in the prefix

parent cf60071c
......@@ -11,10 +11,10 @@ import RealmSwift
//This may be a stupid way to handle filters, but it should work; at least for now
public class WOKFilters {
public class WOPFilters {
public var showOpen = true
public var showClosed = true
public var sortBy = WOKSortMethod.alphabetical
public var sortBy = WOPSortMethod.alphabetical
public var openFirst = true
public var showAlerts = ["Informational":true, "Minor Alerts":true, "Major Alerts":true]
......@@ -27,10 +27,10 @@ public class WOKFilters {
//nothing to do here
}
public func applyFiltersOnFacilities(_ facilities: List<WOKFacility>) -> List<WOKFacility> {
public func applyFiltersOnFacilities(_ facilities: List<WOPFacility>) -> List<WOPFacility> {
//TODO: Add checks for onlyFromLocations and onlyFromCategories here before doing the rest
let specifiedFacilities = List<WOKFacility>()
let specifiedFacilities = List<WOPFacility>()
// facility must be within both a specified location and category
for f in facilities {
if onlyFromLocations[(f.facilityLocation?.building)!.lowercased()] == true && onlyFromCategories[(f.category?.categoryName)!.lowercased()] == true {
......@@ -44,7 +44,7 @@ public class WOKFilters {
switch sortBy {
case .alphabetical:
if(openFirst) {
var returning = List<WOKFacility>()
var returning = List<WOPFacility>()
if(showOpen) {
returning += sortAlphabetically(open)
}
......@@ -64,12 +64,12 @@ public class WOKFilters {
return sortAlphabetically(closed)
}
else {
return List<WOKFacility>()
return List<WOPFacility>()
}
}
case .reverseAlphabetical:
if(openFirst) {
var returning = List<WOKFacility>()
var returning = List<WOPFacility>()
if(showOpen) {
returning += sortAlphabetically(open, reverse: true)
}
......@@ -89,12 +89,12 @@ public class WOKFilters {
return sortAlphabetically(closed, reverse: true)
}
else {
return List<WOKFacility>()
return List<WOPFacility>()
}
}
case .byLocation:
if(openFirst) {
var returning = List<WOKFacility>()
var returning = List<WOPFacility>()
if(showOpen) {
returning += sortByLocation(open)
}
......@@ -114,23 +114,23 @@ public class WOKFilters {
return sortByLocation(closed)
}
else {
return List<WOKFacility>()
return List<WOPFacility>()
}
}
}
}
// Takes in array of Facilities, separates them into those open and closed, returning a tuple of 2 arrays
private func separateOpenAndClosed(_ facilities: List<WOKFacility>) -> (open: List<WOKFacility>, closed: List<WOKFacility>) {
let open = List<WOKFacility>()
let closed = List<WOKFacility>()
private func separateOpenAndClosed(_ facilities: List<WOPFacility>) -> (open: List<WOPFacility>, closed: List<WOPFacility>) {
let open = List<WOPFacility>()
let closed = List<WOPFacility>()
/*
facilities.forEach {
Utilities.isOpen(facility: $0) ? open.append($0) : closed.append($0)
}
*/
for facility in facilities {
if WOKUtilities.isOpen(facility: facility) {
if WOPUtilities.isOpen(facility: facility) {
open.append(facility)
}
else {
......@@ -142,7 +142,7 @@ public class WOKFilters {
//TODO
// Sorts items in the given Facility array by name alphabetically (reverse if told)
private func sortAlphabetically(_ facilities: List<WOKFacility>, reverse: Bool = false) -> List<WOKFacility> {
private func sortAlphabetically(_ facilities: List<WOPFacility>, reverse: Bool = false) -> List<WOPFacility> {
// Convert to a swift array because the realm sorting method crashes the list object for some reason?
var facilitiesArray = facilities.asArray()
if !reverse {
......@@ -157,7 +157,7 @@ public class WOKFilters {
//TODO
// Sorts Facilities by their given location's name, and within those sorts A->Z
private func sortByLocation(_ facilities: List<WOKFacility>) -> List<WOKFacility> {
private func sortByLocation(_ facilities: List<WOPFacility>) -> List<WOPFacility> {
var facilitiesArray = facilities.asArray()
facilitiesArray.sort { (facility, nextFacility) in
guard let location = facility.facilityLocation else { return true }
......@@ -206,7 +206,7 @@ public class WOKFilters {
}
//Is this a viable way to do this?
public enum WOKSortMethod {
public enum WOPSortMethod {
case alphabetical //A -> Z
case reverseAlphabetical //Z -> A
case byLocation // A -> Z Locations, w/ A -> Z Facilities inside
......
......@@ -13,7 +13,7 @@ class AlertCollectionViewCell: UICollectionViewCell {
@IBOutlet var imageView: UIImageView!
@IBOutlet var messageLabel: UILabel!
var alert: WOKAlert!
var alert: WOPAlert!
internal let tapRecognizer: UITapGestureRecognizer = UITapGestureRecognizer()
......
......@@ -15,7 +15,7 @@ class FacilityCollectionViewCell: UICollectionViewCell {
@IBOutlet var timeDescriptionLabel: UILabel!
@IBOutlet var openClosedLabel: PaddedUILabel!
@IBOutlet var categoryLabel: UILabel!
var facility: WOKFacility!
var facility: WOPFacility!
internal let tapRecognizer: UITapGestureRecognizer = UITapGestureRecognizer()
override func awakeFromNib() {
......
......@@ -14,7 +14,7 @@ class DetailViewButtonsViewController: UIViewController {
@IBOutlet var facilityDetailView: UIView!
var detailViewController: FacilityDetailViewController?
var facility: WOKFacility!
var facility: WOPFacility!
@IBOutlet var favoritesButton: UIButton!
@IBOutlet var directionsButton: UIButton!
......@@ -27,11 +27,11 @@ class DetailViewButtonsViewController: UIViewController {
removes from favorites if it is a favorite.
*/
@IBAction func setFavButton(_ sender: Any) {
if(WOKUtilities.isFavoriteFacility(facility)) { // if the facility is a favorite
_ = WOKUtilities.removeFavoriteFacility(facility) // remove it from favorites
if(WOPUtilities.isFavoriteFacility(facility)) { // if the facility is a favorite
_ = WOPUtilities.removeFavoriteFacility(facility) // remove it from favorites
}
else { // else add it to favorites
_ = WOKUtilities.addFavoriteFacility(facility)
_ = WOPUtilities.addFavoriteFacility(facility)
}
setFavoriteButtonText()
}
......@@ -67,7 +67,7 @@ class DetailViewButtonsViewController: UIViewController {
@IBAction func shareFacility(_ sender: Any) {
let str = "\(facility.facilityName) is \(WOKUtilities.openOrClosedUntil(facility)!.lowercased())"
let str = "\(facility.facilityName) is \(WOPUtilities.openOrClosedUntil(facility)!.lowercased())"
let shareSheet = UIActivityViewController(activityItems: ["\(str) https://whatsopen.gmu.edu/"], applicationActivities: nil)
shareSheet.excludedActivityTypes = [.print, .openInIBooks, .addToReadingList] // Sorry you can't print a Facility
present(shareSheet, animated: true, completion: nil)
......@@ -77,7 +77,7 @@ class DetailViewButtonsViewController: UIViewController {
Change the favorite button text depending on if the facility is a favorite
*/
func setFavoriteButtonText() {
if(WOKUtilities.isFavoriteFacility(facility)) {
if(WOPUtilities.isFavoriteFacility(facility)) {
favoritesButton.setTitle("Remove from Favorites", for: .normal)
favoritesButton.titleLabel?.text = "Remove from Favorites"
}
......
......@@ -40,8 +40,8 @@ class FiltersTableViewController: UITableViewController {
tableView.reloadData()
updateFacilities()
}
var filters: WOKFilters!
var facilities: List<WOKFacility>!
var filters: WOPFilters!
var facilities: List<WOPFacility>!
//var allLocations: [Locations] = [Locations]()
//var allCategories: [Categories]! = [Categories]()
......@@ -101,7 +101,7 @@ class FiltersTableViewController: UITableViewController {
case 1:
return 1
case 2:
return WOKSortMethod.count
return WOPSortMethod.count
case 3:
return 2
default:
......@@ -163,20 +163,20 @@ class FiltersTableViewController: UITableViewController {
}
return cell
case 2:
let method: WOKSortMethod
let method: WOPSortMethod
let cellText: String
switch indexPath.row {
case 0:
method = WOKSortMethod.alphabetical
method = WOPSortMethod.alphabetical
cellText = "Alphabetically (A-Z)"
case 1:
method = WOKSortMethod.reverseAlphabetical
method = WOPSortMethod.reverseAlphabetical
cellText = "Reverse Alphabetically (Z-A)"
case 2:
method = WOKSortMethod.byLocation
method = WOPSortMethod.byLocation
cellText = "By Location Name (A-Z)"
default:
method = WOKSortMethod.alphabetical
method = WOPSortMethod.alphabetical
cellText = "Alphabetically (A-Z)"
}
let cell: CheckingTableViewCell
......@@ -261,7 +261,7 @@ class FiltersTableViewController: UITableViewController {
}
func onlyCheckOne(_ method: Any?) -> Bool {
filters.sortBy = method as! WOKSortMethod // Be careful when calling this
filters.sortBy = method as! WOPSortMethod // Be careful when calling this
tableView.reloadData()
return true
}
......
......@@ -14,7 +14,7 @@ class AlertDetailViewController: UIViewController {
@IBOutlet var imageView: UIImageView!
@IBOutlet var nameLabel: UILabel!
@IBOutlet var messageView: UITextView!
var alert: WOKAlert!
var alert: WOPAlert!
override func viewDidLoad() {
super.viewDidLoad()
......
......@@ -14,8 +14,8 @@ import WhatsOpenKit
//Realm Model
class FacilitiesModel: Object {
let facilities = List<WOKFacility>()
let alerts = List<WOKAlert>()
let facilities = List<WOPFacility>()
let alerts = List<WOPAlert>()
@objc dynamic var lastUpdated = Date()
@objc dynamic let id = 0
}
......@@ -33,21 +33,21 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
deleteRealmIfMigrationNeeded: true
))
var facilitiesArray = List<WOKFacility>()
var alertsList = List<WOKAlert>()
var facilitiesArray = List<WOPFacility>()
var alertsList = List<WOPAlert>()
var currentAlerts = List<WOKAlert>()
var currentAlerts = List<WOPAlert>()
// array of facilities that pass the current filters
var filteredFacilities = List<WOKFacility>()
var filteredFacilities = List<WOPFacility>()
// List which actually pertains to what is shown
var shownFacilities = List<WOKFacility>()
var shownFacilities = List<WOPFacility>()
// passing in nil sets the search controller to be this controller
let searchController = UISearchController(searchResultsController: nil)
var filters = WOKFilters()
var filters = WOPFilters()
override var preferredStatusBarStyle: UIStatusBarStyle {
return .default
......@@ -88,12 +88,12 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
- returns:
List of facilities that are favorited
*/
func filterFacilitiesForFavorites() -> List<WOKFacility> {
var favoriteFacilites = List<WOKFacility>()
func filterFacilitiesForFavorites() -> List<WOPFacility> {
var favoriteFacilites = List<WOPFacility>()
// add the facility to favorites list if it is a favorite
favoriteFacilites = filteredFacilities.filter({ (facility: WOKFacility) -> Bool in
return WOKUtilities.isFavoriteFacility(facility)
favoriteFacilites = filteredFacilities.filter({ (facility: WOPFacility) -> Bool in
return WOPUtilities.isFavoriteFacility(facility)
})
return favoriteFacilites
......@@ -129,7 +129,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
}
func checkFilterState() {
if(filters.showOpen && filters.showClosed && filters.openFirst && filters.sortBy == WOKSortMethod.alphabetical) {
if(filters.showOpen && filters.showClosed && filters.openFirst && filters.sortBy == WOPSortMethod.alphabetical) {
for f in filters.onlyFromCategories {
if(f.value != true) {
LeftButton.title = "Filter (On)"
......@@ -340,7 +340,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
// all campuses via updateFilterLists
let campusFilters = defaults.dictionary(forKey: "campuses") as! [String: Bool]?
let filteredByCampus = List<WOKFacility>()
let filteredByCampus = List<WOPFacility>()
for facility in filteredFacilities {
if campusFilters![(facility.facilityLocation?.campus.lowercased())!]! {
filteredByCampus.append(facility)
......@@ -352,7 +352,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
favoritesControlChanges(self)
// Alerts
let shown = List<WOKAlert>()
let shown = List<WOPAlert>()
let formatter = ISO8601DateFormatter()
formatter.timeZone = TimeZone(identifier: "America/New_York")
let now = Date()
......@@ -399,8 +399,8 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
- returns:
List of filtered facilities. Facilities whose names, buildings, or categories match the search text are included.
*/
func filterFacilitiesForSearchText(_ searchText: String) -> List<WOKFacility> {
var filtered: List<WOKFacility>
func filterFacilitiesForSearchText(_ searchText: String) -> List<WOPFacility> {
var filtered: List<WOPFacility>
/*
if showFavorites {
......@@ -425,7 +425,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
LocationsList.reloadData()
return shownFacilities
}
filtered = filteredFacilities.filter({(facility: WOKFacility) -> Bool in
filtered = filteredFacilities.filter({(facility: WOPFacility) -> Bool in
let hasName = facility.facilityName.lowercased().contains(searchText.lowercased())
let hasBuilding = facility.facilityLocation?.building.lowercased().contains(searchText.lowercased()) ?? false
let hasAbbreviation = facility.facilityLocation?.abbreviation.lowercased().contains(searchText.lowercased()) ?? false
......@@ -527,7 +527,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
* and place that new information into Realm
*/
func update(_ sender: Any, completion: (() -> ())? = nil) {
WOKDownloadController.performDownload { (facilities) in
WOPDownloadController.performDownload { (facilities) in
if(facilities == nil) {
DispatchQueue.main.async {
let results = self.realm.objects(FacilitiesModel.self)
......@@ -547,7 +547,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
}
}
else {
self.facilitiesArray = List<WOKFacility>()
self.facilitiesArray = List<WOPFacility>()
}
}
}
......@@ -593,7 +593,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
}
}
}
WOKDownloadController.performAlertsDownload { (alerts) in
WOPDownloadController.performAlertsDownload { (alerts) in
if(alerts == nil) {
DispatchQueue.main.async {
let results = self.realm.objects(FacilitiesModel.self)
......@@ -602,7 +602,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
self.alertsList = model.alerts
}
else {
self.alertsList = List<WOKAlert>()
self.alertsList = List<WOPAlert>()
}
}
}
......@@ -687,7 +687,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
cell.gestureRecognizers?.append(cell.tapRecognizer)
let facility: WOKFacility
let facility: WOPFacility
//let dataArray: [Facility]
/*
......@@ -714,13 +714,13 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
cell.nameLabel.text = name
cell.categoryLabel.text = facility.category?.categoryName.uppercased()
cell.openClosedLabel.text = WOKUtilities.openOrClosedUntil(facility)
cell.openClosedLabel.text = WOPUtilities.openOrClosedUntil(facility)
// TODO: Change the name of this label
cell.timeDescriptionLabel.text = facility.facilityLocation?.building
//change appearence based on open state
let open = WOKUtilities.isOpen(facility: facility)
let open = WOPUtilities.isOpen(facility: facility)
if(open == true) {
//cell.openClosedLabel.text = "Open"
cell.openClosedLabel.textColor = UIColor.black
......@@ -846,7 +846,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
//unused
func getLocationArray(_ facilitiesArray: List<WOKFacility>) -> [WOKFacility] {
func getLocationArray(_ facilitiesArray: List<WOPFacility>) -> [WOPFacility] {
if(!showFavorites) {
return placeOpenFacilitiesFirstInArray(facilitiesArray)
}
......@@ -861,12 +861,12 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
// Returns an array which has the open locations listed first
// Could be improved in the future because currently this means you're checking
// open status twice per cell
func placeOpenFacilitiesFirstInArray(_ facilitiesArray: List<WOKFacility>) -> [WOKFacility] {
var open = [WOKFacility]()
var closed = [WOKFacility]()
func placeOpenFacilitiesFirstInArray(_ facilitiesArray: List<WOPFacility>) -> [WOPFacility] {
var open = [WOPFacility]()
var closed = [WOPFacility]()
for i in facilitiesArray {
if(WOKUtilities.isOpen(facility: i)) {
if(WOPUtilities.isOpen(facility: i)) {
open.append(i)
}
else {
......@@ -878,12 +878,12 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
}
//unused
func countForOpenAndClosedFacilities(_ facilitiesArray: Array<WOKFacility>) -> (open: Int, closed: Int) {
func countForOpenAndClosedFacilities(_ facilitiesArray: Array<WOPFacility>) -> (open: Int, closed: Int) {
var open = 0
var closed = 0
for i in facilitiesArray {
if(WOKUtilities.isOpen(facility: i)) {
if(WOPUtilities.isOpen(facility: i)) {
open += 1
}
else {
......
......@@ -21,11 +21,11 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
let activity = NSUserActivity(activityType: "facility")
var facility: WOKFacility!
var facility: WOPFacility!
override var previewActionItems: [UIPreviewActionItem] {
var title: String
if(WOKUtilities.isFavoriteFacility(facility)) {
if(WOPUtilities.isFavoriteFacility(facility)) {
title = "Remove from Favorites"
}
else {
......@@ -60,8 +60,8 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
CategoryLabel.text = facility.category?.categoryName.uppercased()
let open = WOKUtilities.isOpen(facility: facility)
OpenLabel.text = WOKUtilities.openOrClosedUntil(facility)
let open = WOPUtilities.isOpen(facility: facility)
OpenLabel.text = WOPUtilities.openOrClosedUntil(facility)
OpenLabel.layer.cornerRadius = 4
OpenLabel.layer.masksToBounds = true
if(open) {
......@@ -109,7 +109,7 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return WOKUtilities.getCurrentSchedule(facility)!.openTimes.count
return WOPUtilities.getCurrentSchedule(facility)!.openTimes.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
......@@ -117,10 +117,10 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
cell.selectionStyle = .none
let schedule = WOKUtilities.getCurrentSchedule(facility)
let schedule = WOPUtilities.getCurrentSchedule(facility)
let openTime = schedule!.openTimes[indexPath.row]
cell.textLabel?.text = WOKUtilities.getDayOfWeek(WOKDay(rawValue: openTime.startDay)!)
cell.detailTextLabel?.text = WOKUtilities.getFormattedStartandEnd(openTime)
cell.textLabel?.text = WOPUtilities.getDayOfWeek(WOPDay(rawValue: openTime.startDay)!)
cell.detailTextLabel?.text = WOPUtilities.getFormattedStartandEnd(openTime)
cell.textLabel?.font = UIFont.preferredFont(forTextStyle: .headline)
cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .body)
......@@ -129,11 +129,11 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
}
func markAsFavoritePreviewAction(_ sendingAction: UIPreviewAction, sender: UIViewController) {
if(WOKUtilities.isFavoriteFacility(facility)) {
_ = WOKUtilities.removeFavoriteFacility(facility)
if(WOPUtilities.isFavoriteFacility(facility)) {
_ = WOPUtilities.removeFavoriteFacility(facility)
}
else {
_ = WOKUtilities.addFavoriteFacility(facility)
_ = WOPUtilities.addFavoriteFacility(facility)
}
}
}
......@@ -101,7 +101,7 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
cell.textLabel?.text = "Show Alerts"
cell.textLabel?.font = UIFont.preferredFont(forTextStyle: .body)
cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .footnote)
let alerts = WOKUtilities.getAlertDefaults()
let alerts = WOPUtilities.getAlertDefaults()
var i = 0
for c in alerts {
if(c.value == true) {
......@@ -121,7 +121,7 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
cell.textLabel?.text = "Show Campuses"
cell.textLabel?.font = UIFont.preferredFont(forTextStyle: .body)
cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .footnote)
let campuses = WOKUtilities.getCampusDefaults()
let campuses = WOPUtilities.getCampusDefaults()
var i = 0
for c in campuses {
if(c.value == true) {
......@@ -280,17 +280,17 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
if (sender as! UITableViewCell).textLabel?.text == "Show Alerts" {
let destination = segue.destination as! FilterSelectionTableViewController
destination.navigationItem.title = "Show Alerts"
destination.getFunc = WOKUtilities.getAlertDefaults
destination.selectFunc = WOKUtilities.setAlertDefaults
destination.selectAllFunc = WOKUtilities.setAllAlertDefaults
destination.getFunc = WOPUtilities.getAlertDefaults
destination.selectFunc = WOPUtilities.setAlertDefaults
destination.selectAllFunc = WOPUtilities.setAllAlertDefaults
destination.updateFacilities = updateFacilities
}
else if (sender as! UITableViewCell).textLabel?.text == "Show Campuses" {
let destination = segue.destination as! FilterSelectionTableViewController
destination.navigationItem.title = "Show Campuses"
destination.getFunc = WOKUtilities.getCampusDefaults
destination.selectFunc = WOKUtilities.setCampusDefaults
destination.selectAllFunc = WOKUtilities.setAllCampusDefaults
destination.getFunc = WOPUtilities.getCampusDefaults
destination.selectFunc = WOPUtilities.setCampusDefaults
destination.selectAllFunc = WOPUtilities.setAllCampusDefaults
destination.updateFacilities = updateFacilities
}
}
......
......@@ -11,9 +11,9 @@ import RealmSwift
import Realm
import ObjectMapper
public class WOKDownloadController: NSObject {
public class WOPDownloadController: NSObject {
//https://api.srct.gmu.edu/whatsopen/v2/facilities/?format=json
public static func performDownload(completion: @escaping (_ result: List<WOKFacility>?) -> Void) {
public static func performDownload(completion: @escaping (_ result: List<WOPFacility>?) -> Void) {
let requestURL: NSURL = NSURL(string: "https://api.srct.gmu.edu/whatsopen/v2/facilities/?format=json")!
let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: requestURL as URL)
......@@ -33,8 +33,8 @@ public class WOKDownloadController: NSObject {
if let dataN = data {
if let json = try? JSONSerialization.jsonObject(with: dataN, options: []) as? [[String: Any]] {
// Map function to iterate through each JSON tree
let facilities = json!.map({ (json) -> WOKFacility in
let facility = WOKFacility()
let facilities = json!.map({ (json) -> WOPFacility in
let facility = WOPFacility()
let map = Map(mappingType: .fromJSON, JSON: json, toObject: true, context: facility, shouldIncludeNilValues: true)
facility.mapping(map: map)
return facility
......@@ -52,7 +52,7 @@ public class WOKDownloadController: NSObject {
}
public static func performAlertsDownload(completion: @escaping (_ result: List<WOKAlert>?) -> Void) {
public static func performAlertsDownload(completion: @escaping (_ result: List<WOPAlert>?) -> Void) {
let requestURL: NSURL = NSURL(string: "https://api.srct.gmu.edu/whatsopen/v2/alerts/?format=json")!
let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: requestURL as URL)
......@@ -72,8 +72,8 @@ public class WOKDownloadController: NSObject {
if let dataN = data {
if let json = try? JSONSerialization.jsonObject(with: dataN, options: []) as? [[String: Any]] {
// Map function to iterate through each JSON tree
let alerts = json!.map({ (json) -> WOKAlert in
let alert = WOKAlert()
let alerts = json!.map({ (json) -> WOPAlert in
let alert = WOPAlert()
let map = Map(mappingType: .fromJSON, JSON: json, toObject: true, context: alert, shouldIncludeNilValues: true)
alert.mapping(map: map)
return alert
......
......@@ -8,7 +8,7 @@ import ObjectMapper_Realm
// MARK: - Data Model
//
public enum WOKDay: Int {
public enum WOPDay: Int {
case Monday = 0
case Tuesday = 1
case Wednesday = 2
......@@ -20,15 +20,15 @@ public enum WOKDay: Int {
// Add functions here later if we need them
}
public class WOKFacility: Object, MapContext, Mappable {
public class WOPFacility: Object, MapContext, Mappable {
@objc public dynamic var slug = ""
@objc public dynamic var facilityName = ""
@objc public dynamic var facilityLocation: WOKLocations? = WOKLocations()
@objc public dynamic var category: WOKCategories? = WOKCategories()