Sha256: 65c90e9a1b023376f84ba84e6d42e8acd1be33639809c918083f07dbd234919c

Contents?: true

Size: 895 Bytes

Versions: 6

Compression:

Stored size: 895 Bytes

Contents

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

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

      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

6 entries across 6 versions & 1 rubygems

Version Path
intercom-3.3.0 lib/intercom/service/tag.rb
intercom-3.2.0 lib/intercom/service/tag.rb
intercom-3.1.0 lib/intercom/service/tag.rb
intercom-3.0.6 lib/intercom/service/tag.rb
intercom-3.0.5 lib/intercom/service/tag.rb
intercom-3.0.4 lib/intercom/service/tag.rb