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.
-
#destroy_all(params) ⇒ JSON
Destroys all notifications of the target matching filter criteria.
-
#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
Methods included from StoreController
#store_controller_for_activity_notification
Instance Method Details
#destroy(params) ⇒ JSON
Deletes a notification.
DELETE /:target_type/:target_id/notifications/:id
95 96 97 98 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 95 def destroy super head 204 end |
#destroy_all(params) ⇒ JSON
Destroys all notifications of the target matching filter criteria.
POST /:target_type/:target_id/notifications/destroy_all
70 71 72 73 74 75 76 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 70 def destroy_all super render json: { count: @destroyed_notifications.size, notifications: @destroyed_notifications.as_json() } 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
124 125 126 127 128 129 130 131 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 124 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
107 108 109 110 111 112 113 114 115 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 107 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
49 50 51 52 53 54 55 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 49 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
84 85 86 87 |
# File 'app/controllers/activity_notification/notifications_api_controller.rb', line 84 def show super render json: notification_json end |