Class: Dimelo::CCP::User

Inherits:
API::Model show all
Defined in:
lib/dimelo/ccp/api/model/user.rb

Constant Summary collapse

CUSTOM_FIELD_COUNT =
10
CUSTOM_FIELD_ATTRIBUTES =
(1..CUSTOM_FIELD_COUNT).map { |i| "custom_field_#{i}".to_sym }.freeze

Constants inherited from API::Model

API::Model::INTERPOLATION_PATTERN

Instance Attribute Summary

Attributes inherited from API::Model

#client, #errors, #tracked_attributes

Instance Method Summary collapse

Methods inherited from API::Model

#==, attribute, attributes, #attributes, #attributes=, belongs_to, compute_path, #create, #destroy, find, has_many, #initialize, #merge!, #new_record?, parse, path, #reload, #save, #submit_attributes, submit_attributes, #to_json, #tracked_submit_attributes, #update, #valid?, #warn

Constructor Details

This class inherits a constructor from Dimelo::CCP::API::Model

Instance Method Details

#avatar_url(size = 'normal') ⇒ Object



16
17
18
# File 'lib/dimelo/ccp/api/model/user.rb', line 16

def avatar_url(size='normal')
  @avatar_url || avatar.try(:[], size).try(:[], 'url')
end

#blockObject

Blocks the specified user



21
22
23
24
25
26
# File 'lib/dimelo/ccp/api/model/user.rb', line 21

def block
  path = "#{compute_path(attributes)}/block"
  response = client.transport(:post, path)
  self.attributes = Dimelo::CCP::API.decode_json(response)
  errors.empty?
end

#unblockObject

Unblocks the specified user



29
30
31
32
33
34
# File 'lib/dimelo/ccp/api/model/user.rb', line 29

def unblock
  path = "#{compute_path(attributes)}/unblock"
  response = client.transport(:post, path)
  self.attributes = Dimelo::CCP::API.decode_json(response)
  errors.empty?
end