-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
version: 2 | ||
jobs: | ||
build-and-test: | ||
docker: | ||
- image: circleci/node:6.14.3-browsers | ||
environment: | ||
LANG: en_US.UTF-8 | ||
steps: | ||
- checkout | ||
- run: | ||
name: Update Yarn | ||
command: 'sudo npm update -g yarn' | ||
- restore-cache: | ||
name: Restore Yarn Package Cache | ||
keys: | ||
- yarn-packages-{{ checksum "yarn.lock" }} | ||
- run: | ||
name: Install Dependencies | ||
command: yarn install --pure-lockfile | ||
- save-cache: | ||
name: Save Yarn Package Cache | ||
key: yarn-packages-{{ checksum "yarn.lock" }} | ||
paths: | ||
- ~/.cache/yarn | ||
- run: | ||
name: Check | ||
command: yarn check | ||
- run: | ||
name: Tests | ||
command: yarn test:ci | ||
- run: | ||
name: Generate Coverage | ||
command: yarn test:coverage | ||
|
||
workflows: | ||
version: 2 | ||
build-test-report: | ||
jobs: | ||
- build-and-test |
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
var ArgumentError = require('rest-facade').ArgumentError; | ||
var Auth0RestClient = require('../Auth0RestClient'); | ||
var RetryRestClient = require('../RetryRestClient'); | ||
|
||
/** | ||
* Simple facade for consuming a REST API endpoint. | ||
* @external RestClient | ||
* @see https://github.com/ngonzalvez/rest-facade | ||
*/ | ||
|
||
/** | ||
* @class | ||
* Abstracts interaction with the Guardian endpoint. | ||
* @constructor | ||
* @memberOf module:management | ||
* | ||
* @param {Object} options The client options. | ||
* @param {String} options.baseUrl The URL of the API. | ||
* @param {Object} [options.headers] Headers to be included in all requests. | ||
* @param {Object} [options.retry] Retry Policy Config | ||
*/ | ||
var GuardianManager = function(options) { | ||
if (options === null || typeof options !== 'object') { | ||
throw new ArgumentError('Must provide manager options'); | ||
} | ||
|
||
if (options.baseUrl === null || options.baseUrl === undefined) { | ||
throw new ArgumentError('Must provide a base URL for the API'); | ||
} | ||
|
||
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { | ||
throw new ArgumentError('The provided base URL is invalid'); | ||
} | ||
|
||
var clientOptions = { | ||
errorFormatter: { message: 'message', name: 'error' }, | ||
headers: options.headers, | ||
query: { repeatParams: false } | ||
}; | ||
|
||
/** | ||
* Provides an abstraction layer for retrieving Guardian enrollments. | ||
* | ||
* @type {external:RestClient} | ||
*/ | ||
var guardianEnrollmentsAuth0RestClient = new Auth0RestClient( | ||
options.baseUrl + '/guardian/enrollments/:id', | ||
clientOptions, | ||
options.tokenProvider | ||
); | ||
this.enrollments = new RetryRestClient(guardianEnrollmentsAuth0RestClient, options.retry); | ||
}; | ||
|
||
/** | ||
* Get a single Guardian enrollment. | ||
* | ||
* @method getGuardianEnrollment | ||
* @memberOf module:management.GuardianManager.prototype | ||
* | ||
* @example | ||
* management.users.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) { | ||
* console.log(enrollment); | ||
* }); | ||
* | ||
* @param {Object} data The user data object. | ||
* @param {String} data.id The user id. | ||
* @param {Function} [cb] Callback function. | ||
* | ||
* @return {Promise|undefined} | ||
*/ | ||
GuardianManager.prototype.getGuardianEnrollment = function(params, cb) { | ||
return this.enrollments.get(params, cb); | ||
}; | ||
|
||
/** | ||
* Delete a Guardian enrollment. | ||
* | ||
* @method deleteGuardianEnrollment | ||
* @memberOf module:management.GuardianManager.prototype | ||
* | ||
* @example | ||
* management.users.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollments) { | ||
* console.log(enrollments); | ||
* }); | ||
* | ||
* @param {Object} data The user data object. | ||
* @param {String} data.id The user id. | ||
* @param {Function} [cb] Callback function. | ||
* | ||
* @return {Promise|undefined} | ||
*/ | ||
GuardianManager.prototype.deleteGuardianEnrollment = function(params, cb) { | ||
return this.enrollments.delete(params, cb); | ||
}; | ||
|
||
module.exports = GuardianManager; |