Class: MailSlurpClient::FormControllerApi

Inherits:
Object
  • Object
show all
Defined in:
lib/mailslurp_client/api/form_controller_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ FormControllerApi

Returns a new instance of FormControllerApi.



19
20
21
# File 'lib/mailslurp_client/api/form_controller_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/mailslurp_client/api/form_controller_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#submit_form(opts = {}) ⇒ String

Submit a form to be parsed and sent as an email to an address determined by the form fields This endpoint allows you to submit HTML forms and receive the field values and files via email. #### Parameters The endpoint looks for special meta parameters in the form fields OR in the URL request parameters. The meta parameters can be used to specify the behaviour of the email. You must provide at-least a `_to` email address to tell the endpoint where the form should be emailed. These can be submitted as hidden HTML input fields with the corresponding `name` attributes or as URL query parameters such as `?_to=test@example.com` The endpoint takes all other form fields that are named and includes them in the message body of the email. Files are sent as attachments. #### Submitting This endpoint accepts form submission via POST method. It accepts `application/x-www-form-urlencoded`, and `multipart/form-data` content-types. #### HTML Example “`html <form action="ruby.api.mailslurp.com/forms" method="post" > <input name="_to" type="hidden" value="test@example.com"/> <textarea name="feedback"></textarea> <button type="submit">Submit</button> </form> “` #### URL Example “`html <form action="ruby.api.mailslurp.com/forms?_to=test@example.com" method="post" > <textarea name="feedback"></textarea> <button type="submit">Submit</button> </form> “` The email address is specified by a `_to` field OR is extracted from an email alias specified by a `_toAlias` field (see the alias controller for more information). Endpoint accepts . You can specify a content type in HTML forms using the `enctype` attribute, for instance: `<form enctype="multipart/form-data">`.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :_to (String)

    The email address that submitted form should be sent to.

  • :_subject (String)

    Optional subject of the email that will be sent.

  • :_redirect_to (String)

    Optional URL to redirect form submitter to after submission. If not present user will see a success message.

  • :_email_address (String)

    Email address of the submitting user. Include this if you wish to record the submitters email address and reply to it later.

  • :_success_message (String)

    Optional success message to display if no _redirectTo present.

  • :_spam_check (String)

    Optional but recommended field that catches spammers out. Include as a hidden form field but LEAVE EMPTY. Spam-bots will usually fill every field. If the _spamCheck field is filled the form submission will be ignored.

  • :other_parameters (String)

    All other parameters or fields will be accepted and attached to the sent email. This includes files and any HTML form field with a name. These fields will become the body of the email that is sent.

Returns:

  • (String)


33
34
35
36
# File 'lib/mailslurp_client/api/form_controller_api.rb', line 33

def submit_form(opts = {})
  data, _status_code, _headers = submit_form_with_http_info(opts)
  data
end

#submit_form_with_http_info(opts = {}) ⇒ Array<(String, Integer, Hash)>

Submit a form to be parsed and sent as an email to an address determined by the form fields This endpoint allows you to submit HTML forms and receive the field values and files via email. #### Parameters The endpoint looks for special meta parameters in the form fields OR in the URL request parameters. The meta parameters can be used to specify the behaviour of the email. You must provide at-least a &#x60;_to&#x60; email address to tell the endpoint where the form should be emailed. These can be submitted as hidden HTML input fields with the corresponding &#x60;name&#x60; attributes or as URL query parameters such as &#x60;?_to&#x3D;test@example.com&#x60; The endpoint takes all other form fields that are named and includes them in the message body of the email. Files are sent as attachments. #### Submitting This endpoint accepts form submission via POST method. It accepts &#x60;application/x-www-form-urlencoded&#x60;, and &#x60;multipart/form-data&#x60; content-types. #### HTML Example &#x60;&#x60;&#x60;html &lt;form action&#x3D;&quot;ruby.api.mailslurp.com/forms"; method&#x3D;&quot;post&quot; &gt; &lt;input name&#x3D;&quot;_to&quot; type&#x3D;&quot;hidden&quot; value&#x3D;&quot;test@example.com&quot;/&gt; &lt;textarea name&#x3D;&quot;feedback&quot;&gt;&lt;/textarea&gt; &lt;button type&#x3D;&quot;submit&quot;&gt;Submit&lt;/button&gt; &lt;/form&gt; &#x60;&#x60;&#x60; #### URL Example &#x60;&#x60;&#x60;html &lt;form action&#x3D;&quot;ruby.api.mailslurp.com/forms?_to=test@example.com"; method&#x3D;&quot;post&quot; &gt; &lt;textarea name&#x3D;&quot;feedback&quot;&gt;&lt;/textarea&gt; &lt;button type&#x3D;&quot;submit&quot;&gt;Submit&lt;/button&gt; &lt;/form&gt; &#x60;&#x60;&#x60; The email address is specified by a &#x60;_to&#x60; field OR is extracted from an email alias specified by a &#x60;_toAlias&#x60; field (see the alias controller for more information). Endpoint accepts . You can specify a content type in HTML forms using the &#x60;enctype&#x60; attribute, for instance: &#x60;&lt;form enctype&#x3D;&quot;multipart/form-data&quot;&gt;&#x60;.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :_to (String)

    The email address that submitted form should be sent to.

  • :_subject (String)

    Optional subject of the email that will be sent.

  • :_redirect_to (String)

    Optional URL to redirect form submitter to after submission. If not present user will see a success message.

  • :_email_address (String)

    Email address of the submitting user. Include this if you wish to record the submitters email address and reply to it later.

  • :_success_message (String)

    Optional success message to display if no _redirectTo present.

  • :_spam_check (String)

    Optional but recommended field that catches spammers out. Include as a hidden form field but LEAVE EMPTY. Spam-bots will usually fill every field. If the _spamCheck field is filled the form submission will be ignored.

  • :other_parameters (String)

    All other parameters or fields will be accepted and attached to the sent email. This includes files and any HTML form field with a name. These fields will become the body of the email that is sent.

Returns:

  • (Array<(String, Integer, Hash)>)

    String data, response status code and response headers



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/mailslurp_client/api/form_controller_api.rb', line 49

def submit_form_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FormControllerApi.submit_form ...'
  end
  # resource path
  local_var_path = '/forms'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'_to'] = opts[:'_to'] if !opts[:'_to'].nil?
  query_params[:'_subject'] = opts[:'_subject'] if !opts[:'_subject'].nil?
  query_params[:'_redirectTo'] = opts[:'_redirect_to'] if !opts[:'_redirect_to'].nil?
  query_params[:'_emailAddress'] = opts[:'_email_address'] if !opts[:'_email_address'].nil?
  query_params[:'_successMessage'] = opts[:'_success_message'] if !opts[:'_success_message'].nil?
  query_params[:'_spamCheck'] = opts[:'_spam_check'] if !opts[:'_spam_check'].nil?
  query_params[:'otherParameters'] = opts[:'other_parameters'] if !opts[:'other_parameters'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['*/*'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'String' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FormControllerApi#submit_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end