Class: Eco::API::UseCases::DefaultCases::ReinviteCase

Inherits:
Eco::API::UseCases::DefaultCase show all
Defined in:
lib/eco/api/usecases/default_cases/reinvite_case.rb

Instance Method Summary collapse

Methods inherited from Eco::API::UseCases::DefaultCase

#initialize

Constructor Details

This class inherits a constructor from Eco::API::UseCases::DefaultCase

Instance Method Details

#processObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/eco/api/usecases/default_cases/reinvite_case.rb', line 7

def process
  @cases.define("reinvite", type: :transform) do |people, session, options, usecase|
    invite = session.job_group("main").new("invite", usecase: usecase, type: :update, sets: :account)
    people.users.each do |person|
      person..send_invites = true
      invite.add(person)
    end
    invite
  end

  @cases.define("reinvite", type: :sync) do |entries, people, session, options, usecase|
    invite = session.job_group("main").new("invite", usecase: usecase, type: :update, sets: :account)

    users         = people.users
    strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))

    entries.each_with_index do |entry, i|
      if person = people.find(entry, strict: strict_search)
        person..send_invites = true
        invite.add(person)
      else
        session.logger.error("Entry(#{i}) - this person does not exist: #{entry.to_s(:identify)}")
      end
    end
    
  end
end