summaryrefslogtreecommitdiff
path: root/app/serializers/switchboard_entry_serializer.rb
blob: 1b6c76180db8827ed30d47df7534798f825196c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class SwitchboardEntrySerializer < ActiveModel::Serializer
  attributes :id, :name, :path_to_user, :avatar_src, :callstate

  has_one :sip_account, embed: :ids
  has_one :switchboard, embed: :ids

  def path_to_user
    if object.sip_account && object.sip_account.sip_accountable_type == 'User'
      "/tenants/#{object.sip_account.sip_accountable.current_tenant.id}/users/#{object.sip_account.sip_accountable.id}"
    else
      nil
    end
  end
end