Class: ForestLiana::IntercomAttributesGetter
- Inherits:
-
IntegrationBaseGetter
- Object
- IntegrationBaseGetter
- ForestLiana::IntercomAttributesGetter
- Defined in:
- app/services/forest_liana/intercom_attributes_getter.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(params) ⇒ IntercomAttributesGetter
constructor
A new instance of IntercomAttributesGetter.
- #perform ⇒ Object
Constructor Details
#initialize(params) ⇒ IntercomAttributesGetter
Returns a new instance of IntercomAttributesGetter.
5 6 7 8 |
# File 'app/services/forest_liana/intercom_attributes_getter.rb', line 5 def initialize(params) @params = params @intercom = ::Intercom::Client.new(token: ForestLiana.integrations[:intercom][:access_token]) end |
Instance Attribute Details
#record ⇒ Object
Returns the value of attribute record.
3 4 5 |
# File 'app/services/forest_liana/intercom_attributes_getter.rb', line 3 def record @record end |
Instance Method Details
#perform ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/services/forest_liana/intercom_attributes_getter.rb', line 10 def perform begin resource = collection.find(@params[:id]) user = @intercom.users.find(email: resource.email) user.segments = user.segments.map do |segment| @intercom.segments.find(id: segment.id) end @record = user rescue Intercom::ResourceNotFound rescue Intercom::UnexpectedError => exception FOREST_REPORTER.report exception FOREST_LOGGER.error "Cannot retrieve the Intercom attributes: #{exception.}" end end |