Sha256: 7ec8fed2b9d6bf029433a63bce1c352c57f2b84073b46e276104ec0360361915

Contents?: true

Size: 1.61 KB

Versions: 18

Compression:

Stored size: 1.61 KB

Contents

module ForestLiana
  class IntercomAttributeSerializer
    include JSONAPI::Serializer

    attribute :session_count
    attribute :last_seen_ip

    attribute :created_at do
      object.created_at.utc.try(:iso8601)
    end

    attribute :updated_at do
      object.updated_at.utc.try(:iso8601)
    end

    attribute :signed_up_at do
      object.signed_up_at.utc.try(:iso8601)
    end

    attribute :last_request_at do
      object.last_request_at.utc.try(:iso8601)
    end

    attribute :country do
      object.location_data.country_name
    end

    attribute :city do
      object.location_data.city_name
    end

    attribute :user_agent do
      object.user_agent_data
    end

    attribute :companies do
      object.companies.map(&:name)
    end

    attribute :segments do
      object.segments.map(&:name)
    end

    attribute :tags do
      object.tags.map(&:name)
    end

    attribute :browser do
      useragent = UserAgent.parse(object.user_agent_data)
      "#{useragent.try(:browser)} #{useragent.try(:version)}"
    end

    attribute :platform do
      UserAgent.parse(object.user_agent_data).try(:platform)
    end

    attribute :geoloc do
      [object.location_data.latitude, object.location_data.longitude]
    end

    def self_link
      "/forest#{super}"
    end

    def type
      'intercom-attributes'
    end

    def format_name(attribute_name)
      attribute_name.to_s
    end

    def unformat_name(attribute_name)
      attribute_name.to_s.underscore
    end

    def relationship_self_link(attribute_name)
      nil
    end

    def relationship_related_link(attribute_name)
      nil
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
forest_liana-1.3.0 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.2.6 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.2.5 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.2.3 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.2.2 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.2.1 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.35 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.34 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.33 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.32 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.31 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.30 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.29 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.28 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.27 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.26 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.25 app/serializers/forest_liana/intercom_attribute_serializer.rb
forest_liana-1.1.23 app/serializers/forest_liana/intercom_attribute_serializer.rb