Class: MandateClaw::Api::V1::BreachEventsController

Inherits:
ActionController::API
  • Object
show all
Defined in:
app/controllers/mandate_claw/api/v1/breach_events_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

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.message }, status: :unprocessable_entity
end

#indexObject

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