medmond919

Client Module

May 18th, 2016
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. var request = require('request');
  2.  
  3. module.exports = {
  4.  
  5. authorize : function (id, callback) {
  6. var options = {
  7. method : 'GET',
  8. url : <<removed>>
  9. headers : {
  10. <<removed>>
  11. }
  12. };
  13.  
  14. request(options, function (error, response, body) {
  15. if (!error && response.statusCode == 200) {
  16. var res = JSON.parse(body);
  17. callback(null, res);
  18. } else {
  19. var error = 'Not Found';
  20. callback(error);
  21.  
  22. }
  23.  
  24.  
  25.  
  26. });
  27. },
  28.  
  29. listBuckets : function (auth, callback) {
  30. console.log('The authorization URL is ' + auth.apiUrl);
  31. console.log('The authorization token is ' + auth.authorizationToken);
  32. var options = {
  33. method : 'GET',
  34. url : auth.apiUrl + <<removed>>
  35. headers : {
  36. <<removed>>
  37. }
  38. };
  39.  
  40. request(options, function (error, response, body) {
  41. if (!error && response.statusCode == 200) {
  42. var res = JSON.parse(body);
  43. callback(null, res);
  44. } else {
  45. var error = 'Not Found';
  46. callback(error);
  47. }
  48.  
  49.  
  50. });
  51. },
  52.  
  53. };
Add Comment
Please, Sign In to add comment