Class: Mks::Rent::OfferRequestsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/mks/rent/offer_requests_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
# File 'app/controllers/mks/rent/offer_requests_controller.rb', line 21

def create
  offer_request, success = @service.create(offer_request_params, current_user)
  if success
    render json: Mks::Common::MethodResponse.success_response(offer_request, 'Request created successfully!'),
           status: :created, location: offer_request
  else
    render json: Mks::Common::MethodResponse.failure_response(offer_request), status: :unprocessable_entity
  end
end

#indexObject



7
8
9
10
# File 'app/controllers/mks/rent/offer_requests_controller.rb', line 7

def index
  data = OfferRequest.where(prepared_by: current_user)
  render json: Mks::Common::MethodResponse.success_response(data)
end

#showObject



12
13
14
15
16
17
18
19
# File 'app/controllers/mks/rent/offer_requests_controller.rb', line 12

def show
  data = ActiveModelSerializers::SerializableResource.new(@offer_request,
                                                          serializer: CompleteOfferRequestSerializer).as_json
  # Remove this when MethodResponse.success_response() is
  # updated to accept a serializer
  response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil)
  render json: response
end