Class: MandateClaw::Api::V1::BreachEventsController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- MandateClaw::Api::V1::BreachEventsController
- Defined in:
- app/controllers/mandate_claw/api/v1/breach_events_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /mandate_claw/api/v1/contracts/:contract_id/breach_events Called by the runtime when a prohibited action is attempted.
-
#index ⇒ Object
GET /mandate_claw/api/v1/contracts/:contract_id/breach_events.
Instance Method Details
#create ⇒ Object
POST /mandate_claw/api/v1/contracts/:contract_id/breach_events Called by the runtime when a prohibited action is attempted.
17 18 19 20 21 22 |
# File 'app/controllers/mandate_claw/api/v1/breach_events_controller.rb', line 17 def create event = @contract.breach_events.create!(breach_event_params) render json: serialize(event), status: :created rescue ActiveRecord::RecordInvalid => e render json: { error: e. }, status: :unprocessable_entity end |
#index ⇒ Object
GET /mandate_claw/api/v1/contracts/:contract_id/breach_events
10 11 12 13 |
# File 'app/controllers/mandate_claw/api/v1/breach_events_controller.rb', line 10 def index events = @contract.breach_events.order(occurred_at: :desc) render json: events.map { |e| serialize(e) } end |