您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // @flow
  2. import { SET_ENDPOINT_COUNTED } from './actionTypes';
  3. import { extractVpaasTenantFromPath, getBillingId, sendCountRequest } from './functions';
  4. /**
  5. * Sends a billing count request when needed.
  6. *
  7. * @returns {Function}
  8. */
  9. export function countEndpoint() {
  10. return function(dispatch: Function, getState: Function) {
  11. const state = getState();
  12. const baseUrl = state['features/base/config'].billingCounterUrl;
  13. const jwt = state['features/base/jwt'].jwt;
  14. const tenant = extractVpaasTenantFromPath(state['features/base/connection'].locationURL.pathname);
  15. const shouldSendRequest = Boolean(baseUrl && jwt && tenant);
  16. if (shouldSendRequest) {
  17. const billingId = getBillingId();
  18. sendCountRequest({
  19. baseUrl,
  20. billingId,
  21. jwt,
  22. tenant
  23. });
  24. dispatch(setEndpointCounted());
  25. }
  26. };
  27. }
  28. /**
  29. * Action used to mark the endpoint as counted.
  30. *
  31. * @returns {Object}
  32. */
  33. function setEndpointCounted() {
  34. return {
  35. type: SET_ENDPOINT_COUNTED
  36. };
  37. }