Class: Zedlocales::ContentSections

Inherits:
Object
  • Object
show all
Defined in:
lib/zedlocales/content_sections.rb

Defined Under Namespace

Classes: ContentScopes

Class Method Summary collapse

Class Method Details

.create(zks = {}, &block) ⇒ Object



70
71
72
# File 'lib/zedlocales/content_sections.rb', line 70

def create(zks = {}, &block)
  Zedkit::Client.crud(:create, 'content/sections', zks, [], &block)
end

.delete(zks = {}, &block) ⇒ Object



78
79
80
# File 'lib/zedlocales/content_sections.rb', line 78

def delete(zks = {}, &block)
  Zedkit::Client.crud(:delete, "content/sections/#{zks[:uuid]}", zks, [], &block)
end

.get(zks = {}, &block) ⇒ Object

Zedlocales Content Sections

All Zedkit applications have optional content. You can create, read, update, or delete content sections to organize it. To perform an operation on a specific content section you need its UUID, as available from the Zedkit::Projects::ContentSections.get method.

To get a Content Section:

Zedlocales::ContentSections.get(:user_key => user['user_key'], :uuid => section['uuid'])

To update a Content Section:

Zedlocales::ContentSections.update(:user_key => user['user_key'],
                                   :uuid => section['uuid'], :section => { :key => 'whatever' })

To delete a Content Section:

Zedlocales::ContentSections.delete(:user_key => user['user_key'], :uuid => section['uuid'])

To create a new Content Section you submit the required parameters with the project UUID that you are creating the content section for. Whatever items you send within the :section Hash are passed through to the ZedAPI untouched. There is no client side validation within this gem.

Zedlocales::ContentSections.create(:user_key => user['user_key'],
                                   :project => { :uuid => project['uuid'] }, :section => { :key => 'whatever' })

From each of these requests the Zedkit::Client class will return a response hash for your reference, if needed, or as applicable to the request. If there was a HTTP 401 or 404 you will get a nil response. This indicates a security failure or that an UUID is incorrect, not attached the user’s account, or non-existent.

For each request you can also pass a block to process the response directly:

Zedlocales::ContentSections.get(:user_key => user['user_key'], :uuid => section['uuid']) do |result|
end


66
67
68
# File 'lib/zedlocales/content_sections.rb', line 66

def get(zks = {}, &block)
  Zedkit::Client.crud(:get, "content/sections/#{zks[:uuid]}", zks, [], &block)
end

.update(zks = {}, &block) ⇒ Object



74
75
76
# File 'lib/zedlocales/content_sections.rb', line 74

def update(zks = {}, &block)
  Zedkit::Client.crud(:update, "content/sections/#{zks[:uuid]}", zks, [], &block)
end