Module: Zedkit::Client
- Defined in:
- lib/zedkit/client/client.rb,
lib/zedkit/client/exceptions.rb
Defined Under Namespace
Classes: ClientError, DataValidationError, ResourceNotFound, UnauthorizedAccess
Class Method Summary collapse
- .crud(method, resource, zks, del_keys, &block) ⇒ Object
- .get(resource, user_key = nil, params = {}, &block) ⇒ Object
- .verify(login, password) ⇒ Object
Class Method Details
.crud(method, resource, zks, del_keys, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/zedkit/client/client.rb', line 21 def crud(method, resource, zks, del_keys, &block) rs = nil case method when :get rs = submit_request(:get, resource, zks[:user_key], zks.zdelete_keys!(%w(user_key uuid) + del_keys)) when :create rs = submit_request(:post, resource, zks[:user_key], zks.zdelete_keys!(%w(user_key) + del_keys)) when :update rs = submit_request(:put, resource, zks[:user_key], zks.zdelete_keys!(%w(user_key uuid) + del_keys)) when :delete rs = submit_request(:delete, resource, zks[:user_key]) end if rs && block_given? rs.is_a?(Array) ? rs.each {|i| yield(i) } : yield(rs) end rs end |
.get(resource, user_key = nil, params = {}, &block) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/zedkit/client/client.rb', line 42 def get(resource, user_key = nil, params = {}, &block) rs = submit_request(:get, resource, user_key, params) if rs && block_given? rs.is_a?(Array) ? rs.each {|i| yield(i) } : yield(rs) end rs end |
.verify(login, password) ⇒ Object
39 40 41 |
# File 'lib/zedkit/client/client.rb', line 39 def verify(login, password) submit_request(:verify, "users/verify", nil, {}, { :user => login, :password => password }) end |