<commit_before>import 'es6-promise';
import fetch from 'isomorphic-fetch';

import { sharedHelpers } from '../utils/actionHelpers';

export const GENERATE_APP_SECRET_REQUEST = 'GENERATE_APP_SECRET_REQUEST';
export const GENERATE_APP_SECRET_FAILURE = 'GENERATE_APP_SECRET_FAILURE';
export const GENERATE_APP_SECRET_SUCCESS = 'GENERATE_APP_SECRET_SUCCESS';
export const CLEAR_APP_SECRET = 'CLEAR_APP_SECRET';

export function generateAppSecretRequest() {
  return { type: GENERATE_APP_SECRET_REQUEST };
}

export function generateAppSecretFailure(message) {
  return {
    type: GENERATE_APP_SECRET_FAILURE,
    message,
  };
}

export function generateAppSecretSuccess(app, clientSecret) {
  return {
    type: GENERATE_APP_SECRET_SUCCESS,
    app,
    clientSecret,
  };
}

export function clearAppSecret() {
  return { type: CLEAR_APP_SECRET };
}

export function generateAppSecret(appId) {
  return (dispatch, getState) => {
    dispatch(generateAppSecretRequest());

    const { token } = getState().auth;
    const options = {
      method: 'PATCH',
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${token}`,
      },
    };

    return fetch(`${process.env.DEVCENTER_API_FORMS}/applications/${appId}/secret`, options)
      .then(sharedHelpers.validResponse(dispatch))
      .then(response => response.json())
      .then(({ application: app, clientSecret }) => {
        dispatch(generateAppSecretSuccess(app, clientSecret));
      })
      .catch(err => dispatch(generateAppSecretFailure(err.message)));
  };
}<commit_msg>added empty body on patch to fix 411 error<commit_after>import 'es6-promise';
import fetch from 'isomorphic-fetch';

import { sharedHelpers } from '../utils/actionHelpers';

export const GENERATE_APP_SECRET_REQUEST = 'GENERATE_APP_SECRET_REQUEST';
export const GENERATE_APP_SECRET_FAILURE = 'GENERATE_APP_SECRET_FAILURE';
export const GENERATE_APP_SECRET_SUCCESS = 'GENERATE_APP_SECRET_SUCCESS';
export const CLEAR_APP_SECRET = 'CLEAR_APP_SECRET';

export function generateAppSecretRequest() {
  return { type: GENERATE_APP_SECRET_REQUEST };
}

export function generateAppSecretFailure(message) {
  return {
    type: GENERATE_APP_SECRET_FAILURE,
    message,
  };
}

export function generateAppSecretSuccess(app, clientSecret) {
  return {
    type: GENERATE_APP_SECRET_SUCCESS,
    app,
    clientSecret,
  };
}

export function clearAppSecret() {
  return { type: CLEAR_APP_SECRET };
}

export function generateAppSecret(appId) {
  return (dispatch, getState) => {
    dispatch(generateAppSecretRequest());

    const { token } = getState().auth;
    const options = {
      method: 'PATCH',
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${token}`,
      },
      body: '',
    };

    return fetch(`${process.env.DEVCENTER_API_FORMS}/applications/${appId}/secret`, options)
      .then(sharedHelpers.validResponse(dispatch))
      .then(response => response.json())
      .then(({ application: app, clientSecret }) => {
        dispatch(generateAppSecretSuccess(app, clientSecret));
      })
      .catch(err => dispatch(generateAppSecretFailure(err.message)));
  };
}
{'fraction_non_alphanumeric': 0.11720463804450015, 'fraction_numerical': 0.0015669069257286117, 'mean_word_length': 4.419354838709677, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7578455', 'n_tokens_mistral': 1009, 'n_tokens_neox': 996, 'n_words': 185}