Class: CommandTower::Me::PushController

Inherits:
ApplicationController show all
Includes:
Auth::AuthenticationBoundary, Auth::AuthorizationBoundary
Defined in:
app/controllers/command_tower/me/push_controller.rb

Constant Summary

Constants inherited from ApplicationController

ApplicationController::AUTHENTICATION_EXPIRE_HEADER, ApplicationController::AUTHENTICATION_HEADER, ApplicationController::AUTHENTICATION_WITH_RESET

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user!, #authenticate_user_without_email_verification!, #authorize_user!, #current_user, #safe_boolean

Instance Method Details

#create ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/command_tower/me/push_controller.rb', line 20

def create
  deserialized = CommandTower::Deserializers::Me::Push::TokenDeserializer.call(params)
  return render_deserializer_errors unless deserialized.success?

  result = CommandTower::Workflows::Me::Push::CreateWorkflow.call(
    current_user: current_user,
    address: deserialized.input.address,
    auth_context: current_auth_context,
  )
  render_application_result(result)
end

#destroy ⇒ Object



45
46
47
48
49
50
51
52
# File 'app/controllers/command_tower/me/push_controller.rb', line 45

def destroy
  result = CommandTower::Workflows::Me::Push::DestroyWorkflow.call(
    current_user: current_user,
    endpoint_id: params[:id],
    auth_context: current_auth_context,
  )
  render_application_result(result)
end

#index ⇒ Object



12
13
14
15
16
17
18
# File 'app/controllers/command_tower/me/push_controller.rb', line 12

def index
  result = CommandTower::Workflows::Me::Push::IndexWorkflow.call(
    current_user: current_user,
    auth_context: current_auth_context,
  )
  render_application_result(result)
end

#test ⇒ Object



54
55
56
57
58
59
60
# File 'app/controllers/command_tower/me/push_controller.rb', line 54

def test
  result = CommandTower::Workflows::Me::Push::TestWorkflow.call(
    current_user: current_user,
    auth_context: current_auth_context,
  )
  render_application_result(result)
end

#update ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/command_tower/me/push_controller.rb', line 32

def update
  deserialized = CommandTower::Deserializers::Me::Push::TokenDeserializer.call(params)
  return render_deserializer_errors unless deserialized.success?

  result = CommandTower::Workflows::Me::Push::ReplaceWorkflow.call(
    current_user: current_user,
    endpoint_id: params[:id],
    address: deserialized.input.address,
    auth_context: current_auth_context,
  )
  render_application_result(result)
end