Class: Stay::Api::V1::FeaturesController

Inherits:
BaseApiController
  • Object
show all
Defined in:
app/controllers/stay/api/v1/features_controller.rb

Instance Method Summary collapse

Instance Method Details

#propertyObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/stay/api/v1/features_controller.rb', line 4

def property
  features = Stay::Feature.property

  if features.exists?
    render json: {
      success: true,
      data: ActiveModelSerializers::SerializableResource.new(features, each_serializer: FeatureSerializer)
    }, status: :ok
  else
    render json: {
      success: false,
      message: "No property features found"
    }, status: :not_found
  end
rescue => e
  render json: {
    success: false,
    error: "Failed to fetch property features",
    message: e.message
  }, status: :internal_server_error
end

#roomObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/stay/api/v1/features_controller.rb', line 26

def room
  features = Stay::Feature.room

  if features.exists?
    render json: {
      success: true,
      data: ActiveModelSerializers::SerializableResource.new(features, each_serializer: FeatureSerializer)
    }, status: :ok
  else
    render json: {
      success: false,
      message: "No room features found"
    }, status: :not_found
  end
rescue => e
  render json: {
    success: false,
    error: "Failed to fetch room features",
    message: e.message
  }, status: :internal_server_error
end