Class: CommandTower::Messaging::Endpoints::Query
- Inherits:
-
Object
- Object
- CommandTower::Messaging::Endpoints::Query
- Defined in:
- app/services/command_tower/messaging/endpoints/query.rb
Class Method Summary collapse
Class Method Details
.list(owner_user_id:, channel_key: nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'app/services/command_tower/messaging/endpoints/query.rb', line 7 def self.list(owner_user_id:, channel_key: nil) if channel_key ChannelGate.assert_endpoint_backed!(channel_key) end scope = Endpoint.for_owner(owner_user_id).order(:id) scope = scope.where(channel_key: ChannelGate.supported_channel_keys) scope = scope.for_channel(channel_key) if channel_key scope.map { |record| SafeView.from_record(record) } end |
.show(owner_user_id:, endpoint_id:) ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/services/command_tower/messaging/endpoints/query.rb', line 18 def self.show(owner_user_id:, endpoint_id:) record = Endpoint.for_owner(owner_user_id).find_by(id: endpoint_id) raise NotFoundError, "endpoint not found" if record.nil? ChannelGate.assert_record_supported!(record) SafeView.from_record(record) end |