<commit_before>import _ from 'lodash';
import Immutable from 'immutable';
import ActionField from './ActionField';
import Client from './Client';
import SirenHelpers from './SirenHelpers';

/**
 * Representation of a Siren action, which allows a state within a Siren Hypermedia API
 * to transition to a new state.
 *
 * @param {String} options.name:   null                                [description]
 * @param {String} options.title:  null                                [description]
 * @param {String} options.method: 'GET'                               [description]
 * @param {String} options.href:   null                                [description]
 * @param {String} options.type:   'application/x-www-form-urlencoded' [description]
 * @param {Immutable.Map} options.fields: new Immutable.Map()          [description]
 */
class SirenAction extends Immutable.Record({
	name: null,
	title: null,
	method: 'GET',
	href: null,
	type: 'application/x-www-form-urlencoded',
	fields: new Immutable.Map()
}) {
	/**
	 * Performs the action specified by this Action.
	 *
	 * @param  {Object} data Data to be sent as part of this action
	 * @return {superagent-promise} superagent promise representing the HTTP request to perform this action
	 */
	perform(data) {
		var req = Client.action(this.method, this.href);
		var payload = { };

		this.fields.filter(f => f.value !== null).forEach(f => payload[f.name] = f.value);
		Immutable.fromJS(data).forEach((value, key) => payload[key] = value);<commit_msg>added previously missing action type on request<commit_after>import _ from 'lodash';
import Immutable from 'immutable';
import ActionField from './ActionField';
import Client from './Client';
import SirenHelpers from './SirenHelpers';

/**
 * Representation of a Siren action, which allows a state within a Siren Hypermedia API
 * to transition to a new state.
 *
 * @param {String} options.name:   null                                [description]
 * @param {String} options.title:  null                                [description]
 * @param {String} options.method: 'GET'                               [description]
 * @param {String} options.href:   null                                [description]
 * @param {String} options.type:   'application/x-www-form-urlencoded' [description]
 * @param {Immutable.Map} options.fields: new Immutable.Map()          [description]
 */
class SirenAction extends Immutable.Record({
	name: null,
	title: null,
	method: 'GET',
	href: null,
	type: 'application/x-www-form-urlencoded',
	fields: new Immutable.Map()
}) {
	/**
	 * Performs the action specified by this Action.
	 *
	 * @param  {Object} data Data to be sent as part of this action
	 * @return {superagent-promise} superagent promise representing the HTTP request to perform this action
	 */
	perform(data) {
		var req = Client.action(this.method, this.href);

		if (this.type) {
			req.type(this.type);
		}

		var payload = { };

		this.fields.filter(f => f.value !== null).forEach(f => payload[f.name] = f.value);
		Immutable.fromJS(data).forEach((value, key) => payload[key] = value);
{'fraction_non_alphanumeric': 0.12625445127873097, 'fraction_numerical': 0.0, 'mean_word_length': 2.9015151515151514, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6915362', 'n_tokens_mistral': 917, 'n_tokens_neox': 876, 'n_words': 276}