GithubHelp home page GithubHelp logo

gotranseo / oneroster Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 118 KB

A Swift library for interacting with the OneRoster API

Home Page: https://www.imsglobal.org/oneroster-v11-final-specification

License: Apache License 2.0

Swift 94.16% Dockerfile 0.72% Shell 5.11%
swift vapor oneroster ims

oneroster's Introduction

OneRoster

A Vapor package for interacting with a OneRoster v1.1 JSON IMS API.

What is OneRoster?

OneRoster is a standard developed by IMS Global that specifies how technology providers can communicate with technology repositories of student data. It can be used to auto-populate products when a school subscribes, roster students, and pull grade/demographic information. We built this library to make it easier to interact with.

Installation

OneRoster is available through SPM. To install it, simply add the following to the dependencies array in your Package.swift file:

.package(url: "https://github.com/gotranseo/oneroster.git", from: "2.0.0")

Don't forget to also add it to your target's dependencies:

.product(name: "OneRoster", package: "OneRoster")

Usage

To obtain a client for making OneRoster endpoint requests, call Application.oneRoster(baseURL:) or Request.oneRoster(baseURL:). If you are calling a server which requires OAuth 1 authorization, use, the .oauth1OneRoster(baseURL:clientId:clientSecret:) method. For an OAuth 2 server, use .oauth2OneRoster(baseURL:clientId:clientSecret:):

let imsURL = URL(string: "https://ims-server-here/")!
let noAuthClient = req.oneRoster(baseURL: imsURL)
let oauth1Client = req.oauth1OneRoster(baseURL: imsURL, clientId: "my-client-id", clientSecret: "my-client-secret")
let oauth2Client = req.oauth2OneRoster(baseURL: imsURL, clientId: "my-client-id", clientSecret: "my-client-secret")

Due to the way OneRoster's API is specified, we are forced to have two different request methods: .request(_:as:filter:) for requesting single entities, and request(_:as:offset:limit:filter:) for requesting arrays of entities. For example, to call the getAllSchools endpoint:

let data = try client.request(.getAllSchools, as: OneRoster.SchoolsResponse.self, limit: 100, offset: 0)

To call a single-entity endpoint, such as getSchool:

let school = try client.request(.getSchool(id: "1"), as: OneRoster.SchoolResponse.self)

Enjoy!

oneroster's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

bradrhine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.