WebProfile.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Copyright 2015-2016 PayPal, Inc. */
  2. "use strict";
  3. var generate = require('../generate');
  4. var api = require('../api');
  5. /**
  6. * Exposes REST endpoints for providing a customizing Paypal checkout
  7. * flow for users, supports features such as noshipping.
  8. *
  9. * https://developer.paypal.com/webapps/developer/docs/integration/direct/rest-experience-overview/
  10. * @return {Object} web profile functions
  11. */
  12. function webProfile() {
  13. var baseURL = '/v1/payment-experience/web-profiles/';
  14. var operations = ['create', 'list', 'get', 'del', 'delete'];
  15. var ret = {
  16. baseURL: baseURL,
  17. /**
  18. * Update an experience profile
  19. * @param {String} id Web Profile Id
  20. * @param {Object} data Object with name, flow_config, input_fields and presentation
  21. * @param {Object|Function} config Configuration parameters e.g. client_id, client_secret override or callback
  22. * @param {Function} cb
  23. * @return {} Returns the HTTP status of 204 if the call is successful
  24. */
  25. update: function update(id, data, config, cb) {
  26. api.executeHttp('PUT', this.baseURL + id, data, config, cb);
  27. },
  28. /**
  29. * Partially update a web experience profile
  30. * @param {String} id Web Profile Id
  31. * @param {Array} data Array of patch request objects (operation, path, value, from)
  32. * @param {Object|Function} config Configuration parameters e.g. client_id, client_secret override or callback
  33. * @param {Function} cb
  34. * @return {} Returns the HTTP status of 204 if the call is successful
  35. */
  36. replace: function replace(id, data, config, cb) {
  37. api.executeHttp('PATCH', this.baseURL + id, data, config, cb);
  38. },
  39. };
  40. ret = generate.mixin(ret, operations);
  41. return ret;
  42. }
  43. module.exports = webProfile;