class Layer::User
Public Class Methods
find(id, client = self.client)
click to toggle source
# File lib/layer/user.rb, line 4 def self.find(id, client = self.client) from_response({ 'url' => "/users/#{id}" }, client) end
Public Instance Methods
blocks()
click to toggle source
Returns the users blocked by this user
@return [Layer::RelationProxy] the users the user blocks @!macro platform-api
# File lib/layer/user.rb, line 12 def blocks RelationProxy.new(self, Block, [Operations::Create, Operations::List, Operations::Delete]) do def from_response(response, client) response['url'] ||= "#{base.url}#{resource_type.url}/#{response['user_id']}" super end def create(attributes, client = self.client) response = client.post(url, attributes) from_response({ 'user_id' => attributes['user_id'] }, client) end end end
conversations()
click to toggle source
Returns the user's conversations
@return [Layer::RelationProxy] the user's conversations @!macro platform-api
# File lib/layer/user.rb, line 52 def conversations RelationProxy.new(self, Conversation, [Operations::List, Operations::Find]) end
create(attributes, client = self.client)
click to toggle source
# File lib/layer/user.rb, line 19 def create(attributes, client = self.client) response = client.post(url, attributes) from_response({ 'user_id' => attributes['user_id'] }, client) end
delete(client = self.client)
click to toggle source
# File lib/layer/user.rb, line 42 def delete(client = self.client) client.delete(url) end
from_response(response, client)
click to toggle source
Calls superclass method
Layer::Resource::from_response
# File lib/layer/user.rb, line 14 def from_response(response, client) response['url'] ||= "#{base.url}#{resource_type.url}/#{response['user_id']}" super end
identity()
click to toggle source
Returns the identity object for this user
@return [Layer::RelationProxy] identity object @!macro platform-api
# File lib/layer/user.rb, line 30 def identity SingletonRelationProxy.new(self, Layer::Identity) do def from_response(response, client) response['url'] ||= "#{base.url}#{resource_type.url}" super end def create(attributes, client = self.client) client.post(url, attributes) fetch end def delete(client = self.client) client.delete(url) end end end
messages()
click to toggle source
Returns the user's messages
@return [Layer::RelationProxy] the user's messages @!macro platform-api
# File lib/layer/user.rb, line 60 def messages RelationProxy.new(self, Message, [Operations::Find]) end