Class: ForestLiana::IntercomAttributesGetter
- Inherits:
-
Object
- Object
- ForestLiana::IntercomAttributesGetter
- Defined in:
- app/services/forest_liana/intercom_attributes_getter.rb
Instance Attribute Summary collapse
-
#records ⇒ Object
Returns the value of attribute records.
Instance Method Summary collapse
- #count ⇒ Object
-
#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 9 10 |
# File 'app/services/forest_liana/intercom_attributes_getter.rb', line 5 def initialize(params) @params = params @intercom = ::Intercom::Client.new( app_id: ForestLiana.integrations[:intercom][:app_id], api_key: ForestLiana.integrations[:intercom][:api_key]) end |
Instance Attribute Details
#records ⇒ Object
Returns the value of attribute records.
3 4 5 |
# File 'app/services/forest_liana/intercom_attributes_getter.rb', line 3 def records @records end |
Instance Method Details
#count ⇒ Object
12 13 14 |
# File 'app/services/forest_liana/intercom_attributes_getter.rb', line 12 def count @records.count end |
#perform ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/services/forest_liana/intercom_attributes_getter.rb', line 16 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 @records = user rescue Intercom::ResourceNotFound end end |