Class: Fulcrum::Form
Constant Summary
Constants inherited
from Api
Api::VALID_METHODS
Instance Attribute Summary
Attributes inherited from Api
#configuration, #connection, #response
Class Method Summary
collapse
Methods inherited from Api
call, configuration, configure, connection, get_key, key, parse_opts, response, uri
Class Method Details
.all(opts = {}) ⇒ Object
6
7
8
9
|
# File 'lib/fulcrum/form.rb', line 6
def all(opts = {})
params = self.parse_opts([:page, :schema], opts)
self.call(:get, 'forms.json', params)
end
|
.create(form) ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/fulcrum/form.rb', line 16
def create(form)
validation = FormValidator.new(form)
if validation.valid?
call(:post, "forms.json", form)
else
{ error: { validation: validation.errors } }
end
end
|
.delete(id) ⇒ Object
34
35
36
|
# File 'lib/fulcrum/form.rb', line 34
def delete(id)
call(:delete, "forms/#{id}.json")
end
|
.find(id, opts = {}) ⇒ Object
11
12
13
14
|
# File 'lib/fulcrum/form.rb', line 11
def find(id, opts = {})
params = parse_opts([:include_foreign_elements], opts)
call(:get, "forms/#{id}.json", params)
end
|
.update(id, form) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/fulcrum/form.rb', line 25
def update(id, form)
validation = FormValidator.new(form)
if validation.valid?
call(:put, "forms/#{id}.json", form)
else
{ error: { validation: validation.errors } }
end
end
|