class GatherContent::Api::Items
Attributes
project_id[RW]
Public Class Methods
new(project_id)
click to toggle source
# File lib/gather_content/api/items.rb, line 9 def initialize(project_id) raise ArgumentError, "Project_id is required!" if project_id.nil? @project_id = project_id end
Public Instance Methods
create(data)
click to toggle source
# File lib/gather_content/api/items.rb, line 20 def create(data) data.delete("parent_id") if data["parent_id"].nil? || data["parent_id"].empty? data.delete("template_id") if data["template_id"].nil? || data["template_id"].empty? config = data.delete("config") data["config"] = Base64.strict_encode64(config.to_json) unless config.nil? || config.empty? raise ArgumentError, "name is required!" if data["name"].nil? || data["name"].empty? result = post_json(data.merge({ 'project_id' => @project_id })) if result.status == 202 item_id = result.headers['location'].split('/').last GatherContent::Api::Item.new(item_id) else raise GatherContent::Error::RequestError.new(result) end end
each() { |item| ... }
click to toggle source
# File lib/gather_content/api/items.rb, line 14 def each(&block) fetch.each do |item| yield GatherContent::Api::Item.new(item['id'], item) end end
Private Instance Methods
params()
click to toggle source
# File lib/gather_content/api/items.rb, line 40 def params { project_id: project_id } end
path()
click to toggle source
# File lib/gather_content/api/items.rb, line 44 def path @path ||= '/items' end