Advertisement
Guest User

Untitled

a guest
May 8th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. 'use strict';
  2.  
  3. module.exports = function(Healthtrackercommonservice) {
  4.  
  5. Healthtrackercommonservice.getAccountFromEmail = async (email, tokenId) => {
  6. let rp = require('request-promise');
  7.  
  8. let BASEURL = "https://craftpoints-healthtracker-common.eu-gb.mybluemix.net/api/Accounts/getAccountFromEmail/";
  9. let options = {
  10. method: 'POST',
  11. uri: BASEURL + email + '?access_token=' + tokenId,
  12. json: true
  13. };
  14.  
  15. return rp.post(options)
  16. .then(response => {
  17. return response;
  18. })
  19. .catch(error => {
  20. return (error);
  21. });
  22. };
  23.  
  24. Healthtrackercommonservice.addOrUpdateCraftPointsId = async (email, id, tokenId) => {
  25.  
  26. let rp = require('request-promise');
  27.  
  28.  
  29. let BASEURL = "https://craftpoints-healthtracker-common.eu-gb.mybluemix.net/api/Accounts/addOrUpdateCraftPointsId/"
  30. let options = {
  31. method: 'POST',
  32. uri: BASEURL + email + "/" + id + "?access_token=" + tokenId,
  33. json: true
  34. };
  35.  
  36. return rp.post(options)
  37. .then(response => {
  38. return response;
  39. })
  40. .catch(error => {
  41. return (error);
  42. });
  43.  
  44. };
  45.  
  46. Healthtrackercommonservice.login = async () => {
  47.  
  48. let rp = require('request-promise');
  49. let username = "System";
  50. let password = "D4zf4zqf15Elk52Gq4f";
  51.  
  52. let BASEURL = "https://craftpoints-healthtracker-common.eu-gb.mybluemix.net/api/CommonUsers/";
  53. let options = {
  54. method: 'POST',
  55. uri: BASEURL + 'login',
  56. body: {
  57. username: username,
  58. password: password
  59. },
  60. json: true
  61. };
  62.  
  63. return rp.post(options)
  64. .then(response => {
  65. return response;
  66. })
  67. .catch(error => {
  68. return (error);
  69. });
  70.  
  71. };
  72.  
  73. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement