Class: Moonbase::Resources::Forms

Inherits:
Object
  • Object
show all
Defined in:
lib/moonbase/resources/forms.rb

Overview

Manage your marketing campaigns and forms

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Forms

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Forms.

Parameters:



139
140
141
# File 'lib/moonbase/resources/forms.rb', line 139

def initialize(client:)
  @client = client
end

Instance Method Details

#create(name:, business_email_required: nil, pages_enabled: nil, redirect_url: nil, request_options: {}) ⇒ Moonbase::Models::Form

Some parameter documentations has been truncated, see Models::FormCreateParams for more details.

Creates a new form with an auto-generated collection and default fields.

Parameters:

  • name (String)

    The name of the form, used as the title on its public page.

  • business_email_required (Boolean)

    If ‘true`, submissions require a business email address. Defaults to `false`.

  • pages_enabled (Boolean)

    If ‘true`, enables a Moonbase Pages hosted page for this form, providing a stand

  • redirect_url (String)

    Optional URL the user is redirected to after a successful submission. Omit to le

  • request_options (Moonbase::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



27
28
29
30
# File 'lib/moonbase/resources/forms.rb', line 27

def create(params)
  parsed, options = Moonbase::FormCreateParams.dump_request(params)
  @client.request(method: :post, path: "forms", body: parsed, model: Moonbase::Form, options: options)
end

#delete(id, request_options: {}) ⇒ nil

Permanently deletes a form. The backing collection is preserved.

Parameters:

Returns:

  • (nil)

See Also:



127
128
129
130
131
132
133
134
# File 'lib/moonbase/resources/forms.rb', line 127

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["forms/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(after: nil, before: nil, limit: nil, request_options: {}) ⇒ Moonbase::Internal::CursorPage<Moonbase::Models::Form>

Some parameter documentations has been truncated, see Models::FormListParams for more details.

Returns a list of your forms.

Parameters:

  • after (String)

    When specified, returns results starting immediately after the item identified b

  • before (String)

    When specified, returns results starting immediately before the item identified

  • limit (Integer)

    Maximum number of items to return per page. Must be between 1 and 100. Defaults

  • request_options (Moonbase::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/moonbase/resources/forms.rb', line 103

def list(params = {})
  parsed, options = Moonbase::FormListParams.dump_request(params)
  query = Moonbase::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "forms",
    query: query,
    page: Moonbase::Internal::CursorPage,
    model: Moonbase::Form,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ Moonbase::Models::Form

Retrieves the details of an existing form.

Parameters:

Returns:

See Also:



43
44
45
46
47
48
49
50
# File 'lib/moonbase/resources/forms.rb', line 43

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["forms/%1$s", id],
    model: Moonbase::Form,
    options: params[:request_options]
  )
end

#update(id, business_email_required: nil, name: nil, pages_enabled: nil, redirect_url: nil, request_options: {}) ⇒ Moonbase::Models::Form

Some parameter documentations has been truncated, see Models::FormUpdateParams for more details.

Updates an existing form.

Parameters:

  • id (String)

    The ID of the Form to update.

  • business_email_required (Boolean)

    If ‘true`, submissions require a business email address.

  • name (String)

    The new name for the form.

  • pages_enabled (Boolean)

    If ‘true`, a Moonbase Pages hosted page is enabled for this form, providing a st

  • redirect_url (String, nil)

    Updated redirect URL, or ‘null` to clear. Omit to leave the existing value uncha

  • request_options (Moonbase::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



74
75
76
77
78
79
80
81
82
83
# File 'lib/moonbase/resources/forms.rb', line 74

def update(id, params = {})
  parsed, options = Moonbase::FormUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["forms/%1$s", id],
    body: parsed,
    model: Moonbase::Form,
    options: options
  )
end