Class: GatherContent::Api::Item
- Inherits:
-
Base
- Object
- Base
- GatherContent::Api::Item
show all
- Defined in:
- lib/gather_content/api/item.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#fetch, #get, #post, #post_json, #reset
Constructor Details
permalink
#initialize(item_id, data = nil) ⇒ Item
Returns a new instance of Item.
[View source]
8
9
10
11
12
|
# File 'lib/gather_content/api/item.rb', line 8
def initialize(item_id, data = nil)
raise ArgumentError, "Item_id is required!" if item_id.nil?
@item_id = item_id
@data = data
end
|
Instance Attribute Details
Returns the value of attribute item_id.
6
7
8
|
# File 'lib/gather_content/api/item.rb', line 6
def item_id
@item_id
end
|
Instance Method Details
[View source]
14
15
16
|
# File 'lib/gather_content/api/item.rb', line 14
def [](key)
fetch[key]
end
|
permalink
#apply_template(template_id) ⇒ Object
[View source]
28
29
30
|
# File 'lib/gather_content/api/item.rb', line 28
def apply_template(template_id)
post_save({ "template_id" => template_id }, "#{path}/apply_template")
end
|
permalink
#choose_status(status_id) ⇒ Object
[View source]
32
33
34
|
# File 'lib/gather_content/api/item.rb', line 32
def choose_status(status_id)
post_save({ "status_id" => status_id }, "#{path}/choose_status")
end
|
permalink
#save(config) ⇒ Object
[View source]
18
19
20
21
22
23
24
25
26
|
# File 'lib/gather_content/api/item.rb', line 18
def save(config)
encoded = Base64.strict_encode64(config.to_json)
result = post_json({config: encoded}, "#{path}/save")
if result.status == 202
true
else
raise GatherContent::Error::RequestError.new(result)
end
end
|