Last active
January 19, 2016 22:08
-
-
Save wesleytodd/1b386885186bce9ed358 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var http = require('v-http'); | |
module.exports = function updateAccount (acct) { | |
return new Promise(function (resolve, reject) { | |
http({ | |
method: 'PUT', | |
url: '/api-user/v1/me', | |
data: { | |
username: acct.username, | |
displayName: acct.displayName, | |
email: acct.email, | |
location: acct.location, | |
birthdate: acct.birthdate, | |
gender: acct.gender | |
} | |
}, function (err, resp) { | |
if (err) { | |
return reject({ | |
type: 'updateAccountError', | |
error: { | |
message: err.message, | |
code: 'update-account-error', | |
level: 'error' | |
} | |
}); | |
} | |
if (resp.statusCode >= 400) { | |
return reject({ | |
type: 'updateAccountError', | |
error: { | |
message: 'Failed to update account', | |
code: 'update-account-error', | |
level: 'error' | |
} | |
}); | |
} | |
resolve({ | |
type: 'updateAccount', | |
user: resp.data | |
}); | |
}); | |
}); | |
}; |
This file contains hidden or 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
var defaultAction = require('v-default-action'); | |
module.exports = function updateAccount (acct) { | |
return defaultAction({ | |
method: 'PUT', | |
url: '/api-user/v1/me', | |
data: { | |
username: acct.username, | |
displayName: acct.displayName, | |
email: acct.email, | |
location: acct.location, | |
birthdate: acct.birthdate, | |
gender: acct.gender | |
} | |
}, function (err, resp) { | |
if (err || resp.statusCode >= 400) { | |
return defaultError(err, resp, 'updateAccountError', 'Failed to update Account'); | |
} | |
return { | |
type: 'updateAccount', | |
user: resp.data | |
}; | |
}); | |
}; |
This file contains hidden or 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
var http = require('v-http'); | |
var defaultError = require('v-default-error'); | |
module.exports = function updateAccount (acct) { | |
return new Promise(function (resolve, reject) { | |
http({ | |
method: 'PUT', | |
url: '/api-user/v1/me', | |
data: { | |
username: acct.username, | |
displayName: acct.displayName, | |
email: acct.email, | |
location: acct.location, | |
birthdate: acct.birthdate, | |
gender: acct.gender | |
} | |
}, function (err, resp) { | |
if (err || resp.statusCode >= 400) { | |
return reject(defaultError(err, resp, 'updateAccountError', 'Failed to update Account')); | |
} | |
resolve({ | |
type: 'updateAccount', | |
user: resp.data | |
}); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment