Skip to content

Commit

Permalink
fixed readme and added bulk slide update
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonwright committed Jun 18, 2015
1 parent 1471986 commit 0fd7b91
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A small library providing access to traitify's api
#### Config
```js
var traitify = require('traitify');

traitify.setHost("lvh.me");
traitify.setVersion("v1");
traitify.setSecretKey("fakeKey");
Expand Down Expand Up @@ -53,12 +53,23 @@ A small library providing access to traitify's api
```js
var assessmentId = "Your Assessment Id";

traitify.setSlide(assessmentId, {"value":true, response_time: 1000}, function(assessment){
traitify.addSlide(assessmentId, {response: true, response_time: 1000}, function(assessment){
// Use assessment here.
console.log(assessment);
});
```

#### Bulk Set Assessment Slides
```js
var assessmentId = "Your Assessment Id";

traitify.addSlides(assessmentId, [{id: "slide-uuid", "response":true, response_time: 1000}], function(assessment){
// Use assessment here.
console.log(assessment);
})
```


#### Get Assessment Personality Types
```js
var assessmentId = "Your Assessment Id";
Expand Down
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ module.exports = {
callBack(JSON.parse(responseData));
});
});
if(params){
params = JSON.stringify(params)
}

request.end(params);
},
Expand All @@ -78,7 +81,7 @@ module.exports = {
},

createAssessment: function(deckId, callBack){
this.post("/assessments", '{"deck_id":"' + deckId + '"}', callBack);
this.post("/assessments", {deck_id: deckId }, callBack);
},

getAssessment: function(assessmentId, callBack){
Expand All @@ -88,11 +91,12 @@ module.exports = {
getSlides: function(assessmentId, callBack){
this.get("/assessments/" + assessmentId + "/slides", String(), callBack);
},

setSlide: function(assessmentId, slideId, params, callBack){
addSlide: function(assessmentId, slideId, params, callBack){
this.put("/assessments/" + assessmentId + "/slides/" + slideId, params, callBack);
},

addSlides: function(assessmentId, params, callBack){
this.put("/assessments/" + assessmentId + "/slides", params, callBack);
},
getPersonalityTypes: function(assessmentId, callBack){
this.get("/assessments/" + assessmentId + "/personality_types", String(), callBack);
},
Expand Down Expand Up @@ -134,5 +138,3 @@ module.exports = {
return url;
}
};


23 changes: 19 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,29 @@ describe('#Traitify', function() {
});
});

it("Sets Assessment's Slide", function(done) {
it("Adds Assessment's Slide", function(done) {
var responseData = {
"slides":[
{"caption":"Very Cool"}
slides:[
{"caption":"Very Cool"}
]
};
nockApiHelper("put", "/assessments/fakeAssessmentId/slides/fakeSlideId", responseData, function(){
traitify.setSlide("fakeAssessmentId", "fakeSlideId", {value: true, responseTime: 1000}, function(data){
traitify.addSlide("fakeAssessmentId", "fakeSlideId", {value: true, responseTime: 1000}, function(data){
data.slides[0].caption.should.equal("Very Cool");
done();
});
});
});

it("Adds Assessment's Slides", function(done) {
var responseData = {
"slides":[
{"caption":"Very Cool"}

]
};
nockApiHelper("put", "/assessments/fakeAssessmentId/slides", responseData, function(){
traitify.addSlides("fakeAssessmentId", {value: true, responseTime: 1000}, function(data){
data.slides[0].caption.should.equal("Very Cool");
done();
});
Expand Down

0 comments on commit 0fd7b91

Please sign in to comment.