Class: Mautic::Form

Inherits:
Model
  • Object
show all
Defined in:
app/models/mautic/form.rb

Instance Attribute Summary

Attributes inherited from Model

#changed, #connection, #errors

Instance Method Summary collapse

Methods inherited from Model

#attributes, #attributes=, #changed?, #changes, #create, #destroy, endpoint, in, #initialize, #mautic_id, #save, #to_mautic, #update, #update_columns

Constructor Details

This class inherits a constructor from Mautic::Model

Instance Method Details

#assign_attributes(source = nil) ⇒ Object



4
5
6
# File 'app/models/mautic/form.rb', line 4

def assign_attributes(source = nil)
  self.attributes = { name: source['name'], fields: source['fields'] } if source.is_a? Hash
end

#submission(submission_id) ⇒ Object

Returns Mautic::Submissions::Form.

Parameters:

  • submission_id (Integer)

Returns:

  • Mautic::Submissions::Form

See Also:



11
12
13
14
15
16
# File 'app/models/mautic/form.rb', line 11

def submission(submission_id)
  json = @connection.request(:get, "api/forms/#{id}/submissions/#{submission_id}")
  Mautic::Submissions::Form.new @connection, json["submission"]
rescue Mautic::RecordNotFound => _e
  nil
end

#submissions(**options) ⇒ Object

Parameters:

  • options (Hash)

Options Hash (**options):

  • :search (String)

    String or search command to filter entities by.

  • :start (String)

    Starting row for the entities returned. Defaults to 0.

  • :limit (String)

    Limit number of entities to return. Defaults to the system configuration for pagination (30).

  • :orderBy (String)

    Column to sort by. Can use any column listed in the response, also can use column of joined table with prefix. Sort by submitted date is s.date_submitted

  • :orderByDir (String)

    Sort direction: asc or desc.

  • :publishedOnly (String)

    Only return currently published entities.

  • :minimal (String)

    Return only array of entities without additional lists in it.

See Also:



28
29
30
31
32
33
34
35
# File 'app/models/mautic/form.rb', line 28

def submissions(**options)
  json = @connection.request(:get, "api/forms/#{id}/submissions", params: options)
  @submissions = json["submissions"].collect do |attributes|
    Mautic::Submissions::Form.new @connection, attributes
  end
rescue RequestError => _e
  []
end