Class: Zedlocales::Content
- Inherits:
-
Object
- Object
- Zedlocales::Content
- Defined in:
- lib/zedlocales/content.rb
Defined Under Namespace
Classes: Translations
Class Method Summary collapse
- .create(*args) {|reshh| ... } ⇒ Object
- .delete(*args) {|reshh| ... } ⇒ Object
-
.get(*args) {|reshh| ... } ⇒ Object
Zedlocales Content.
- .update(*args) {|reshh| ... } ⇒ Object
Class Method Details
.create(*args) {|reshh| ... } ⇒ Object
78 79 80 81 82 83 |
# File 'lib/zedlocales/content.rb', line 78 def create(*args) zopts = args. reshh = Zedkit::Client.create('content/content', zopts[:user_key], zopts.zdelete_keys!(%w(user_key))) yield(reshh) if (not reshh.nil?) && block_given? reshh end |
.delete(*args) {|reshh| ... } ⇒ Object
93 94 95 96 97 98 |
# File 'lib/zedlocales/content.rb', line 93 def delete(*args) zopts = args. reshh = Zedkit::Client.delete("content/content/#{zopts[:uuid]}", zopts[:user_key]) yield(reshh) if (not reshh.nil?) && block_given? reshh end |
.get(*args) {|reshh| ... } ⇒ Object
Zedlocales Content
All Zedkit applications have optional content that can be maintained with the Zedkit management interface. You can create, read, update, or delete content within content scopes. To perform an operation on a specific content scope you need its UUID, as available from the Zedlocales::ContentScopes::Content.get method.
To get a Content item:
Zedlocales::Content.get(:user_key => user['user_key'], :uuid => content['uuid'])
To update a Content item:
Zedlocales::Content.update(:user_key => user['user_key'],
:uuid => content['uuid'], :content => { :content => 'whatever' })
To delete a Content item:
Zedlocales::Content.delete(:user_key => user['user_key'], :uuid => scope['uuid'])
To create a new Content item you submit the required parameters with the scope UUID that you are creating the content for. Whatever items you send within the :content Hash are passed through to the ZedAPI untouched. There is no client side validation within this gem.
Zedlocales::Content.create(:user_key => user['user_key'], :scope => { :uuid => scope['uuid'] },
:content => { :key => 'whatever', :content => 'yo this the api' })
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::Content.get(:user_key => user['user_key'], :uuid => content['uuid']) do |result|
end
70 71 72 73 74 75 76 |
# File 'lib/zedlocales/content.rb', line 70 def get(*args) zopts = args. reshh = Zedkit::Client.get("content/content/#{zopts[:uuid]}", zopts[:user_key], zopts.zdelete_keys!(%w(uuid user_key))) yield(reshh) if (not reshh.nil?) && block_given? reshh end |
.update(*args) {|reshh| ... } ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/zedlocales/content.rb', line 85 def update(*args) zopts = args. reshh = Zedkit::Client.update("content/content/#{zopts[:uuid]}", zopts[:user_key], zopts.zdelete_keys!(%w(uuid user_key))) yield(reshh) if (not reshh.nil?) && block_given? reshh end |