Class: ForestLiana::IntercomController

Inherits:
ApplicationController show all
Defined in:
app/controllers/forest_liana/intercom_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user_from_jwt, #forest_user, #internal_server_error, papertrail?, #serialize_model, #serialize_models

Methods inherited from BaseController

#route_not_found

Instance Method Details

#attributesObject



22
23
24
25
26
27
28
29
# File 'app/controllers/forest_liana/intercom_controller.rb', line 22

def attributes
  getter = IntercomAttributesGetter.new(params)
  getter.perform

  render serializer: nil, json: serialize_model(getter.record, {
    context: { type: get_serializer_type('intercom_attributes') }
  })
end

#conversationObject



13
14
15
16
17
18
19
20
# File 'app/controllers/forest_liana/intercom_controller.rb', line 13

def conversation
  getter = IntercomConversationGetter.new(params)
  getter.perform

  render serializer: nil, json: serialize_model(getter.record, {
    context: { type: get_serializer_type('intercom_conversations') }
  })
end

#conversationsObject



3
4
5
6
7
8
9
10
11
# File 'app/controllers/forest_liana/intercom_controller.rb', line 3

def conversations
  getter = IntercomConversationsGetter.new(params)
  getter.perform

  render serializer: nil, json: serialize_models(getter.records, {
    context: { type: get_serializer_type('intercom_conversations') },
    meta: { count: getter.count }
  })
end

#get_serializer_type(suffix) ⇒ Object



31
32
33
# File 'app/controllers/forest_liana/intercom_controller.rb', line 31

def get_serializer_type(suffix)
  "#{params[:collection]}_#{suffix}"
end