Sha256: 08b7c48b38ec674fb58511f871484d7c65e1ec71113bb567b8569f185fef2e07

Contents?: true

Size: 995 Bytes

Versions: 21

Compression:

Stored size: 995 Bytes

Contents

class ContactsController < ApplicationController
  skip_before_action :verify_authenticity_token, only: %i[manage]

  def index
    @contact_list = if params[:search].present?
      @search_q = params[:search]
      Services::Hubspot::Contacts::Search.new(email: @search_q).call
    else
      Services::Hubspot::Contacts::GetPage.new(limit: 100).call.sort_by(&:created_at).reverse
    end
    @associated_contacts = Services::Hubspot::Associations::GetById.new(params[:company_id]).call || []
  end

  def manage
    selected_ids = contacts_ids_params.select { |id, value| value == '1' }.keys
    if params[:commit] == 'Add'
      Services::Hubspot::Associations::Create.new(params[:company_id], selected_ids).call
    elsif params[:commit] == 'Delete'
      Services::Hubspot::Associations::Delete.new(params[:company_id], selected_ids).call
    end

    redirect_to company_path(params[:company_id])
  end

  def contacts_ids_params
    params.require(:contacts_ids).permit!.to_hash
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
hubspot-api-client-9.0.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-8.0.1 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-8.0.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-7.3.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-7.2.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-7.1.1 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-7.1.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-7.0.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-6.0.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-5.0.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-4.0.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-3.3.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-3.2.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-3.1.1 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-3.1.0.pre.beta sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-3.0.0.pre.beta sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-2.3.2 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-2.3.1 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-2.2.0 sample-apps/companies-app/app/controllers/contacts_controller.rb
hubspot-api-client-2.1.0 sample-apps/companies-app/app/controllers/contacts_controller.rb