1. 1 :
  2. 2 : (function(root, factory) {
  3. 3 :
  4. 4 : if (typeof module === 'object' && module.exports) {
  5. 5 : // CommonJS-like environments that support module.exports, like Node.
  6. 6 : module.exports = factory(require('logtown').getLogger('/src/handlers/GetCustomerHandler'), require('../ApiClient'), require('../api/CustomerApi'), require('../OrbipayApiError'), require('../CommonUtil'));
  7. 7 : }
  8. 8 : }(this, function(logger, ApiClient, CustomerApi, OrbipayApiError, CommonUtil) {
  9. 9 : 'use strict';
  10. 10 :
  11. 11 : /**
  12. 12 : * @module ApiClient
  13. 13 : */
  14. 14 :
  15. 15 : /**
  16. 16 : * <h3 style="color:red"> This class subject to change without prior notice, Please dont use this class directly. </h3>
  17. 17 :
  18. 18 : * @module handlers/GetCustomerHandler
  19. 19 : * @class
  20. 20 : */
  21. 21 :
  22. 22 : var exports = function() {
  23. 23 : };
  24. 24 :
  25. 25 : exports.prototype.process = function (customer, callback) {
  26. 26 :
  27. 27 : var secret = customer.invocation_context.secret;
  28. 28 : var host = customer.api_end_point;
  29. 29 : var api_key = customer.invocation_context.api_key;
  30. 30 : var auth_scheme = customer.invocation_context.auth_scheme;
  31. 31 : var _this=this;
  32. 32 : var response = {};
  33. 33 : var exception;
  34. 34 : try {
  35. 35 : var api_client = new ApiClient(secret, host,api_key,auth_scheme);
  36. 36 : var api_instance = new CustomerApi(api_client);
  37. 37 : var channel = customer.invocation_context['channel'];
  38. 38 : var client_key = customer.invocation_context['client_key'];
  39. 39 : var product = customer.invocation_context['product'];
  40. 40 : var timestamp;
  41. 41 : if (customer.invocation_context['timestamp'])
  42. 42 : {
  43. 43 : timestamp = customer.invocation_context['timestamp'];
  44. 44 : }
  45. 45 : else
  46. 46 : {
  47. 47 : timestamp = CommonUtil.getTimeStamp();
  48. 48 : }
  49. 49 : var idempotent_request_key = customer.invocation_context['idempotent_request_key'];
  50. 50 : var requestor_type = customer.invocation_context['requestor_type'];
  51. 51 : var id_customer = customer['ID_CUSTOMER'];
  52. 52 : var opts = _this.getOptions(customer);
  53. 53 : var result = api_instance.getCustomer(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, id_customer, opts, callback);
  54. 54 : response['request'] = result;
  55. 55 : return response;
  56. 56 : } catch (e) {
  57. 57 : exception = OrbipayApiError.getDefaultException(e);
  58. 58 : if (callback) {
  59. 59 : callback(null, null, null, exception);
  60. 60 : }
  61. 61 : response['exception'] = exception;
  62. 62 : return response;
  63. 63 : }
  64. 64 : };
  65. 65 :
  66. 66 : exports.prototype.getOptions = function (customer) {
  67. 67 : return {
  68. 68 : 'requestor': customer['invocation_context']['requestor'],
  69. 69 : 'x_opay_headers': customer['invocation_context']['X-OPAY-Headers'],
  70. 70 : 'trace_id': customer['invocation_context']['trace_id']
  71. 71 : };
  72. 72 : };
  73. 73 :
  74. 74 :
  75. 75 : return exports;
  76. 76 : }));