TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Feb 2018 |
SPMSupports SPM | ✗ |
Maintained by John Kotz.
Depends on: | |
SwiftyJSON | >= 0 |
Socket.IO-Client-Swift | >= 0 |
A framework used by DALI Lab members to access the internal API, which stores all information about DALI's projects, members, and events.
The API protects its data using two methods: private API key and Google OAuth2. This is done to support two different use cases: static installment or user-personal device.
A user-personal product could be an iOS app, Watch OS app, or anything that is personal to a user. This type of authentication uses the user's login credentials with Google to authenticate and identify them.
Qualifications:
Authenticating Using Google Signin:
user.authentication
DALIapi.signin(accessToken: accessToken, refreshToken: refreshToken) { (success, error) in
if success {
// Continue into the app
// Your api will handle authenticated requests from here on
} else if let error = error {
// There was an error
// Most likely the user didn't use a @dali.dartmouth.edu email
}
}
Althernate Method: Google OAuth2:
Some Google Signing sign-in systems (Not GoogleSignIn) may not sign the user in all the way, and instead of giving access and refresh tokens gives an authCode. In this case use DALIapi.signin(authCode: authCode) { ... }
.
A static-installment product could be an Apple TV app, a kiosk-type desktop application, or pretty much anything that doesn't need user sign-in. Its up to your imagination
Qualifications:
Authenticating Using API Key:
let file = NSDictionary(contentsOfFile: "path/to/your/file.plist")
let config = DALIConfig(dict: file)
// ...
let config = DALIConfig(dict: file)
DALIapi.configure(config)
Done! Now you may make all the requests you are authorized to.
Now that you have authenticated your system you can move on to Events. The event route is one of the simplest because it requires no special data and no requirements on authentication usage.
DALIEvent.getAll { (events, error) in
if let error = error {
// Encountered a problem
// Check the type;
if error == DALIError.General.Unauthorized {
// ...
}else if ... {
// ...
}
return
}
// The events list is a [DALIEvent]? object
}
DALIEvent.getUpcoming { (events, error) in
// ...
}
DALIEvent.create { (success, error) in
// ...
}
DALI uses bluetooth beacon technology to identify when a device is in the lab. You can use this to gain access to the location flag (in DALI or not) for Tim or any other member.
DALILocation.Tim.get { (tim, error) in
if let error = error {
// Encountered error...
return
}
if tim.inDALI {
// ...
}else if tim.inOffice {
// ...
}
}
DALILocation.Shared.get { (members, error) in
if let error = error {
//...
}
guard let members: [DALIMember] = members else {
return
}
// ..
}
DALI is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "DALI"
Example project is still in alpha
To run the example project, clone the repo, and run pod install
from the Example directory first.
John Kotz, [email protected]
You must be a member of the DALI Lab or be working on behalf (with the permission) of the DALI Lab to use this pod. By using this cocoapod you acknowledge this requirement.
Some routes will intentionally crash your app if you use them without proper permission. Check out the docs on Protected Functions.
DALI is available under the MIT license. See the LICENSE file for more info.