Class: ApiEngineBase::Inbox::MessageController

Inherits:
ApplicationController show all
Includes:
SchemaHelper
Defined in:
app/controllers/api_engine_base/inbox/message_controller.rb

Constant Summary

Constants inherited from ApplicationController

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

Instance Method Summary collapse

Methods included from SchemaHelper

#invalid_arguments!, #schema_succesful!

Methods inherited from ApplicationController

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

Instance Method Details

#ackObject

POST: /inbox/messages/ack Body { ids: [<list of ids to ack>] }



46
47
48
# File 'app/controllers/api_engine_base/inbox/message_controller.rb', line 46

def ack
  modify(type: ApiEngineBase::InboxService::Message::Modify::VIEWED)
end

#deleteObject

POST: /inbox/messages/delete Body { ids: [<list of ids to delete>] }



52
53
54
# File 'app/controllers/api_engine_base/inbox/message_controller.rb', line 52

def delete
  modify(type: ApiEngineBase::InboxService::Message::Modify::DELETE)
end

#messageObject

GET: /inbox/messages/:id



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/api_engine_base/inbox/message_controller.rb', line 28

def message
  result = ApiEngineBase::InboxService::Message::Retrieve.(user: current_user, id: params[:id].to_i)
  if result.success?
    schema = result.message
    status = 200
    schema_succesful!(status:, schema:)
  else
    invalid_arguments!(
      status: 400,
      message: result.msg,
      argument_object: result.invalid_argument_hash,
      schema: ApiEngineBase::Schema::PlainText::LoginRequest
    )
  end
end

#metadataObject

GET: /inbox/messages



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/api_engine_base/inbox/message_controller.rb', line 11

def 
  result = ApiEngineBase::InboxService::Message::Metadata.(user: current_user)
  if result.success?
    schema = result.
    status = 200
    schema_succesful!(status:, schema:)
  else
    invalid_arguments!(
      status: 400,
      message: result.msg,
      argument_object: result.invalid_argument_hash,
      schema: ApiEngineBase::Schema::PlainText::LoginRequest
    )
  end
end