Class: Fulcrum::ChoiceList
- Inherits:
-
Api
- Object
- Api
- Fulcrum::ChoiceList
show all
- Defined in:
- lib/fulcrum/choice_list.rb
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/choice_list.rb', line 6
def all(opts = {})
params = parse_opts([:page], opts)
call(:get, 'choice_lists.json', params)
end
|
.create(choice_list) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/fulcrum/choice_list.rb', line 15
def create(choice_list)
validation = ChoiceListValidator.new(choice_list)
if validation.valid?
call(:post, 'choice_lists.json', choice_list)
else
{ error: { validation: validation.errors } }
end
end
|
.delete(id) ⇒ Object
33
34
35
|
# File 'lib/fulcrum/choice_list.rb', line 33
def delete(id)
call(:delete, "choice_lists/#{id}.json")
end
|
.find(id) ⇒ Object
11
12
13
|
# File 'lib/fulcrum/choice_list.rb', line 11
def find(id)
call(:get, "choice_lists/#{id}.json")
end
|
.update(id, choice_list) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/fulcrum/choice_list.rb', line 24
def update(id, choice_list)
validation = ChoiceListValidator.new(choice_list)
if validation.valid?
call(:put, "choice_lists/#{id}.json", choice_list)
else
{ error: { validation: validation.errors } }
end
end
|