Class: CommandTower::Messaging::Endpoints::Replace

Inherits:
Object
  • Object
show all
Defined in:
app/services/command_tower/messaging/endpoints/replace.rb

Overview

Local retire+insert only. New row is always unverified; never contacts providers.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner_user_id:, channel_key:, endpoint_id:, address:, credentials:) ⇒ Replace

Returns a new instance of Replace.



12
13
14
15
16
17
18
# File 'app/services/command_tower/messaging/endpoints/replace.rb', line 12

def initialize(owner_user_id:, channel_key:, endpoint_id:, address:, credentials:)
  @owner_user_id = owner_user_id
  @address = address
  @credentials = credentials
  @channel_key = channel_key&.to_s
  @endpoint_id = endpoint_id
end

Class Method Details

.call(owner_user_id:, channel_key: nil, endpoint_id: nil, address: nil, credentials: nil) ⇒ Object



8
9
10
# File 'app/services/command_tower/messaging/endpoints/replace.rb', line 8

def self.call(owner_user_id:, channel_key: nil, endpoint_id: nil, address: nil, credentials: nil)
  new(owner_user_id:, channel_key:, endpoint_id:, address:, credentials:).call
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
# File 'app/services/command_tower/messaging/endpoints/replace.rb', line 20

def call
  if @endpoint_id
    replace_by_endpoint_id
  elsif @channel_key
    replace_single_active_channel
  else
    raise ValidationError, "replace requires endpoint_id (push) or channel_key (pushover)"
  end
end