Class: ForestLiana::IntercomConversationGetter

Inherits:
IntegrationBaseGetter show all
Defined in:
app/services/forest_liana/intercom_conversation_getter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ IntercomConversationGetter

Returns a new instance of IntercomConversationGetter.



5
6
7
8
9
# File 'app/services/forest_liana/intercom_conversation_getter.rb', line 5

def initialize(params)
  @params = params
  @access_token = ForestLiana.integrations[:intercom][:access_token]
  @intercom = ::Intercom::Client.new(token: @access_token)
end

Instance Attribute Details

#recordObject

Returns the value of attribute record.



3
4
5
# File 'app/services/forest_liana/intercom_conversation_getter.rb', line 3

def record
  @record
end

Instance Method Details

#performObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/forest_liana/intercom_conversation_getter.rb', line 11

def perform
  begin
    @record = @intercom.conversations.find(id: @params[:conversation_id])
  rescue Intercom::ResourceNotFound
    @record = nil
  rescue Intercom::UnexpectedError => exception
    FOREST_REPORTER.report exception
    FOREST_LOGGER.error "Cannot retrieve the Intercom conversation: #{exception.message}"
    @record = nil
  end
end