clever

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

README

clever-go

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

Documentation

GoDoc

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.3. 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 (
	"code.google.com/p/goauth2/oauth"
	clevergo "gopkg.in/Clever/clever-go.v1"
	"log"
)

func main() {
	t := &oauth.Transport{
		Token: &oauth.Token{AccessToken: "DEMO_TOKEN"},
	}
	client := t.Client()
	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"

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 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 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{}
	}
}

type EventResp added in v1.4.0

type EventResp struct {
	Links []Link
	Event Event `json:"data"`
	Uri   string
}
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
}

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 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"`
}

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

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
}

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"`
}

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
}

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