Class: Layer::User
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
Instance Method Summary collapse
-
#blocks ⇒ Layer::RelationProxy
Returns the users blocked by this user.
-
#conversations ⇒ Layer::RelationProxy
Returns the user’s conversations.
-
#identity ⇒ Layer::RelationProxy
Returns the identity object for this user.
-
#messages ⇒ Layer::RelationProxy
Returns the user’s messages.
Methods inherited from Resource
class_name, from_response, #id, #initialize, #respond_to_missing?, url, #url
Constructor Details
This class inherits a constructor from Layer::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Layer::Resource
Class Method Details
.find(id, client = self.client) ⇒ Object
4 5 6 |
# File 'lib/layer/user.rb', line 4 def self.find(id, client = self.client) from_response({ 'url' => "/users/#{id}" }, client) end |
Instance Method Details
#blocks ⇒ Layer::RelationProxy
Note:
This is only available via the Platform API.
Returns the users blocked by this user
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# 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 ⇒ Layer::RelationProxy
Note:
This is only available via the Platform API.
Returns the user’s conversations
52 53 54 |
# File 'lib/layer/user.rb', line 52 def conversations RelationProxy.new(self, Conversation, [Operations::List, Operations::Find]) end |
#identity ⇒ Layer::RelationProxy
Note:
This is only available via the Platform API.
Returns the identity object for this user
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# 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 ⇒ Layer::RelationProxy
Note:
This is only available via the Platform API.
Returns the user’s messages
60 61 62 |
# File 'lib/layer/user.rb', line 60 def RelationProxy.new(self, Message, [Operations::Find]) end |