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
0 parents
commit 1c91a1e
Showing
10 changed files
with
109 additions
and
0 deletions.
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,20 @@ | ||
lib-cov | ||
*.seed | ||
*.log | ||
*.csv | ||
*.dat | ||
*.out | ||
*.pid | ||
*.gz | ||
|
||
pids | ||
logs | ||
results | ||
|
||
node_modules | ||
npm-debug.log | ||
|
||
*.sublime-project | ||
*.sublime-workspace | ||
|
||
test/config.coffee |
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,4 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- 0.6 |
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 @@ | ||
REPORTER = spec | ||
|
||
test: | ||
@./node_modules/mocha/bin/mocha \ | ||
--reporter $(REPORTER) \ | ||
test/*.coffee | ||
|
||
.PHONY: test |
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,4 @@ | ||
node-quizlet | ||
============ | ||
|
||
Node.js Quizlet API interface |
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,2 @@ | ||
require('coffee-script') | ||
module.exports = require('./lib/') |
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,35 @@ | ||
querystring = require 'querystring' | ||
|
||
request = require 'superagent' | ||
oauth = require('oauth').OAuth | ||
|
||
baseURL = 'https://api.quizlet.com/2.0/' | ||
|
||
class QuizletAPI | ||
### | ||
Interface to the Quizlet API. | ||
### | ||
|
||
get: (resource, params, cb) -> | ||
### | ||
Gets the given resource. | ||
### | ||
cb {} | ||
|
||
getUser: (username, cb) -> | ||
@get "users/#{username}", {}, cb | ||
|
||
exports.Public = class QuizletPublic extends QuizletAPI | ||
|
||
constructor: (@clientId) -> | ||
### | ||
Creates a new Quizlet API interface instance. | ||
### | ||
|
||
get: (resource, params, cb) -> | ||
params.client_id = @clientId | ||
request.get(baseURL + resource + '?' + querystring.stringify(params)).end (res) -> | ||
cb res.body | ||
|
||
exports.Authed = class QuizletAuthed extends QuizletAPI | ||
|
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": "quizlet", | ||
"description": "Quizlet Node.js API interface", | ||
"author": "Ian Macalinao <ianmacalinao@gmail.com>", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"test": "make test" | ||
}, | ||
"dependencies": { | ||
"superagent": "*", | ||
"coffee-script": "*", | ||
"oauth": "*" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"should": "*" | ||
} | ||
} |
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,2 @@ | ||
module.exports = | ||
clientId: 'YOUR-CLIENT-ID' |
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,4 @@ | ||
--require should | ||
--reporter spec | ||
--ui bdd | ||
--compilers coffee:coffee-script |
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 @@ | ||
Quizlet = require '../lib/index' | ||
config = require './config' | ||
|
||
describe 'QuizletPublic', -> | ||
describe '#getUser', -> | ||
beforeEach -> | ||
@api = new Quizlet.Public config.clientId | ||
|
||
it 'should get the details of a user', (done) -> | ||
@api.getUser 'simplyianm', (user) -> | ||
user.username.should.equal 'simplyianm' | ||
done() |