-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd018ad
commit 06dbdf7
Showing
30 changed files
with
1,837 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build | ||
run: swift build -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: SwiftLint | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
swiftlint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: SwiftLint | ||
uses: norio-nomura/[email protected] | ||
with: | ||
args: --strict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
included: | ||
- Sources | ||
- ./Package.swift | ||
disabled_rules: | ||
todo | ||
line_length: | ||
warning: 170 | ||
ignores_urls: true | ||
ignores_function_declarations: true | ||
ignores_comments: true | ||
ignores_interpolated_strings: true | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
8 changes: 8 additions & 0 deletions
8
.swiftpm/xcode/package.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1430" | ||
version = "1.7"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "StudentVue" | ||
BuildableName = "StudentVue" | ||
BlueprintName = "StudentVue" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "NO" | ||
buildForArchiving = "NO" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "StudentVueTests" | ||
BuildableName = "StudentVueTests" | ||
BlueprintName = "StudentVueTests" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
shouldAutocreateTestPlan = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "StudentVueTests" | ||
BuildableName = "StudentVueTests" | ||
BlueprintName = "StudentVueTests" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "StudentVue" | ||
BuildableName = "StudentVue" | ||
BlueprintName = "StudentVue" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "swxmlhash", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/drmohundro/SWXMLHash", | ||
"state" : { | ||
"revision" : "4d0f62f561458cbe1f732171e625f03195151b60", | ||
"version" : "7.0.1" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// swift-tools-version: 5.8 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "StudentVue", | ||
platforms: [ | ||
.iOS(.v13), | ||
.macOS(.v13) | ||
], | ||
products: [ | ||
.library( | ||
name: "StudentVue", | ||
targets: ["StudentVue"]) | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/drmohundro/SWXMLHash", from: "7.0.1") | ||
], | ||
targets: [ | ||
.target( | ||
name: "StudentVue", | ||
dependencies: [ | ||
"SWXMLHash" | ||
]) | ||
], | ||
swiftLanguageVersions: [.v5] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,52 @@ | ||
# StudentVue.swift | ||
Swift StudentVue library | ||
|
||
![Supported Platforms](https://img.shields.io/badge/platform-ios%20%7C%20macos-lightgrey.svg?style=flat) | ||
[![MIT](https://img.shields.io/github/license/TheMoonThatRises/StudentVue.swift.svg?style=flat)](https://github.com/TheMoonThatRises/StudentVue.swift) | ||
|
||
Swift library for interacting with StudentVue's api. This project was heavily influenced by [StudentVue.js](https://github.com/StudentVue/StudentVue.js) and relied on information provided by their [documentation](https://github.com/StudentVue/docs). This library is still a work in progress and if you encounter an issue, feel free to create an [issue](https://github.com/TheMoonThatRises/StudentVue.swift/issues/new) or submit a [pull request](https://github.com/TheMoonThatRises/StudentVue.swift/pulls). | ||
|
||
## Installation | ||
|
||
```swift | ||
.package(url: "https://github.com/TheMoonThatRises/StudentVue.swift", from: "0.0.1") | ||
``` | ||
|
||
## Basic usage | ||
|
||
### Logging in as a student | ||
|
||
To create a client instance, use | ||
|
||
```swift | ||
import StudentVue | ||
|
||
let client = StudentVue(domain: "something.edupoint.com", username: "123456789", password: "password") | ||
``` | ||
|
||
With the client initialized, you can access information by using the provided functions such as `getGradeBook`, `getClassSchedule`, `getSchoolInfo`, and many more. If one of the functions fails to parse or you want to access information in which a data structure is not created, you can call the `makeServiceRequest` and parse the XML manually. | ||
|
||
```swift | ||
let gradebook = client.getGradeBook() | ||
``` | ||
|
||
### Static functions | ||
|
||
For some functions, logging in is not required, such as getting district zip codes | ||
|
||
```swift | ||
|
||
import StudentVue | ||
|
||
let districts = StudentVue.getDistricts(zip: "a zip code") | ||
``` | ||
|
||
## Todo List | ||
|
||
- [ ] A website for documentation | ||
- [ ] More complete structures for returned data | ||
- [ ] Use the WSDL file to help with the data structure | ||
- [ ] Use a proper SOAP handler instead of the "hacky" solution | ||
|
||
## Library Used | ||
|
||
- [SWXMLHash](https://github.com/drmohundro/SWXMLHash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Errors.swift | ||
// | ||
// | ||
// Created by TheMoonThatRises on 4/11/23. | ||
// | ||
|
||
import Foundation | ||
|
||
enum StudentVueErrors: LocalizedError { | ||
case unreachableURL(String) | ||
case emptyResponse | ||
case clientNotIntialised | ||
case soapError(String) | ||
} | ||
|
||
extension StudentVueErrors { | ||
var errorDescription: String? { | ||
switch self { | ||
case .unreachableURL(let string): | ||
return "Unable to reach domain: \(string)" | ||
case .emptyResponse: | ||
return "Empty response body" | ||
case .clientNotIntialised: | ||
return "StudentVue client has not been created" | ||
case .soapError(let string): | ||
return "Soap request returned error: \(string)" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Date+deserialize.swift | ||
// | ||
// | ||
// Created by TheMoonThatRises on 4/12/23. | ||
// | ||
|
||
import Foundation | ||
import SWXMLHash | ||
|
||
extension Date: XMLValueDeserialization { | ||
/// Allows for deserialization of dates from an XML element | ||
/// | ||
/// - Parameter element: XMLElement where the date is parsed | ||
/// | ||
/// - Throws: `XMLDeserializationError.typeConversionFailed` Unable to convert XMLElement to Date | ||
/// | ||
/// - Returns: Date converted from XMLElement | ||
public static func deserialize(_ element: XMLHash.XMLElement) throws -> Date { | ||
let date = stringToDate(element.text) | ||
|
||
guard let validDate = date else { | ||
throw XMLDeserializationError.typeConversionFailed(type: "Date", element: element) | ||
} | ||
|
||
return validDate | ||
} | ||
|
||
/// Allows for deserialization of dates from an XML attribute | ||
/// | ||
/// - Parameter attribute: XMLAttribute where the date is parsed | ||
/// | ||
/// - Throws: `XMLDeserializationError.typeConversionFailed` Unable to convert XMLAttribute to Date | ||
/// | ||
/// - Returns: Date converted from XMLAttribute | ||
public static func deserialize(_ attribute: XMLAttribute) throws -> Date { | ||
let date = stringToDate(attribute.text) | ||
|
||
guard let validDate = date else { | ||
throw XMLDeserializationError.attributeDeserializationFailed(type: "Date", attribute: attribute) | ||
} | ||
|
||
return validDate | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by TheMoonThatRises on 4/16/23. | ||
// | ||
|
||
import Foundation | ||
import SWXMLHash | ||
|
||
extension Date { | ||
/// Formats of dates StudentVue returns | ||
private static let decodeDateFormats = ["MM/dd/yy", "MM/dd/yy HH:mm:ss", "MM/dd/yy HH:mm:ss a", "yyyy-MM-dd'T'HH:mm:ss", "HH:mm a"] | ||
|
||
/// Converts String to Date using a defined array of date formats | ||
/// | ||
/// - Parameter dateAsString: The date to be converted as a string | ||
/// | ||
/// - Returns: Date converted from a string | ||
public static func stringToDate(_ dateAsString: String) -> Date? { | ||
let dateFormatter = DateFormatter() | ||
|
||
for format in decodeDateFormats { | ||
dateFormatter.dateFormat = format | ||
|
||
if let formatted = dateFormatter.date(from: dateAsString) { | ||
return formatted | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
} |
Oops, something went wrong.