Class: ProntoForms::Form

Inherits:
Resource show all
Defined in:
lib/prontoforms/form.rb

Overview

A form includes inputs, validations, logic, and other configuration that facilitates data capture for a specific purpose.

Instance Attribute Summary

Attributes inherited from Resource

#client, #data, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#initialize, property, #resource_name

Constructor Details

This class inherits a constructor from ProntoForms::Resource

Class Method Details

.resource_nameObject



10
11
12
# File 'lib/prontoforms/form.rb', line 10

def self.resource_name
  'forms'
end

Instance Method Details

#active_version_idObject



29
30
31
# File 'lib/prontoforms/form.rb', line 29

def active_version_id
  full_data.dig('activeVersion', 'identifier')
end

#current_versionObject



33
34
35
36
37
38
39
# File 'lib/prontoforms/form.rb', line 33

def current_version
  res = client.connection.get do |req|
    req.url "#{url}/iterations/#{active_version_id}"
  end

  FormIteration.new(JSON.parse(res.body), client, self)
end

#descriptionString

Returns Form description.

Returns:

  • (String)

    Form description



19
# File 'lib/prontoforms/form.rb', line 19

property :description, key: 'description'

#form_space_idString

Get the Form’s form space ID

Returns:

  • (String)

    Form space identifier



25
26
27
# File 'lib/prontoforms/form.rb', line 25

def form_space_id
  parent.id
end

#idString

Returns The Form identifier.

Returns:

  • (String)

    The Form identifier



15
# File 'lib/prontoforms/form.rb', line 15

property :id, key: 'identifier'

#iteration(id) ⇒ Object

Raises:

  • (ArgumentError)


41
42
43
44
45
46
47
48
49
# File 'lib/prontoforms/form.rb', line 41

def iteration(id)
  raise ArgumentError, 'id must be provided' if id.nil?

  res = client.connection.get do |req|
    req.url "#{url}/iterations/#{id}"
  end

  FormIteration.new(JSON.parse(res.body), client, self)
end

#iterations(query: {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/prontoforms/form.rb', line 51

def iterations(query: {})
  res = client.connection.get do |req|
    req.url "#{url}/iterations"
  end

  ResourceList.new(JSON.parse(res.body), {
    'p' => 0,
    's' => 100
  }.merge(query), :iterations, FormIteration, client, self)
end

#nameString

Returns Form name.

Returns:

  • (String)

    Form name



17
# File 'lib/prontoforms/form.rb', line 17

property :name, key: 'name'

#stateString

Returns Form state.

Returns:

  • (String)

    Form state



21
# File 'lib/prontoforms/form.rb', line 21

property :state, key: 'state'