Sha256: f528404f226189a2a3642b191d7f6d3644b35745b0f1d2cb82792319aabcf6bd

Contents?: true

Size: 859 Bytes

Versions: 15

Compression:

Stored size: 859 Bytes

Contents

require 'intercom/service/base_service'
require 'intercom/api_operations/save'
require 'intercom/api_operations/list'
require 'intercom/api_operations/find_all'

module Intercom
  module Service
    class Tag < BaseService
      include ApiOperations::Save
      include ApiOperations::List
      include ApiOperations::FindAll
      include ApiOperations::Archive

      def collection_class
        Intercom::Tag
      end

      def tag(params)
        params['tag_or_untag'] = 'tag'
        create(params)
      end

      def untag(params)
        params['tag_or_untag'] = 'untag'
        users_or_companies(params).each do |user_or_company|
          user_or_company[:untag] = true
        end
        create(params)
      end

      private

      def users_or_companies(params)
        params[:users] || params[:companies]
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
intercom-3.9.5 lib/intercom/service/tag.rb
intercom-3.9.4 lib/intercom/service/tag.rb
intercom-3.9.3 lib/intercom/service/tag.rb
intercom-3.9.2 lib/intercom/service/tag.rb
intercom-3.9.0 lib/intercom/service/tag.rb
intercom-3.8.1 lib/intercom/service/tag.rb
intercom-3.8.0 lib/intercom/service/tag.rb
intercom-3.7.7 lib/intercom/service/tag.rb
intercom-3.7.6 lib/intercom/service/tag.rb
intercom-3.7.5 lib/intercom/service/tag.rb
intercom-3.7.4 lib/intercom/service/tag.rb
intercom-3.7.3 lib/intercom/service/tag.rb
intercom-3.7.2 lib/intercom/service/tag.rb
intercom-3.7.1 lib/intercom/service/tag.rb
intercom-3.7.0 lib/intercom/service/tag.rb