Skip to content

Instantly share code, notes, and snippets.

@greggyNapalm
Created September 26, 2013 18:15
Show Gist options
  • Select an option

  • Save greggyNapalm/6718271 to your computer and use it in GitHub Desktop.

Select an option

Save greggyNapalm/6718271 to your computer and use it in GitHub Desktop.
/* JSHint strict mode tweak */
/*jshint globalstrict: true*/
/*jshint browser: true*/
/*global $, _, angular, ya, app */
'use strict';
var APITestMixIn = {
get_tests: function (url, per_page) {
/* Retrieve test entries from REST API, infinit data pagination aka
* GitHUb api.
*/
url = url || url_base + 'tests/';
if(!(_.isUndefined(per_page))) {
url = url + '?per_page=' + per_page;
}
return $http.get(url);
},
get_test: function (test_id) {
/* Fetch single test resource by uniq id.
*/
if(typeof(test_id) === 'undefined') {
throw 'Rrequired parameters missing:*test_id*';
}
return $http.get(url_base + 'tests/' + test_id);
},
get_lunapark_test: function (lunapark_test_id) {
/* Fetch load test resource or retrive KSHM API repr if missing.
*/
if(typeof(lunapark_test_id) === 'undefined') {
throw 'Rrequired parameters missing:*lunapark_test_id*';
}
return $http.get(url_base + 'tests/luna/' + lunapark_test_id);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment