Latest 3.1.2
Homepage https://github.com/WeirdMath/TimetableSDK
License MIT
Platforms ios 8.0, osx 10.10, watchos 2.0, tvos 9.0
Dependencies SwiftyJSON, PromiseKit
Authors

Build Status
codecov
Cocoapods

Simple SDK for macOS, iOS and watchOS that allows you to get the data you need from timetable.spbu.ru.

Requirements

  • Swift 3
  • iOS 8.0+
  • macOS 10.10+
  • tvOS 9.0+
  • watchOS 2.0+

Installation

CocoaPods

For the latest release in CocoaPods add the following to your Podfile:

use_frameworks!

pod 'TimetableSDK'

Swift Package Manager

Add TimetableSDK as a dependency to your Package.swift. For example:

let package = Package(
    name: "YourPackageName",
    dependencies: [
        .Package(url: "https://github.com/WeirdMath/TimetableSDK.git", majorVersion: 3)
    ]
)

Usage

You can use the SDK for getting data directly from timetable.spbu.ru:

import TimetableSDK

let timetable = Timetable()

timetable.fetchDivisions() { result in

    switch result {
    case .success(let divisions):

        let physics = divisions[19]

        print(physics.name)
        // "Физика"

        physics.fetchStudyLevels(){ result in

            switch result {
            case .success(let studyLevels):

                print(studyLevels[0].specializations[0].name)
                // "Информационные технологии и численные методы"

            case .failure(let error):
                print(error)
            }
        }
    case .failure(let error):
        print(error)
    }
}

Or — if you want to just test your app and don’t need networking — the data can be deserialized from
JSON files:

import Foundation
import TimetableSDK

let timetable = Timetable()

let url = Bundle.main.url(forResource: "divisions", withExtension: "json")!
let jsonData = try! Data(contentsOf: url)

timetable.fetchDivisions(using: jsonData) { result in
    // ...
}

You can specify a dispatch queue if you need to:

import Dispatch
import TimetableSDK

timetable.fetchDivisions(dispatchQueue: .global(qos: .background)) { result in
    // ...
}

You can use promises!

import TimetableSDK
import PromiseKit

let timetable = Timetable()

timetable.fetchDivisions().then { divisions -> Promise<[StudyLevel]> in

    let physics = divisions[19]

    print(physics.name)
    // "Физика"

    return physics.fetchStudyLevels()

}.then { studyLevels in

    print(studyLevels[0].specializations[0].name)
    // "Информационные технологии и численные методы"

}.catch { error in
    print(error)
}

Contributing

In order to generate an Xcode project for TimetableSDK execute the following command in the root directory of the project:

$ swift package generate-xcodeproj

Latest podspec

{
    "name": "TimetableSDK",
    "version": "3.1.2",
    "summary": "Simple SDK for timetable.spbu.ru that works on macOS, iOS and watchOS",
    "description": "Simple SDK for macOS, iOS and watchOS that allows you to get the datanyou need from timetable.spbu.ru.",
    "homepage": "https://github.com/WeirdMath/TimetableSDK",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Sergej Jaskiewicz": "[email protected]"
    },
    "social_media_url": "http://twitter.com/broadway_lamb",
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/WeirdMath/TimetableSDK.git",
        "tag": "3.1.2"
    },
    "source_files": "Sources/**/*.swift",
    "dependencies": {
        "SwiftyJSON": [
            "~> 3.0"
        ],
        "PromiseKit": [
            "~> 4.0"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This