Class: ActivityNotification::NotificationsApiController
- Inherits:
-
NotificationsController
- Object
- NotificationsController
- ActivityNotification::NotificationsApiController
- Includes:
- CommonApiController, Swagger::NotificationsApi
- Defined in:
- app/controllers/activity_notification/notifications_api_controller.rb
Overview
Controller to manage notifications API.
Direct Known Subclasses
Constant Summary
Constants included from CommonController
CommonController::DEFAULT_VIEW_DIRECTORY
Instance Method Summary collapse
-
#destroy(params) ⇒ JSON
Deletes a notification.
-
#index(params) ⇒ JSON
Returns notification index of the target.
-
#open(params) ⇒ JSON
Moves to notifiable_path of the notification.
-
#open(params) ⇒ JSON
Opens a notification.
-
#open_all(params) ⇒ JSON
Opens all notifications of the target.
-
#show(params) ⇒ JSON
Returns a single notification.
Methods inherited from NotificationsController
Instance Method Details
#destroy(params) ⇒ JSON
Deletes a notification.
DELETE /:target_type/:target_id/notifications/:id
73 74 75 76 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 73 def destroy super head 204 end |
#index(params) ⇒ JSON
Returns notification index of the target.
GET /:target_type/:target_id/notifications
28 29 30 31 32 33 34 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 28 def index super render json: { count: @notifications.size, notifications: @notifications.as_json() } end |
#open(params) ⇒ JSON
Moves to notifiable_path of the notification.
GET /:target_type/:target_id/notifications/:id/move
102 103 104 105 106 107 108 109 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 102 def move super render status: 302, location: @notification.notifiable_path, json: { location: @notification.notifiable_path, count: (@opened_notifications_count || 0), notification: notification_json } end |
#open(params) ⇒ JSON
Opens a notification.
PUT /:target_type/:target_id/notifications/:id/open
85 86 87 88 89 90 91 92 93 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 85 def open super unless params[:move].to_s.to_boolean(false) render json: { count: @opened_notifications_count, notification: notification_json } end end |
#open_all(params) ⇒ JSON
Opens all notifications of the target.
POST /:target_type/:target_id/notifications/open_all
48 49 50 51 52 53 54 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 48 def open_all super render json: { count: @opened_notifications.size, notifications: @opened_notifications.as_json() } end |
#show(params) ⇒ JSON
Returns a single notification.
GET /:target_type/:target_id/notifications/:id
62 63 64 65 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 62 def show super render json: notification_json end |