clever

package module
v2.2.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

README

clever-go

clever-go is a Go library for the Clever API.

Documentation

GoDoc

Usage

import "gopkg.in/Clever/clever-go.v2"

Releasing a new version

clever-go is versioned with gopkg.in. To release a new version of the library, you should increment the version in the VERSION file according to the semver spec and create a tag with the corresponding version.

You can use gitsem to accomplish this all with one command. For example, to release a new minor version, you can just run gitsem minor && git push && git push --tag from the repository.

Developing

clever-go is built and tested against Go 1.5. Ensure this is the version of Go you're running with go version. Make sure your GOPATH is set, e.g. export GOPATH=~/go. Clone the repository to a location outside your GOPATH, and symlink it to $GOPATH/src/github.com/Clever/clever-go. Since some dependencies are Mercurial repositories, ensure that you have Mercurial installed. The godoc command line tool can be used to generate documentation from comments in source. This is useful for enforcing good commenting practices and ensures a standard, readable format for the resulting documentation. If godoc is not already installed, instructions to install can be found here. If you have done all of the above, then you should be able to run

make

Documentation

Overview

Package clever is a Go library for the Clever API: https://clever.com/developers/docs.

Usage

package main

import (
	"golang.org/x/oauth2"
	clevergo "gopkg.in/Clever/clever-go.v2"
	"log"
)

func main() {
	t := &oauth.Transport{
		Source: oauth.StaticTokenSource(&oauth2.Token{AccessToken: "DEMO_TOKEN"}),
	}
	client := &http.client{Transport: t}
	clever := clevergo.New(client, "https://api.clever.com")
	paged := clever.QueryAll("/v1.1/districts", nil)
	for paged.Next() {
		var district clevergo.District
		if err := paged.Scan(&district); err != nil {
			log.Fatal(err)
		}
		log.Println(district)
	}
	if err := paged.Error(); err != nil {
		log.Fatal(err)
	}
}

Index

Constants

View Source
const Version = "1.4.0"

Version is the current Clever API version.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuthTransport

type BasicAuthTransport struct {
	Username string
	Password string
}

BasicAuthTransport is an http.Transport that performs HTTP Basic Auth.

func (*BasicAuthTransport) Client

func (bat *BasicAuthTransport) Client() *http.Client

Client returns a new Client object for the specified BasicAuthTransport

func (BasicAuthTransport) RoundTrip

func (bat BasicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip makes a request and returns the response

type Clever

type Clever struct {
	// contains filtered or unexported fields
}

Clever wraps the Clever API at the specified URL e.g. "https://api.clever.com"

func New

func New(client *http.Client, url string) *Clever

New returns a new Clever object to make requests with. URL must be a valid base url, e.g. "https://api.clever.com"

func (*Clever) Query

func (clever *Clever) Query(path string, params url.Values, resp interface{}) error

Query makes a GET request to Clever using the Request function (see below)

func (*Clever) QueryAll

func (clever *Clever) QueryAll(path string, params url.Values) PagedResult

QueryAll returns a PagedResult to allow for paged reading of large responses from the Clever API

func (*Clever) Request

func (clever *Clever) Request(method string, path string, params url.Values, body interface{}, resp interface{}) error

Request makes a request to Clever given a Clever object, http method, endpoint path, parameters (pass in nil for no parameters), and a body .

type CleverError

type CleverError struct {
	Code    int
	Message string `json:"error"`
}

CleverError contains an error that occurred within the Clever API

func (*CleverError) Error

func (err *CleverError) Error() string

Error returns a string representation of a CleverError

type Contact

type Contact struct {
	ID           string
	Student      string
	Type         string
	Name         string
	Relationship string
	Phone        string
	PhoneType    string `json:"phone_type"`
	Email        string
	District     string
}

Contact corresponds to the Contact resource in the Clever data schema: clever.com/schema

type ContactResp

type ContactResp struct {
	Links   []Link
	Contact Contact `json:"data"`
}

ContactResp wraps the response given when the user queries for a Contact

type Credentials

type Credentials struct {
	DistrictUsername string `json:"district_username"`
}

Credentials corresponds to credentials for a Student or Teacher

type District

type District struct {
	ID        string
	Name      string
	MdrNumber string `json:"mdr_number"`
}

District corresponds to the District resource in the Clever data schema: clever.com/schema

type DistrictAdmin

type DistrictAdmin struct {
	ID       string
	District string
	Name     Name
	Title    string
	Email    string
}

DistrictAdmin corresponds to the DistrictAdmin resource in the Clever data schema: clever.com/schema

type DistrictAdminResp

type DistrictAdminResp struct {
	Links         []Link
	DistrictAdmin DistrictAdmin `json:"data"`
}

DistrictAdminResp wraps the response given when the user queries for a DistrictAdmin

type DistrictResp

type DistrictResp struct {
	District District `json:"data"`
	Links    []Link
	URI      string
}

DistrictResp wraps the response given when the user queries for a District

type Event added in v1.4.0

type Event struct {
	Type    string
	Created string
	ID      string
	Data    struct {
		Object map[string]interface{}
	}
}

Event represents a data change on an underlying collection. Example types include students.created and teachers.deleted.

type EventResp added in v1.4.0

type EventResp struct {
	Links []Link
	Event Event `json:"data"`
	URI   string
}

EventResp represents an HTTP response returning data on one Event.

type Link struct {
	Rel string
	URI string
}

Link represents a stable link for querying the API

type Location

type Location struct {
	Address string
	City    string
	State   string
	Zip     string
	Lon     string
	Lat     string
}

Location represents a complete address for use with the Student and School resources

type Name

type Name struct {
	First  string
	Middle string
	Last   string
}

Name represents the full name of a Student or Teacher resource

type PagedResult

type PagedResult struct {
	// contains filtered or unexported fields
}

PagedResult wraps a response. It allows for paged reading of a response in conjunction with QueryAll() and Next()

func (*PagedResult) Error

func (r *PagedResult) Error() error

Error returns the error in a response, if there is one

func (*PagedResult) Next

func (r *PagedResult) Next() bool

Next returns true if a PagedResult contains additional data and false if the cursor has reached the end of the available data for this response.

func (*PagedResult) Scan

func (r *PagedResult) Scan(result interface{}) error

Scan parses the next page of results in a PagedResult r into result. Scan throws an error if r is invalid JSON.

type Paging

type Paging struct {
	Count   int
	Current int
	Total   int
}

Paging contains information for paging a response

type Principal

type Principal struct {
	Name  string
	Email string
}

Principal represents a principal for a school

type School

type School struct {
	Created      string
	District     string
	HighGrade    string `json:"high_grade"`
	ID           string
	LastModified string `json:"last_modified"`
	Location     Location
	LowGrade     string `json:"low_grade"`
	Name         string
	NcesID       string `json:"nces_id"`
	Phone        string
	SchoolNumber string `json:"school_number"`
	SisID        string `json:"sis_id"`
	StateID      string `json:"state_id"`
	MdrNumber    string `json:"mdr_number"`
	Principal    Principal
}

School corresponds to the School resource in the Clever data schema: clever.com/schema

type SchoolAdmin

type SchoolAdmin struct {
	ID       string
	District string
	Name     Name
	Title    string
	Email    string
	Schools  []string
	StaffID  string `json:"staff_id"`
}

SchoolAdmin corresponds to the SchoolAdmin resource in the Clever data schema: clever.com/schema

type SchoolAdminResp

type SchoolAdminResp struct {
	Links       []Link
	SchoolAdmin SchoolAdmin `json:"data"`
}

SchoolAdminResp wraps the response given when the user queries for a SchoolAdmin

type SchoolResp

type SchoolResp struct {
	Links  []Link
	School School `json:"data"`
	URI    string
}

SchoolResp wraps the response given when the user queries for a School

type Section

type Section struct {
	CourseName        string `json:"course_name"`
	CourseNumber      string `json:"course_number"`
	Created           string
	District          string
	Grade             string
	ID                string
	LastModified      string `json:"last_modified"`
	Name              string
	School            string
	SisID             string `json:"sis_id"`
	Students          []string
	Subject           string
	Teacher           string
	Term              Term
	Teachers          []string
	CourseDescription string `json:"course_description"`
	Period            string
	SectionNumber     string `json:"section_number"`
}

Section corresponds to the Section resource in the Clever data schema: clever.com/schema

type SectionResp

type SectionResp struct {
	Links   []Link
	Section Section `json:"data"`
	URI     string
}

SectionResp wraps the response given when the user queries for a Section

type Student

type Student struct {
	Created           string
	District          string
	Dob               string
	Email             string
	FrlStatus         string `json:"frl_status"`
	Gender            string
	Grade             string
	HispanicEthnicity string `json:"hispanic_ethnicity"`
	ID                string
	LastModified      string `json:"last_modified"`
	Location          Location
	Name              Name
	Race              string
	School            string
	SisID             string `json:"sis_id"`
	StateID           string `json:"state_id"`
	StudentNumber     string `json:"student_number"`
	EllStatus         string `json:"ell_status"`
	Credentials       Credentials
}

Student corresponds to the Student resource in the Clever data schema: clever.com/schema

type StudentResp

type StudentResp struct {
	Links   []Link
	Student Student `json:"data"`
	URI     string
}

StudentResp wraps the response given when the user queries for a Student

type Teacher

type Teacher struct {
	Created       string
	District      string
	Email         string
	ID            string
	LastModified  string `json:"last_modified"`
	Name          Name
	School        string
	SisID         string `json:"sis_id"`
	TeacherNumber string `json:"teacher_number"`
	Title         string
	StateID       string `json:"state_id"`
	Credentials   Credentials
}

Teacher corresponds to the Teacher resource in the Clever data schema: clever.com/schema

type TeacherResp

type TeacherResp struct {
	Links   []Link
	Teacher Teacher `json:"data"`
	URI     string
}

TeacherResp wraps the response given when the user queries for a Teacher

type Term

type Term struct {
	Name      string
	StartDate string `json:"start_date"`
	EndDate   string `json:"end_date"`
}

Term holds information about the duration of a school term

type TooManyRequestsError

type TooManyRequestsError struct {
	Header http.Header
}

TooManyRequestsError indicates the number of requests has exceeded the rate limit

func (*TooManyRequestsError) Error

func (err *TooManyRequestsError) Error() string

TooManyRequestsError creates a TooManyRequestsError

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL