Skip to content
This repository was archived by the owner on May 29, 2018. It is now read-only.

[SB-1001] [SB-645] GLOBAL SKILLS APIs- Create/Update user, get all locations #14

Merged
merged 1 commit into from
Mar 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ node_modules/

# Built files
coverage/
__TEST__/
__TEST__/

# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
34 changes: 33 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,44 @@ class Sprucebot {
* Get a user without a location. GLOBAL SKILLS ONLY
*
* @param {String} userId
* @param {Object} Optional query stirng to be added to the request
* @param {Object} Optional query string to be added to the request
*/
async globalUser(userId, query) {
return this.https.get(`/users/${userId}`, query)
}

/**
* Get all locations. GLOBAL SKILLS ONLY
*
* @param {Object} Optional query string to be added to the request
*/
async globalLocations(query) {
return this.https.get(`/ge/locations`, query)
}

/**
* Create a user
*
* @param {Object} values
* @returns {Promise}
*/
async createUser(values) {
return this.https.post('/ge/users', values)
}

/**
* Update a users role
*
* @param {String} locationId
* @param {String} userId
* @param {String} role
* @returns {Promise}
*/
async updateRole(locationId, userId, role) {
return this.https.patch(
`/ge/locations/${locationId}/users/${userId}/${role}`
)
}
/**
* Search for users who have been to this location
*
Expand Down
3 changes: 1 addition & 2 deletions utilities/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ module.exports = {
// Construct URL using the query
pathWithQuery += pathWithQuery.search(/\?/) === -1 ? '?' : '&'
if (query) {
pathWithQuery += '&' + this.serialize(query)
pathWithQuery += this.serialize(query)
}

return pathWithQuery
}
}